@@ -1726,6 +1726,25 @@ static int decode_frame(AVCodecContext *avctx, void *data,
if (bytestream2_get_bytes_left(&s->gb) < nb_blocks * 8)
return AVERROR_INVALIDDATA;
+ // check line offset table and recreate if first entry is 0
+ if (bytestream2_peek_le64(&s->gb) == 0)
+ {
+ uint64_t *table = (uint64_t *)s->gb.buffer;
+ uint8_t *head = avpkt->data;
+ uint8_t *marker = head + bytestream2_tell(&s->gb) + nb_blocks * 8;
+
+ av_log(s->avctx, AV_LOG_INFO, "Recreating invalid offset table.\n");
+
+ // recreate the line offset table using the length field for each line
+ // decode_block() will check for out-of-bounds offsets, so do not bother
+ // to check here
+ 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;
The EXR decoder cannot handle the image files included in NVidia's HDR SDK. After debugging, I found that the line offset table in the image files contained 0's. Other EXR decoders, including the official OpenEXR decoder, can detect and reconstruct missing line offset tables, so I added some code to do so. I filed a trac ticket for this issue here: https://trac.ffmpeg.org/ticket/6220. The image files are here: http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket6220/ Dzung Hoang Signed-off-by: Dzung Hoang <dthoang@yahoo.com> --- libavcodec/exr.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) -- 2.1.4