X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Ffft-test.c;h=0a2b93895de4486359953ec2e252fdb7d64c2f5a;hb=ddffcb2d3a81e203cff6f3e39e40bf5720f7391e;hp=5a79c88b0e19291ede77f7023d4e5f440f0ff57a;hpb=12807c8d874746d143d7f6a945e031e1aa646709;p=ffmpeg diff --git a/libavcodec/fft-test.c b/libavcodec/fft-test.c index 5a79c88b0e1..0a2b93895de 100644 --- a/libavcodec/fft-test.c +++ b/libavcodec/fft-test.c @@ -19,10 +19,11 @@ */ /** - * @file fft-test.c + * @file libavcodec/fft-test.c * FFT and MDCT tests. */ +#include "libavutil/lfg.h" #include "dsputil.h" #include #include @@ -32,8 +33,6 @@ #undef exit -int mm_flags; - /* reference fft */ #define MUL16(a,b) ((a) * (b)) @@ -46,10 +45,10 @@ int mm_flags; FFTComplex *exptab; -void fft_ref_init(int nbits, int inverse) +static void fft_ref_init(int nbits, int inverse) { int n, i; - float c1, s1, alpha; + double c1, s1, alpha; n = 1 << nbits; exptab = av_malloc((n / 2) * sizeof(FFTComplex)); @@ -65,10 +64,10 @@ void fft_ref_init(int nbits, int inverse) } } -void fft_ref(FFTComplex *tabr, FFTComplex *tab, int nbits) +static void fft_ref(FFTComplex *tabr, FFTComplex *tab, int nbits) { int n, i, j, k, n2; - float tmp_re, tmp_im, s, c; + double tmp_re, tmp_im, s, c; FFTComplex *q; n = 1 << nbits; @@ -94,10 +93,11 @@ void fft_ref(FFTComplex *tabr, FFTComplex *tab, int nbits) } } -void imdct_ref(float *out, float *in, int n) +static void imdct_ref(float *out, float *in, int nbits) { + int n = 1<= 1e-3) { + double e= fabsf(tab1[i] - tab2[i]); + if (e >= 1e-3) { av_log(NULL, AV_LOG_ERROR, "ERROR %d: %f %f\n", i, tab1[i], tab2[i]); } + error+= e*e; + if(e>max) max= e; } + av_log(NULL, AV_LOG_INFO, "max:%f e:%g\n", max, sqrt(error)/n); } -void help(void) +static void help(void) { av_log(NULL, AV_LOG_INFO,"usage: fft-test [-h] [-s] [-i] [-n b]\n" "-h print this help\n" @@ -170,7 +179,7 @@ void help(void) int main(int argc, char **argv) { FFTComplex *tab, *tab1, *tab_ref; - FFTSample *tabtmp, *tab2; + FFTSample *tab2; int it, i, c; int do_speed = 0; int do_mdct = 0; @@ -179,7 +188,6 @@ int main(int argc, char **argv) MDCTContext m1, *m = &m1; int fft_nbits, fft_size; - mm_flags = 0; fft_nbits = 9; for(;;) { c = getopt(argc, argv, "hsimn:"); @@ -208,7 +216,6 @@ int main(int argc, char **argv) tab = av_malloc(fft_size * sizeof(FFTComplex)); tab1 = av_malloc(fft_size * sizeof(FFTComplex)); tab_ref = av_malloc(fft_size * sizeof(FFTComplex)); - tabtmp = av_malloc(fft_size / 2 * sizeof(FFTSample)); tab2 = av_malloc(fft_size * sizeof(FFTSample)); if (do_mdct) { @@ -239,13 +246,13 @@ int main(int argc, char **argv) if (do_mdct) { if (do_inverse) { - imdct_ref((float *)tab_ref, (float *)tab1, fft_size); - ff_imdct_calc(m, tab2, (float *)tab1, tabtmp); + imdct_ref((float *)tab_ref, (float *)tab1, fft_nbits); + ff_imdct_calc(m, tab2, (float *)tab1); check_diff((float *)tab_ref, tab2, fft_size); } else { - mdct_ref((float *)tab_ref, (float *)tab1, fft_size); + mdct_ref((float *)tab_ref, (float *)tab1, fft_nbits); - ff_mdct_calc(m, tab2, (float *)tab1, tabtmp); + ff_mdct_calc(m, tab2, (float *)tab1); check_diff((float *)tab_ref, tab2, fft_size / 2); } @@ -272,9 +279,9 @@ int main(int argc, char **argv) for(it=0;it