From 21b1134aa260c33864853a37335f010ddc6449cc Mon Sep 17 00:00:00 2001
From: Jean-Marc Valin <jean-marc.valin@octasic.com>
Date: Fri, 13 May 2011 17:41:33 -0400
Subject: [PATCH] Code cleanup

defining HALF16() too
---
 libcelt/arch.h          | 1 +
 libcelt/fixed_debug.h   | 1 +
 libcelt/fixed_generic.h | 1 +
 libcelt/vq.c            | 3 +--
 4 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libcelt/arch.h b/libcelt/arch.h
index e4015f1f7..68da0debd 100644
--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -199,6 +199,7 @@ typedef float celt_mask;
 #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))
diff --git a/libcelt/fixed_debug.h b/libcelt/fixed_debug.h
index ddf569518..7992fa217 100644
--- a/libcelt/fixed_debug.h
+++ b/libcelt/fixed_debug.h
@@ -180,6 +180,7 @@ static inline int SHL32(long long a, int shift)
 #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))
diff --git a/libcelt/fixed_generic.h b/libcelt/fixed_generic.h
index 069070fa4..c39ada41f 100644
--- 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 */
diff --git a/libcelt/vq.c b/libcelt/vq.c
index 5c743511c..74aba5391 100644
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -87,8 +87,7 @@ static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int
    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) */
-- 
GitLab