From patchwork Mon Mar 4 13:06:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46766 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2790421pzb; Mon, 4 Mar 2024 05:10:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXa7kLQr3//FrlgAc3mSsV1g5/nIbVz7Q9o2Wzkhb5t+Wy8tT9kMZxAyDEQgGLmv4QwCj/nwkcveoqCpmPq+XeZ0oa37RG7lIn9Bg== X-Google-Smtp-Source: AGHT+IG2NhXMvPvCjGkTmXqTpgYAYgjeYjH6IOXe0/TYyLNsxoI3GFfSkmKOLzs07iAmMglJuR6l X-Received: by 2002:a05:6512:2f5:b0:513:19cb:be72 with SMTP id m21-20020a05651202f500b0051319cbbe72mr5791853lfq.64.1709557829051; Mon, 04 Mar 2024 05:10:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557829; cv=none; d=google.com; s=arc-20160816; b=CaB/NAWHNtW581M3wr6iW6LgG7yjJT8TriOY4VCJiTfDxMwdJZDFa7LoWlrm/9YP55 d9sFA3fOLbNKiHZtUIBZ8XXvTis4w6R7eMnyQ3mRGka0HI/xF04jHSlx8ZOFJL+tE+yV 795R36qSD7/JWyaCX3+J9rWkcGYzdzZf8RKuHbEjV4mFQeNxIPBQnsUglq0XaL7suKzx BZ6cWYyrSH2C22uBTmJCJCNkkorNB7g4y0twR03fStd+2E2d+Wwe9GE/LLEtYrLEKUvj umDLYfavJJVnQzL1KgrYJmu0mmbj1ArvT2wUAibVedg3VUk7NwdYb/aC1hyW9sMwk+fg 7sjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=U/QZj4C7VePgMPEw8dF5rsSAaG0l+3i21QRbqe+oAPI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=aAAiSkRWNEieSlej2ZjaGaZWkpcLT0L4EVAz06f3XOhEhBOmomB3lPpqiFRQ3p58zZ tcKuFHeklcUt8g3IGg3yguW8xMe4jNcCPj2Pl0to4YKqUSAA7uen9YTsHvuUv9IH4Zk4 jZnODcofKx8For0LHvztjR6aX8rqRB2LrMgycvV3Gw1lWUAhVnDcypbmXTw66WEpSUKa lNltcCRuzxi73EhYKYnhCthqOmr7IMhAvviVJwXmu/5SbRnls66PSVPzHy3Foa0U79HL /UrP/lGCI1N2prVu4ieYUTXr8Em4y31rR+Au4eY38R/i7brCgLxJp4fhEp0njnML8nEA QDCg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=L15kr4DE; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id kg23-20020a17090776f700b00a450971bc9asi1503285ejc.490.2024.03.04.05.10.28; Mon, 04 Mar 2024 05:10:29 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=L15kr4DE; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7020768D4AA; Mon, 4 Mar 2024 15:07:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8496968D448 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=L15kr4DE; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 196AD4D71 for ; Mon, 4 Mar 2024 14:07:11 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id NCvIsX2xxJRc for ; Mon, 4 Mar 2024 14:07:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=XA+7t9vN7BuC5OtZr3s4MD25X7QXpD0W6yhhVs6BDAo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=L15kr4DEGa00qQ5HR/3jp8YDUixeFLoLw2mys9bpdE5pOrubmlh2g4lQK6gRCT/Mz 4rQTL6WFrzH5NZGfylnv88E2TSI1CrOstUXsJTr1+ClSuC3kUqE9VGymKf5aBL1DmQ UhIuVSD5TT5eVvU2LXI8fh+KmtDDovGcvVoC2B7MFSzhMKNSPoYEiJVQhCTt3PDagr g5IRnQdd/K8rdWZ0yLKIjiNvjFDhvJmp5Qfyq3SVm7uqGgEtCIDUbthKWa6Dxc2UiX 6oVMjCNyPGGoW0DtJMiSgyJXdd4xbzmOHAq+ARDgHcw/7egcb7zSNjfvy9Z6sXE9Za MbfJqG1w867sg== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id A2B9C4D66 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id AF8A83A1592 for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:33 +0100 Message-ID: <20240304130657.30631-18-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/29] avcodec/pngdec: respect side data preference X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qsSCzB6OkOsg From: Niklas Haas --- 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;