You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-07-16 22:42:38 +02:00
exr: check color channel subsampling too
If there is unsupported subsampling encountered abort early instead of failing decoding later. Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
@ -434,6 +434,7 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
while (channel_list_end - buf >= 19) {
|
while (channel_list_end - buf >= 19) {
|
||||||
int current_bits_per_color_id = -1;
|
int current_bits_per_color_id = -1;
|
||||||
int channel_index = -1;
|
int channel_index = -1;
|
||||||
|
int xsub, ysub;
|
||||||
|
|
||||||
if (!strcmp(buf, "R"))
|
if (!strcmp(buf, "R"))
|
||||||
channel_index = 0;
|
channel_index = 0;
|
||||||
@ -460,6 +461,14 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf += 4;
|
||||||
|
xsub = bytestream_get_le32(&buf);
|
||||||
|
ysub = bytestream_get_le32(&buf);
|
||||||
|
if (xsub != 1 || ysub != 1) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Unsupported subsampling %dx%d\n", xsub, ysub);
|
||||||
|
return AVERROR_PATCHWELCOME;
|
||||||
|
}
|
||||||
|
|
||||||
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->bits_per_color_id != -1 && s->bits_per_color_id != current_bits_per_color_id) {
|
||||||
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");
|
||||||
@ -470,7 +479,6 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
current_channel_offset += 1 << current_bits_per_color_id;
|
current_channel_offset += 1 << current_bits_per_color_id;
|
||||||
buf += 12;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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
|
||||||
|
Reference in New Issue
Block a user