diff mbox series

[FFmpeg-devel,18/29] avcodec/pngdec: respect side data preference

Message ID 20240304130657.30631-18-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/29] lavu/opt: factor per-type dispatch out of av_opt_get() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov March 4, 2024, 1:06 p.m. UTC
From: Niklas Haas <git@haasn.dev>

---
 libavcodec/pngdec.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
diff mbox series

Patch

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;