shithub: opus

Download patch

ref: a6d29ed5311896e72a57495c811b4633d4caaa69
parent: 140e0982702ca75ce7246e6e2baa0df2938866d9
author: Jean-Marc Valin <jeanmarcv@google.com>
date: Fri Jul 5 09:20:42 EDT 2024

Fix undefined left shift of negative value

--- a/celt/rate.c
+++ b/celt/rate.c
@@ -189,7 +189,7 @@
                   /* Offset the number of qtheta bits by log2(N)/2
                       + QTHETA_OFFSET compared to their "fair share" of
                       total/N */
-                  offset = ((m->logN[j]+((LM0+k)<<BITRES))>>1)-QTHETA_OFFSET;
+                  offset = ((m->logN[j]+(opus_int32)((opus_uint32)(LM0+k)<<BITRES))>>1)-QTHETA_OFFSET;
                   /* The number of qtheta bits we'll allocate if the remainder
                       is to be max_bits.
                      The average measured cost for theta is 0.89701 times qb,
--