shithub: opus

Download patch

ref: 3fed34ae00214e9620dd2ff4b897690e5cdf433a
parent: f33a7fb8e0f16009527f04e245e470522501b2bd
author: Jean-Marc Valin <[email protected]>
date: Fri Dec 17 09:17:27 EST 2010

Giving less bits to single-bin bands.

This improves the allocation for 2.5 ms frames.

--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -387,14 +387,18 @@
    ALLOC(thresh, len, int);
    ALLOC(trim_offset, len, int);
 
-   /* Below this threshold, we're sure not to allocate any PVQ bits */
    for (j=start;j<end;j++)
+   {
+      /* Below this threshold, we're sure not to allocate any PVQ bits */
       thresh[j] = IMAX((C)<<BITRES, (3*(m->eBands[j+1]-m->eBands[j])<<LM<<BITRES)>>4);
-   /* Tilt of the allocation curve */
-   for (j=start;j<end;j++)
+      /* Tilt of the allocation curve */
       trim_offset[j] = C*(m->eBands[j+1]-m->eBands[j])*(alloc_trim-5-LM)*(m->nbEBands-j-1)
             <<(LM+BITRES)>>6;
-
+      /* Giving less resolution to single-coefficient bands because they get
+         more benefit from having one coarse value per coefficient*/
+      if ((m->eBands[j+1]-m->eBands[j])<<LM==1)
+         trim_offset[j] -= C<<BITRES;
+   }
    lo = 1;
    hi = m->nbAllocVectors - 2;
    do