@@ -107,8 +107,11 @@ static void
107107print_help (bool full )
108108{
109109 printf ("gpujpegtool [options] input.rgb output.jpg [input2.rgb output2.jpg ...]\n"
110- " -h, --help print help\n"
111- " -v, --verbose verbose output (multiply to increase verbosity - max 3) \n"
110+ " -h, --help print help\n" );
111+ if (!full ) {
112+ printf (" -H, --fullhelp print all options\n" );
113+ }
114+ printf (" -v, --verbose verbose output (multiply to increase verbosity - max 3) \n"
112115 " -D, --device set cuda device id (default 0)\n"
113116 " -L, --device-list list cuda devices\n"
114117 "\n" );
@@ -145,11 +148,7 @@ print_help(bool full)
145148 );
146149 if ( full ) {
147150 printf (" -b, --debug debug helpers (reset GPU for leakcheck, dump infile if not regular)\n"
148- " -O " GPUJPEG_DEC_OPT_TGA_RLE_BOOL "=[" GPUJPEG_VAL_FALSE "|" GPUJPEG_VAL_TRUE
149- "] set decoder option (not) to output RLE TGA; other options exist\n" );
150- }
151- else {
152- printf (" -H, --fullhelp print all options\n" );
151+ " -O <key>=<value>|help set encoder/decoder option, 'help' for list\n" );
153152 }
154153 printf ("recognized raw input/output file extensions: rgb, yuv, pnm... (use`gpujpegtool exts` for the full list)\n" );
155154}
@@ -351,18 +350,26 @@ struct coder_opts
351350 char * opt ;
352351 char * val ;
353352};
354- static bool
353+ static int
355354assign_coder_opt (struct coder_opts * encoder_opts , struct coder_opts * decoder_opts , char * optval )
356355{
356+ if (strcmp (optval , "help" ) == 0 ) {
357+ printf ("Available options:\n" );
358+ printf ("decoder:\n" );
359+ gpujpeg_decoder_print_options ();
360+ printf ("\nencoder:\n" );
361+ gpujpeg_encoder_print_options ();
362+ return 1 ;
363+ }
357364 char * opt = optval ;
358365 char * delim = strchr (optval , '=' );
359366 if ( delim == NULL ) {
360367 fprintf (stderr , "No value for %s!\n" , optval );
361- return false ;
368+ return -1 ;
362369 }
363370 if ( strncmp (optval , "enc_" , 4 ) != 0 && strncmp (optval , "dec_" , 4 ) != 0 ) {
364371 fprintf (stderr , "Option should start with either enc_ or dec_, given %s!\n" , optval );
365- return false ;
372+ return -1 ;
366373 }
367374 * delim = '\0' ;
368375 char * val = delim + 1 ;
@@ -371,11 +378,11 @@ assign_coder_opt(struct coder_opts* encoder_opts, struct coder_opts* decoder_opt
371378 if ( opts [i ].opt == NULL ) {
372379 opts [i ].opt = opt ;
373380 opts [i ].val = val ;
374- return true ;
381+ return 0 ;
375382 }
376383 }
377384 fprintf (stderr , "Too much options!\n" );
378- return false ;
385+ return -1 ;
379386}
380387static bool
381388set_encoder_opts (struct gpujpeg_encoder * encoder , const struct coder_opts * opts )
@@ -612,8 +619,9 @@ main(int argc, char *argv[])
612619 debug = true;
613620 break ;
614621 case 'O' :
615- if ( !assign_coder_opt (encoder_options , decoder_options , tstr_to_mbs (optarg )) ) {
616- return 1 ;
622+ rc = assign_coder_opt (encoder_options , decoder_options , tstr_to_mbs (optarg ));
623+ if (rc != 0 ) {
624+ return rc < 0 ? 1 : 0 ;
617625 }
618626 break ;
619627 case '?' :
0 commit comments