summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorRobert Gabriel Jakabosky <rjakabosky+github@neoawareness.com>2022-02-10 21:27:17 +0800
committerGitHub <noreply@github.com>2022-02-10 14:27:17 +0100
commit883c31dbe09771aab043744ac2b490d7386878e3 (patch)
tree254f62d7e8158b28eea45e6ff6a58b212a380371 /src/bin
parent99d555c0f1818277645a0c79a5199f2e827d68cc (diff)
Add support for partial bitstream decoding (#1407) (fixes #715)
Add a -allow-partial option to opj_decompress utility and a opj_decoder_set_strict_mode() option to the API Co-authored-by: Chris Hafey <chafey@gmail.com>
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/jp2/opj_decompress.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c
index f00f1403..c32cc3dc 100644
--- a/src/bin/jp2/opj_decompress.c
+++ b/src/bin/jp2/opj_decompress.c
@@ -153,6 +153,8 @@ typedef struct opj_decompress_params {
int num_threads;
/* Quiet */
int quiet;
+ /* Allow partial decode */
+ int allow_partial;
/** 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, " -allow-partial\n"
+ " Disable strict mode to allow decoding partial codestreams.\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},
+ {"allow-partial", 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->allow_partial);
totlen = sizeof(long_option);
opj_reset_options_reading();
img_fol->set_out_format = 0;
@@ -1491,6 +1497,16 @@ int main(int argc, char **argv)
goto fin;
}
+ /* Disable strict mode if we want to decode partial codestreams. */
+ if (parameters.allow_partial &&
+ !opj_decoder_set_strict_mode(l_codec, OPJ_FALSE)) {
+ fprintf(stderr, "ERROR -> opj_decompress: failed to disable 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");