diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-10-17 00:10:35 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-17 13:56:36 +0400 |
commit | 364c60bf64a21c804b5255e9a2336a59cfae54d8 (patch) | |
tree | 3a44759dad822b9c4828d8965a6daa62443ac501 /libswscale/swscale-test.c | |
parent | 711ffb84df29b1179e2dac9c689e3f112a0bf046 (diff) |
sws-test: parse command line args before initing contexts
This fixes parsing comand line args after ref
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswscale/swscale-test.c')
-rw-r--r-- | libswscale/swscale-test.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/libswscale/swscale-test.c b/libswscale/swscale-test.c index 3484c9b771..40dec546b0 100644 --- a/libswscale/swscale-test.c +++ b/libswscale/swscale-test.c @@ -356,34 +356,20 @@ int main(int argc, char **argv) AVLFG rand; int res = -1; int i; + FILE *fp = NULL; if (!rgb_data || !data) return -1; - sws = sws_getContext(W / 12, H / 12, AV_PIX_FMT_RGB32, W, H, - AV_PIX_FMT_YUVA420P, SWS_BILINEAR, NULL, NULL, NULL); - - av_lfg_init(&rand, 1); - - for (y = 0; y < H; y++) - for (x = 0; x < W * 4; x++) - rgb_data[ x + y * 4 * W] = av_lfg_get(&rand); - sws_scale(sws, rgb_src, rgb_stride, 0, H, src, stride); - sws_freeContext(sws); - av_free(rgb_data); - for (i = 1; i < argc; i += 2) { if (argv[i][0] != '-' || i + 1 == argc) goto bad_option; if (!strcmp(argv[i], "-ref")) { - FILE *fp = fopen(argv[i + 1], "r"); + fp = fopen(argv[i + 1], "r"); if (!fp) { fprintf(stderr, "could not open '%s'\n", argv[i + 1]); goto error; } - res = fileTest(src, stride, W, H, fp, srcFormat, dstFormat); - fclose(fp); - goto end; } else if (!strcmp(argv[i], "-src")) { srcFormat = av_get_pix_fmt(argv[i + 1]); if (srcFormat == AV_PIX_FMT_NONE) { @@ -403,9 +389,25 @@ bad_option: } } - selfTest(src, stride, W, H, srcFormat, dstFormat); -end: - res = 0; + sws = sws_getContext(W / 12, H / 12, AV_PIX_FMT_RGB32, W, H, + AV_PIX_FMT_YUVA420P, SWS_BILINEAR, NULL, NULL, NULL); + + av_lfg_init(&rand, 1); + + for (y = 0; y < H; y++) + for (x = 0; x < W * 4; x++) + rgb_data[ x + y * 4 * W] = av_lfg_get(&rand); + sws_scale(sws, rgb_src, rgb_stride, 0, H, src, stride); + sws_freeContext(sws); + av_free(rgb_data); + + if(fp) { + res = fileTest(src, stride, W, H, fp, srcFormat, dstFormat); + fclose(fp); + } else { + selfTest(src, stride, W, H, srcFormat, dstFormat); + res = 0; + } error: av_free(data); |