Skip to content

Commit bf7e9cc

Browse files
cgisquetmichaelni
authored andcommitted
tests: allow passing dimensions to videogen
Signed-off-by: Michael Niedermayer <[email protected]>
1 parent 7b4c460 commit bf7e9cc

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

tests/videogen.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,37 @@ static void gen_image(int num, int w, int h)
141141
}
142142
}
143143

144+
void print_help(const char* name)
145+
{
146+
printf("usage: %s file|dir [w=%i] [h=%i]\n"
147+
"generate a test video stream\n",
148+
name, DEFAULT_WIDTH, DEFAULT_HEIGHT);
149+
exit(1);
150+
}
151+
144152
int main(int argc, char **argv)
145153
{
146154
int w, h, i;
147155
char buf[1024];
148156
int isdir = 0;
149157

150-
if (argc != 2) {
151-
printf("usage: %s file|dir\n"
152-
"generate a test video stream\n", argv[0]);
153-
exit(1);
158+
if (argc < 2 || argc > 4) {
159+
print_help(argv[0]);
154160
}
155161

156162
if (!freopen(argv[1], "wb", stdout))
157163
isdir = 1;
158164

159165
w = DEFAULT_WIDTH;
166+
if(argc > 2) {
167+
w = atoi(argv[2]);
168+
if (w < 1) print_help(argv[0]);
169+
}
160170
h = DEFAULT_HEIGHT;
171+
if(argc > 3) {
172+
h = atoi(argv[3]);
173+
if (h < 1) print_help(argv[0]);
174+
}
161175

162176
rgb_tab = malloc(w * h * 3);
163177
wrap = w * 3;

0 commit comments

Comments
 (0)