diff options
author | Martin Vignali <martin.vignali@gmail.com> | 2017-04-02 21:11:32 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-04-03 03:02:50 +0200 |
commit | 8163314967ae0f08971eac9745177e5de0550754 (patch) | |
tree | 6452a69086f8c6be7d742ce54427323d9891c655 /libavcodec | |
parent | 08087f54626780b6955e470d59b1c7eff6c57f72 (diff) | |
download | ffmpeg-8163314967ae0f08971eac9745177e5de0550754.tar.gz |
libavcodec/exr : fix scanline offset table recreation on big endian
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/exr.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/libavcodec/exr.c b/libavcodec/exr.c index e5dea0756d..7cf3620d7f 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -1648,9 +1648,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int y, ret; int out_line_size; int nb_blocks; /* nb scanline or nb tile */ - uint64_t *table; /* scanline offset table */ - uint8_t *marker; /* used to recreate invalid scanline offset table */ - uint8_t *head; + uint64_t start_offset_table; + uint64_t start_next_scanline; + PutByteContext offset_table_writer; bytestream2_init(&s->gb, avpkt->data, avpkt->size); @@ -1738,16 +1738,21 @@ static int decode_frame(AVCodecContext *avctx, void *data, // check offset table and recreate it if need if (!s->is_tile && bytestream2_peek_le64(&s->gb) == 0) { - head = avpkt->data; - table = (uint64_t *)s->gb.buffer; - marker = head + bytestream2_tell(&s->gb) + nb_blocks * 8; - av_log(s->avctx, AV_LOG_DEBUG, "recreating invalid scanline offset table\n"); + start_offset_table = bytestream2_tell(&s->gb); + start_next_scanline = start_offset_table + nb_blocks * 8; + bytestream2_init_writer(&offset_table_writer, &avpkt->data[start_offset_table], nb_blocks * 8); + for (y = 0; y < nb_blocks; y++) { - table[y] = marker - head; - marker += ((uint32_t *)marker)[1] + 8; + /* write offset of prev scanline in offset table */ + bytestream2_put_le64(&offset_table_writer, start_next_scanline); + + /* get len of next scanline */ + bytestream2_seek(&s->gb, start_next_scanline + 4, SEEK_SET);/* skip line number */ + start_next_scanline += (bytestream2_get_le32(&s->gb) + 8); } + bytestream2_seek(&s->gb, start_offset_table, SEEK_SET); } // save pointer we are going to use in decode_block |