aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-07-01 10:01:20 +0200
committerLuca Barbato <lu_zero@gentoo.org>2013-07-02 20:05:46 +0200
commitf9581f1414ec8e3e7d0868793cda4f2e4fa113ea (patch)
tree5afd91c63899f0f8beb7720d715defe280fb7518 /libavcodec
parent952f7ed3c0b036c1a53834cf2015072a90a1f0ae (diff)
downloadffmpeg-f9581f1414ec8e3e7d0868793cda4f2e4fa113ea.tar.gz
jpeg2000: Improve reduced resolution decoding
Correctly scale down the component coordinates and clean up some redundant code. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/jpeg2000dec.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 9befa8b31d..47b07ebb67 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -84,8 +84,7 @@ typedef struct Jpeg2000DecoderContext {
Jpeg2000Tile *tile;
/*options parameters*/
- int16_t lowres;
- int16_t reduction_factor;
+ int reduction_factor;
} Jpeg2000DecoderContext;
/* get_bits functions for JPEG2000 packet bitstream
@@ -599,12 +598,10 @@ static int init_tile(Jpeg2000DecoderContext *s, int tileno)
comp->coord_o[1][0] = FFMAX(tiley * s->tile_height + s->tile_offset_y, s->image_offset_y);
comp->coord_o[1][1] = FFMIN((tiley + 1) * s->tile_height + s->tile_offset_y, s->height);
- // FIXME: add a dcinema profile check ?
- // value is guaranteed by profile (orig=0, 1 tile)
- comp->coord[0][0] = 0;
- comp->coord[0][1] = s->avctx->width;
- comp->coord[1][0] = 0;
- comp->coord[1][1] = s->avctx->height;
+ comp->coord[0][0] = ff_jpeg2000_ceildivpow2(comp->coord_o[0][0], s->reduction_factor);
+ comp->coord[0][1] = ff_jpeg2000_ceildivpow2(comp->coord_o[0][1], s->reduction_factor);
+ comp->coord[1][0] = ff_jpeg2000_ceildivpow2(comp->coord_o[1][0], s->reduction_factor);
+ comp->coord[1][1] = ff_jpeg2000_ceildivpow2(comp->coord_o[1][1], s->reduction_factor);
if (ret = ff_jpeg2000_init_component(comp, codsty, qntsty,
s->cbps[compno], s->cdx[compno],
@@ -1351,9 +1348,6 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data,
bytestream2_init(&s->g, avpkt->data, 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;
-
if (bytestream2_get_bytes_left(&s->g) < 2)
return AVERROR_INVALIDDATA;
@@ -1413,7 +1407,7 @@ static void jpeg2000_init_static_data(AVCodec *codec)
static const AVOption options[] = {
{ "lowres", "Lower the decoding resolution by a power of two",
- OFFSET(lowres), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, JPEG2000_MAX_RESLEVELS - 1, VD },
+ OFFSET(reduction_factor), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, JPEG2000_MAX_RESLEVELS - 1, VD },
{ NULL },
};