avcodec/jpeg2000dec: account two last bytes from end of bytestream as EOC marker
authorPaul B Mahol <onemda@gmail.com>
Fri, 25 Mar 2016 10:22:39 +0000 (11:22 +0100)
committerPaul B Mahol <onemda@gmail.com>
Fri, 25 Mar 2016 21:00:52 +0000 (22:00 +0100)
This silences missing EOC marker when decoding j2k files with Psot set to 0.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
libavcodec/jpeg2000dec.c

index c13670e..962b7bc 100644 (file)
@@ -737,9 +737,9 @@ static int get_sot(Jpeg2000DecoderContext *s, int n)
     bytestream2_get_byteu(&s->g);               // TNsot
 
     if (!Psot)
-        Psot = bytestream2_get_bytes_left(&s->g) + n + 2;
+        Psot = bytestream2_get_bytes_left(&s->g) - 2 + n + 2;
 
-    if (Psot > bytestream2_get_bytes_left(&s->g) + n + 2) {
+    if (Psot > bytestream2_get_bytes_left(&s->g) - 2 + n + 2) {
         av_log(s->avctx, AV_LOG_ERROR, "Psot %"PRIu32" too big\n", Psot);
         return AVERROR_INVALIDDATA;
     }