shithub: opus

Download patch

ref: 185cabfa188a833b2468a136531714fe3fe2825f
parent: 39f68ac99735ddf504f50ea64bd8872e324c947e
author: Jean-Marc Valin <[email protected]>
date: Sat Oct 3 21:17:42 EDT 2009

stereo allocator tuning

--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -145,10 +145,14 @@
       int offset;
 
       N=m->eBands[j+1]-m->eBands[j]; 
-      d=C*N<<BITRES; 
+      /* Compensate for the extra DoF in stereo */
+      d=(C*N+ ((C==2 && N>2) ? 1 : 0))<<BITRES; 
       offset = FINE_OFFSET - log2_frac(N, BITRES);
       /* Offset for the number of fine bits compared to their "fair share" of total/N */
       offset = bits[j]-offset*N*C;
+      /* Compensate for the prediction gain in stereo */
+      if (C==2)
+         offset -= 1<<BITRES;
       if (offset < 0)
          offset = 0;
       ebits[j] = (2*offset+d)/(2*d);