shithub: opus

Download patch

ref: 44203907995199447d8a0052e6b1eb0189ae6385
parent: 235c64b94dded15c841e9df955b232892531d181
author: Jean-Marc Valin <[email protected]>
date: Wed Jan 12 04:22:29 EST 2011

Enforces bands of even size even for custom modes

--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -171,7 +171,8 @@
    for (i=0;i<high;i++)
    {
       int target = bark_freq[lin+i];
-      eBands[i+low] = (target+(offset+res)/2)/res;
+      /* Round to an even value */
+      eBands[i+low] = (target+offset/2+res)/(2*res)*2;
       offset = eBands[i+low]*res - target;
    }
    /* Enforce the minimum spacing at the boundary */
@@ -178,7 +179,8 @@
    for (i=0;i<*nbEBands;i++)
       if (eBands[i] < i)
          eBands[i] = i;
-   eBands[*nbEBands] = (bark_freq[nBark]+res/2)/res;
+   /* Round to an even value */
+   eBands[*nbEBands] = (bark_freq[nBark]+res)/(2*res)*2;
    if (eBands[*nbEBands] > frame_size)
       eBands[*nbEBands] = frame_size;
    for (i=1;i<*nbEBands-1;i++)