| Jean-Marc Valin | 387a20d | 2008-02-27 13:49:54 +1100 | [diff] [blame^] | 1 | #ifdef HAVE_CONFIG_H |
| 2 | #include "config.h" |
| 3 | #endif |
| 4 | |
| 5 | #include <stdio.h> |
| 6 | #include <stdlib.h> |
| 7 | #include "celt_types.h" |
| 8 | #include "bands.h" |
| 9 | #include <math.h> |
| 10 | #define MAX_SIZE 100 |
| 11 | |
| 12 | int ret=0; |
| 13 | void test_rotation(int N, int K) |
| 14 | { |
| 15 | int i; |
| 16 | double err = 0, ener = 0, snr; |
| 17 | float theta = .007*N/K; |
| 18 | celt_word16_t x0[MAX_SIZE]; |
| 19 | celt_word16_t x1[MAX_SIZE]; |
| 20 | for (i=0;i<N;i++) |
| 21 | x1[i] = x0[i] = rand()%32767-16384; |
| 22 | exp_rotation(x1, N, theta, 1, 1, 8); |
| 23 | exp_rotation(x1, N, theta, -1, 1, 8); |
| 24 | for (i=0;i<N;i++) |
| 25 | { |
| 26 | err += (x0[i]-(double)x1[i])*(x0[i]-(double)x1[i]); |
| 27 | ener += x0[i]*(double)x0[i]; |
| 28 | } |
| 29 | snr = 20*log10(ener/err); |
| 30 | printf ("SNR for size %d (%d pulses) is %f\n", N, K, snr); |
| 31 | if (snr < 60) |
| 32 | ret = 1; |
| 33 | } |
| 34 | |
| 35 | int main() |
| 36 | { |
| 37 | test_rotation(4, 40); |
| 38 | test_rotation(7, 20); |
| 39 | test_rotation(10, 10); |
| 40 | test_rotation(23, 5); |
| 41 | test_rotation(50, 3); |
| 42 | return ret; |
| 43 | } |