Fix 'Left shift cannot be represented in int32_t'.
In the legacy C part of AGC, an audio level 'cur_level' is represented as (1+frac) * 2^(31 - zeros) The 'zeros' exponent part is used for looking up a gain value in a table, and 'frac' is used for interpolating between two nearby table values. Code snippet below: zeros = WebRtcSpl_NormU32((uint32_t)cur_level); tmp32 = (cur_level << zeros) & 0x7FFFFFFF; frac = (int16_t)(tmp32 >> 19); In the second line, 'cur_level' is shifted upwards so that the leading bit is '1', after which the leading bit is cleared. The result is 'frac' in Q31. The compiler type of 'cur_level << zeros' is 'int32_t'. This is a fuzzer error 'Left shift cannot be represented in int32_t', because the leading sign bit is 1. This CL changes the compiler type to uint32_t. Bug: chromium:776286 Change-Id: Ie29552b75e690057bd76fc88e747841b531e3802 Reviewed-on: https://webrtc-review.googlesource.com/14841 Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Commit-Queue: Alex Loiko <aleloi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20405}
This commit is contained in:
@ -410,7 +410,7 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc* stt,
|
||||
if (cur_level == 0) {
|
||||
zeros = 31;
|
||||
}
|
||||
tmp32 = (cur_level << zeros) & 0x7FFFFFFF;
|
||||
tmp32 = ((uint32_t)cur_level << zeros) & 0x7FFFFFFF;
|
||||
frac = (int16_t)(tmp32 >> 19); // Q12.
|
||||
tmp32 = (stt->gainTable[zeros - 1] - stt->gainTable[zeros]) * frac;
|
||||
gains[k + 1] = stt->gainTable[zeros] + (tmp32 >> 12);
|
||||
@ -429,7 +429,7 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc* stt,
|
||||
if (stt->capacitorFast == 0) {
|
||||
zeros_fast = 31;
|
||||
}
|
||||
tmp32 = (stt->capacitorFast << zeros_fast) & 0x7FFFFFFF;
|
||||
tmp32 = ((uint32_t)stt->capacitorFast << zeros_fast) & 0x7FFFFFFF;
|
||||
zeros_fast <<= 9;
|
||||
zeros_fast -= (int16_t)(tmp32 >> 22);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user