ffmpeg | branch: master | Michael Niedermayer <michae...@gmx.at> | Tue Jun 9 00:27:15 2015 +0200| [074159ed70acd379d94378b72a9202283e651ba0] | committer: Michael Niedermayer
avcodec/jpeg2000dec: Fix subsampled decoding Fixes part of Ticket3619 Signed-off-by: Michael Niedermayer <michae...@gmx.at> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=074159ed70acd379d94378b72a9202283e651ba0 --- libavcodec/jpeg2000.c | 5 ----- libavcodec/jpeg2000dec.c | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 644e25d..770dffb 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -364,11 +364,6 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp, log2_band_prec_height = reslevel->log2_prec_height - 1; } - for (j = 0; j < 2; j++) - band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx); - for (j = 0; j < 2; j++) - band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy); - if (reslevel->num_precincts_x * (uint64_t)reslevel->num_precincts_y > INT_MAX) { band->prec = NULL; return AVERROR(ENOMEM); diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index ee70bde..537f6e2 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -690,6 +690,12 @@ static int init_tile(Jpeg2000DecoderContext *s, int tileno) comp->coord_o[0][1] = FFMIN((tilex + 1) * s->tile_width + s->tile_offset_x, s->width); 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); + if (compno) { + comp->coord_o[0][0] /= s->cdx[compno]; + comp->coord_o[0][1] /= s->cdx[compno]; + comp->coord_o[1][0] /= s->cdy[compno]; + comp->coord_o[1][1] /= s->cdy[compno]; + } 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); @@ -1260,14 +1266,14 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, y = tile->comp[compno].coord[1][0] - s->image_offset_y; line = picture->data[plane] + y / s->cdy[compno] * picture->linesize[plane]; - for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) { + for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y ++) { uint8_t *dst; x = tile->comp[compno].coord[0][0] - s->image_offset_x; dst = line + x / s->cdx[compno] * pixelsize + compno*!planar; if (codsty->transform == FF_DWT97) { - for (; x < w; x += s->cdx[compno]) { + for (; x < w; x ++) { int val = lrintf(*datap) + (1 << (cbps - 1)); /* DC level shift and clip see ISO 15444-1:2002 G.1.2 */ val = av_clip(val, 0, (1 << cbps) - 1); @@ -1276,7 +1282,7 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, dst += pixelsize; } } else { - for (; x < w; x += s->cdx[compno]) { + for (; x < w; x ++) { int val = *i_datap + (1 << (cbps - 1)); /* DC level shift and clip see ISO 15444-1:2002 G.1.2 */ val = av_clip(val, 0, (1 << cbps) - 1); @@ -1306,13 +1312,13 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, y = tile->comp[compno].coord[1][0] - s->image_offset_y; linel = (uint16_t *)picture->data[plane] + y / s->cdy[compno] * (picture->linesize[plane] >> 1); - for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) { + for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y ++) { uint16_t *dst; x = tile->comp[compno].coord[0][0] - s->image_offset_x; dst = linel + (x / s->cdx[compno] * pixelsize + compno*!planar); if (codsty->transform == FF_DWT97) { - for (; x < w; x += s-> cdx[compno]) { + for (; x < w; x ++) { int val = lrintf(*datap) + (1 << (cbps - 1)); /* DC level shift and clip see ISO 15444-1:2002 G.1.2 */ val = av_clip(val, 0, (1 << cbps) - 1); @@ -1322,7 +1328,7 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, dst += pixelsize; } } else { - for (; x < w; x += s-> cdx[compno]) { + for (; x < w; x ++) { int val = *i_datap + (1 << (cbps - 1)); /* DC level shift and clip see ISO 15444-1:2002 G.1.2 */ val = av_clip(val, 0, (1 << cbps) - 1); _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog