mdct_end(m);
ff_mdct_end(m);
int main(int argc, char **argv){    FFTComplex *tab, *tab1, *tab_ref;    FFTSample *tabtmp, *tab2;    int it, i, c;    int do_speed = 0;    int do_mdct = 0;    int do_inverse = 0;    FFTContext s1, *s = &s1;    MDCTContext m1, *m = &m1;    int fft_nbits, fft_size;    mm_flags = 0;    fft_nbits = 9;    for(;;) {        c = getopt(argc, argv, "hsimn:");        if (c == -1)            break;        switch(c) {        case 'h':            help();            break;        case 's':            do_speed = 1;            break;        case 'i':            do_inverse = 1;            break;        case 'm':            do_mdct = 1;            break;        case 'n':            fft_nbits = atoi(optarg);            break;        }    }    fft_size = 1 << fft_nbits;    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) {        if (do_inverse)            printf("IMDCT");        else            printf("MDCT");        mdct_init(m, fft_nbits, do_inverse);    } else {        if (do_inverse)            printf("IFFT");        else            printf("FFT");        fft_init(s, fft_nbits, do_inverse);        fft_ref_init(fft_nbits, do_inverse);    }    printf(" %d test\n", fft_size);    /* generate random data */    for(i=0;i<fft_size;i++) {        tab1[i].re = frandom();        tab1[i].im = frandom();    }    /* checking result */    printf("Checking...\n");    if (do_mdct) {        if (do_inverse) {            imdct_ref((float *)tab_ref, (float *)tab1, fft_size);            imdct_calc(m, tab2, (float *)tab1, tabtmp);            check_diff((float *)tab_ref, tab2, fft_size);        } else {            mdct_ref((float *)tab_ref, (float *)tab1, fft_size);                        mdct_calc(m, tab2, (float *)tab1, tabtmp);            check_diff((float *)tab_ref, tab2, fft_size / 2);        }    } else {        memcpy(tab, tab1, fft_size * sizeof(FFTComplex));        fft_permute(s, tab);        fft_calc(s, tab);                fft_ref(tab_ref, tab1, fft_nbits);        check_diff((float *)tab_ref, (float *)tab, fft_size * 2);    }    /* do a speed test */    if (do_speed) {        INT64 time_start, duration;        int nb_its;        printf("Speed test...\n");        /* we measure during about 1 seconds */        nb_its = 1;        for(;;) {            time_start = gettime();            for(it=0;it<nb_its;it++) {                if (do_mdct) {                    if (do_inverse) {                        imdct_calc(m, (float *)tab, (float *)tab1, tabtmp);                    } else {                        mdct_calc(m, (float *)tab, (float *)tab1, tabtmp);                    }                } else {                    memcpy(tab, tab1, fft_size * sizeof(FFTComplex));                    fft_calc(s, tab);                }            }            duration = gettime() - time_start;            if (duration >= 1000000)                break;            nb_its *= 2;        }        printf("time: %0.1f us/transform [total time=%0.2f s its=%d]\n",                (double)duration / nb_its,                (double)duration / 1000000.0,               nb_its);    }        if (do_mdct) {        mdct_end(m);    } else {        fft_end(s);    }    return 0;}