Skip to content

Commit 7751536

Browse files
committed
gpujpegtool: if invalid raw ext passed, print avail
eg. `gpujpegtool -s 1920x1080 -e null.bla out.jpg`, but as with HEAD~4, the .bla file can be an existent file as well, which will convert (with warnings, however).
1 parent e1212db commit 7751536

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/gpujpeg_common.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,16 @@ gpujpeg_image_get_file_format(const char* filename)
420420
PRINTF("\nUse \"help.tst\" (eg. `gpujpegtool help.tst null.jpg`) for test image usage).\n");
421421
return GPUJPEG_IMAGE_FILE_UNKNOWN;
422422
}
423+
if ( strcmp(filename, "rawhelp") == 0 ) {
424+
PRINTF("Recognized raw extensions:");
425+
for ( unsigned i = 0; i < sizeof extensions / sizeof extensions[0]; i++ ) {
426+
if ( extensions[i].format > GPUJPEG_IMAGE_FILE_RAW ) {
427+
PRINTF(" %s", extensions[i].ext);
428+
}
429+
}
430+
PRINTF("\n");
431+
return GPUJPEG_IMAGE_FILE_UNKNOWN;
432+
}
423433

424434
const char * ext = strrchr(filename, '.');
425435
if ( ext == NULL )

src/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ main(int argc, char *argv[])
565565
enum gpujpeg_image_file_format output_format = gpujpeg_image_get_file_format(output);
566566
if ( !GPUJPEG_IMAGE_FORMAT_IS_RAW(input_format) ) {
567567
fprintf(stderr, "[Warning] Encoder input file [%s] should be raw image (" RAW_EXTS ")!\n", input);
568+
gpujpeg_image_get_file_format("rawhelp");
568569
if ( input_format & GPUJPEG_IMAGE_FILE_JPEG ) {
569570
return -1;
570571
}
@@ -711,6 +712,7 @@ main(int argc, char *argv[])
711712
}
712713
if ( !GPUJPEG_IMAGE_FORMAT_IS_RAW(output_format) ) {
713714
fprintf(stderr, "[Warning] Decoder output file [%s] should be raw image (" RAW_EXTS ")!\n", output);
715+
gpujpeg_image_get_file_format("rawhelp");
714716
if ( output_format & GPUJPEG_IMAGE_FILE_JPEG ) {
715717
ret = EXIT_FAILURE; continue;
716718
}

0 commit comments

Comments
 (0)