If lowres value greater than number of decomposition level: raise a
warning and set decomposition level to the lowest value.
---
libavcodec/jpeg2000dec.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index f789d19..013ef0f 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -88,7 +88,6 @@ typedef struct Jpeg2000DecoderContext {
/*options parameters*/
int16_t lowres;
- int16_t reduction_factor;
} Jpeg2000DecoderContext;
/* get_bits functions for JPEG2000 packet bitstream
@@ -203,12 +202,6 @@ static int get_siz(Jpeg2000DecoderContext *s)
return AVERROR(ENOMEM);
}
- /* compute image size with reduction factor */
- s->avctx->width = ff_jpeg2000_ceildivpow2(s->width - s->image_offset_x,
- s->reduction_factor);
- s->avctx->height = ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y,
- s->reduction_factor);
-
switch (s->avctx->profile) {
case FF_PROFILE_JPEG2000_DCINEMA_2K:
case FF_PROFILE_JPEG2000_DCINEMA_4K:
@@ -251,13 +244,24 @@ static int get_cox(Jpeg2000DecoderContext *s,
Jpeg2000CodingStyle *c)
if (s->buf_end - s->buf < 5)
return AVERROR(EINVAL);
- c->nreslevels = bytestream_get_byte(&s->buf) + 1; // num of resolution
levels - 1
+ c->nreslevels = bytestream_get_byte(&s->buf) + 1; // num of resolution
levels
/* compute number of resolution levels to decode */
- if (c->nreslevels < s->reduction_factor)
+ if (c->nreslevels <= s->lowres) {
+ av_log(s->avctx, AV_LOG_WARNING,
+ "Cannot set lowres to %d, so set to minimum value for this
file(%d).\n",
+ s->lowres, c->nreslevels - 1);
c->nreslevels2decode = 1;
- else
- c->nreslevels2decode = c->nreslevels - s->reduction_factor;
+ s->lowres = c->nreslevels - 1;
+ } else
+ c->nreslevels2decode = c->nreslevels - s->lowres;
+
+ /* compute image size with reduction factor */
+ s->avctx->width = ff_jpeg2000_ceildivpow2(s->width - s->image_offset_x,
+ s->lowres);
+ s->avctx->height = ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y,
+ s->lowres);
+
c->log2_cblk_width = bytestream_get_byte(&s->buf) + 2; // cblk width
c->log2_cblk_height = bytestream_get_byte(&s->buf) + 2; // cblk height
@@ -1252,8 +1256,6 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx,
void *data,
s->buf_end = s->buf_start + avpkt->size;
s->curtileno = 0; // TODO: only one tile in DCI JP2K. to implement for
more tiles
- // reduction factor, i.e number of resolution levels to skip
- s->reduction_factor = s->lowres;
ff_jpeg2000_init_tier1_luts();
--
1.7.9.5
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel