shithub: opus

Download patch

ref: 21b1134aa260c33864853a37335f010ddc6449cc
parent: f54a0a39e5031713a778e003fdd4c74e560f7d92
author: Jean-Marc Valin <[email protected]>
date: Fri May 13 13:41:33 EDT 2011

Code cleanup

defining HALF16() too

--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -199,6 +199,7 @@
 #define SATURATE(x,a)   (x)
 
 #define ROUND16(a,shift)  (a)
+#define HALF16(x)       (.5f*(x))
 #define HALF32(x)       (.5f*(x))
 
 #define ADD16(a,b) ((a)+(b))
--- a/libcelt/fixed_debug.h
+++ b/libcelt/fixed_debug.h
@@ -180,6 +180,7 @@
 #define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
 
 #define ROUND16(x,a) (celt_mips--,EXTRACT16(PSHR32((x),(a))))
+#define HALF16(x)  (SHR16(x,1))
 #define HALF32(x)  (SHR32(x,1))
 
 //#define SHR(a,shift) ((a) >> (shift))
--- a/libcelt/fixed_generic.h
+++ b/libcelt/fixed_generic.h
@@ -93,6 +93,7 @@
 /** Shift by a and round-to-neareast 32-bit value. Result is a 16-bit value */
 #define ROUND16(x,a) (EXTRACT16(PSHR32((x),(a))))
 /** Divide by two */
+#define HALF16(x)  (SHR16(x,1))
 #define HALF32(x)  (SHR32(x,1))
 
 /** Add two 16-bit values */
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -87,8 +87,7 @@
    factor = SPREAD_FACTOR[spread-1];
 
    gain = celt_div((celt_word32)MULT16_16(Q15_ONE,len),(celt_word32)(len+factor*K));
-   /* FIXME: Make that HALF16 instead of HALF32 */
-   theta = HALF32(MULT16_16_Q15(gain,gain));
+   theta = HALF16(MULT16_16_Q15(gain,gain));
 
    c = celt_cos_norm(EXTEND32(theta));
    s = celt_cos_norm(EXTEND32(SUB16(Q15ONE,theta))); /*  sin(theta) */