PR #25432 opened by Kacper Michajłow (kasper93) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25432 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25432.patch
A code-block has Mb - P coded bit-planes, where P is the number of missing most significant bit-planes from the packet header and Mb the number of bit-planes of its band from Equation E-2, raised by the scaling value with an ROI. The missing bit-planes are zero (B.10.5), so with P >= Mb the code-block is zero. The packet decoder rejected P > Mb as invalid data and failed the whole frame. A 2K DCP contains such code-blocks, P = 13 in bands with Mb = 10 or 12 and one empty coding pass. Store zero coded bit-planes for them and skip the code-block in the tile decoder like one without data. From 7d35383a6b2c61242ac6a47cbb6c97e2de657e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]> Date: Sat, 24 Oct 2026 07:46:52 +0200 Subject: [PATCH] avcodec/jpeg2000dec: decode code-blocks without coded bit-planes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A code-block has Mb - P coded bit-planes, where P is the number of missing most significant bit-planes from the packet header and Mb the number of bit-planes of its band from Equation E-2, raised by the scaling value with an ROI. The missing bit-planes are zero (B.10.5), so with P >= Mb the code-block is zero. The packet decoder rejected P > Mb as invalid data and failed the whole frame. A 2K DCP contains such code-blocks, P = 13 in bands with Mb = 10 or 12 and one empty coding pass. Store zero coded bit-planes for them and skip the code-block in the tile decoder like one without data. Signed-off-by: Kacper Michajłow <[email protected]> --- libavcodec/jpeg2000dec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 9282f7610ef..c4600690b36 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -1206,13 +1206,13 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, if (incl) { int zbp = tag_tree_decode(s, prec->zerobits + cblkno, 100); int v = expn[bandno] + numgbits - 1 - (zbp - tile->comp->roi_shift); - if (v < 0 || v > 30) { + if (v > 30) { av_log(s->avctx, AV_LOG_ERROR, "nonzerobits %d invalid or unsupported\n", v); return AVERROR_INVALIDDATA; } cblk->incl = 1; - cblk->nonzerobits = v; + cblk->nonzerobits = FFMAX(v, 0); cblk->zbp = zbp; cblk->lblock = 3; } @@ -2285,6 +2285,10 @@ static inline int tile_codeblocks(const Jpeg2000DecoderContext *s, Jpeg2000Tile Jpeg2000Cblk *cblk = prec->cblk + cblkno; + // No coded bit-planes, nothing to decode. + if (!cblk->nonzerobits) + continue; + if (cblk->modes & JPEG2000_CTSY_HTJ2K_F) ret = ff_jpeg2000_decode_htj2k(s, codsty, &t1, cblk, cblk->coord[0][1] - cblk->coord[0][0], -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
