summaryrefslogtreecommitdiff
path: root/src/lib/openjp2/openjpeg.c
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/lib/openjp2/openjpeg.c
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/lib/openjp2/openjpeg.c')
-rw-r--r--src/lib/openjp2/openjpeg.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/openjp2/openjpeg.c b/src/lib/openjp2/openjpeg.c
index 0c5f2d5f..29d3ee52 100644
--- a/src/lib/openjp2/openjpeg.c
+++ b/src/lib/openjp2/openjpeg.c
@@ -219,6 +219,10 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
l_codec->m_codec_data.m_decompression.opj_setup_decoder =
(void (*)(void *, opj_dparameters_t *)) opj_j2k_setup_decoder;
+ l_codec->m_codec_data.m_decompression.opj_decoder_set_strict_mode =
+ (void (*)(void *, OPJ_BOOL)) opj_j2k_decoder_set_strict_mode;
+
+
l_codec->m_codec_data.m_decompression.opj_read_tile_header =
(OPJ_BOOL(*)(void *,
OPJ_UINT32*,
@@ -326,6 +330,9 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
l_codec->m_codec_data.m_decompression.opj_setup_decoder =
(void (*)(void *, opj_dparameters_t *)) opj_jp2_setup_decoder;
+ l_codec->m_codec_data.m_decompression.opj_decoder_set_strict_mode =
+ (void (*)(void *, OPJ_BOOL)) opj_jp2_decoder_set_strict_mode;
+
l_codec->m_codec_data.m_decompression.opj_set_decode_area =
(OPJ_BOOL(*)(void *,
opj_image_t*,
@@ -426,6 +433,26 @@ OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
return OPJ_FALSE;
}
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode(opj_codec_t *p_codec,
+ OPJ_BOOL strict)
+{
+ if (p_codec) {
+ opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+
+ if (! l_codec->is_decompressor) {
+ opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR,
+ "Codec provided to the opj_decoder_set_strict_mode function is not a decompressor handler.\n");
+ return OPJ_FALSE;
+ }
+
+ l_codec->m_codec_data.m_decompression.opj_decoder_set_strict_mode(
+ l_codec->m_codec,
+ strict);
+ return OPJ_TRUE;
+ }
+ return OPJ_FALSE;
+}
+
OPJ_BOOL OPJ_CALLCONV opj_read_header(opj_stream_t *p_stream,
opj_codec_t *p_codec,
opj_image_t **p_image)