Commit 364c60bf authored by Michael Niedermayer's avatar Michael Niedermayer

sws-test: parse command line args before initing contexts

This fixes parsing comand line args after ref
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 711ffb84
...@@ -356,34 +356,20 @@ int main(int argc, char **argv) ...@@ -356,34 +356,20 @@ int main(int argc, char **argv)
AVLFG rand; AVLFG rand;
int res = -1; int res = -1;
int i; int i;
FILE *fp = NULL;
if (!rgb_data || !data) if (!rgb_data || !data)
return -1; 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) { for (i = 1; i < argc; i += 2) {
if (argv[i][0] != '-' || i + 1 == argc) if (argv[i][0] != '-' || i + 1 == argc)
goto bad_option; goto bad_option;
if (!strcmp(argv[i], "-ref")) { if (!strcmp(argv[i], "-ref")) {
FILE *fp = fopen(argv[i + 1], "r"); fp = fopen(argv[i + 1], "r");
if (!fp) { if (!fp) {
fprintf(stderr, "could not open '%s'\n", argv[i + 1]); fprintf(stderr, "could not open '%s'\n", argv[i + 1]);
goto error; goto error;
} }
res = fileTest(src, stride, W, H, fp, srcFormat, dstFormat);
fclose(fp);
goto end;
} else if (!strcmp(argv[i], "-src")) { } else if (!strcmp(argv[i], "-src")) {
srcFormat = av_get_pix_fmt(argv[i + 1]); srcFormat = av_get_pix_fmt(argv[i + 1]);
if (srcFormat == AV_PIX_FMT_NONE) { if (srcFormat == AV_PIX_FMT_NONE) {
...@@ -403,9 +389,25 @@ bad_option: ...@@ -403,9 +389,25 @@ bad_option:
} }
} }
selfTest(src, stride, W, H, srcFormat, dstFormat); sws = sws_getContext(W / 12, H / 12, AV_PIX_FMT_RGB32, W, H,
end: AV_PIX_FMT_YUVA420P, SWS_BILINEAR, NULL, NULL, NULL);
res = 0;
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: error:
av_free(data); av_free(data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment