shithub: opus

Download patch

ref: 74cdcaeca925f3adf7aa0533aafea76ca48878ef
parent: 462c50d302e7bd57d908eb99f9e8378c26c89ba7
author: Jean-Marc Valin <jeanmarcv@google.com>
date: Thu Jun 5 07:22:24 EDT 2025

Fix potential overflow in IMDCT headroom

--- a/celt/mdct.c
+++ b/celt/mdct.c
@@ -292,11 +292,11 @@
       opus_val32 maxval=0;
       for (i=0;i<N2;i++) {
          maxval = MAX32(maxval, ABS32(in[i*stride]));
-         sumval = ADD32_ovflw(sumval, ABS32(SHR32(in[i*stride],4)));
+         sumval = ADD32_ovflw(sumval, ABS32(SHR32(in[i*stride],11)));
       }
       pre_shift = IMAX(0, 29-celt_ilog2(1+SHR32(maxval,2)*3));
       /* Worst-case where all the energy goes to a single sample. */
-      post_shift = IMAX(0, 26-celt_ilog2(ABS32(sumval)));
+      post_shift = IMAX(0, 19-celt_ilog2(ABS32(sumval)));
       post_shift = IMIN(post_shift, pre_shift);
       fft_shift = pre_shift - post_shift;
    }
--