From 454691a2ec35cbcb6a489b089e1c5957d65cdcab Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sat, 17 Feb 2024 21:53:00 +0100 Subject: avcodec/pngdec: respect side data preference --- libavcodec/pngdec.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 026da30c25..8f409c74b8 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -660,6 +660,7 @@ static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s, static int populate_avctx_color_fields(AVCodecContext *avctx, AVFrame *frame) { PNGDecContext *s = avctx->priv_data; + int ret; if (s->have_cicp) { if (s->cicp_primaries >= AVCOL_PRI_NB) @@ -678,11 +679,15 @@ static int populate_avctx_color_fields(AVCodecContext *avctx, AVFrame *frame) avctx->color_range = frame->color_range = AVCOL_RANGE_UNSPECIFIED; } } else if (s->iccp_data) { - AVFrameSideData *sd = av_frame_new_side_data(frame, AV_FRAME_DATA_ICC_PROFILE, s->iccp_data_len); - if (!sd) - return AVERROR(ENOMEM); - memcpy(sd->data, s->iccp_data, s->iccp_data_len); - av_dict_set(&sd->metadata, "name", s->iccp_name, 0); + AVFrameSideData *sd; + ret = ff_frame_new_side_data(avctx, frame, AV_FRAME_DATA_ICC_PROFILE, + s->iccp_data_len, &sd); + if (ret < 0) + return ret; + if (sd) { + memcpy(sd->data, s->iccp_data, s->iccp_data_len); + av_dict_set(&sd->metadata, "name", s->iccp_name, 0); + } } else if (s->have_srgb) { avctx->color_primaries = frame->color_primaries = AVCOL_PRI_BT709; avctx->color_trc = frame->color_trc = AVCOL_TRC_IEC61966_2_1; -- cgit v1.2.3