Fix crashes with VBR for short duration frames and very low bitrates. This may, howev...
[opus.git] / tests / real-fft-test.c
index fc73f70..f4bb20b 100644 (file)
@@ -7,17 +7,20 @@
 #include <stdio.h>
 #include <string.h>
 
+#define CELT_C 
+#include "../libcelt/stack_alloc.h"
+#include "../libcelt/kiss_fft.c"
+#include "../libcelt/kiss_fftr.c"
+
+#ifdef FIXED_DEBUG
+long long celt_mips=0;
+#endif
 int ret=0;
 
 static
 kiss_fft_scalar rand_scalar(void) 
 {
-#ifdef USE_SIMD
-    return _mm_set1_ps(rand()-RAND_MAX/2);
-#else
-    kiss_fft_scalar s = (kiss_fft_scalar)(rand() -RAND_MAX/2);
-    return s/2;
-#endif
+    return (rand()%32767)-16384;
 }
 
 static
@@ -88,10 +91,14 @@ int main(void)
     kiss_fft_scalar rin[NFFT+2];
     kiss_fft_scalar rout[NFFT+2];
     kiss_fft_scalar zero;
+    ALLOC_STACK;
     memset(&zero,0,sizeof(zero) ); // ugly way of setting short,int,float,double, or __m128 to zero
 
     for (i=0;i<NFFT;++i) {
         rin[i] = rand_scalar();
+#if defined(FIXED_POINT) && defined(DOUBLE_PRECISION)
+        rin[i] *= 32768;
+#endif
         cin[i].r = rin[i];
         cin[i].i = zero;
     }
@@ -105,7 +112,6 @@ int main(void)
             NFFT,0, snr_compare(cout,sout,(NFFT/2)) );
 
     memset(cin,0,sizeof(cin));
-#if 1
     cin[0].r = rand_scalar();
     cin[NFFT/2].r = rand_scalar();
     for (i=1;i< NFFT/2;++i) {
@@ -113,11 +119,6 @@ int main(void)
         cin[i].r = rand_scalar();
         cin[i].i = rand_scalar();
     }
-#else
-    cin[0].r = 12000;
-    cin[3].r = 12000;
-    cin[NFFT/2].r = 12000;
-#endif
 
     // conjugate symmetry of real signal 
     for (i=1;i< NFFT/2;++i) {