shithub: opus

Download patch

ref: 949f18010fdb720a79dfa926bb581622267360b1
parent: fa7215fdb9f8fdbd8498da39b3cc27c14ac888ca
author: Timothy B. Terriberry <[email protected]>
date: Thu Dec 30 03:38:48 EST 2010

Move fine_priority calculation after the bust cap.

This way if a band doesn't get the fine bits we want because it
 wasn't allocated enough bits to start with, then we will still
 give it priority for any spare bits after PVQ.

--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -320,10 +320,6 @@
          /* Divide with rounding */
          ebits[j] = IMAX(0, (bits[j] + offset + (den<<(BITRES-1))) / (den<<BITRES));
 
-         /* If we rounded down, make it a candidate for final
-             fine energy pass */
-         fine_priority[j] = ebits[j]*(den<<BITRES) >= bits[j]+offset;
-
          /* Make sure not to bust */
          if (C*ebits[j] > (bits[j]>>BITRES))
             ebits[j] = bits[j] >> stereo >> BITRES;
@@ -331,6 +327,10 @@
          /* More than 8 is useless because that's about as far as PVQ can go */
          if (ebits[j]>8)
             ebits[j]=8;
+
+         /* If we rounded down or capped this band, make it a candidate for the
+             final fine energy pass */
+         fine_priority[j] = ebits[j]*(den<<BITRES) >= bits[j]+offset;
 
       } else {
          /* For N=1, all bits go to fine energy except for a single sign bit */