diff --git a/libswresample/swresample_test.c b/libswresample/swresample_test.c index b7ef365cc8..e64f804a31 100644 --- a/libswresample/swresample_test.c +++ b/libswresample/swresample_test.c @@ -132,6 +132,10 @@ static void setup_array(uint8_t *out[SWR_CH_MAX], uint8_t *in, enum AVSampleForm } } +static int cmp(const int *a, const int *b){ + return *a - *b; +} + int main(int argc, char **argv){ int in_sample_rate, out_sample_rate, ch ,i, in_ch_layout_index, out_ch_layout_index, osr, flush_count; int in_sample_fmt_index, out_sample_fmt_index; @@ -145,24 +149,50 @@ int main(int argc, char **argv){ uint8_t *amid[SWR_CH_MAX]; int flush_i=0; int mode = 0; + int max_tests = FF_ARRAY_ELEMS(rates) * FF_ARRAY_ELEMS(layouts) * FF_ARRAY_ELEMS(formats) * FF_ARRAY_ELEMS(layouts) * FF_ARRAY_ELEMS(formats); + int num_tests = 10000; + uint32_t seed = 0; + int remaining_tests[max_tests]; + int test; struct SwrContext * forw_ctx= NULL; struct SwrContext *backw_ctx= NULL; + if (argc > 1) { + if (!strcmp(argv[1], "-h")) { + av_log(NULL, AV_LOG_INFO, "Usage: swresample-test []\n" + "Default is %d\n", num_tests); + return 0; + } + num_tests = strtol(argv[1], NULL, 0); + if(num_tests<= 0 || num_tests>max_tests) + num_tests = max_tests; + } + + for(i=0; i>32; + FFSWAP(int, remaining_tests[r], remaining_tests[max_tests - test - 1]); + } + qsort(remaining_tests + max_tests - num_tests, num_tests, sizeof(remaining_tests[0]), cmp); in_sample_rate=16000; - for(osr=0; osr%d, rate:%5d->%5d, fmt:%s->%s\n", in_ch_count, out_ch_count, @@ -271,10 +301,6 @@ int main(int argc, char **argv){ fprintf(stderr, "\n"); - } - } - } - } } return 0;