Skip to content

Commit 4d269fc

Browse files
committed
Saturate dc_reject() input to prevent wrap-around
1 parent 38e08cf commit 4d269fc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/opus_encoder.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,9 @@ static void dc_reject(const opus_res *in, opus_int32 cutoff_Hz, opus_res *out, o
457457
for (i=0;i<len;i++)
458458
{
459459
opus_val32 x, y;
460-
x = SHL32((opus_val32)in[channels*i+c], 14-RES_SHIFT);
460+
/* Saturate at +6 dBFS to avoid any wrap-around. */
461+
x = SATURATE((opus_val32)in[channels*i+c], (1<<16<<RES_SHIFT)-1);
462+
x = SHL32(x, 14-RES_SHIFT);
461463
y = x-hp_mem[2*c];
462464
hp_mem[2*c] = hp_mem[2*c] + PSHR32(x - hp_mem[2*c], shift);
463465
#ifdef ENABLE_RES24

0 commit comments

Comments
 (0)