diff mbox

[FFmpeg-devel] avcodec/exr detect invalid line offset table and recreate table

Message ID 312902492.1008037.1490155674446@mail.yahoo.com
State New
Headers show

Commit Message

Dzung Hoang March 22, 2017, 4:07 a.m. UTC
Sorry about the bad format for the patch. Here's another try.

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

Comments

Martin Vignali March 25, 2017, 11:54 a.m. UTC | #1
Hello,

The latest patch appear to have a problem :
fatal: corrupt patch at line 6

And it doesn't work for me (head variable seems to be important).

I put in attach a patch, based on the previous one, who works for me.


Martin
diff mbox

Patch

diff --git a/libavcodec/exr.c b/libavcodec/exr.c 
index 034920f..265d44d 100644 
--- a/libavcodec/exr.c 
+++ b/libavcodec/exr.c 
@@ -1640,6 +1640,9 @@  static int decode_frame(AVCodecContext *avctx, void *data, 
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 */ 
+ 
bytestream2_init(&s->gb, avpkt->data, avpkt->size); 

if ((ret = decode_header(s, picture)) < 0) 
@@ -1731,6 +1734,21 @@  static int decode_frame(AVCodecContext *avctx, void *data, 
s->buf_size = avpkt->size; 
ptr         = picture->data[0]; 

+    // check offset table 
+    if (!s->is_tile && bytestream2_peek_le64(&s->gb) == 0) 
+    { 
+        table = (uint64_t *)s->gb.buffer; 
+        marker = avpkt->data + 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 - s->buf; 
+            marker += ((uint32_t *)marker)[1] + 8; 
+        } 
+    } 
+ 
// Zero out the start if ymin is not 0 
for (y = 0; y < s->ymin; y++) { 
memset(ptr, 0, out_line_size);