diff mbox

[FFmpeg-devel] libavcodec/exr : Fix channel size calc

Message ID CAJiLW2O59s6MTvXxmPVtOOATt=ixvVDOTimCYKVn9whkkC+GDQ@mail.gmail.com
State Accepted
Headers show

Commit Message

Martin Vignali Nov. 16, 2016, 10:24 p.m. UTC
Hello,

Following discussion "exr : limit expected_len to tmp buffer size"

Patch in attach fix channel calc when there is uint32 channel and other
kind of channel (float or half).

Found by Andreas Cadhalpun


I will try to make a fate test for this.


Martin

Comments

Andreas Cadhalpun Nov. 16, 2016, 11:01 p.m. UTC | #1
On 16.11.2016 23:24, Martin Vignali wrote:
> Following discussion "exr : limit expected_len to tmp buffer size"
> 
> Patch in attach fix channel calc when there is uint32 channel and other kind of channel (float or half).

Thanks, I've pushed this patch now.

Best regards,
Andreas
diff mbox

Patch

From 374291fae7edd403c4f827e03348f69af3b737f1 Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vignali@gmail.com>
Date: Wed, 16 Nov 2016 23:15:27 +0100
Subject: [PATCH] libavcodec/exr : fix channel size calculation for uint32
 channel

uint32 need 4 bytes not 1.
Fix decoding when there is half/float and uint32 channel.
---
 libavcodec/exr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 51c17d6..f02337e 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -1448,7 +1448,11 @@  static int decode_header(EXRContext *s)
                 channel->xsub       = xsub;
                 channel->ysub       = ysub;
 
-                s->current_channel_offset += 1 << current_pixel_type;
+                if (current_pixel_type == EXR_HALF) {
+                    s->current_channel_offset += 2;
+                } else {/* Float or UINT32 */
+                    s->current_channel_offset += 4;
+                }
             }
 
             /* Check if all channels are set with an offset or if the channels
-- 
1.9.3 (Apple Git-50)