shithub: opus

Download patch

ref: 2fe4700f761e21788dd3c23c7eca9dc0d436ef10
parent: faec6736cb4dc3d7cd7982f4b72378d5c0ca560c
author: Jean-Marc Valin <[email protected]>
date: Sun May 26 14:50:13 EDT 2013

Skip down-sampling in deemphasis() when not needed.

--- a/celt/celt_decoder.c
+++ b/celt/celt_decoder.c
@@ -191,6 +191,7 @@
 {
    int c;
    int Nd;
+   int apply_downsampling=0;
    opus_val16 coef0;
 
    coef0 = coef[0];
@@ -215,8 +216,10 @@
             tmp = SHL32(MULT16_32_Q15(coef3, tmp), 2);
             scratch[j] = tmp;
          }
+         apply_downsampling=1;
       } else
 #endif
+      if (downsample>1)
       {
          /* Shortcut for the standard (non-custom modes) case */
          for (j=0;j<N;j++)
@@ -225,12 +228,24 @@
             m = MULT16_32_Q15(coef0, tmp);
             scratch[j] = tmp;
          }
+         apply_downsampling=1;
+      } else {
+         /* Shortcut for the standard (non-custom modes) case */
+         for (j=0;j<N;j++)
+         {
+            celt_sig tmp = x[j] + m;
+            m = MULT16_32_Q15(coef0, tmp);
+            y[j*C] = SCALEOUT(SIG2WORD16(tmp));
+         }
       }
       mem[c] = m;
 
-      /* Perform down-sampling */
-      for (j=0;j<Nd;j++)
-         y[j*C] = SCALEOUT(SIG2WORD16(scratch[j*downsample]));
+      if (apply_downsampling)
+      {
+         /* Perform down-sampling */
+         for (j=0;j<Nd;j++)
+            y[j*C] = SCALEOUT(SIG2WORD16(scratch[j*downsample]));
+      }
    } while (++c<C);
 }