Skip to content

Commit a8b806b

Browse files
committed
gpujpegtool: do not deducde direction for >1 file
If more than one pair of file names (in+out) is given, do not deduce the direction. The user may have given something like: gpujpegtool in1.pnm out1.jpg in2.jpg out.pam # 1st enc, 2nd dec gpujpegtool in1.pnm out1.jpg foo bar # ambigous second pair
1 parent eb080ca commit a8b806b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,19 +467,20 @@ main(int argc, char *argv[])
467467
}
468468

469469
// Detect action if none is specified
470-
if ( encode == 0 && decode == 0 ) {
470+
if ( encode == 0 && decode == 0 && argc == 2 ) {
471471
enum gpujpeg_image_file_format input_format = gpujpeg_image_get_file_format(argv[0]);
472472
enum gpujpeg_image_file_format output_format = gpujpeg_image_get_file_format(argv[1]);
473473
if ( (input_format >= GPUJPEG_IMAGE_FILE_RAW) && output_format == GPUJPEG_IMAGE_FILE_JPEG ) {
474474
encode = 1;
475475
} else if ( input_format == GPUJPEG_IMAGE_FILE_JPEG && (output_format >= GPUJPEG_IMAGE_FILE_RAW) ) {
476476
decode = 1;
477-
} else {
478-
fprintf(stderr, "Action can't be recognized for specified images!\n");
479-
fprintf(stderr, "You must specify --encode or --decode option!\n");
480-
return -1;
481477
}
482478
}
479+
if ( encode == 0 && decode == 0 ) {
480+
fprintf(stderr, "Action can't be recognized for specified images!\n");
481+
fprintf(stderr, "You must specify --encode or --decode option!\n");
482+
return -1;
483+
}
483484

484485
struct gpujpeg_parameters param_saved = param;
485486
struct gpujpeg_image_parameters param_image_saved = param_image;

0 commit comments

Comments
 (0)