From: Michael Niedermayer <[email protected]>

This also changes the cblk size storage method to what jpeg2000 uses

Signed-off-by: Michael Niedermayer <[email protected]>

Conflicts:

        libavcodec/j2k.c
        libavcodec/j2k.h
        libavcodec/j2kdec.c
        libavcodec/j2kenc.c
---
 libavcodec/jpeg2000.h    |    2 --
 libavcodec/jpeg2000dec.c |   10 +++++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h
index 1e46f07..946f908 100644
--- a/libavcodec/jpeg2000.h
+++ b/libavcodec/jpeg2000.h
@@ -134,8 +134,6 @@ typedef struct Jpeg2000CodingStyle {
             log2_cblk_height; // exponent of codeblock size
     uint8_t transform;        // DWT type
     uint8_t csty;             // coding style
-    uint8_t log2_prec_width,
-            log2_prec_height; // precinct size
     uint8_t nlayers;          // number of layers
     uint8_t mct;              // multiple component transformation
     uint8_t cblk_style;       // codeblock coding style
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 5546fa4..e1be5a0 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -256,6 +256,10 @@ static int get_cox(Jpeg2000DecoderContext *s, 
Jpeg2000CodingStyle *c)
     if (bytestream2_get_bytes_left(&s->g) < 5)
         return AVERROR(EINVAL);
     c->nreslevels = bytestream2_get_byteu(&s->g) + 1; // num of resolution 
levels - 1
+    if (c->nreslevels >= JPEG2000_MAX_RESLEVELS) {
+        av_log(s->avctx, AV_LOG_ERROR, "nreslevels %d is invalid\n", 
c->nreslevels);
+        return AVERROR_INVALIDDATA;
+    }
 
     /* compute number of resolution levels to decode */
     if (c->nreslevels < s->reduction_factor)
@@ -289,6 +293,9 @@ static int get_cox(Jpeg2000DecoderContext *s, 
Jpeg2000CodingStyle *c)
             c->log2_prec_widths[i]  =  byte       & 0x0F;    // precinct PPx
             c->log2_prec_heights[i] = (byte >> 4) & 0x0F;    // precinct PPy
         }
+    } else {
+        memset(c->log2_prec_widths , 15, sizeof(c->log2_prec_widths ));
+        memset(c->log2_prec_heights, 15, sizeof(c->log2_prec_heights));
     }
     return 0;
 }
@@ -303,9 +310,6 @@ static int get_cod(Jpeg2000DecoderContext *s, 
Jpeg2000CodingStyle *c,
     if (bytestream2_get_bytes_left(&s->g) < 5)
         return AVERROR(EINVAL);
 
-    tmp.log2_prec_width  =
-    tmp.log2_prec_height = 15;
-
     tmp.csty = bytestream2_get_byteu(&s->g);
 
     // get progression order
-- 
1.7.9.5

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to