Add strict mode parameter to opj_decompress CLI.

This commit is contained in:
Robert G. Jakabosky 2022-01-29 21:12:21 +08:00
parent fd4a757cf8
commit f4088f9a74
No known key found for this signature in database
GPG Key ID: 0C38AF433FE0B1C0
1 changed files with 15 additions and 0 deletions

View File

@ -153,6 +153,8 @@ typedef struct opj_decompress_params {
int num_threads;
/* Quiet */
int quiet;
/* Strict decoding mode */
int strict;
/** number of components to decode */
OPJ_UINT32 numcomps;
/** indices of components to decode */
@ -246,6 +248,8 @@ static void decode_help_display(void)
fprintf(stdout, " -threads <num_threads|ALL_CPUS>\n"
" Number of threads to use for decoding or ALL_CPUS for all available cores.\n");
}
fprintf(stdout, " -strict\n"
" Enable strict decoding mode.\n");
fprintf(stdout, " -quiet\n"
" Disable output from the library and other output.\n");
/* UniPG>> */
@ -601,6 +605,7 @@ int parse_cmdline_decoder(int argc, char **argv,
{"split-pnm", NO_ARG, NULL, 1},
{"threads", REQ_ARG, NULL, 'T'},
{"quiet", NO_ARG, NULL, 1},
{"strict", NO_ARG, NULL, 1},
};
const char optlist[] = "i:o:r:l:x:d:t:p:c:"
@ -616,6 +621,7 @@ int parse_cmdline_decoder(int argc, char **argv,
long_option[3].flag = &(parameters->upsample);
long_option[4].flag = &(parameters->split_pnm);
long_option[6].flag = &(parameters->quiet);
long_option[7].flag = &(parameters->strict);
totlen = sizeof(long_option);
opj_reset_options_reading();
img_fol->set_out_format = 0;
@ -1491,6 +1497,15 @@ int main(int argc, char **argv)
goto fin;
}
/* Set strict mode. */
if (!opj_decoder_set_strict_mode(l_codec, parameters.strict)) {
fprintf(stderr, "ERROR -> opj_decompress: failed to set strict mode\n");
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
failed = 1;
goto fin;
}
if (parameters.num_threads >= 1 &&
!opj_codec_set_threads(l_codec, parameters.num_threads)) {
fprintf(stderr, "ERROR -> opj_decompress: failed to set number of threads\n");