diff options
author | Mans Rullgard <mans@mansr.com> | 2012-06-06 17:12:29 +0100 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2012-06-07 11:28:39 +0100 |
commit | d0e9415d234f701bed8837f4e315131ea4e84482 (patch) | |
tree | ba27266099df653546bc8efc7e7e132857e2a393 /tests/rotozoom.c | |
parent | ecf79c4d3e8baaf2f303278ef81db6f8407656bc (diff) | |
download | ffmpeg-d0e9415d234f701bed8837f4e315131ea4e84482.tar.gz |
fate: avoid freopen(NULL) in videogen/rotozoom
A number of systems do not implement freopen() with a NULL filename
correctly. This changes these programs to output individual images
if opening a named output argument as a file fails, in this case
assuming it is a directory.
Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'tests/rotozoom.c')
-rw-r--r-- | tests/rotozoom.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/rotozoom.c b/tests/rotozoom.c index 683e070860..69c88c2e95 100644 --- a/tests/rotozoom.c +++ b/tests/rotozoom.c @@ -158,15 +158,16 @@ int main(int argc, char **argv) { int w, h, i; char buf[1024]; + int isdir = 0; - if (argc > 3) { - printf("usage: %s image.pnm [directory/]\n" + if (argc != 3) { + printf("usage: %s image.pnm file|dir\n" "generate a test video stream\n", argv[0]); return 1; } - if (argc < 3) - err_if(!freopen(NULL, "wb", stdout)); + if (!freopen(argv[2], "wb", stdout)) + isdir = 1; w = DEFAULT_WIDTH; h = DEFAULT_HEIGHT; @@ -181,7 +182,7 @@ int main(int argc, char **argv) for (i = 0; i < DEFAULT_NB_PICT; i++) { gen_image(i, w, h); - if (argc > 2) { + if (isdir) { snprintf(buf, sizeof(buf), "%s%02d.pgm", argv[2], i); pgmyuv_save(buf, w, h, rgb_tab); } else { |