shithub: opus

Download patch

ref: 08f5ff06bb4c769e48802e87160dd3c1ca230b1e
parent: c0eb2ca56df7b0fabfd061adc818d2f6d988e49e
author: Jean-Marc Valin <jeanmarcv@google.com>
date: Wed Jun 18 11:10:11 EDT 2025

Make IMDCT scaling a bit more conservative

Fixes 2941f08a

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