[FFmpeg-devel] [PATCH] avcodec/exr

Dzung Hoang dthoang at yahoo.com
Mon Mar 6 19:00:22 EET 2017


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 patch is below.
Regards,Dzung Hoang


diff --git a/libavcodec/exr.c b/libavcodec/exr.c

index 034920f..de48e76 100644

--- a/libavcodec/exr.c

+++ b/libavcodec/exr.c

@@ -1726,6 +1726,24 @@ static intdecode_frame(AVCodecContext *avctx, void *data,

    if(bytestream2_get_bytes_left(&s->gb) < nb_blocks * 8)

         returnAVERROR_INVALIDDATA;


 
+    // check offset table

+    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;

+        uint64_t offset;

+

+       av_log(s->avctx, AV_LOG_DEBUG, "recreating invalid offsettable\n");

+

+        for (y = 0; y< nb_blocks; y++)

+        {

+           offset = marker - head;

+           table[y] = offset;

+           marker += ((uint32_t *)marker)[1] + 8;

+        }

+    }

+

     // save pointer we are going to usein decode_block

    s->buf      = avpkt->data;

     s->buf_size = avpkt->size;




More information about the ffmpeg-devel mailing list