shithub: opus

Download patch

ref: e368e62092f7c7f511585757af9e16a374a1e048
parent: ba1bd031c778fdb7bc15d42af516744a193caa96
author: Jean-Marc Valin <[email protected]>
date: Thu Jan 3 09:28:28 EST 2013

Remove condition in pre/de-emphasis when not building with custom modes

Should slightly improve coverage and reduce code size

--- a/celt/celt_decoder.c
+++ b/celt/celt_decoder.c
@@ -191,10 +191,9 @@
 {
    int c;
    int Nd;
-   opus_val16 coef0, coef1;
+   opus_val16 coef0;
 
    coef0 = coef[0];
-   coef1 = coef[1];
    Nd = N/downsample;
    c=0; do {
       int j;
@@ -203,26 +202,31 @@
       celt_sig m = mem[c];
       x =in[c];
       y = pcm+c;
-      /* Shortcut for the standard (non-custom modes) case */
-      if (coef1 == 0)
+#ifdef CUSTOM_MODES
+      if (coef[1] != 0)
       {
+         opus_val16 coef1 = coef[1];
+         opus_val16 coef3 = coef[3];
          for (j=0;j<N;j++)
          {
             celt_sig tmp = x[j] + m;
-            m = MULT16_32_Q15(coef0, tmp);
+            m = MULT16_32_Q15(coef0, tmp)
+                          - MULT16_32_Q15(coef1, x[j]);
+            tmp = SHL32(MULT16_32_Q15(coef3, tmp), 2);
             scratch[j] = tmp;
          }
-      } else {
-         opus_val16 coef3 = coef[3];
+      } else
+#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)
-              - MULT16_32_Q15(coef1, x[j]);
-            tmp = SHL32(MULT16_32_Q15(coef3, tmp), 2);
+            m = MULT16_32_Q15(coef0, tmp);
             scratch[j] = tmp;
          }
       }
+#endif
       mem[c] = m;
 
       /* Perform down-sampling */
--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -392,12 +392,11 @@
                         int N, int CC, int upsample, const opus_val16 *coef, celt_sig *mem, int clip)
 {
    int i;
-   opus_val16 coef0, coef1;
+   opus_val16 coef0;
    celt_sig m;
    int Nu;
 
    coef0 = coef[0];
-   coef1 = coef[1];
 
 
    Nu = N/upsample;
@@ -428,17 +427,10 @@
    }
 #endif
    m = *mem;
-   if (coef1 == 0)
+#ifdef CUSTOM_MODES
+   if (coef[1] != 0)
    {
-      for (i=0;i<N;i++)
-      {
-         celt_sig x;
-         x = SHL32(inp[i], SIG_SHIFT);
-         /* Apply pre-emphasis */
-         inp[i] = x + m;
-         m = - MULT16_32_Q15(coef0, x);
-      }
-   } else {
+      opus_val16 coef1 = coef[1];
       opus_val16 coef2 = coef[2];
       for (i=0;i<N;i++)
       {
@@ -449,7 +441,19 @@
          inp[i] = tmp + m;
          m = MULT16_32_Q15(coef1, inp[i]) - MULT16_32_Q15(coef0, tmp);
       }
+   } else
+#else
+   {
+      for (i=0;i<N;i++)
+      {
+         celt_sig x;
+         x = SHL32(inp[i], SIG_SHIFT);
+         /* Apply pre-emphasis */
+         inp[i] = x + m;
+         m = - MULT16_32_Q15(coef0, x);
+      }
    }
+#endif
    *mem = m;
 }