Hello,

In attach a patch who fix channel detection, if an exr have for example
channel
RGBZ. In that case, we need to use RGB channel not RGZ (actual case).

I let the identation modification inside the patch, because it's a small
patch.

The patch set the target channel offset, only if no channel have been
previously found.

./ScanLines/Blobbies.exr of the official sample :
http://download.savannah.nongnu.org/releases/openexr/openexr-images-1.7.0.tar.gz

before the patch return error : "RGB channels not of the same depth.\n");
Because the Z channel of this picture doesn't have the same pixel type than
RGB channel.
But in theory, this channel need to be ignore.

This patch still doesn't allow to decode it, but it's because there is
another trouble
(datawindow who exceed display window).

I will fix datawindow/display window trouble in another patch soon.

Comments welcome.

Martin
Jokyo Images
From a0f2008f31bdee75350da520377807f3664b64c2 Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vign...@gmail.com>
Date: Thu, 7 Apr 2016 11:17:18 +0200
Subject: [PATCH] libavcodec/exr : fix channel detection

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

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 2763126..9dd2ee9 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -1382,15 +1382,17 @@ static int decode_header(EXRContext *s)
                     return AVERROR_PATCHWELCOME;
                 }
 
-                if (channel_index >= 0) {
-                    if (s->pixel_type != EXR_UNKNOWN &&
-                        s->pixel_type != current_pixel_type) {
-                        av_log(s->avctx, AV_LOG_ERROR,
-                               "RGB channels not of the same depth.\n");
-                        return AVERROR_INVALIDDATA;
+                if (s->channel_offsets[channel_index] == -1){/* channel have not been previously assign */
+                    if (channel_index >= 0) {
+                        if (s->pixel_type != EXR_UNKNOWN &&
+                            s->pixel_type != current_pixel_type) {
+                            av_log(s->avctx, AV_LOG_ERROR,
+                                   "RGB channels not of the same depth.\n");
+                            return AVERROR_INVALIDDATA;
+                        }
+                        s->pixel_type                     = current_pixel_type;
+                        s->channel_offsets[channel_index] = s->current_channel_offset;
                     }
-                    s->pixel_type                     = current_pixel_type;
-                    s->channel_offsets[channel_index] = s->current_channel_offset;
                 }
 
                 s->channels = av_realloc(s->channels,
-- 
1.9.3 (Apple Git-50)

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to