From patchwork Tue Jan 10 21:19:47 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: 39956 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp4271107pzb; Tue, 10 Jan 2023 13:20:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXtczG4diw6RoMMzRXe9bts3UyxAkkQuePI+JqCqvr918ABPt10l+yY6HloyjMufxgTbERg9 X-Received: by 2002:a17:906:2854:b0:7c0:e30a:d3e5 with SMTP id s20-20020a170906285400b007c0e30ad3e5mr56330098ejc.18.1673385617042; Tue, 10 Jan 2023 13:20:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673385617; cv=none; d=google.com; s=arc-20160816; b=lR54SD4/tcG9Z9h8cMkGsjPuS5NxhTgSOOCpWzc0Uh3yX1rV7yoV8jyeRLK+Df/5Rq LCJUC3Y5qRkSLMKyRIQyzgO1nZdClbQDoSfYfyPOnrPRPpId5u/H6oiBEO40yMU/qHme ZCxEP0r7QZkgGDqGxU7V1Ne38JbZyIxISCxrlMCa/PyeaI8LESF+Dq3sEsFvOFWNS4xe BwgzpGDFZpXDksGa5Q5jNyxNZopMdiLB7GVJUKcaZ2XQPgkP5IRU7TMsdpkk4L1WsrvK VvcTJkWP49K5KHGoR4196PopUQPXby07sqdtpuDggzEUqxQ17tv34FsHZqoMA9jkti/k mNhw== 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=zuBwfLOe9v/Ow6aOfUMlSLNuYHzBkAqdwKxBl4v+Isk=; b=YH4A7clKltuvL0Fgo9e6YkOTjJOHbZ+DJFIZrXvPcy6lOIGzxreeUrVqGVWRQPNsrv NSfyOlFodkUYQl+3HAGCf+BCokaPimK9tIpNst873kCnPkbfxtXSRpezgJqLpSpxS/Ck WzpdHwaROLUrbcgPhc4UDknFH4ecOVX41NaBDcnru8DEXg+ThpgzTNoFg93LcicYUije dZkIU05ZEkWKY1QiWsmSGUJZkcH/2lLb9FiLJJfwfy0Rz/XKrFzVUxirlnori7XsaXaS Mzw/GImuELHaMfOcNYM1bn+sFcqIKMTK8DacoHzTYNFXDdtSoHQ8DPvYclWwAzetm8/W wF+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="D//bTMKQ"; 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 ht17-20020a170907609100b007adfe2889efsi12948603ejc.607.2023.01.10.13.20.16; Tue, 10 Jan 2023 13:20:17 -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="D//bTMKQ"; 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 B0DB968BD26; Tue, 10 Jan 2023 23:20:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E588C68B103 for ; Tue, 10 Jan 2023 23:19:57 +0200 (EET) Received: by mail-lf1-f46.google.com with SMTP id bf43so20486869lfb.6 for ; Tue, 10 Jan 2023 13:19:57 -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=xsnfvb8XJD/QoCFWFABRGhBqUQeS3QUN6hRD2w0+WNU=; b=D//bTMKQhMuGZ576IF/uUg9446h1ttBVvuouy1DuwtGhC+rykYEqjCeI8ettnZ4L2J burz5w5eugcdKmbrTesQ2M6ooLnIN6Z8Ex5J/a2aBmevdt+Q4cTeKAlSKUHtgFpdJYjs 6FyvVRxwLnPJf9PAiK+Qxxnvxz5xnXBwvxdMlxol17hIC04OLzhdEhs4PwN+/MLDWyqv RO5IeORwd3ltmOjsrU53dRrltc2Rvtv0xabjj2xDBkty1lXDQjE5l+zyO2kmEEFfosy9 jxIkTT3vSqg6Ehf0Z3275/bFV2dJPLNyVXqw6Jg5AEKylexzmAlk625QpFkz/hYRzhp6 PK0g== 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=xsnfvb8XJD/QoCFWFABRGhBqUQeS3QUN6hRD2w0+WNU=; b=oVNjDi3ldIcVRcbi7i7QeBxK5MoCU6vTe5sVqspWhJ3ElMKYsiXk8FJO7tBhBKGhdy GU72ebpCMD7xhp5l6Zan/LOx2lEtBpCRJZXmhpGanRUjdODthm8QxgZPxIRO2esvjHzA LHPKanfUaxNWkrYsSKIENhIhWp8rNGwmvl8YmjtgRmTCGxz1sqCYMlXP4oFZiDpt7Pdo SkMkNuCw+KWoTSl9Vtieh9pLO9EcvNxuzD/5m/T5jWPbDOlvnok2ibGEMu0D/EiT+erG 28rT4TWQys5W34CAQwfqE5QeDMyekqpFHFxvhcGiqvMGgDt/62+uzcQ+OR2dtxmpvflm qp1g== X-Gm-Message-State: AFqh2kqkAT3h8a7X+aPXfb5TbJRdkZbEyFh+d53kxyTRb1Jq8DinvcSE 48rqBKKboJehRnooEs8kqNQsKgQ3xTM= X-Received: by 2002:a05:6512:2102:b0:4ca:f9bd:3390 with SMTP id q2-20020a056512210200b004caf9bd3390mr15880963lfr.31.1673385597107; Tue, 10 Jan 2023 13:19:57 -0800 (PST) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id r4-20020a2e8e24000000b00283ad9caa59sm1142240ljk.140.2023.01.10.13.19.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 13:19:56 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Jan 2023 23:19:47 +0200 Message-Id: <20230110211949.8195-2-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110211949.8195-1-jeebjp@gmail.com> References: <20230110211949.8195-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: Zkv97zyw/Tri This enables exposing H.274 Ambient Viewing Environment metadata in the framework. --- doc/APIchanges | 6 +++ libavutil/Makefile | 2 + libavutil/ambient_viewing_environment.c | 51 ++++++++++++++++++ libavutil/ambient_viewing_environment.h | 72 +++++++++++++++++++++++++ libavutil/frame.c | 1 + libavutil/frame.h | 5 ++ libavutil/version.h | 2 +- 7 files changed, 138 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..f13b4f1149 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 + 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..e7d150796e --- /dev/null +++ b/libavutil/ambient_viewing_environment.c @@ -0,0 +1,51 @@ +/* + * 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 +#include "ambient_viewing_environment.h" +#include "frame.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, \