shithub: opus

Download patch

ref: f5b0587bd2768a22735fd28b66da20e45e11616b
parent: 83006eec60ee90fe85081c8d7edcfe16aa5db50e
author: Jean-Marc Valin <[email protected]>
date: Fri Mar 21 06:46:17 EDT 2008

s/ROUND/ROUND16/

--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -170,7 +170,7 @@
 #define SHL(a,shift)    (a)
 #define SATURATE(x,a)   (x)
 
-#define ROUND(a,shift)  (a)
+#define ROUND16(a,shift)  (a)
 #define HALF32(x)       (.5f*(x))
 
 #define ADD16(a,b) ((a)+(b))
--- a/libcelt/fixed_debug.h
+++ b/libcelt/fixed_debug.h
@@ -174,7 +174,7 @@
 #define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
 #define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
 
-#define ROUND(x,a) (EXTRACT16(PSHR32((x),(a))))
+#define ROUND16(x,a) (EXTRACT16(PSHR32((x),(a))))
 #define HALF32(x)  (SHR32(x,1))
 
 //#define SHR(a,shift) ((a) >> (shift))
--- a/libcelt/fixed_generic.h
+++ b/libcelt/fixed_generic.h
@@ -90,7 +90,7 @@
 #define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
 
 /** Shift by a and round-to-neareast 32-bit value. Result is a 16-bit value */
-#define ROUND(x,a) (EXTRACT16(PSHR32((x),(a))))
+#define ROUND16(x,a) (EXTRACT16(PSHR32((x),(a))))
 /** Divide by two */
 #define HALF32(x)  (SHR32(x,1))
 
--- a/libcelt/pitch.c
+++ b/libcelt/pitch.c
@@ -166,7 +166,7 @@
       celt_word32_t tmp;
       /*printf ("%d %d ", X[2*i]*X[2*i]+X[2*i+1]*X[2*i+1], Y[2*i]*Y[2*i]+Y[2*i+1]*Y[2*i+1]);*/
       /*n = DIV32_16(Q15ONE,celt_sqrt(EPSILON+curve[i]));*/
-      n = ROUND(celt_rcp(celt_sqrt(EPSILON+curve[i])),16);
+      n = ROUND16(celt_rcp(celt_sqrt(EPSILON+curve[i])),16);
       /*printf ("%f ", n);*/
       tmp = X[2*i];
       X[2*i] = MULT16_32_Q15(n, ADD32(MULT16_16(X[2*i  ],Y[2*i  ]), MULT16_16(X[2*i+1],Y[2*i+1])));
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -64,7 +64,7 @@
 static inline celt_word16_t amp2dB(celt_ener_t amp)
 {
    /* equivalent to return 6.0207*log2(.3+amp) */
-   return ROUND(MULT16_16(24661,celt_log2(ADD32(QCONST32(.3f,14),amp))),12);
+   return ROUND16(MULT16_16(24661,celt_log2(ADD32(QCONST32(.3f,14),amp))),12);
    /* return DB_SCALING*20*log10(.3+ENER_SCALING_1*amp); */
 }
 #else
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -71,7 +71,7 @@
       the encoded (int) one */
    for (i=0;i<N;i++)
       y[i] = SUB16(SHL16(iy[i],yshift),
-                   MULT16_16_Q15(alpha,MULT16_16_Q14(ROUND(Ryp,14),P[i])));
+                   MULT16_16_Q15(alpha,MULT16_16_Q14(ROUND16(Ryp,14),P[i])));
 
    /* Recompute after the projection (I think it's right) */
    Ryp = 0;
@@ -84,13 +84,13 @@
 
    /* g = (sqrt(Ryp^2 + Ryy - Rpp*Ryy)-Ryp)/Ryy */
    g = MULT16_32_Q15(
-            celt_sqrt(MULT16_16(ROUND(Ryp,14),ROUND(Ryp,14)) + Ryy -
-                      MULT16_16(ROUND(Ryy,14),ROUND(Rpp,14)))
-            - ROUND(Ryp,14),
+            celt_sqrt(MULT16_16(ROUND16(Ryp,14),ROUND16(Ryp,14)) + Ryy -
+                      MULT16_16(ROUND16(Ryy,14),ROUND16(Rpp,14)))
+            - ROUND16(Ryp,14),
        celt_rcp(SHR32(Ryy,9)));
 
    for (i=0;i<N;i++)
-      X[i] = P[i] + ROUND(MULT16_16(y[i], g),11);
+      X[i] = P[i] + ROUND16(MULT16_16(y[i], g),11);
    RESTORE_STACK;
 }
 
@@ -165,8 +165,8 @@
       Rpp = MAC16_16(Rpp, P[j],P[j]);
       Rxp = MAC16_16(Rxp, X[j],P[j]);
    }
-   Rpp = ROUND(Rpp, NORM_SHIFT);
-   Rxp = ROUND(Rxp, NORM_SHIFT);
+   Rpp = ROUND16(Rpp, NORM_SHIFT);
+   Rxp = ROUND16(Rxp, NORM_SHIFT);
    celt_assert2(Rpp<=NORM_SCALING, "Rpp should never have a norm greater than unity");
 
    /* We only need to initialise the zero because the first iteration only uses that */
@@ -228,15 +228,15 @@
                
                /* Compute the gain such that ||p + g*y|| = 1 */
                g = MULT16_32_Q15(
-                        celt_sqrt(MULT16_16(ROUND(Ryp,14),ROUND(Ryp,14)) + Ryy -
-                                  MULT16_16(ROUND(Ryy,14),Rpp))
-                        - ROUND(Ryp,14),
+                        celt_sqrt(MULT16_16(ROUND16(Ryp,14),ROUND16(Ryp,14)) + Ryy -
+                                  MULT16_16(ROUND16(Ryy,14),Rpp))
+                        - ROUND16(Ryp,14),
                    celt_rcp(SHR32(Ryy,12)));
                /* Knowing that gain, what's the error: (x-g*y)^2 
                   (result is negated and we discard x^2 because it's constant) */
                /*score = 2.f*g*Rxy - 1.f*g*g*Ryy*NORM_SCALING_1;*/
-               score = 2*MULT16_32_Q14(ROUND(Rxy,14),g)
-                       - MULT16_32_Q14(EXTRACT16(MULT16_32_Q14(ROUND(Ryy,14),g)),g);
+               score = 2*MULT16_32_Q14(ROUND16(Rxy,14),g)
+                       - MULT16_32_Q14(EXTRACT16(MULT16_32_Q14(ROUND16(Ryy,14),g)),g);
 
                if (score>nbest[Lupdate-1]->score)
                {
@@ -378,7 +378,7 @@
          xy = MAC16_16(xy, x[j], Y[i+N-j-1]);
          yy = MAC16_16(yy, Y[i+N-j-1], Y[i+N-j-1]);
       }
-      score = DIV32(MULT16_16(ROUND(xy,14),ROUND(xy,14)), ROUND(yy,14));
+      score = DIV32(MULT16_16(ROUND16(xy,14),ROUND16(xy,14)), ROUND16(yy,14));
       if (score > best_score)
       {
          best_score = score;