aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2013-02-28 16:50:33 +0000
committerPaul B Mahol <onemda@gmail.com>2013-02-28 18:38:14 +0000
commita71926a548af7e7923b5fcaf6b057c319947415f (patch)
tree50319f6164270a4e39eadad4f319ab1e6b52fbd4
parentd9fad53f4b447db1e436dcf3fc4a57e604616e6c (diff)
downloadffmpeg-a71926a548af7e7923b5fcaf6b057c319947415f.tar.gz
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@gmail.com>
-rw-r--r--libavcodec/exr.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 2850790a0d..d8b5f7a22a 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;
}