Skip to content

Commit 74cdcae

Browse files
committed
Fix potential overflow in IMDCT headroom
1 parent 462c50d commit 74cdcae

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

celt/mdct.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,11 @@ void clt_mdct_backward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_sca
292292
opus_val32 maxval=0;
293293
for (i=0;i<N2;i++) {
294294
maxval = MAX32(maxval, ABS32(in[i*stride]));
295-
sumval = ADD32_ovflw(sumval, ABS32(SHR32(in[i*stride],4)));
295+
sumval = ADD32_ovflw(sumval, ABS32(SHR32(in[i*stride],11)));
296296
}
297297
pre_shift = IMAX(0, 29-celt_ilog2(1+SHR32(maxval,2)*3));
298298
/* Worst-case where all the energy goes to a single sample. */
299-
post_shift = IMAX(0, 26-celt_ilog2(ABS32(sumval)));
299+
post_shift = IMAX(0, 19-celt_ilog2(ABS32(sumval)));
300300
post_shift = IMIN(post_shift, pre_shift);
301301
fft_shift = pre_shift - post_shift;
302302
}

0 commit comments

Comments
 (0)