diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-06-13 12:58:45 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-13 13:09:13 +0200 |
commit | 0a3eb0422a75200b7d932f68166752fa6c3d2025 (patch) | |
tree | c0a47fbf472b23fd23b4a3f0669ae1280b81ed8f | |
parent | 7c244349fc1443a0dc349fce9907b01c03383b09 (diff) | |
download | ffmpeg-0a3eb0422a75200b7d932f68166752fa6c3d2025.tar.gz |
avcodec/jpeg2000dec: try to correct tile location in CPRL code
No testcase
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/jpeg2000dec.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 46b9155829..4e644f8cf7 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -966,18 +966,24 @@ static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile Jpeg2000QuantStyle *qntsty = tile->qntsty + compno; int step_x = 32; int step_y = 32; + int maxlogstep_x = 0; + int maxlogstep_y = 0; for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) { uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; // ==> N_L - r Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno; step_x = FFMIN(step_x, rlevel->log2_prec_width + reducedresno); step_y = FFMIN(step_y, rlevel->log2_prec_height + reducedresno); + maxlogstep_x = FFMAX(maxlogstep_x, rlevel->log2_prec_width + reducedresno); + maxlogstep_y = FFMAX(maxlogstep_y, rlevel->log2_prec_height + reducedresno); } step_x = 1<<step_x; step_y = 1<<step_y; - for (y = 0; y < s->height; y += step_y) { - for (x = 0; x < s->width; x += step_x) { + y = comp->coord_o[1][0] >> maxlogstep_y << maxlogstep_y; + for (; y < comp->coord_o[1][1]; y += step_y) { + x = comp->coord_o[0][0] >> maxlogstep_x << maxlogstep_x; + for (; x < comp->coord_o[0][1]; x += step_x) { for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) { uint16_t prcx, prcy; uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; // ==> N_L - r |