exr: s/bits_per_color_id/pixel_type
Previous naming was misleading. Also fix wrong message about missing support for 32-bit unsigned int pixel type. Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
@@ -70,7 +70,7 @@ typedef struct EXRThreadData {
|
|||||||
typedef struct EXRContext {
|
typedef struct EXRContext {
|
||||||
AVFrame picture;
|
AVFrame picture;
|
||||||
int compr;
|
int compr;
|
||||||
int bits_per_color_id;
|
enum ExrPixelType pixel_type;
|
||||||
int channel_offsets[4]; // 0 = red, 1 = green, 2 = blue and 3 = alpha
|
int channel_offsets[4]; // 0 = red, 1 = green, 2 = blue and 3 = alpha
|
||||||
const AVPixFmtDescriptor *desc;
|
const AVPixFmtDescriptor *desc;
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
|
|||||||
// Zero out the start if xmin is not 0
|
// Zero out the start if xmin is not 0
|
||||||
memset(ptr_x, 0, bxmin);
|
memset(ptr_x, 0, bxmin);
|
||||||
ptr_x += s->xmin * s->desc->nb_components;
|
ptr_x += s->xmin * s->desc->nb_components;
|
||||||
if (s->bits_per_color_id == 2) {
|
if (s->pixel_type == EXR_FLOAT) {
|
||||||
// 32-bit
|
// 32-bit
|
||||||
for (x = 0; x < xdelta; x++) {
|
for (x = 0; x < xdelta; x++) {
|
||||||
*ptr_x++ = exr_flt2uint(bytestream_get_le32(&r));
|
*ptr_x++ = exr_flt2uint(bytestream_get_le32(&r));
|
||||||
@@ -418,7 +418,7 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
s->channel_offsets[1] = -1;
|
s->channel_offsets[1] = -1;
|
||||||
s->channel_offsets[2] = -1;
|
s->channel_offsets[2] = -1;
|
||||||
s->channel_offsets[3] = -1;
|
s->channel_offsets[3] = -1;
|
||||||
s->bits_per_color_id = -1;
|
s->pixel_type = -1;
|
||||||
s->nb_channels = 0;
|
s->nb_channels = 0;
|
||||||
s->compr = -1;
|
s->compr = -1;
|
||||||
s->buf = buf;
|
s->buf = buf;
|
||||||
@@ -459,7 +459,7 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
channel_list_end = buf + variable_buffer_data_size;
|
channel_list_end = buf + variable_buffer_data_size;
|
||||||
while (channel_list_end - buf >= 19) {
|
while (channel_list_end - buf >= 19) {
|
||||||
EXRChannel *channel;
|
EXRChannel *channel;
|
||||||
int current_bits_per_color_id = -1;
|
int current_pixel_type = -1;
|
||||||
int channel_index = -1;
|
int channel_index = -1;
|
||||||
int xsub, ysub;
|
int xsub, ysub;
|
||||||
|
|
||||||
@@ -482,9 +482,9 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
current_bits_per_color_id = bytestream_get_le32(&buf);
|
current_pixel_type = bytestream_get_le32(&buf);
|
||||||
if (current_bits_per_color_id > 2) {
|
if (current_pixel_type > 2) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Unknown color format\n");
|
av_log(avctx, AV_LOG_ERROR, "Unknown pixel type\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,11 +497,11 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (channel_index >= 0) {
|
if (channel_index >= 0) {
|
||||||
if (s->bits_per_color_id != -1 && s->bits_per_color_id != current_bits_per_color_id) {
|
if (s->pixel_type != -1 && s->pixel_type != current_pixel_type) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "RGB channels not of the same depth\n");
|
av_log(avctx, AV_LOG_ERROR, "RGB channels not of the same depth\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
s->bits_per_color_id = current_bits_per_color_id;
|
s->pixel_type = current_pixel_type;
|
||||||
s->channel_offsets[channel_index] = current_channel_offset;
|
s->channel_offsets[channel_index] = current_channel_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,11 +509,11 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
if (!s->channels)
|
if (!s->channels)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
channel = &s->channels[s->nb_channels - 1];
|
channel = &s->channels[s->nb_channels - 1];
|
||||||
channel->pixel_type = current_bits_per_color_id;
|
channel->pixel_type = current_pixel_type;
|
||||||
channel->xsub = xsub;
|
channel->xsub = xsub;
|
||||||
channel->ysub = ysub;
|
channel->ysub = ysub;
|
||||||
|
|
||||||
current_channel_offset += 1 << current_bits_per_color_id;
|
current_channel_offset += 1 << current_pixel_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if all channels are set with an offset or if the channels
|
/* Check if all channels are set with an offset or if the channels
|
||||||
@@ -624,20 +624,19 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
buf++;
|
buf++;
|
||||||
|
|
||||||
switch (s->bits_per_color_id) {
|
switch (s->pixel_type) {
|
||||||
case 2: // 32-bit
|
case EXR_FLOAT:
|
||||||
case 1: // 16-bit
|
case EXR_HALF:
|
||||||
if (s->channel_offsets[3] >= 0)
|
if (s->channel_offsets[3] >= 0)
|
||||||
avctx->pix_fmt = AV_PIX_FMT_RGBA64;
|
avctx->pix_fmt = AV_PIX_FMT_RGBA64;
|
||||||
else
|
else
|
||||||
avctx->pix_fmt = AV_PIX_FMT_RGB48;
|
avctx->pix_fmt = AV_PIX_FMT_RGB48;
|
||||||
break;
|
break;
|
||||||
// 8-bit
|
case EXR_UINT:
|
||||||
case 0:
|
av_log_missing_feature(avctx, "32-bit unsigned int", 1);
|
||||||
av_log_missing_feature(avctx, "8-bit OpenEXR", 1);
|
|
||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR_PATCHWELCOME;
|
||||||
default:
|
default:
|
||||||
av_log(avctx, AV_LOG_ERROR, "Unknown color format : %d\n", s->bits_per_color_id);
|
av_log(avctx, AV_LOG_ERROR, "Unknown pixel type : %d\n", s->pixel_type);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user