shithub: opus

Download patch

ref: 32a1e6b6a37b17255be8fb5591ad315116076feb
parent: fffae794eaabb1eb691d52d606bfdae58d71608d
author: Jean-Marc Valin <[email protected]>
date: Mon Aug 30 19:35:02 EDT 2010

More fine energy tuning, compensation for N=2

--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -189,6 +189,10 @@
       /* Offset for the number of fine bits compared to their "fair share" of total/N */
       offset = N*C*(((m->logN[j] + logM)>>1)-FINE_OFFSET);
 
+      /* N=2 is the only point that doesn't match the curve */
+      if (N==2)
+         offset += N*C<<BITRES>>2;
+
       /* Changing the offset for allocating the second and third fine energy bit */
       if (bits[j] + offset < den*2<<BITRES)
          offset += (m->logN[j] + logM)*N*C>>BITRES-1;
--- a/libcelt/rate.h
+++ b/libcelt/rate.h
@@ -40,7 +40,7 @@
 #define LOG_MAX_PULSES 7
 
 #define BITRES 3
-#define FINE_OFFSET 19
+#define FINE_OFFSET 21
 #define QTHETA_OFFSET 6
 #define QTHETA_OFFSET_STEREO 4