[FFmpeg-devel] [PATCH] libavcodec/jpeg2000.c: Precinct size check removed
gautamramk at gmail.com
gautamramk at gmail.com
Mon Jun 29 20:59:06 EEST 2020
From: Gautam Ramakrishnan <gautamramk at gmail.com>
This patch removes a check which throws an error if
the log2 precinct width/height is 0. The standard allows
the first component to have 0 as the log2 width/height.
However, to ensure proper intialization of coding style,
an extra check has been added.
---
libavcodec/jpeg2000.c | 3 ---
libavcodec/jpeg2000.h | 1 +
libavcodec/jpeg2000dec.c | 6 ++++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 73206d17f3..1aca31ffa4 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -509,9 +509,6 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
// update precincts size: 2^n value
reslevel->log2_prec_width = codsty->log2_prec_widths[reslevelno];
reslevel->log2_prec_height = codsty->log2_prec_heights[reslevelno];
- if (!reslevel->log2_prec_width || !reslevel->log2_prec_height) {
- return AVERROR_INVALIDDATA;
- }
/* Number of bands for each resolution level */
if (reslevelno == 0)
diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h
index 0f82716981..27df43786d 100644
--- a/libavcodec/jpeg2000.h
+++ b/libavcodec/jpeg2000.h
@@ -144,6 +144,7 @@ typedef struct Jpeg2000CodingStyle {
uint8_t prog_order; // progression order
uint8_t log2_prec_widths[JPEG2000_MAX_RESLEVELS]; // precincts size according resolution levels
uint8_t log2_prec_heights[JPEG2000_MAX_RESLEVELS]; // TODO: initialize prec_size array with 0?
+ uint8_t init;
} Jpeg2000CodingStyle;
typedef struct Jpeg2000QuantStyle {
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 546a646668..3f4a9ef96c 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -567,7 +567,7 @@ static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
if ((ret = get_cox(s, &tmp)) < 0)
return ret;
-
+ tmp.init = 1;
for (compno = 0; compno < s->ncomponents; compno++)
if (!(properties[compno] & HAD_COC))
memcpy(c + compno, &tmp, sizeof(tmp));
@@ -605,6 +605,7 @@ static int get_coc(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
return ret;
properties[compno] |= HAD_COC;
+ c->init = 1;
return 0;
}
@@ -991,7 +992,8 @@ static int init_tile(Jpeg2000DecoderContext *s, int tileno)
if (!comp->roi_shift)
comp->roi_shift = s->roi_shift[compno];
-
+ if (!codsty->init)
+ return AVERROR_INVALIDDATA;
if (ret = ff_jpeg2000_init_component(comp, codsty, qntsty,
s->cbps[compno], s->cdx[compno],
s->cdy[compno], s->avctx))
--
2.17.1
More information about the ffmpeg-devel
mailing list