Making VBR slightly exceed the budget rather than fail
[opus.git] / tests / mdct-test.c
index c03c191..eb03333 100644 (file)
@@ -2,10 +2,29 @@
 #include "config.h"
 #endif
 
+#define SKIP_CONFIG_H
+
+#ifdef STATIC_MODES
+#undef STATIC_MODES
+#endif
+
 #include <stdio.h>
 #include "mdct.h"
-#include "stack_alloc.h"
+#define CELT_C 
+#include "../libcelt/stack_alloc.h"
+
+#include "../libcelt/kiss_fft.c"
+#include "../libcelt/mdct.c"
+#include "../libcelt/mathops.c"
+#include "../libcelt/entcode.c"
 
+#ifndef M_PI
+#define M_PI 3.141592653
+#endif
+
+#ifdef FIXED_DEBUG  
+long long celt_mips=0;
+#endif
 int ret = 0;
 void check(kiss_fft_scalar  * in,kiss_fft_scalar  * out,int nfft,int isinverse)
 {
@@ -20,7 +39,7 @@ void check(kiss_fft_scalar  * in,kiss_fft_scalar  * out,int nfft,int isinverse)
            double phase = 2*M_PI*(k+.5+.25*nfft)*(bin+.5)/nfft;
            double re = cos(phase);
             
-           re /= nfft/2;
+           re /= nfft/4;
 
            ansr += in[k] * re;
         }
@@ -75,16 +94,20 @@ void test1d(int nfft,int isinverse)
 
     kiss_fft_scalar  * in = (kiss_fft_scalar*)malloc(buflen);
     kiss_fft_scalar  * out= (kiss_fft_scalar*)malloc(buflen);
+    celt_word16  * window= (celt_word16*)malloc(sizeof(celt_word16)*nfft/2);
     int k;
 
-    mdct_init(&cfg, nfft);
+    clt_mdct_init(&cfg, nfft, 0);
     for (k=0;k<nfft;++k) {
         in[k] = (rand() % 32768) - 16384;
     }
 
+    for (k=0;k<nfft/2;++k) {
+       window[k] = Q15ONE;
+    }
 #ifdef DOUBLE_PRECISION
     for (k=0;k<nfft;++k) {
-       in[k] *= 65536;
+       in[k] *= 32768;
     }
 #endif
     
@@ -99,10 +122,12 @@ void test1d(int nfft,int isinverse)
        
     if (isinverse)
     {
-       mdct_backward(&cfg,in,out, NULL, 0);
+       for (k=0;k<nfft;++k)
+          out[k] = 0;
+       clt_mdct_backward(&cfg,in,out, window, nfft/2, 0);
        check_inv(in,out,nfft,isinverse);
     } else {
-       mdct_forward(&cfg,in,out,NULL, 0);
+       clt_mdct_forward(&cfg,in,out,window, nfft/2, 0);
        check(in,out,nfft,isinverse);
     }
     /*for (k=0;k<nfft;++k) printf("%d %d ", out[k].r, out[k].i);printf("\n");*/
@@ -110,7 +135,7 @@ void test1d(int nfft,int isinverse)
 
     free(in);
     free(out);
-    mdct_clear(&cfg);
+    clt_mdct_clear(&cfg);
 }
 
 int main(int argc,char ** argv)
@@ -132,8 +157,6 @@ int main(int argc,char ** argv)
 #ifndef RADIX_TWO_ONLY
         test1d(40,0);
         test1d(40,1);
-        test1d(56,0);
-        test1d(56,1);
         test1d(120,0);
         test1d(120,1);
         test1d(240,0);