shithub: opus

Download patch

ref: ae76e553db3d411b5ebb9a8b6df28c18d3a30f82
parent: 9c50c6bc686d5745c99672777e9066ec80c35de3
author: Jean-Marc Valin <[email protected]>
date: Fri Mar 28 13:59:36 EDT 2008

Changed the rules for using the pulse spreading. It should be used less often
and mainly in the mid-range.

--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -331,11 +331,15 @@
       
       if (q > 0)
       {
-         int nb_rotations = (B*(eBands[i+1]-eBands[i])+4*q)/(8*q);
-         exp_rotation(P+B*eBands[i], B*(eBands[i+1]-eBands[i]), -1, B, nb_rotations);
-         exp_rotation(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), -1, B, nb_rotations);
+         int nb_rotations = q <= 2*B ? 2*B/q : 0;
+         if (nb_rotations != 0)
+         {
+            exp_rotation(P+B*eBands[i], B*(eBands[i+1]-eBands[i]), -1, B, nb_rotations);
+            exp_rotation(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), -1, B, nb_rotations);
+         }
          alg_quant(X+B*eBands[i], W+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, P+B*eBands[i], enc);
-         exp_rotation(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), 1, B, nb_rotations);
+         if (nb_rotations != 0)
+            exp_rotation(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), 1, B, nb_rotations);
       }
       for (j=B*eBands[i];j<B*eBands[i+1];j++)
          norm[j] = MULT16_16_Q15(n,X[j]);
@@ -388,10 +392,12 @@
       
       if (q > 0)
       {
-         int nb_rotations = (B*(eBands[i+1]-eBands[i])+4*q)/(8*q);
-         exp_rotation(P+B*eBands[i], B*(eBands[i+1]-eBands[i]), -1, B, nb_rotations);
+         int nb_rotations = q <= 2*B ? 2*B/q : 0;
+         if (nb_rotations != 0)
+            exp_rotation(P+B*eBands[i], B*(eBands[i+1]-eBands[i]), -1, B, nb_rotations);
          alg_unquant(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, P+B*eBands[i], dec);
-         exp_rotation(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), 1, B, nb_rotations);
+         if (nb_rotations != 0)
+            exp_rotation(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), 1, B, nb_rotations);
       }
       for (j=B*eBands[i];j<B*eBands[i+1];j++)
          norm[j] = MULT16_16_Q15(n,X[j]);