[FFmpeg-cvslog] avcodec/exr: add support for scanline file where offsets are set to zero

Dzung Hoang git at videolan.org
Sat Apr 1 19:07:57 EEST 2017


ffmpeg | branch: master | Dzung Hoang <dthoang-at-yahoo.com at ffmpeg.org> | Sat Mar 25 12:40:08 2017 +0100| [68e3c9a3b680ffdc5ea4961090d8d7ec3efbdb1f] | committer: Paul B Mahol

avcodec/exr: add support for scanline file where offsets are set to zero

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=68e3c9a3b680ffdc5ea4961090d8d7ec3efbdb1f
---

 libavcodec/exr.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index ddce1e5..e5dea07 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -1647,7 +1647,10 @@ static int decode_frame(AVCodecContext *avctx, void *data,
 
     int y, ret;
     int out_line_size;
-    int nb_blocks;/* nb scanline or nb tile */
+    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;
 
     bytestream2_init(&s->gb, avpkt->data, avpkt->size);
 
@@ -1733,6 +1736,20 @@ static int decode_frame(AVCodecContext *avctx, void *data,
     if (bytestream2_get_bytes_left(&s->gb) < nb_blocks * 8)
         return AVERROR_INVALIDDATA;
 
+    // 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");
+
+        for (y = 0; y < nb_blocks; y++) {
+            table[y] = marker - head;
+            marker += ((uint32_t *)marker)[1] + 8;
+        }
+    }
+
     // save pointer we are going to use in decode_block
     s->buf      = avpkt->data;
     s->buf_size = avpkt->size;



More information about the ffmpeg-cvslog mailing list