From patchwork Sun Mar 27 23:25:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 35005 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6d9d:b0:79:214c:b845 with SMTP id gl29csp4097565pzb; Sun, 27 Mar 2022 16:25:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWCdPFJNy8XZNQbMyUspAm6KmNjEYzZoqN0jQm2kLQYEMyNe3b6sOCG2Kr0oLa1YSOXf0u X-Received: by 2002:a17:907:c2a:b0:6e0:e1d3:2ab with SMTP id ga42-20020a1709070c2a00b006e0e1d302abmr8523236ejc.706.1648423531443; Sun, 27 Mar 2022 16:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648423531; cv=none; d=google.com; s=arc-20160816; b=iXh4qVcvfDgSk8U5L5PeKW6t0Hh365inTX6pd2l5ehZug8jly7Q4aqdnDwR3oU6IVj gSqExmaiik9Y/5KmzVwoHDGUrpKzXpwLEB6UdhJwY6Q6esAiVv4R8fQRb93FCvmx6bfA gISOQA6NYuvWiN0RlzUZlwpi7iKGygkvUicQ1x7fsIkcWhoR5rey/QiPRgJ2eR3lRbbk 9rEftJaYI8CGaQQHxZ6eGo0ezlFs6gy7m76Y3zzjEIY8QkMeWL1Cc5qK9iZdfAbxPJLL 8XePXzjNUHzDNWWTtEUdzyw4EU2Cy4zMoTZy9Ab2pbfp81pZRR5pM4RKTpDqz6gcUIpE porg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to; bh=DOhd43yvNE3MKVYiPD/6uCCDuPgNKABJNsZLF4I1XAo=; b=Febh3aOU0EO8Tv/M6nmLq53i9KBjlfidhjuVE6TwXUYompYabDMrApWuK/oFY8zTXH M52VfWRA87fpsDLKgyKaWQmnE0CWcsKE6VLl+aBeudQ9MDDcJdCE/DDk9PKkwr1d4uHh TYk4wGC5PCfHoNa8ExQ8OAiX0NGneDVM2bvOEnVl5RQmNUe5gNWk+DXw8/veXIoVgEmV FlNMSO39jJ9G/oNOjK4sOYB7hYO9H7hEYTcVBRTX2ctujjvBGeBioFnEY5r3yuURTCQ4 iLVPbvpZyyUQT5B+DEuCGQDYZn/c2VMqlGvYwgoQ8F8dZqTqpDdGwsDZE5CMMAmEXmMf uGqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=ltQQoL9g; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f9-20020a170906084900b006df76385c11si10795703ejd.177.2022.03.27.16.25.30; Sun, 27 Mar 2022 16:25:31 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=ltQQoL9g; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3AF8C68B279; Mon, 28 Mar 2022 02:25:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 28B0F68A8FD for ; Mon, 28 Mar 2022 02:25:20 +0300 (EEST) Received: by mail-pj1-f43.google.com with SMTP id v4so12419694pjh.2 for ; Sun, 27 Mar 2022 16:25:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=ih9vS+qxEGP1W8EZENUhZZmTDchz5zaOABBz4YKC0j4=; b=ltQQoL9g6xQjt0oH6i5XoCiO/Sbujs1gseF5LWnQsKuQM4ZpWB/AGdNyAYWqjr339G WccF1DiXa1dcgVkIv7ID3M2n1ZXn/YSp/Syld8l5iY5Z+MYXvHsLqgiKb0NvQs/K8u2U WEDix86eOnEY5/Dlvb4e6mvndkBt5ZE8Shme+s2vz4Vn8ZURP9/Rv8gQLUCRGcQiR+mG acSEDc44+TFVMAswZsbpqy5XVldEcm7Qx2ARx7+espgGGqVms2qyMRsn4nutrYThHumq q9f7+9sAuChMsvoDq3xBE/lwYDoL9bYTIUcPIC6iIe0/eo7OFJjwyHHrIjeYXJEtLlGx eddQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ih9vS+qxEGP1W8EZENUhZZmTDchz5zaOABBz4YKC0j4=; b=Ruct7UnXpFzUmQoXLIouPucBk+JW6LeMsQTudygenUrIVuZhwnv1ovZ515xRmF7lWF zqafaDdrnMQ8UeK8uRRLQKSvQCmM/DjlG+2vP8z5S06FbG3/ick6lcN/eCmUcnMKZix8 /LhakNxC0rNK9cLAFXnFOgU45IH5nzyZny912b1OcE5nIiA54BrR0+l/Mpd5D5GdRDmw onL2+u1d+MqUwd/BatimCCrRsH+UBX5yN7s8op6qs6UJLfBUdWjI/djdzqKd8nSIyuVl gXMibJDDkiDyep2n+F7ePg5jmgT9Aiih0s7ZBQANz42d4QqEs/AVBXcPHUahLDyAwyKx lQgg== X-Gm-Message-State: AOAM531DP8/0LGng/G0uDDXYIaVF9Wt2IOEbvL4BWm8VrxMV1pJ518s3 6g+tREYX6n1680wMXyhz3fregQpnPP8dvg== X-Received: by 2002:a17:902:ecc6:b0:154:2a81:c810 with SMTP id a6-20020a170902ecc600b001542a81c810mr23054854plh.7.1648423517770; Sun, 27 Mar 2022 16:25:17 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id bh3-20020a056a02020300b00378b62df320sm11000934pgb.73.2022.03.27.16.25.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Mar 2022 16:25:17 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Mar 2022 07:25:10 +0800 Message-Id: <1648423513-21261-1-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 Subject: [FFmpeg-devel] [PATCH 1/4] 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Zh9vQ5h5rE1g From: Limin Wang Signed-off-by: Limin Wang --- libavutil/Makefile | 2 + libavutil/ambient_viewing_env_metadata.c | 47 +++++++++++++++++++++ libavutil/ambient_viewing_env_metadata.h | 72 ++++++++++++++++++++++++++++++++ libavutil/frame.c | 1 + libavutil/frame.h | 6 +++ 5 files changed, 128 insertions(+) create mode 100644 libavutil/ambient_viewing_env_metadata.c create mode 100644 libavutil/ambient_viewing_env_metadata.h diff --git a/libavutil/Makefile b/libavutil/Makefile index 81df3b0..e388d33 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -26,6 +26,7 @@ HEADERS = adler32.h \ display.h \ dovi_meta.h \ downmix_info.h \ + ambient_viewing_env_metadata.h \ encryption_info.h \ error.h \ eval.h \ @@ -119,6 +120,7 @@ OBJS = adler32.o \ display.o \ dovi_meta.o \ downmix_info.o \ + ambient_viewing_env_metadata.o \ encryption_info.o \ error.o \ eval.o \ diff --git a/libavutil/ambient_viewing_env_metadata.c b/libavutil/ambient_viewing_env_metadata.c new file mode 100644 index 0000000..7006b64 --- /dev/null +++ b/libavutil/ambient_viewing_env_metadata.c @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2022 Limin Wang + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include "ambient_viewing_env_metadata.h" +#include "mem.h" + +AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_alloc(size_t *size) +{ + AVAmbientViewingEnvMetadata *metadata = av_mallocz(sizeof(*metadata)); + + if (size) + *size = sizeof(*metadata); + + return metadata; +} + +AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_create_side_data(AVFrame *frame) +{ + AVFrameSideData *side_data = av_frame_new_side_data(frame, + AV_FRAME_DATA_AMBIENT_VIEWING_ENV, + sizeof(AVAmbientViewingEnvMetadata)); + if (!side_data) + return NULL; + + memset(side_data->data, 0, sizeof(AVAmbientViewingEnvMetadata)); + + return (AVAmbientViewingEnvMetadata *)side_data->data; +} diff --git a/libavutil/ambient_viewing_env_metadata.h b/libavutil/ambient_viewing_env_metadata.h new file mode 100644 index 0000000..b0fbcd0 --- /dev/null +++ b/libavutil/ambient_viewing_env_metadata.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2022 Limin Wang + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AMBIENT_VIEWING_ENV_METADATA_H +#define AVUTIL_AMBIENT_VIEWING_ENV_METADATA_H + +#include "frame.h" + + +/** + * 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_metadata_alloc() + * and its size is not a part of the public ABI. + */ +typedef struct AVAmbientViewingEnvMetadata { + /** + * 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 50 000 + */ + uint16_t ambient_light_x; + uint16_t ambient_light_y; +} AVAmbientViewingEnvMetadata; + +/** + * Allocate an AVAmbientViewingEnvMetadata structure and set its fields to + * default values. The resulting struct can be freed using av_freep(). + * + * @return An AVAmbientViewingEnvMetadata filled with default values or NULL + * on failure. + */ +AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_alloc(size_t *size); + +/** + * Allocate a complete AVAmbientViewingEnvMetadata and add it to the frame. + * + * @param frame The frame which side data is added to. + * + * @return The AVAmbientViewingEnvMetadata structure to be filled by caller. + */ +AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_create_side_data(AVFrame *frame); + +#endif /* AVUTIL_AMBIENT_VIEWING_ENV_METADATA_H */ 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..f7b1d4e 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 AVAmbientViewingEnvMetadata. + */ + AV_FRAME_DATA_AMBIENT_VIEWING_ENV, }; enum AVActiveFormatDescription {