From patchwork Wed Jan 11 18:57:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 39969 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp4979261pzb; Wed, 11 Jan 2023 10:57:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXtsTg9ASn8ZNem56M4YqIv4Ydb0SWj7AN7MBpEtKxKNp6PNx7DjJ5G/ty3ZbdmraU5vrkf0 X-Received: by 2002:a17:906:685:b0:856:6884:675f with SMTP id u5-20020a170906068500b008566884675fmr6537364ejb.52.1673463453086; Wed, 11 Jan 2023 10:57:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673463453; cv=none; d=google.com; s=arc-20160816; b=vIk39kuERQQeuoyASBfmRdv/q6xxxpvp00iGImzyGEkrNzWbPkMuHOJvxi0TqrX57B VHiCD72WmnkMALY7RQvN3oNdU7AOYRt4692bbD8F2+1MwxrD/ixGs78ayZGeGn96cl/M ECGxnjZeiyw6E9saV4q0EZcYKqxBnUp6z1Tn3OpPDhO92s+eDzc8pavZRtq/sFwqlsM8 gzqy8S8nf5Kb+tM/vRwMU+MfYjS1etEyoK6SdAi/oD2XPhcRJ/vq6UD4sVLS7XSgEQjS buJrdoEkk5GHs6bn4iMZiz+lYysTVQKKPTVFFJgyXttp4xeVTv4WXXdetUk6LblJbDvL yiqQ== 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=nGjZVSPaJ9D+TMMePg15WO5zOpu/fn5G9pwgTNOJu+g=; b=e+Ks2F6BFWv54BUYRRKGed8f4i2lSmYQbBQnOr/95S4j5FJNz2DE1S38y1a1w0nbzk 8P5LgJElq93bgA/zqpBb8x9Ank8ODMonCsCT/hQLb8KlgnkSq0T0ySOsgHSweKDR7Emh bxhU/UnuFcaSR2NBxeTbFzyeCNIyvKojMV1NmmApkEOPZnjFAYE9oSK4H6qD2LSDIYcS DfQT/wawLrRRWa4MDpsn178+36knaqZDFK8ockMBMTrgx2W2ffsdiVs16WnwLLHbHzh7 cpQi5HCFtUCfvavLauHu0Vqxk/hPERzJnIltnDdViLnBuC8RVMqqzkFnV83sll41oYwu 1/kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=ezgUm6ZW; 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 dr13-20020a170907720d00b007be1d7d1c22si16065314ejc.32.2023.01.11.10.57.32; Wed, 11 Jan 2023 10:57:33 -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=@gmail.com header.s=20210112 header.b=ezgUm6ZW; 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 BBC7668BCF7; Wed, 11 Jan 2023 20:57:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0E80A68BC64 for ; Wed, 11 Jan 2023 20:57:15 +0200 (EET) Received: by mail-lf1-f45.google.com with SMTP id bf43so24976804lfb.6 for ; Wed, 11 Jan 2023 10:57:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=29whK7zxyVFWU3tjjipP7WJrJpJqKxxEylC8ym61xr8=; b=ezgUm6ZWk1TFj9DYRIlo51SNxnRHDMJiPZAnMPnlwiR0uidDCC5AEJOoQ7MUS8tTIh Nig3TyJzsIodKn86Fvj3oV6iihvb3rsojiUHNDVmwBIR3fL0hSM6KDZRt07X2h0T/pCr X/5+FHMzp2yJ03ZR8vwhF0twIxHhnmYtM/glB0szNFQjTZPVz/iMg6QPkQuu18t8inOK xgZ7qCXa1XxuhZklZFHvYDzTOWvt7azNFtpA4cgQ09cWQ2nISvXP8fKDxaeNKujCjLSq rvfImw4IVvfdN4/rk3RejvRrkPdRrtSSworZpeXcuwYjoVAQuo/LMCUSRvgHR8WrtRmZ 5Y5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=29whK7zxyVFWU3tjjipP7WJrJpJqKxxEylC8ym61xr8=; b=7TeILDobBpVtJQWkWPchMPD4YJ16Qi09jTP7yayI4C0wKcvEs5X2+fC/tD1eC8rKa4 RzIjRtLwH+t7FFGE+H3dq3xu70m8jXPQeuoiMF12mGNT/fZ/TZZn/M+kQOIkDuZ33+yT dKA/CjtrEAmZcvDN3fOvDXDmeCLP2Eo9/s0j1YDl4MWmzNcumSgo3qW1nxXHZe3pCnnh EMl5F6ttHc7QMsrvzDwONdIrN5LwonYh/5kWnMoxQphlt3NiQHtL2xZkkTKMEMYyv3Wt 4gQCw5cDmTwMJU7PMW9E0I95Vcntplt4CWjNjLT54YsMhI8l4a4tniKS6RCVN7oUgtCx q9KA== X-Gm-Message-State: AFqh2kr+G2TxdQSjQgZ/nFLOS1IOK4KG5+GF9DBbATwNA5CCyeHBYLX0 TQXhTuEdjHHBnLpSVWetZzL1Z9xizQI= X-Received: by 2002:a05:6512:70a:b0:4c0:4214:cd2c with SMTP id b10-20020a056512070a00b004c04214cd2cmr18109138lfs.43.1673463434318; Wed, 11 Jan 2023 10:57:14 -0800 (PST) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id j5-20020a05651231c500b004b5480edf67sm2842017lfe.36.2023.01.11.10.57.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 10:57:13 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Jan 2023 20:57:05 +0200 Message-Id: <20230111185707.22132-2-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230111185707.22132-1-jeebjp@gmail.com> References: <20230110211949.8195-1-jeebjp@gmail.com> <20230111185707.22132-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/4] avutil: introduce AVAmbientViewingEnvironment 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: tz33qy9Ot0TT This enables exposing H.274 Ambient Viewing Environment metadata in the framework. --- doc/APIchanges | 6 +++ libavutil/Makefile | 2 + libavutil/ambient_viewing_environment.c | 49 +++++++++++++++++ libavutil/ambient_viewing_environment.h | 72 +++++++++++++++++++++++++ libavutil/frame.c | 1 + libavutil/frame.h | 5 ++ libavutil/version.h | 2 +- 7 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 libavutil/ambient_viewing_environment.c create mode 100644 libavutil/ambient_viewing_environment.h diff --git a/doc/APIchanges b/doc/APIchanges index 328028f293..4356f8bbd5 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,12 @@ libavutil: 2021-04-27 API changes, most recent first: +2023-01-10 - xxxxxxxxxx - lavu 57.44.100 - ambient_viewing_environment.h frame.h + Adds a new structure for holding H.274 Ambient Viewing Environment metadata, + AVAmbientViewingEnvironment. + Adds a new AVFrameSideDataType entry AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT + for it. + 2022-12-xx - xxxxxxxxxx - lavc 59.55.100 - avcodec.h Add AV_HWACCEL_FLAG_UNSAFE_OUTPUT. diff --git a/libavutil/Makefile b/libavutil/Makefile index 3d9c07aea8..29b06665f5 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -4,6 +4,7 @@ DESC = FFmpeg utility library HEADERS = adler32.h \ aes.h \ aes_ctr.h \ + ambient_viewing_environment.h \ attributes.h \ audio_fifo.h \ avassert.h \ @@ -102,6 +103,7 @@ BUILT_HEADERS = avconfig.h \ OBJS = adler32.o \ aes.o \ aes_ctr.o \ + ambient_viewing_environment.o \ audio_fifo.o \ avstring.o \ avsscanf.o \ diff --git a/libavutil/ambient_viewing_environment.c b/libavutil/ambient_viewing_environment.c new file mode 100644 index 0000000000..c47458cfa8 --- /dev/null +++ b/libavutil/ambient_viewing_environment.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Jan Ekström + * + * 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 "ambient_viewing_environment.h" +#include "mem.h" + +AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size) +{ + AVAmbientViewingEnvironment *env = + av_mallocz(sizeof(AVAmbientViewingEnvironment)); + if (!env) + return NULL; + + if (size) + *size = sizeof(*env); + + return env; +} + +AVAmbientViewingEnvironment *av_ambient_viewing_environment_create_side_data(AVFrame *frame) +{ + AVFrameSideData *side_data = + av_frame_new_side_data(frame, + AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT, + sizeof(AVAmbientViewingEnvironment)); + if (!side_data) + return NULL; + + memset(side_data->data, 0, side_data->size); + + return (AVAmbientViewingEnvironment *)side_data->data; +} diff --git a/libavutil/ambient_viewing_environment.h b/libavutil/ambient_viewing_environment.h new file mode 100644 index 0000000000..e5e4ac2173 --- /dev/null +++ b/libavutil/ambient_viewing_environment.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023 Jan Ekström + * + * 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_ENVIRONMENT_H +#define AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H + +#include +#include "frame.h" +#include "rational.h" + +/** + * Ambient viewing environment metadata as defined by H.274. The values are + * saved in AVRationals so that they keep their exactness, while allowing for + * easy access to a double value with f.ex. av_q2d. + * + * @note sizeof(AVAmbientViewingEnvironment) is not part of the public ABI, and + * it must be allocated using av_ambient_viewing_environment_alloc. + */ +typedef struct AVAmbientViewingEnvironment { + /** + * Environmental illuminance of the ambient viewing environment in lux. + */ + AVRational ambient_illuminance; + + /** + * Normalized x chromaticity coordinate of the environmental ambient light + * in the nominal viewing environment according to the CIE 1931 definition + * of x and y as specified in ISO/CIE 11664-1. + */ + AVRational ambient_light_x; + + /** + * Normalized y chromaticity coordinate of the environmental ambient light + * in the nominal viewing environment according to the CIE 1931 definition + * of x and y as specified in ISO/CIE 11664-1. + */ + AVRational ambient_light_y; +} AVAmbientViewingEnvironment; + +/** + * Allocate an AVAmbientViewingEnvironment structure. + * + * @return the newly allocated struct or NULL on failure + */ +AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size); + +/** + * Allocate and add an AVAmbientViewingEnvironment structure to an existing + * AVFrame as side data. + * + * @return the newly allocated struct, or NULL on failure + */ +AVAmbientViewingEnvironment *av_ambient_viewing_environment_create_side_data(AVFrame *frame); + +#endif /* AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H */ diff --git a/libavutil/frame.c b/libavutil/frame.c index de4ad1f94d..fa9b11aa54 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -831,6 +831,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_ENVIRONMENT: return "Ambient viewing environment"; } return NULL; } diff --git a/libavutil/frame.h b/libavutil/frame.h index e60a82f6c0..bbe909ee2d 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -209,6 +209,11 @@ enum AVFrameSideDataType { * volume transform - CUVA 005.1-2021. */ AV_FRAME_DATA_DYNAMIC_HDR_VIVID, + + /** + * Ambient viewing environment metadata, as defined by H.274. + */ + AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT, }; enum AVActiveFormatDescription { diff --git a/libavutil/version.h b/libavutil/version.h index 3b616ea489..60f96af5df 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 43 +#define LIBAVUTIL_VERSION_MINOR 44 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \