shithub: opus

Download patch

ref: c209c342bffc3a601adf09bf3092e47808dae646
parent: 957a4fae0e5a2b7f16d05c3f067aff7f412d42f7
author: Jean-Marc Valin <[email protected]>
date: Fri Mar 7 12:50:45 EST 2008

fixed-point: defined HALF32() and used it for the forward mdct.

--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -153,12 +153,13 @@
 #define SATURATE16(x,a) (x)
 #define SATURATE32(x,a) (x)
 
-#define PSHR(a,shift)       (a)
-#define SHR(a,shift)       (a)
-#define SHL(a,shift)       (a)
-#define SATURATE(x,a) (x)
+#define PSHR(a,shift)   (a)
+#define SHR(a,shift)    (a)
+#define SHL(a,shift)    (a)
+#define SATURATE(x,a)   (x)
 
-#define ROUND(a,shift)       (a)
+#define ROUND(a,shift)  (a)
+#define HALF32(x)       (.5f*(x))
 
 #define ADD16(a,b) ((a)+(b))
 #define SUB16(a,b) ((a)-(b))
--- a/libcelt/fixed_debug.h
+++ b/libcelt/fixed_debug.h
@@ -172,6 +172,7 @@
 #define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
 
 #define ROUND(x,a) (EXTRACT16(PSHR32((x),(a))))
+#define HALF32(x)  (SHR32(x,1))
 
 //#define SHR(a,shift) ((a) >> (shift))
 //#define SHL(a,shift) ((a) << (shift))
--- a/libcelt/fixed_generic.h
+++ b/libcelt/fixed_generic.h
@@ -58,6 +58,7 @@
 #define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
 
 #define ROUND(x,a) (EXTRACT16(PSHR32((x),(a))))
+#define HALF32(x)  (SHR32(x,1))
 
 #define ADD16(a,b) ((celt_word16_t)((celt_word16_t)(a)+(celt_word16_t)(b)))
 #define SUB16(a,b) ((celt_word16_t)(a)-(celt_word16_t)(b))
--- a/libcelt/mdct.c
+++ b/libcelt/mdct.c
@@ -104,8 +104,8 @@
    {
       kiss_fft_scalar re, im;
       /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/
-      re = -.5*(in[N2+N4+2*i] + in[N2+N4-2*i-1]);
-      im = -.5*(in[N4+2*i]    - in[N4-2*i-1]);
+      re = -HALF32(in[N2+N4+2*i] + in[N2+N4-2*i-1]);
+      im = -HALF32(in[N4+2*i]    - in[N4-2*i-1]);
       out[2*i]   = S_MUL(re,l->trig[i])  -  S_MUL(im,l->trig[i+N4]);
       out[2*i+1] = S_MUL(im,l->trig[i])  +  S_MUL(re,l->trig[i+N4]);
    }
@@ -113,8 +113,8 @@
    {
       kiss_fft_scalar re, im;
       /* Real part arranged as a-bR, Imag part arranged as -c-dR */
-      re =  .5*(in[2*i-N4] - in[N2+N4-2*i-1]);
-      im = -.5*(in[N4+2*i] + in[N+N4-2*i-1]);
+      re =  HALF32(in[2*i-N4] - in[N2+N4-2*i-1]);
+      im = -HALF32(in[N4+2*i] + in[N+N4-2*i-1]);
       out[2*i]   = S_MUL(re,l->trig[i])  -  S_MUL(im,l->trig[i+N4]);
       out[2*i+1] = S_MUL(im,l->trig[i])  +  S_MUL(re,l->trig[i+N4]);
    }