void test_rotation(int N, int K) { int i; double err = 0, ener = 0, snr, snr0; opus_val16 x0[MAX_SIZE]; opus_val16 x1[MAX_SIZE]; for (i=0;i<N;i++) x1[i] = x0[i] = rand()%32767-16384; exp_rotation(x1, N, 1, 1, K, SPREAD_NORMAL); for (i=0;i<N;i++) { err += (x0[i]-(double)x1[i])*(x0[i]-(double)x1[i]); ener += x0[i]*(double)x0[i]; } snr0 = 20*log10(ener/err); err = ener = 0; exp_rotation(x1, N, -1, 1, K, SPREAD_NORMAL); for (i=0;i<N;i++) { err += (x0[i]-(double)x1[i])*(x0[i]-(double)x1[i]); ener += x0[i]*(double)x0[i]; } snr = 20*log10(ener/err); printf ("SNR for size %d (%d pulses) is %f (was %f without inverse)\n", N, K, snr, snr0); if (snr < 60 || snr0 > 20) { fprintf(stderr, "FAIL!\n"); ret = 1; } }
void test_rotation(int N, int K) { int i; double err = 0, ener = 0, snr, snr0; celt_word16_t x0[MAX_SIZE]; celt_word16_t x1[MAX_SIZE]; int nb_rotations = (N+4*K)/(8*K); for (i=0;i<N;i++) x1[i] = x0[i] = rand()%32767-16384; exp_rotation(x1, N, 1, 1, nb_rotations); for (i=0;i<N;i++) { err += (x0[i]-(double)x1[i])*(x0[i]-(double)x1[i]); ener += x0[i]*(double)x0[i]; } snr0 = 20*log10(ener/err); err = ener = 0; exp_rotation(x1, N, -1, 1, nb_rotations); for (i=0;i<N;i++) { err += (x0[i]-(double)x1[i])*(x0[i]-(double)x1[i]); ener += x0[i]*(double)x0[i]; } snr = 20*log10(ener/err); printf ("SNR for size %d (%d pulses) is %f (was %f without inverse)\n", N, K, snr, snr0); if (snr < 60 || snr0 > 20) ret = 1; }