Mercurial > libavcodec.hg
changeset 12364:2e96cab6ecde libavcodec
fft-test: exit with non-zero status if test failed
author | mru |
---|---|
date | Wed, 04 Aug 2010 06:56:55 +0000 |
parents | 8e3a8008bb90 |
children | 7c54834209f6 |
files | fft-test.c |
diffstat | 1 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/fft-test.c Wed Aug 04 05:20:49 2010 +0000 +++ b/fft-test.c Wed Aug 04 06:56:55 2010 +0000 @@ -176,22 +176,25 @@ return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; } -static void check_diff(float *tab1, float *tab2, int n, double scale) +static int check_diff(float *tab1, float *tab2, int n, double scale) { int i; double max= 0; double error= 0; + int err = 0; for (i = 0; i < n; i++) { double e= fabsf(tab1[i] - (tab2[i] / scale)); if (e >= 1e-3) { av_log(NULL, AV_LOG_ERROR, "ERROR %d: %f %f\n", i, tab1[i], tab2[i]); + err = 1; } error+= e*e; if(e>max) max= e; } av_log(NULL, AV_LOG_INFO, "max:%f e:%g\n", max, sqrt(error)/n); + return err; } @@ -223,6 +226,7 @@ FFTSample *tab2; int it, i, c; int do_speed = 0; + int err = 1; enum tf_transform transform = TRANSFORM_FFT; int do_inverse = 0; FFTContext s1, *s = &s1; @@ -324,13 +328,13 @@ if (do_inverse) { imdct_ref((float *)tab_ref, (float *)tab1, fft_nbits); ff_imdct_calc(m, tab2, (float *)tab1); - check_diff((float *)tab_ref, tab2, fft_size, scale); + err = check_diff((float *)tab_ref, tab2, fft_size, scale); } else { mdct_ref((float *)tab_ref, (float *)tab1, fft_nbits); ff_mdct_calc(m, tab2, (float *)tab1); - check_diff((float *)tab_ref, tab2, fft_size / 2, scale); + err = check_diff((float *)tab_ref, tab2, fft_size / 2, scale); } break; case TRANSFORM_FFT: @@ -339,7 +343,7 @@ ff_fft_calc(s, tab); fft_ref(tab_ref, tab1, fft_nbits); - check_diff((float *)tab_ref, (float *)tab, fft_size * 2, 1.0); + err = check_diff((float *)tab_ref, (float *)tab, fft_size * 2, 1.0); break; case TRANSFORM_RDFT: if (do_inverse) { @@ -359,7 +363,7 @@ tab[i].re = tab2[i]; tab[i].im = 0; } - check_diff((float *)tab_ref, (float *)tab, fft_size * 2, 0.5); + err = check_diff((float *)tab_ref, (float *)tab, fft_size * 2, 0.5); } else { for (i = 0; i < fft_size; i++) { tab2[i] = tab1[i].re; @@ -368,7 +372,7 @@ ff_rdft_calc(r, tab2); fft_ref(tab_ref, tab1, fft_nbits); tab_ref[0].im = tab_ref[fft_size_2].re; - check_diff((float *)tab_ref, (float *)tab2, fft_size, 1.0); + err = check_diff((float *)tab_ref, (float *)tab2, fft_size, 1.0); } break; case TRANSFORM_DCT: @@ -379,7 +383,7 @@ } else { dct_ref(tab_ref, tab1, fft_nbits); } - check_diff((float *)tab_ref, (float *)tab, fft_size, 1.0); + err = check_diff((float *)tab_ref, (float *)tab, fft_size, 1.0); break; } @@ -442,5 +446,5 @@ ff_dct_end(d); break; } - return 0; + return err; }