mirror of https://git.ffmpeg.org/ffmpeg.git
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>
This commit is contained in:
parent
711ffb84df
commit
364c60bf64
|
@ -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:
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
end:
|
||||
res = 0;
|
||||
}
|
||||
error:
|
||||
av_free(data);
|
||||
|
||||
|
|
Loading…
Reference in New Issue