shithub: opus

Download patch

ref: 09213de91c1da66be193ad27a61f08eb43f2302d
parent: a928572055cb8151e0fdde8f0d859d98f3d23e4b
author: Jean-Marc Valin <[email protected]>
date: Thu Jan 27 16:43:24 EST 2011

Don't rebalance bits for itheta=0 or 16384

--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -991,7 +991,7 @@
                   lowband, resynth, ec, remaining_bits, LM, next_lowband_out1,
                   NULL, next_level, seed, stereo ? Q15ONE : MULT16_16_P15(gain,mid), lowband_scratch, fill);
             rebalance = mbits - (rebalance-*remaining_bits);
-            if (rebalance > 3<<BITRES)
+            if (rebalance > 3<<BITRES && itheta!=0)
                sbits += rebalance - (3<<BITRES);
 
             /* For a stereo split, the high bits of fill are always zero, so no
@@ -1006,7 +1006,7 @@
                   next_lowband2, resynth, ec, remaining_bits, LM, NULL,
                   NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<(B0>>1&stereo-1);
             rebalance = sbits - (rebalance-*remaining_bits);
-            if (rebalance > 3<<BITRES)
+            if (rebalance > 3<<BITRES && itheta!=16384)
                mbits += rebalance - (3<<BITRES);
             /* In stereo mode, we do not apply a scaling to the mid because we need the normalized
                mid for folding later */
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -318,19 +318,19 @@
    {
       mode->preemph[0] =  QCONST16(0.3500061035f, 15);
       mode->preemph[1] = -QCONST16(0.1799926758f, 15);
-      mode->preemph[2] =  QCONST16(0.2719726562f, SIG_SHIFT);
+      mode->preemph[2] =  QCONST16(0.2719968125f, SIG_SHIFT); /* exact 1/preemph[3] */
       mode->preemph[3] =  QCONST16(3.6765136719f, 13);
    } else if(Fs < 24000) /* 16 kHz */
    {
       mode->preemph[0] =  QCONST16(0.6000061035f, 15);
       mode->preemph[1] = -QCONST16(0.1799926758f, 15);
-      mode->preemph[2] =  QCONST16(0.4425048828f, SIG_SHIFT);
-      mode->preemph[3] =  QCONST16(2.259887f, 13);
+      mode->preemph[2] =  QCONST16(0.4424998650f, SIG_SHIFT); /* exact 1/preemph[3] */
+      mode->preemph[3] =  QCONST16(2.2598876953f, 13);
    } else if(Fs < 40000) /* 32 kHz */
    {
       mode->preemph[0] =  QCONST16(0.7799987793f, 15);
       mode->preemph[1] = -QCONST16(0.1000061035f, 15);
-      mode->preemph[2] =  QCONST16(.75f, SIG_SHIFT);
+      mode->preemph[2] =  QCONST16(0.7499771125f, SIG_SHIFT); /* exact 1/preemph[3] */
       mode->preemph[3] =  QCONST16(1.3333740234f, 13);
    } else /* 48 kHz */
    {