]> git.sesse.net Git - ffmpeg/commitdiff
libavcodec/jpeg2000dec: Fix codeblock decode check
authorGautam Ramakrishnan <gautamramk@gmail.com>
Thu, 23 Jul 2020 17:11:10 +0000 (22:41 +0530)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 24 Jul 2020 20:34:15 +0000 (22:34 +0200)
The codeblock decoder checks whether the mqc decoder
has decoded the right number of bytes. However, this
check does not account for the fact that the mqc encoder's
flush routine adds 2 bytes of data which does not have to be
read by the decoder. The check is modified to account for
this. This patch solves issue #4827

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/jpeg2000dec.c

index e941ebb5d0708fb20157378b3d2383f1484d5728..a470cf47dabfaff061e475359b3caa5290cef725 100644 (file)
@@ -1754,9 +1754,13 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
         pass_cnt ++;
     }
 
-    if (cblk->data + cblk->length - 2*(term_cnt < cblk->nb_terminations) != t1->mqc.bp) {
+    if (cblk->data + cblk->length - 2 > t1->mqc.bp) {
         av_log(s->avctx, AV_LOG_WARNING, "End mismatch %"PTRDIFF_SPECIFIER"\n",
-               cblk->data + cblk->length - 2*(term_cnt < cblk->nb_terminations) - t1->mqc.bp);
+               cblk->data + cblk->length - 2 - t1->mqc.bp);
+    }
+
+    if (cblk->data + cblk->length < t1->mqc.bp) {
+        av_log(s->avctx, AV_LOG_WARNING, "Synthetic End of Stream Marker Read.\n");
     }
 
     return 1;