shithub: opus

Download patch

ref: bd43729ecdbbf6d37042d5a35f2b9decb4273aa0
parent: 2e8a3b20d0a8ab6bc9288cbe8ba7ed5cc2cf8ce6
author: Jean-Marc Valin <[email protected]>
date: Mon Feb 25 07:07:13 EST 2008

MDCT is in fixed-point now

--- a/libcelt/mdct.c
+++ b/libcelt/mdct.c
@@ -56,8 +56,6 @@
 #define M_PI 3.14159263
 #endif
 
-#undef S_MUL
-#define S_MUL(a,b) ((a)*(b))
 void mdct_init(mdct_lookup *l,int N)
 {
    int i;
@@ -68,8 +66,18 @@
    l->kfft = kiss_fft_alloc(N4, NULL, NULL);
    l->trig = celt_alloc(N2*sizeof(float));
    /* We have enough points that sine isn't necessary */
+#if defined(FIXED_POINT)
+#if defined(DOUBLE_PRECISION) & !defined(MIXED_PRECISION)
    for (i=0;i<N2;i++)
+      l->trig[i] = SAMP_MAX*cos(2*M_PI*(i+1./8.)/N);
+#else
+   for (i=0;i<N2;i++)
+      l->trig[i] = TRIG_UPSCALE*celt_cos_norm(DIV32(ADD32(SHL32(i,17),16386),N));
+#endif
+#else
+   for (i=0;i<N2;i++)
       l->trig[i] = cos(2*M_PI*(i+1./8.)/N);
+#endif
 }
 
 void mdct_clear(mdct_lookup *l)
--- a/libcelt/mdct.h
+++ b/libcelt/mdct.h
@@ -47,7 +47,7 @@
 typedef struct {
    int n;
    kiss_fft_cfg kfft;
-   float *trig;
+   kiss_twiddle_scalar *trig;
 } mdct_lookup;
 
 void mdct_init(mdct_lookup *l,int N);
--- a/tests/mdct-test.c
+++ b/tests/mdct-test.c
@@ -78,12 +78,12 @@
 
     mdct_init(&cfg, nfft);
     for (k=0;k<nfft;++k) {
-        in[k] = (rand() % 65536) - 32768;
+        in[k] = (rand() % 32768) - 16384;
     }
 
 #ifdef DOUBLE_PRECISION
     for (k=0;k<nfft;++k) {
-       in[k] *= 32768;
+       in[k] *= 65536;
     }
 #endif