shithub: opus

Download patch

ref: 104c218c9b1565a8d4bc403fea1a527c19271935
parent: b311554ccda8d03267b38ba2a491ba57e9c8ed65
author: Jean-Marc Valin <[email protected]>
date: Wed Mar 19 05:33:49 EDT 2008

Random numbers should work on 16-bit archs.

--- a/tests/dft-test.c
+++ b/tests/dft-test.c
@@ -58,8 +58,8 @@
     int k;
 
     for (k=0;k<nfft;++k) {
-        in[k].r = (rand() % 65536) - 32768;
-        in[k].i = (rand() % 65536) - 32768;
+        in[k].r = (rand() % 32767) - 16384;
+        in[k].i = (rand() % 32767) - 16384;
     }
 
 #ifdef DOUBLE_PRECISION
--- a/tests/real-fft-test.c
+++ b/tests/real-fft-test.c
@@ -12,12 +12,7 @@
 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
@@ -92,6 +87,9 @@
 
     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 +103,6 @@
             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 +110,6 @@
         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) {