From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 46B73428D2 for ; Tue, 5 Apr 2022 19:00:33 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C7B8D68B026; Tue, 5 Apr 2022 22:00:31 +0300 (EEST) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 25273689B39 for ; Tue, 5 Apr 2022 22:00:25 +0300 (EEST) Received: from w3.tutanota.de (unknown [192.168.1.164]) by w4.tutanota.de (Postfix) with ESMTP id BE832106034F for ; Tue, 5 Apr 2022 19:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1649185224; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=+MgEWN9EHAIXzJyZzb+c1OO/hSTZy8r3hyRI1jb8Aq4=; b=Zb22Aj59Pq2OSJtX8wQZWX4BPOm0B3iogpNuhArPFJtwlOW9IFhHmSFta4ee/PT8 O10kIkZK/2iQynjZRTZvvQimZXXDwK1s5h0r+b+gaMN19pyiBKljnBpFQXeSaxS1Bx2 g/wv/7cR3i5yvSXkGQD1NvWy/WDHBDitZ7ne4Cg/LC1vcEt3z+RzHKo6cSVlsRc+C2O ooobRnG4QEq+L5wUy2acUAHuLtD7n+lKy6bSjepB6v3B9cqK8NRpYeTfgjVgArFsdBh vz+mHQDS9SBU9p7THa+y4sKTdD4tOR4KDar6NtevbyecQ5/zBB2W2A0/k3ZbCVRYmog 2s/TlZqirg== Date: Tue, 5 Apr 2022 21:00:24 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: <1648423513-21261-1-git-send-email-lance.lmwang@gmail.com> <1649166427-9667-1-git-send-email-lance.lmwang@gmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v3 1/5] avutil: add ambient viewing environment metadata side data 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 5 Apr 2022, 17:32 by andreas.rheinhardt@outlook.com: > lance.lmwang@gmail.com: > >> From: Limin Wang >> >> Signed-off-by: Limin Wang >> --- >> libavutil/frame.c | 1 + >> libavutil/frame.h | 6 +++++ >> libavutil/mastering_display_metadata.c | 23 +++++++++++++++++ >> libavutil/mastering_display_metadata.h | 45 ++++++++++++++++++++++++++++++++++ >> libavutil/version.h | 2 +- >> 5 files changed, 76 insertions(+), 1 deletion(-) >> >> diff --git a/libavutil/frame.c b/libavutil/frame.c >> index fbb869f..8882da2 100644 >> --- a/libavutil/frame.c >> +++ b/libavutil/frame.c >> @@ -815,6 +815,7 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type) >> case AV_FRAME_DATA_DETECTION_BBOXES: return "Bounding boxes for object detection and classification"; >> case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision RPU Data"; >> case AV_FRAME_DATA_DOVI_METADATA: return "Dolby Vision Metadata"; >> + case AV_FRAME_DATA_AMBIENT_VIEWING_ENV: return "Ambient Viewing Environment"; >> } >> return NULL; >> } >> diff --git a/libavutil/frame.h b/libavutil/frame.h >> index 33fac20..92413c9 100644 >> --- a/libavutil/frame.h >> +++ b/libavutil/frame.h >> @@ -209,6 +209,12 @@ enum AVFrameSideDataType { >> * volume transform - CUVA 005.1-2021. >> */ >> AV_FRAME_DATA_DYNAMIC_HDR_VIVID, >> + >> + /** >> + * ambient viewing environment for a video frame, as described by >> + * the AVAmbientViewingEnv >> + */ >> + AV_FRAME_DATA_AMBIENT_VIEWING_ENV, >> }; >> >> enum AVActiveFormatDescription { >> diff --git a/libavutil/mastering_display_metadata.c b/libavutil/mastering_display_metadata.c >> index 6069347..f094eab 100644 >> --- a/libavutil/mastering_display_metadata.c >> +++ b/libavutil/mastering_display_metadata.c >> @@ -64,3 +64,26 @@ AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame *fram >> >> return (AVContentLightMetadata *)side_data->data; >> } >> + >> +AVAmbientViewingEnv *av_ambient_viewing_env_alloc(size_t *size) >> +{ >> + AVAmbientViewingEnv *metadata = av_mallocz(sizeof(*metadata)); >> + >> + if (size) >> + *size = sizeof(*metadata); >> + >> + return metadata; >> +} >> + >> +AVAmbientViewingEnv *av_ambient_viewing_env_create_side_data(AVFrame *frame) >> +{ >> + AVFrameSideData *side_data = av_frame_new_side_data(frame, >> + AV_FRAME_DATA_AMBIENT_VIEWING_ENV, >> + sizeof(AVAmbientViewingEnv)); >> + if (!side_data) >> + return NULL; >> + >> + memset(side_data->data, 0, sizeof(AVAmbientViewingEnv)); >> + >> + return (AVAmbientViewingEnv *)side_data->data; >> +} >> diff --git a/libavutil/mastering_display_metadata.h b/libavutil/mastering_display_metadata.h >> index c23b07c..c1ba659 100644 >> --- a/libavutil/mastering_display_metadata.h >> +++ b/libavutil/mastering_display_metadata.h >> @@ -125,4 +125,49 @@ AVContentLightMetadata *av_content_light_metadata_alloc(size_t *size); >> */ >> AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame *frame); >> >> +/** >> + * The characteristics of the nominal ambient viewing environment for >> + * the display of the associated video content. >> + * To be used as payload of a AVFrameSideData the appropriate type. >> + * >> + * @note The struct should be allocated with av_ambient_viewing_env_alloc() >> + * and its size is not a part of the public ABI. >> + */ >> +typedef struct AVAmbientViewingEnv { >> + /** >> + * specifies the environmental illuminance of the ambient viewing >> + * environment in units of 0.0001 lux. >> + * ambient_illuminance shall not be equal to 0. >> + */ >> + uint32_t ambient_illuminance; >> + /** >> + * specify the normalized x and y chromaticity coordinates, respectively, >> + * of the environmental ambient light in the nominal viewing environment, >> + * according to the CIE 1931 definition of x and y as specified in ISO >> + * 11664-1 (see also ISO 11664-3 and CIE 15), in normalized increments of >> + * 0.00002. The values of ambient_light_x and ambient_light_y shall be in >> + * the range of 0 to 50000 >> + */ >> + uint16_t ambient_light_x; >> + uint16_t ambient_light_y; >> +} AVAmbientViewingEnv; >> + >> +/** >> + * Allocate an AVAmbientViewingEnv structure and set its fields to >> + * default values. The resulting struct can be freed using av_freep(). >> + * >> + * @return An AVAmbientViewingEnv filled with default values or NULL >> + * on failure. >> + */ >> +AVAmbientViewingEnv *av_ambient_viewing_env_alloc(size_t *size); >> + >> +/** >> + * Allocate a complete AVAmbientViewingEnv and add it to the frame. >> + * >> + * @param frame The frame which side data is added to. >> + * >> + * @return The AVAmbientViewingEnv structure to be filled by caller. >> + */ >> +AVAmbientViewingEnv *av_ambient_viewing_env_create_side_data(AVFrame *frame); >> > > All this boilerplate code for the various side-data--types makes me > wonder whether they should not be replaced by something like > void *av_frame_side_data_alloc(enum AVFrameSideDataType, size_t *size) > and a corresponding av_frame_create_side_data(AVFrame *frame, enum > AVFrameSideDataType). > These functions would return an error in case it doesn't make sense to > create a side data this way (because there is no struct associated to > this side data type or because the size of this struct depends upon > other parameters, too). > Why is this side data type allocated, rather than what used to be the standard, making the side data struct size const? Copy-paste? Are new fields expected to be added in the future? HDR mastering metadata is also allocated, but we've never added any fields since it was merged. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".