[FFmpeg-cvslog] exr: track channels properties

Paul B Mahol git at videolan.org
Thu Feb 28 19:48:44 CET 2013


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Thu Feb 28 16:50:33 2013 +0000| [a71926a548af7e7923b5fcaf6b057c319947415f] | committer: Paul B Mahol

exr: track channels properties

Needed for proper decoding of channels with subsampling
and also for remaining compression methods.

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a71926a548af7e7923b5fcaf6b057c319947415f
---

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

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 2850790..d8b5f7a 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -48,6 +48,17 @@ enum ExrCompr {
     EXR_B44A  = 7,
 };
 
+enum ExrPixelType {
+    EXR_UINT,
+    EXR_HALF,
+    EXR_FLOAT
+};
+
+typedef struct EXRChannel {
+    int               xsub, ysub;
+    enum ExrPixelType pixel_type;
+} EXRChannel;
+
 typedef struct EXRThreadData {
     uint8_t *uncompressed_data;
     int uncompressed_size;
@@ -73,6 +84,9 @@ typedef struct EXRContext {
     const uint8_t *buf, *table;
     int buf_size;
 
+    EXRChannel *channels;
+    int nb_channels;
+
     EXRThreadData *thread_data;
     int thread_data_size;
 } EXRContext;
@@ -405,6 +419,7 @@ static int decode_frame(AVCodecContext *avctx,
     s->channel_offsets[2] = -1;
     s->channel_offsets[3] = -1;
     s->bits_per_color_id = -1;
+    s->nb_channels = 0;
     s->compr = -1;
     s->buf = buf;
     s->buf_size = buf_size;
@@ -443,6 +458,7 @@ static int decode_frame(AVCodecContext *avctx,
 
             channel_list_end = buf + variable_buffer_data_size;
             while (channel_list_end - buf >= 19) {
+                EXRChannel *channel;
                 int current_bits_per_color_id = -1;
                 int channel_index = -1;
                 int xsub, ysub;
@@ -489,6 +505,14 @@ static int decode_frame(AVCodecContext *avctx,
                     s->channel_offsets[channel_index] = current_channel_offset;
                 }
 
+                s->channels = av_realloc_f(s->channels, ++s->nb_channels, sizeof(EXRChannel));
+                if (!s->channels)
+                    return AVERROR(ENOMEM);
+                channel = &s->channels[s->nb_channels - 1];
+                channel->pixel_type = current_bits_per_color_id;
+                channel->xsub = xsub;
+                channel->ysub = ysub;
+
                 current_channel_offset += 1 << current_bits_per_color_id;
             }
 
@@ -725,6 +749,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
 
     av_freep(&s->thread_data);
     s->thread_data_size = 0;
+    av_freep(&s->channels);
 
     return 0;
 }



More information about the ffmpeg-cvslog mailing list