diff options
author | Nick Renieris <velocityra@gmail.com> | 2019-08-29 16:10:45 +0300 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2019-09-02 09:26:52 +0200 |
commit | f98a8666de6cdd8426e0ddf0272322498225467d (patch) | |
tree | 780e3cb7acb738d434486432b38eb8784122e009 /libavcodec | |
parent | 03f95403eb1105be50a983ef8dd135927d39f407 (diff) | |
download | ffmpeg-f98a8666de6cdd8426e0ddf0272322498225467d.tar.gz |
lavc/tiff: Fix edge case with full-length/width tiles
When the height is equal to the tile length (full-height tile)
after `height % tile_length` is applied with the current code,
it results in the operating tile_length to be 0. This commit
makes this leftover logic only applies if it's necessary.
Signed-off-by: Nick Renieris <velocityra@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/tiff.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index ff4b5ce826..816fb930c7 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -887,10 +887,14 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame) int tile_byte_count_offset, tile_byte_count; int tile_count_x, tile_count_y; int tile_width, tile_length; + int has_width_leftover, has_height_leftover; int tile_x = 0, tile_y = 0; int pos_x = 0, pos_y = 0; int ret; + has_width_leftover = (s->width % s->tile_width != 0); + has_height_leftover = (s->height % s->tile_length != 0); + /* Calculate tile counts (round up) */ tile_count_x = (s->width + s->tile_width - 1) / s->tile_width; tile_count_y = (s->height + s->tile_length - 1) / s->tile_length; @@ -900,12 +904,12 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame) tile_x = tile_idx % tile_count_x; tile_y = tile_idx / tile_count_x; - if (tile_x == tile_count_x - 1) // If on the right edge + if (has_width_leftover && tile_x == tile_count_x - 1) // If on the right-most tile tile_width = s->width % s->tile_width; else tile_width = s->tile_width; - if (tile_y == tile_count_y - 1) // If on the bottom edge + if (has_height_leftover && tile_y == tile_count_y - 1) // If on the bottom-most tile tile_length = s->height % s->tile_length; else tile_length = s->tile_length; |