From patchwork Fri Feb 23 13:58:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46473 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:26a3:b0:19e:cdac:8cce with SMTP id h35csp993588pze; Fri, 23 Feb 2024 06:34:08 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWhtAaIz/UhfeHmFaxPvOJzkBD1wr4Tm0hkK6gRUcWGo+qSFI3r2RkCu+lPNmGwQ43NSLa2EF78aAMt2+I8YFiH5fuAwjbIaw3oiQ== X-Google-Smtp-Source: AGHT+IG8BFFOOq9nfTn84vwiaIp2T903miyDSy03fMyzg1v7ZsMWRv0ePNx8hSjXlRQEvrWrkaMp X-Received: by 2002:aa7:ccd8:0:b0:565:1ee9:4f11 with SMTP id y24-20020aa7ccd8000000b005651ee94f11mr6129edt.15.1708698848601; Fri, 23 Feb 2024 06:34:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708698848; cv=none; d=google.com; s=arc-20160816; b=k9m9MibXCu1gVScNEV7GSbSXBrZcH0tVVjeWh7jUXwIeE2s3MMuuQUBKbgYyTaBTru EEqFHpTSerNdAZZ++chtjzJka/LxOiUgnfQ8kozsXt0b67w+tftLWGjhetr4aYALj7rH htqHaUsH0qF9Q+QSNmxSWqw2S7KPFAUqQXqS4o6cOZTScT3PXf3NYSfdlaogtTxkFeOQ fhicIrI9KHrxQcVmXha8bj5qpCGdUHrIIcJDPztm4UVzHY0TAEsmLqVnsI1k7qDqKf73 FpUrkrRjF9pxpA4gPf0ImUO40epchR7gU52a7S3JdYYkzBdt1XzXA2YWup8tfJrOpRbv IA4Q== 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=htkBzh6O7tFsR3vCjliPFD6mPSN/i27GtT9KNRoGdj0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=vfvOTy8OGfL901DX+NWiytbFqpabU6KF8i4TO4oGfuNnVXpAEtUzJuTTi902VVs0eX 8A5e1mH1RS+Bdyb4PW5/kL3G2DldeMsN9zg2dXSvCQIyq9oalxjpWtFBx9TyAVAK6M6H I6tabjYKy4IA5OszkIEHS9UAqi6OgwDwv0XGQ3YE2S3OCT+WXuctnbgZIwElDhgUjBYV AzIlW2QqhRn+yUkt4hkEDHEchPG8hCdnMkz/FS19ffr3OSQ96oa3hcJITplsi9zfmJNY g13/0eIruOjNQFzEkQaqQxH/XqEmqH9ZDrZdGddX2XuVP3hqkkxgFz052iYLcNgU4gwP tlSQ==; 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=AtmRpHuk; 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 w5-20020a056402128500b00563f3ee44c9si6081669edv.428.2024.02.23.06.34.08; Fri, 23 Feb 2024 06:34:08 -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=AtmRpHuk; 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 1D06E68C678; Fri, 23 Feb 2024 16:31:55 +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 C5E3B68C66E for ; Fri, 23 Feb 2024 16:31:35 +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=AtmRpHuk; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 7B4E44D44 for ; Fri, 23 Feb 2024 15:31:32 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id HIbWr8cQUUiu for ; Fri, 23 Feb 2024 15:31:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1708698687; bh=18TVeLg340D0tfVaUhYhKcaXJfvEt+fQAcrT4elNadU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AtmRpHukpHNI8tTHM2XTUF/yOwH1W/KpzTuB4Q3rdNMd+G0YBRm1wUhpVHJm8Oapo loaBrBakDsLfBGkUU1mjWxRDujA/T1YUtZSU6h7V9RrK68y+4F6HrP47Q78oeURheA n3/4R8WW0HuCs0fSyTIjp5HgHvjA/soVKVavzG89vSxkkGSguNonCCoaPGi2uaGMl9 rg+Pl5e9sBbFTtqqiD+6OaP33JzWCh/x1cdslLFSh3tkNkKqTKYC1EUmSJEUtDaW71 C9rYlwbV4ADuf+zENyLb7laB5kvZc+PDgdd/+DPRlzQzOVmVFZxnEZ1/gbyOL0H9Qx fgr64CgeSZr5A== 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 982D24D4C for ; Fri, 23 Feb 2024 15:31:27 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A474B3A1E2E for ; Fri, 23 Feb 2024 15:31:22 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 23 Feb 2024 14:58:40 +0100 Message-ID: <20240223143115.16521-19-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240223143115.16521-1-anton@khirnov.net> References: <20240223143115.16521-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/38] lavc: add content light/mastering display side data wrappers 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: 2Mgd1McjPOmy --- libavcodec/decode.c | 25 +++++++++++++++++++++++++ libavcodec/decode.h | 21 +++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 10946f208a..ad5525860c 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -35,6 +35,7 @@ #include "libavutil/hwcontext.h" #include "libavutil/imgutils.h" #include "libavutil/internal.h" +#include "libavutil/mastering_display_metadata.h" #include "avcodec.h" #include "avcodec_internal.h" @@ -1904,6 +1905,30 @@ AVFrameSideData *ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, return av_frame_new_side_data_from_buf(frame, type, buf); } +int ff_decode_mastering_display_new(const AVCodecContext *avctx, AVFrame *frame, + AVMasteringDisplayMetadata **mdm) +{ + if (side_data_pref(avctx, frame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA)) { + *mdm = NULL; + return 0; + } + + *mdm = av_mastering_display_metadata_create_side_data(frame); + return *mdm ? 0 : AVERROR(ENOMEM); +} + +int ff_decode_content_light_new(const AVCodecContext *avctx, AVFrame *frame, + AVContentLightMetadata **clm) +{ + if (side_data_pref(avctx, frame, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL)) { + *clm = NULL; + return 0; + } + + *clm = av_content_light_metadata_create_side_data(frame); + return *clm ? 0 : AVERROR(ENOMEM); +} + int ff_copy_palette(void *dst, const AVPacket *src, void *logctx) { size_t size; diff --git a/libavcodec/decode.h b/libavcodec/decode.h index a131b9940a..b8df095532 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -175,4 +175,25 @@ AVFrameSideData *ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, enum AVFrameSideDataType type, AVBufferRef *buf); +struct AVMasteringDisplayMetadata; +struct AVContentLightMetadata; + +/** + * Wrapper around av_mastering_display_metadata_create_side_data(), which + * rejects side data overridden by the demuxer. Returns 0 on success, and a + * negative error code otherwise. If successful, *mdm may either be a pointer to + * the new side data, or NULL in case the side data was already present. + */ +int ff_decode_mastering_display_new(const AVCodecContext *avctx, AVFrame *frame, + struct AVMasteringDisplayMetadata **mdm); + +/** + * Wrapper around av_content_light_metadata_create_side_data(), which + * rejects side data overridden by the demuxer. Returns 0 on success, and a + * negative error code otherwise. If successful, *clm may either be a pointer to + * the new side data, or NULL in case the side data was already present. + */ +int ff_decode_content_light_new(const AVCodecContext *avctx, AVFrame *frame, + struct AVContentLightMetadata **clm); + #endif /* AVCODEC_DECODE_H */