[FFmpeg-cvslog] avcodec/jpeg2000: Fast fail if HTJ2K codeblocks are present.

caleb git at videolan.org
Sun Aug 7 23:04:21 EEST 2022


ffmpeg | branch: master | caleb <etemesicaleb at gmail.com> | Fri May  6 09:55:43 2022 +0300| [6a0cec53153b58a553ebb79f32309cc4533704eb] | committer: Michael Niedermayer

avcodec/jpeg2000: Fast fail if HTJ2K codeblocks are present.

Reviewed-by: Pierre-Anthony Lemieux <pal at sandflow.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6a0cec53153b58a553ebb79f32309cc4533704eb
---

 libavcodec/jpeg2000.h    | 2 ++
 libavcodec/jpeg2000dec.c | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h
index d06313425e..e5ecb4cbf9 100644
--- a/libavcodec/jpeg2000.h
+++ b/libavcodec/jpeg2000.h
@@ -110,6 +110,8 @@ enum Jpeg2000Quantsty { // quantization style
 #define JPEG2000_CSTY_PREC      0x01 // Precincts defined in coding style
 #define JPEG2000_CSTY_SOP       0x02 // SOP marker present
 #define JPEG2000_CSTY_EPH       0x04 // EPH marker present
+#define JPEG2000_CTSY_HTJ2K_F   0x40 // Only HT code-blocks (Rec. ITU-T T.814 | ISO/IEC 15444-15) are present
+#define JPEG2000_CTSY_HTJ2K_M   0xC0 // HT code blocks (Rec. ITU-T T.814 | ISO/IEC 15444-15) can be present
 
 // Progression orders
 #define JPEG2000_PGOD_LRCP      0x00  // Layer-resolution level-component-position progression
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 503753c4d6..5e177cec25 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -521,6 +521,10 @@ static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)
 
     c->cblk_style = bytestream2_get_byteu(&s->g);
     if (c->cblk_style != 0) { // cblk style
+        if (c->cblk_style & JPEG2000_CTSY_HTJ2K_M || c->cblk_style & JPEG2000_CTSY_HTJ2K_F) {
+            av_log(s->avctx, AV_LOG_ERROR, "Support for High throughput JPEG 2000 is not yet available\n");
+            return AVERROR_PATCHWELCOME;
+        }
         av_log(s->avctx, AV_LOG_WARNING, "extra cblk styles %X\n", c->cblk_style);
         if (c->cblk_style & JPEG2000_CBLK_BYPASS)
             av_log(s->avctx, AV_LOG_WARNING, "Selective arithmetic coding bypass\n");



More information about the ffmpeg-cvslog mailing list