From patchwork Mon Feb 14 23:44:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 34297 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:14aa:0:0:0:0 with SMTP id bz10csp5960319nkb; Mon, 14 Feb 2022 15:45:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlkFS8KT5Pl0/XtiYrrojr22VgQzdsN/D4lx8nNfMkb1b02uhO+1PtUPSrdxahamLBbuCI X-Received: by 2002:aa7:ccce:: with SMTP id y14mr1275338edt.89.1644882302639; Mon, 14 Feb 2022 15:45:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644882302; cv=none; d=google.com; s=arc-20160816; b=MeBhtNCVaobsW0vNs2RRD3hyto3/7GmqBDnfV0db176vZsBPOfnF2MIHd5ThI5/HZe hDK3adF42bRaqxZvt9b5UhJPlGPQtS3+GVMXj8USmAUrzCbMidlvt/xwETxMN2M+1Txe ARo9cWhWV/3O5WY4xW8+OGFouJhvGL6EhfuajI0Sh+FGM4EkULhIposxFREfzZM7ujqq afOQOLmPA+VbBx+xMViXvK3zUrP0Ha3sZDM6Rm0oG2GiIdXIPQ6zybBaH9nz1xGdswAu YfazcjeuFjSsyBF/kQZRq5FUR0meSbVqnsoxpBxc1NBO9H6m/AEoysceXh/7uh/Xruvk TjDg== 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=rRTS6cNCP3ZiQdkGK9AloDG5mHyAOWNCloLmkDIqTbo=; b=anwj6P+KrbarvugbEzKiMdKJGRG/4L36pwZx9KgfFIIdkoJeE+Q9NIeKrsVzMoL/d2 jUE0+FeNJ1Rq66xsjfEcMJNJ9/9dh/51fBwQr8/3TXnYS8dW1fxvt7cFE2pGMV4NTDLs juqre6RRp2yfKvfu2etY8H8EuuMHEVbT51f1bKF44ilxHQQPbVvpPcMXcHvI6DVSkYua FFr2/p2gddGb8bSks6+1soTg+lrE/joubeS6TohU2TwsgtWX9pdqXlhcFiiOxzM0/awf SqrybKzVPnq7E0KDqQmnvNGTKb/M0DxbmQfObXd8U3Y0S3lwL5op23CM87ou4R9COPtL q/BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=pRwrv+5s; 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 h23si3474434eja.3.2022.02.14.15.44.38; Mon, 14 Feb 2022 15:45:02 -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=pRwrv+5s; 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 3F19568B193; Tue, 15 Feb 2022 01:44:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7BC0168AE70 for ; Tue, 15 Feb 2022 01:44:27 +0200 (EET) Received: by mail-pl1-f173.google.com with SMTP id l8so5742786pls.7 for ; Mon, 14 Feb 2022 15:44:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=/dF0pKmyDccJf0+HFvG3blglC43HpyDRZv4EmOL0QUI=; b=pRwrv+5s6l4EhB+DTjvIB/hSKKwAv1MZKoS8XKn2K3DfalzTqfi2Dv7dAbzegSNfQd FMw6wp8c6gANlJ+gkmZVDupQpPf2cJtwz1AiJBMPAw4GQvrNYWScPr83K59anIpFTXKk 9GzcorlBag39uwWxN6EiBlnm83OhwF/fat1swIc8iKO4gY1NiVoF1/cYe63o1r2pkVvy sX+dCoV+skB+CiCUjOCQrzwd0O5u3dIs3oZWlYp1DAvr6z/cl8hfBhYeZ39eeG1SkBj2 zgznV3Pz0eWT1iNbxaEcQn1Yc7ykrTldVxfoELp1QAIIcx5qQdpUudpm2swsZYCldw9O 8fWQ== 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=/dF0pKmyDccJf0+HFvG3blglC43HpyDRZv4EmOL0QUI=; b=7FEb5UhQWLdajVtHYCRau1QE7IiLDu4znAMm9jHag1Ab6qfeQWnuQsWR/k63KYP3Z9 kwbKdBfInynDKSgvh66h7LurMwzchliUzO8mUZKOz/xh2AjybK4aoAjpSBUOj+snwIVA jt4tBDLu1yQ1BmTSv5I+wCcvky4b5NPPyVm3mVL8cs5BLgtf72tXimofm/55XAC9i5Hy Iiecv4zgm7lMIGFTLi/+ZGnwP/BOsj0w+tVAPiZ7cV6ek3lo+zvDAJMQdjvuF2Ib35LV BHwxABbKS5VbpoBYV6UUy2ZBCTZMIUvfQ/J/NlFCgiwy50kZtBgw2QwdMrFEfpvH80li ezhg== X-Gm-Message-State: AOAM533+4mAPFyDM3j1FRC86c+ewoG2WM3DO/GDoLjtKLPGgmjCbwrQP KQr8CeLUiG3nakiIwjdgnKTYv2Prsx4= X-Received: by 2002:a17:902:bd81:: with SMTP id q1mr1493578pls.100.1644882265298; Mon, 14 Feb 2022 15:44:25 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id mi7sm492304pjb.21.2022.02.14.15.44.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Feb 2022 15:44:24 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Feb 2022 07:44:17 +0800 Message-Id: <1644882260-8559-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 support for CUVA HDR Vivid metadata 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: rP8wamaBpRWc From: Limin Wang Signed-off-by: Limin Wang --- libavutil/Makefile | 2 + libavutil/frame.c | 1 + libavutil/frame.h | 7 + libavutil/hdr_dynamic_vivid_metadata.c | 47 ++++++ libavutil/hdr_dynamic_vivid_metadata.h | 285 +++++++++++++++++++++++++++++++++ libavutil/version.h | 2 +- 6 files changed, 343 insertions(+), 1 deletion(-) create mode 100644 libavutil/hdr_dynamic_vivid_metadata.c create mode 100644 libavutil/hdr_dynamic_vivid_metadata.h diff --git a/libavutil/Makefile b/libavutil/Makefile index d17876d..a8d7587 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -34,6 +34,7 @@ HEADERS = adler32.h \ frame.h \ hash.h \ hdr_dynamic_metadata.h \ + hdr_dynamic_vivid_metadata.h \ hmac.h \ hwcontext.h \ hwcontext_cuda.h \ @@ -130,6 +131,7 @@ OBJS = adler32.o \ frame.o \ hash.o \ hdr_dynamic_metadata.o \ + hdr_dynamic_vivid_metadata.o \ hmac.o \ hwcontext.o \ imgutils.o \ diff --git a/libavutil/frame.c b/libavutil/frame.c index 8997c85..b035e28 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -723,6 +723,7 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type) case AV_FRAME_DATA_SPHERICAL: return "Spherical Mapping"; case AV_FRAME_DATA_ICC_PROFILE: return "ICC profile"; case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: return "HDR Dynamic Metadata SMPTE2094-40 (HDR10+)"; + case AV_FRAME_DATA_DYNAMIC_HDR_VIVID: return "HDR Dynamic Metadata CUVA 005.1 2021 (Vivid)"; case AV_FRAME_DATA_REGIONS_OF_INTEREST: return "Regions Of Interest"; case AV_FRAME_DATA_VIDEO_ENC_PARAMS: return "Video encoding parameters"; case AV_FRAME_DATA_SEI_UNREGISTERED: return "H.26[45] User Data Unregistered SEI message"; diff --git a/libavutil/frame.h b/libavutil/frame.h index 18e239f..32cde3c 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -158,6 +158,13 @@ enum AVFrameSideDataType { AV_FRAME_DATA_DYNAMIC_HDR_PLUS, /** + * HDR Vivid dynamic metadata associated with a video frame. The payload is + * an AVDynamicHDRVivid type and contains information for color + * volume transform - CUVA 005.1-2021. + */ + AV_FRAME_DATA_DYNAMIC_HDR_VIVID, + + /** * Regions Of Interest, the data is an array of AVRegionOfInterest type, the number of * array element is implied by AVFrameSideData.size / AVRegionOfInterest.self_size. */ diff --git a/libavutil/hdr_dynamic_vivid_metadata.c b/libavutil/hdr_dynamic_vivid_metadata.c new file mode 100644 index 0000000..32da01f --- /dev/null +++ b/libavutil/hdr_dynamic_vivid_metadata.c @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2021 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 "hdr_dynamic_vivid_metadata.h" +#include "mem.h" + +AVDynamicHDRVivid *av_dynamic_hdr_vivid_alloc(size_t *size) +{ + AVDynamicHDRVivid *hdr_vivid = av_mallocz(sizeof(AVDynamicHDRVivid)); + if (!hdr_vivid) + return NULL; + + if (size) + *size = sizeof(*hdr_vivid); + + return hdr_vivid; +} + +AVDynamicHDRVivid *av_dynamic_hdr_vivid_create_side_data(AVFrame *frame) +{ + AVFrameSideData *side_data = av_frame_new_side_data(frame, + AV_FRAME_DATA_DYNAMIC_HDR_VIVID, + sizeof(AVDynamicHDRVivid)); + if (!side_data) + return NULL; + + memset(side_data->data, 0, sizeof(AVDynamicHDRVivid)); + + return (AVDynamicHDRVivid *)side_data->data; +} diff --git a/libavutil/hdr_dynamic_vivid_metadata.h b/libavutil/hdr_dynamic_vivid_metadata.h new file mode 100644 index 0000000..832f7f9 --- /dev/null +++ b/libavutil/hdr_dynamic_vivid_metadata.h @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2021 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_HDR_DYNAMIC_VIVID_METADATA_H +#define AVUTIL_HDR_DYNAMIC_VIVID_METADATA_H + +#include "frame.h" +#include "rational.h" + +/** + * Color tone mapping parameters at a processing window in a dynamic metadata for + * CUVA 005.1:2021. + */ +typedef struct AVHDRVividColorToneMappingParams { + /** + * The nominal maximum display luminance of the targeted system display, + * in multiples of 1.0/4095 candelas per square metre. The value shall be in + * the range of 0.0 to 1.0, inclusive. + */ + AVRational targeted_system_display_maximum_luminance; + + /** + * This flag indicates that transfer the base paramter(for value of 1) + */ + int base_enable_flag; + + /** + * base_param_m_p in the base parameter, + * in multiples of 1.0/16383. The value shall be in + * the range of 0.0 to 1.0, inclusive. + */ + AVRational base_param_m_p; + + /** + * base_param_m_m in the base parameter, + * in multiples of 1.0/10. The value shall be in + * the range of 0.0 to 6.3, inclusive. + */ + AVRational base_param_m_m; + + /** + * base_param_m_a in the base parameter, + * in multiples of 1.0/1023. The value shall be in + * the range of 0.0 to 1.0 inclusive. + */ + AVRational base_param_m_a; + + /** + * base_param_m_b in the base parameter, + * in multiples of 1/1023. The value shall be in + * the range of 0.0 to 1.0, inclusive. + */ + AVRational base_param_m_b; + + /** + * base_param_m_n in the base parameter, + * in multiples of 1.0/10. The value shall be in + * the range of 0.0 to 6.3, inclusive. + */ + AVRational base_param_m_n; + + /** + * indicates k1_0 in the base parameter, + * base_param_k1 <= 1: k1_0 = base_param_k1 + * base_param_k1 > 1: reserved + */ + int base_param_k1; + + /** + * indicates k2_0 in the base parameter, + * base_param_k2 <= 1: k2_0 = base_param_k2 + * base_param_k2 > 1: reserved + */ + int base_param_k2; + + /** + * indicates k3_0 in the base parameter, + * base_param_k3 == 1: k3_0 = base_param_k3 + * base_param_k3 == 2: k3_0 = maximum_maxrgb + * base_param_k3 > 2: reserved + */ + int base_param_k3; + + /** + * This flag indicates that delta mode of base paramter(for value of 1) + */ + int base_param_Delta_enable_mode; + + /** + * base_param_Delta in the base parameter, + * in multiples of 1.0/127. The value shall be in + * the range of 0.0 to 1.0, inclusive. + */ + AVRational base_param_Delta; + + /** + * indicates 3Spline_flag in the base parameter, + * This flag indicates that transfer three Spline of base paramter(for value of 1) + */ + int three_Spline_flag; + + /** + * The number of three Spline. The value shall be in the range + * of 1 to 2, inclusive. + */ + int three_Spline_num; + + /** + * The mode of three Spline. the value shall be in the range + * of 0 to 3, inclusive. + */ + int three_Spline_TH_mode; + + /** + * three_Spline_TH_enable MB is in the range of 0.0 to 1.0, inclusive + * and in multiples of 1.0/255. + * + */ + AVRational three_Spline_TH_enable_MB; + + /** + * 3Spline_TH_enable of three Spline. + * The value shall be in the range of 0.0 to 1.0, inclusive. + * and in multiples of 1.0/4095. + */ + AVRational three_Spline_TH; + + /** + * 3Spline_TH_Delta1 of three Spline. + * The value shall be in the range of 0.0 to 0.25, inclusive, + * and in multiples of 0.25/1023. + */ + AVRational three_Spline_TH_Delta1; + + /** + * 3Spline_TH_Delta2 of three Spline. + * The value shall be in the range of 0.0 to 0.25, inclusive, + * and in multiples of 0.25/1023. + */ + AVRational three_Spline_TH_Delta2; + + /** + * 3Spline_enable_Strength of three Spline. + * The value shall be in the range of 0.0 to 1, inclusive, + * and in multiples of 1.0/255. + */ + AVRational three_Spline_enable_Strength; +} AVHDRVividColorToneMappingParams; + + +/** + * Color transform parameters at a processing window in a dynamic metadata for + * CUVA 005.1:2021. + */ +typedef struct AVHDRVividColorTransformParams { + /** + * Indicates the minimum brightness of the displayed content. + * The values should be in the range of 0.0 to 1.0, + * inclusive and in multiples of 1/4095. + */ + AVRational minimum_maxrgb; + + /** + * Indicates the average brightness of the displayed content. + * The values should be in the range of 0.0 to 1.0, + * inclusive and in multiples of 1/4095. + */ + AVRational average_maxrgb; + + /** + * Indicates the variance brightness of the displayed content. + * The values should be in the range of 0.0 to 1.0, + * inclusive and in multiples of 1/4095. + */ + AVRational variance_maxrgb; + + /** + * Indicates the maximum brightness of the displayed content. + * The values should be in the range of 0.0 to 1.0, inclusive + * and in multiples of 1/4095. + */ + AVRational maximum_maxrgb; + + /** + * This flag indicates that the metadata for the tone mapping function in + * the processing window is present (for value of 1). + */ + int tone_mapping_mode_flag; + + /** + * The number of tone mapping param. The value shall be in the range + * of 1 to 2, inclusive. + */ + int tone_mapping_param_num; + + /** + * The color tone mapping parameters. + */ + AVHDRVividColorToneMappingParams tm_params[2]; + + /** + * This flag indicates that the metadata for the color saturation mapping in + * the processing window is present (for value of 1). + */ + int color_saturation_mapping_flag; + + /** + * The number of color saturation param. The value shall be in the range + * of 0 to 7, inclusive. + */ + int color_saturation_num; + + /** + * Indicates the color correction strength parameter. + * The values should be in the range of 0.0 to 2.0, inclusive + * and in multiples of 1/128. + */ + AVRational color_saturation_gain[8]; +} AVHDRVividColorTransformParams; + +/** + * This struct represents dynamic metadata for color volume transform - + * CUVA 005.1:2021 standard + * + * To be used as payload of a AVFrameSideData or AVPacketSideData with the + * appropriate type. + * + * @note The struct should be allocated with + * av_dynamic_hdr_vivid_alloc() and its size is not a part of + * the public ABI. + */ +typedef struct AVDynamicHDRVivid { + /** + * The system start code. The value shall be set to 0x01. + */ + uint8_t system_start_code; + + /** + * The number of processing windows. The value shall be set to 0x01 + * if the system_start_code is 0x01. + */ + uint8_t num_windows; + + /** + * The color transform parameters for every processing window. + */ + AVHDRVividColorTransformParams params[3]; +} AVDynamicHDRVivid; + +/** + * Allocate an AVDynamicHDRVivid structure and set its fields to + * default values. The resulting struct can be freed using av_freep(). + * + * @return An AVDynamicHDRVivid filled with default values or NULL + * on failure. + */ +AVDynamicHDRVivid *av_dynamic_hdr_vivid_alloc(size_t *size); + +/** + * Allocate a complete AVDynamicHDRVivid and add it to the frame. + * @param frame The frame which side data is added to. + * + * @return The AVDynamicHDRVivid structure to be filled by caller or NULL + * on failure. + */ +AVDynamicHDRVivid *av_dynamic_hdr_vivid_create_side_data(AVFrame *frame); + +#endif /* AVUTIL_HDR_DYNAMIC_VIVID_METADATA_H */ diff --git a/libavutil/version.h b/libavutil/version.h index a9c9bc6..c80e9d7 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 21 +#define LIBAVUTIL_VERSION_MINOR 22 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ From patchwork Mon Feb 14 23:44:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 34295 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:14aa:0:0:0:0 with SMTP id bz10csp5960234nkb; Mon, 14 Feb 2022 15:44:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/VXf5FXngOlMSIDZM2Cuwa5Ydx5sCJslYj48mfnqQkQMvaSLy0SydC06w6cTEgWUU6Pcu X-Received: by 2002:a17:907:ea0:: with SMTP id ho32mr892553ejc.147.1644882289721; Mon, 14 Feb 2022 15:44:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644882289; cv=none; d=google.com; s=arc-20160816; b=vFDxUy2TvJX/YpFiRf+HblisOAEmcwJB7Udr1jGFIehv/AJbTytJQPYjLTpv2Xw7dG Ny8kbRQ+orpyGfR9heJuIFfvTWfWbrz290IhnvsiSLM38hwZdM1ttTulEOxwOu08hYFi rqUcBMlACkTTtwCZzVqfDX5ipw6qng5pAuv1p6pTRlazNaFLe6BFLwyn3cUDYl/mQUd9 dFHBg0Vhdw716R+eH02ki3pxU7jqtDq6ZOvHcLcJsPbWDN9Pssc8aq7R+ddJzgspLFBx nL7vj+btFeOE+k4IUmUOaapSaL+9tvPail3l7PIEUC7UT5eYi80TpL0cLmbySN/uOJng HY0Q== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=CFOHuAVPGaUrX8AuBl+pdpv3jL+HNYTnE5OZx8hWvnc=; b=TC/9J2vDNSkdnxMTE9bAusGsiozzJzn13X+ysInu1R5jAFWs8zLpBT+DnneFFR7o2L V54QM97eIJLstFHdTprGxcNWP38vmRa/yTXXdJ6tFePAWJKGHQ2xxIbeoCrj7v21KVcr rAWT0sb3/dnlnFOTXuIL0sB/Px0WjK8kwYA3y8ODmb0LKiCM2V1Vb+sfI9Hyxv8TTASh dFVxvC7hs38UOxuZ7aA6VRS/onXuQhGgj8vrf8ltmWIacGLCn+mKa+f8SNWgjdof4amx kE9g1OICTb+N3pDGrY8BA4j4rDRocaM9zgzMjxfe/jtrWYrTd/bCEqM+PmZ2HXC+jVqc t8NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=jZVjYrka; 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 r7si1832316edd.171.2022.02.14.15.44.49; Mon, 14 Feb 2022 15:44:49 -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=jZVjYrka; 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 422B068B1D4; Tue, 15 Feb 2022 01:44:35 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8BB0268AEDA for ; Tue, 15 Feb 2022 01:44:28 +0200 (EET) Received: by mail-pf1-f170.google.com with SMTP id l19so26103193pfu.2 for ; Mon, 14 Feb 2022 15:44:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z5To2RKiLWhoKESbOQdTp+91LE+b5R756qyG0F/4YbM=; b=jZVjYrkaxPB7WHbteu6Ygj/e01q4VkXFlwNljqhRe1gv1Yg6iGK/dT/EiCYWekb2A3 FGPFh+5m2O0QjhZH0nmZkb+hVoxmqwOQxUF1vMryAqSHMYFqQsqCsi6XFaPyWagLNTBG AjUfnzdt7r3B1ToMMSDfLsofH0vc4/damepQ5mQkzXwiyyUE4yC4ToxkNYl9n/9IpPOB lKqxr7Cw0ytigKuo6M3PO38N4UgV45PtMsUkfJVhGbqzJ5hGRtgG3Gyc8cyrwAzfFwLP kCsCfBSvSZCnqhBJ1W5zAxkypUfE2Yc6Orw3LMXT3GlsUB1x+x+9CtPuUjiHWbLZJJ5v z/ow== 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:in-reply-to :references; bh=Z5To2RKiLWhoKESbOQdTp+91LE+b5R756qyG0F/4YbM=; b=TG9UyBY8K5Kjh5SuiZL2swtzRlX4U/nUaUct4mhzycjc/qZeqL1cAeO8taa012r0yq lDt1zguPDaYMSmVRFmpmsCfEQl+2rzAyJaamqrQ/8haO+Q8L4THdOBHxY34qO3s9j1Sd UdPxXMUfN+dyTZcL85WndLcVu9pXgda2zJJSajvXAZi7DFF386d7x4GRai/2lUmn0Xgw RacDNl5QrMs+DTdralYm4P+2x/hUezh9jhxbxwJFTcYcuaiJ4TbWLUhmKySKCc4inHQ9 DuX+xW9g+ALhFcV2TngwjKQk6FKMLJxxW1BQjyTVKpz3mMHsVtn8jbz5nwAQdqtqxdkR o6NQ== X-Gm-Message-State: AOAM531bDtUUXcaXXCuSkICyaDuETB6UitsACX4xYch9iDsZcxWDgMlg +PhvF7SiXOUDuNfY6k5KDY4+2kjnNKY= X-Received: by 2002:a63:6f45:: with SMTP id k66mr1205484pgc.511.1644882266532; Mon, 14 Feb 2022 15:44:26 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id mi7sm492304pjb.21.2022.02.14.15.44.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Feb 2022 15:44:26 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Feb 2022 07:44:18 +0800 Message-Id: <1644882260-8559-2-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1644882260-8559-1-git-send-email-lance.lmwang@gmail.com> References: <1644882260-8559-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/4] avcodec: support for CUVA HDR Vivid metadata 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: SrcYjcfUmod3 From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/Makefile | 2 +- libavcodec/dynamic_hdr_vivid.c | 139 +++++++++++++++++++++++++++++++++++++++++ libavcodec/dynamic_hdr_vivid.h | 35 +++++++++++ libavcodec/hevc_sei.c | 48 +++++++++++++- libavcodec/hevc_sei.h | 5 ++ libavcodec/hevcdec.c | 15 +++++ 6 files changed, 241 insertions(+), 3 deletions(-) create mode 100644 libavcodec/dynamic_hdr_vivid.c create mode 100644 libavcodec/dynamic_hdr_vivid.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index cfc70a3..1910137 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -96,7 +96,7 @@ OBJS-$(CONFIG_H264PARSE) += h264_parse.o h2645_parse.o h264_ps.o OBJS-$(CONFIG_H264PRED) += h264pred.o OBJS-$(CONFIG_H264QPEL) += h264qpel.o OBJS-$(CONFIG_HEVCPARSE) += hevc_parse.o h2645_parse.o hevc_ps.o hevc_sei.o hevc_data.o \ - dynamic_hdr10_plus.o + dynamic_hdr10_plus.o dynamic_hdr_vivid.o OBJS-$(CONFIG_HPELDSP) += hpeldsp.o OBJS-$(CONFIG_HUFFMAN) += huffman.o OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c new file mode 100644 index 0000000..7d0bd43 --- /dev/null +++ b/libavcodec/dynamic_hdr_vivid.c @@ -0,0 +1,139 @@ +/* + * 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 "dynamic_hdr_vivid.h" +#include "get_bits.h" + +static const int32_t maxrgb_den = 4095; +static const int32_t color_saturation_gain_den = 128; +static const int32_t maximum_luminance_den = 4095; +static const int32_t base_param_m_p_den = 16383; +static const int32_t base_param_m_m_den = 10; +static const int32_t base_param_m_a_den = 1023; +static const int32_t base_param_m_b_den = 1023; +static const int32_t base_param_m_n_den = 10; +static const int32_t base_param_Delta_den = 127; + +int ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const uint8_t *data, + int size) +{ + GetBitContext gbc, *gb = &gbc; + int ret; + + if (!s) + return AVERROR(ENOMEM); + + ret = init_get_bits8(gb, data, size); + if (ret < 0) + return ret; + + if (get_bits_left(gb) < 8) + return AVERROR_INVALIDDATA; + + s->system_start_code = get_bits(gb, 8); + if (s->system_start_code == 0x01) { + s->num_windows = 1; + + if (get_bits_left(gb) < 12 * 4 * s->num_windows) + return AVERROR_INVALIDDATA; + for (int w = 0; w < s->num_windows; w++) { + AVHDRVividColorTransformParams *params = &s->params[w]; + + params->minimum_maxrgb = (AVRational){get_bits(gb, 12), maxrgb_den}; + params->average_maxrgb = (AVRational){get_bits(gb, 12), maxrgb_den}; + params->variance_maxrgb = (AVRational){get_bits(gb, 12), maxrgb_den}; + params->maximum_maxrgb = (AVRational){get_bits(gb, 12), maxrgb_den}; + } + + if (get_bits_left(gb) < 2 * s->num_windows) + return AVERROR_INVALIDDATA; + for (int w = 0; w < s->num_windows; w++) { + AVHDRVividColorTransformParams *params = &s->params[w]; + + params->tone_mapping_mode_flag = get_bits(gb, 1); + if (params->tone_mapping_mode_flag) { + if (get_bits_left(gb) < 1 ) + return AVERROR_INVALIDDATA; + params->tone_mapping_param_num = get_bits(gb, 1) + 1; + for (int i = 0; i < params->tone_mapping_param_num; i++) { + AVHDRVividColorToneMappingParams *tm_params = ¶ms->tm_params[i]; + + if (get_bits_left(gb) < 13) + return AVERROR_INVALIDDATA; + tm_params->targeted_system_display_maximum_luminance = (AVRational){get_bits(gb, 12), maximum_luminance_den}; + tm_params->base_enable_flag = get_bits(gb, 1); + if (tm_params->base_enable_flag) { + if (get_bits_left(gb) < (14 + 6 + 10 + 10 + 6 + 8 + 10)) + return AVERROR_INVALIDDATA; + tm_params->base_param_m_p = (AVRational){get_bits(gb, 14), base_param_m_p_den}; + tm_params->base_param_m_m = (AVRational){get_bits(gb, 6), base_param_m_m_den}; + tm_params->base_param_m_a = (AVRational){get_bits(gb, 10), base_param_m_a_den}; + tm_params->base_param_m_b = (AVRational){get_bits(gb, 10), base_param_m_b_den}; + tm_params->base_param_m_n = (AVRational){get_bits(gb, 6), base_param_m_n_den}; + tm_params->base_param_k1 = get_bits(gb, 2); + tm_params->base_param_k2 = get_bits(gb, 2); + tm_params->base_param_k3 = get_bits(gb, 4); + tm_params->base_param_Delta_enable_mode = get_bits(gb, 3); + if (tm_params->base_param_Delta_enable_mode == 2 || tm_params->base_param_Delta_enable_mode == 6) + tm_params->base_param_Delta = (AVRational){-get_bits(gb, 7), base_param_Delta_den}; + else + tm_params->base_param_Delta = (AVRational){get_bits(gb, 7), base_param_Delta_den}; + + if (get_bits_left(gb) < 1) + return AVERROR_INVALIDDATA; + tm_params->three_Spline_flag = get_bits(gb, 1); + if (tm_params->three_Spline_flag) { + if (get_bits_left(gb) < 1 + tm_params->three_Spline_num * (2 + 12 + 28 + 1)) + return AVERROR_INVALIDDATA; + tm_params->three_Spline_num = get_bits(gb, 1) + 1; + for (int j = 0; j < tm_params->three_Spline_num; j++) { + tm_params->three_Spline_TH_mode = get_bits(gb, 2); + if (tm_params->three_Spline_TH_mode == 0 || tm_params->three_Spline_TH_mode == 2) { + if (get_bits_left(gb) < 8) + return AVERROR_INVALIDDATA; + tm_params->three_Spline_TH_enable_MB = (AVRational){get_bits(gb, 8), 255}; + } + tm_params->three_Spline_TH = (AVRational){get_bits(gb, 12), 4095}; + tm_params->three_Spline_TH_Delta1 = (AVRational){get_bits(gb, 10), 1023}; + tm_params->three_Spline_TH_Delta2 = (AVRational){get_bits(gb, 10), 1023}; + tm_params->three_Spline_enable_Strength = (AVRational){get_bits(gb, 8), 255}; + } + } else { + tm_params->three_Spline_num = 1; + tm_params->three_Spline_TH_mode = 0; + } + + } + } + } + + params->color_saturation_mapping_flag = get_bits(gb, 1); + if (params->color_saturation_mapping_flag) { + if (get_bits_left(gb) < 3 + params->color_saturation_num * 8) + return AVERROR_INVALIDDATA; + + params->color_saturation_num = get_bits(gb, 3); + for (int i = 0; i < params->color_saturation_num; i++) { + params->color_saturation_gain[i] = (AVRational){get_bits(gb, 8), color_saturation_gain_den}; + } + } + } + } + + return 0; +} diff --git a/libavcodec/dynamic_hdr_vivid.h b/libavcodec/dynamic_hdr_vivid.h new file mode 100644 index 0000000..d521b3d --- /dev/null +++ b/libavcodec/dynamic_hdr_vivid.h @@ -0,0 +1,35 @@ +/* + * 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 AVCODEC_DYNAMIC_HDR_VIVID_H +#define AVCODEC_DYNAMIC_HDR_VIVID_H + +#include "libavutil/hdr_dynamic_vivid_metadata.h" + +/** + * Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRVivid). + * @param s A pointer containing the decoded AVDynamicHDRVivid structure. + * @param data The byte array containing the raw ITU-T T.35 data. + * @param size Size of the data array in bytes. + * + * @return 0 if succeed. Otherwise, returns the appropriate AVERROR. + */ +int ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const uint8_t *data, + int size); + +#endif /* AVCODEC_DYNAMIC_HDR_VIVID_H */ diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c index 7fd8226..ec3036f 100644 --- a/libavcodec/hevc_sei.c +++ b/libavcodec/hevc_sei.c @@ -24,6 +24,7 @@ #include "atsc_a53.h" #include "dynamic_hdr10_plus.h" +#include "dynamic_hdr_vivid.h" #include "golomb.h" #include "hevc_ps.h" #include "hevc_sei.h" @@ -245,6 +246,34 @@ static int decode_registered_user_data_dynamic_hdr_plus(HEVCSEIDynamicHDRPlus *s return 0; } +static int decode_registered_user_data_dynamic_hdr_vivid(HEVCSEIDynamicHDRVivid *s, + GetBitContext *gb, int size) +{ + size_t meta_size; + int err; + AVDynamicHDRVivid *metadata = av_dynamic_hdr_vivid_alloc(&meta_size); + if (!metadata) + return AVERROR(ENOMEM); + + err = ff_parse_itu_t_t35_to_dynamic_hdr_vivid(metadata, + gb->buffer + get_bits_count(gb) / 8, size); + if (err < 0) { + av_free(metadata); + return err; + } + + av_buffer_unref(&s->info); + s->info = av_buffer_create((uint8_t *)metadata, meta_size, NULL, NULL, 0); + if (!s->info) { + av_free(metadata); + return AVERROR(ENOMEM); + } + + skip_bits_long(gb, size * 8); + + return 0; +} + static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetBitContext *gb, void *logctx, int size) { @@ -263,9 +292,9 @@ static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetBitConte size--; } - if (country_code != 0xB5) { // usa_country_code + if (country_code != 0xB5 && country_code != 0x26) { // usa_country_code and cn_country_code av_log(logctx, AV_LOG_VERBOSE, - "Unsupported User Data Registered ITU-T T35 SEI message (country_code = %d)\n", + "Unsupported User Data Registered ITU-T T35 SEI message (country_code = 0x%x)\n", country_code); goto end; } @@ -273,6 +302,20 @@ static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetBitConte provider_code = get_bits(gb, 16); switch (provider_code) { + case 0x04: { // cuva_provider_code + const uint16_t cuva_provider_oriented_code = 0x0005; + uint16_t provider_oriented_code; + + if (size < 2) + return AVERROR_INVALIDDATA; + size -= 2; + + provider_oriented_code = get_bits(gb, 16); + if (provider_oriented_code == cuva_provider_oriented_code) { + return decode_registered_user_data_dynamic_hdr_vivid(&s->dynamic_hdr_vivid, gb, size); + } + break; + } case 0x3C: { // smpte_provider_code // A/341 Amendment - 2094-40 const uint16_t smpte2094_40_provider_oriented_code = 0x0001; @@ -559,4 +602,5 @@ void ff_hevc_reset_sei(HEVCSEI *s) s->unregistered.nb_buf_ref = 0; av_freep(&s->unregistered.buf_ref); av_buffer_unref(&s->dynamic_hdr_plus.info); + av_buffer_unref(&s->dynamic_hdr_vivid.info); } diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h index ac8c61c..f198402 100644 --- a/libavcodec/hevc_sei.h +++ b/libavcodec/hevc_sei.h @@ -78,6 +78,10 @@ typedef struct HEVCSEIDynamicHDRPlus { AVBufferRef *info; } HEVCSEIDynamicHDRPlus; +typedef struct HEVCSEIDynamicHDRVivid { + AVBufferRef *info; +} HEVCSEIDynamicHDRVivid; + typedef struct HEVCSEIContentLight { int present; uint16_t max_content_light_level; @@ -139,6 +143,7 @@ typedef struct HEVCSEI { HEVCSEIUnregistered unregistered; HEVCSEIMasteringDisplay mastering_display; HEVCSEIDynamicHDRPlus dynamic_hdr_plus; + HEVCSEIDynamicHDRVivid dynamic_hdr_vivid; HEVCSEIContentLight content_light; int active_seq_parameter_set_id; HEVCSEIAlternativeTransfer alternative_transfer; diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 1d4ad42..068750d 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2984,6 +2984,17 @@ static int set_side_data(HEVCContext *s) if ((ret = ff_dovi_attach_side_data(&s->dovi_ctx, out)) < 0) return ret; + if (s->sei.dynamic_hdr_vivid.info) { + AVBufferRef *info_ref = av_buffer_ref(s->sei.dynamic_hdr_vivid.info); + if (!info_ref) + return AVERROR(ENOMEM); + + if (!av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_DYNAMIC_HDR_VIVID, info_ref)) { + av_buffer_unref(&info_ref); + return AVERROR(ENOMEM); + } + } + return 0; } @@ -3777,6 +3788,10 @@ static int hevc_update_thread_context(AVCodecContext *dst, if (ret < 0) return ret; + ret = av_buffer_replace(&s->sei.dynamic_hdr_vivid.info, s0->sei.dynamic_hdr_vivid.info); + if (ret < 0) + return ret; + s->sei.frame_packing = s0->sei.frame_packing; s->sei.display_orientation = s0->sei.display_orientation; s->sei.mastering_display = s0->sei.mastering_display; From patchwork Mon Feb 14 23:44:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 34296 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:14aa:0:0:0:0 with SMTP id bz10csp5960299nkb; Mon, 14 Feb 2022 15:44:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjf1Xo5+BIw1EzdS+SFuF2SgTm1z2Kxnhd2TwycOUz2Yx+U4LpcNB5n4k38uLGZkSGt2pW X-Received: by 2002:a17:906:72d4:: with SMTP id m20mr860465ejl.601.1644882299249; Mon, 14 Feb 2022 15:44:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644882299; cv=none; d=google.com; s=arc-20160816; b=w4EvCh9l0TvBWC6ZAUmO+GEHLocSWJbFtD7jaTxMMxOQ722u4SnW8kzgQM9MLAvl9E 7zcvK6hVL1IT0mPZdslHgABXeAGfcCIAMf9/andHaXbHVsEyEZ9rgMae7PZ/ykrgdAkD CqyjKmg0eMuNZPmvSKC+Fj/iKOoDlrr9TT1ly/TbzI8K6zk/omOofrz/E5HLQ8F0Xxib MtPLhXgpmml2EH0wGd7jtyfm+CEmcVSVsVFmBD1QH9I95hlOtC2sqdUSb2MKm6xJi4nc VzUIJN6i1niZxuGdzPlTusb3f9wvyDiXibAYae4559c2LrLADl0Ypnj3bAKa3lQJVaMY hZSw== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=djTGVMa6w4pJyZtrrWYKeBzaXzhYsQIWYtrYfdvj/CI=; b=bwRrFs4VUh4uYrn3r03h5lfmmmjpnfk2rqtz5BiBwBbW5qMfPnx6lh5/87VOtJvY7C qxpZg3ETg/ft7RTNqeFDjJJwwwm4JXCotf7cDBoiWBu6uFAdpyt3hcLIVbtbhocZq1ly u6mxWGsIbSbQrLwah/Disgt4MRRz/H/3BroRuVAmEqL4A0zPD+sC+b8h22Wa6tvQ2YG0 fm1HAziSZKytsop0g/OW9U2GZQYay1p96UxKc7XNyxL2uycF/ktLs8MI56FuF1w6X0rU Rgi4Yr0qMFMCHBZW2F5AQ/av8EJg7kRQuo1sxmuOuWFIl2Jet/SZiMuLIcS9pbvHWDPN JcuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=cnSVZoMn; 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 nd29si34546706ejc.75.2022.02.14.15.44.58; Mon, 14 Feb 2022 15:44:59 -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=cnSVZoMn; 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 3B08068B1F8; Tue, 15 Feb 2022 01:44:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8B0EF68B1C1 for ; Tue, 15 Feb 2022 01:44:29 +0200 (EET) Received: by mail-pf1-f178.google.com with SMTP id p10so11269176pfo.12 for ; Mon, 14 Feb 2022 15:44:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sv6/h7x/NmF7XfuUIA8S+IsfmqQeFIIKBuQ/k1w1ZZ4=; b=cnSVZoMno8osaTA4A6udiM5z44WUBQnQ9u6aJI3hrd4ge7E0+Q4LrF6MUdTU+V+20j HMIqOkon2w2Ha3vW1I+Ob0zJJ2pCHIX0OqTKdOX7UWsa+iEqRI4/JtJnVR11l6LMWEO0 qh5pI9iIaYjPsAvcMGsOUt+szbcNiLRi8EEiupp/bRKW9lN6NZzjH6fDtru+06ajG5mk MbdCU4qoB3jdJ1W+KxqShQLBynj8l0vjDuvBeck/uvpIuhrdPt3CL4qCKM2yF2lLJQGI o0eTqAY7t+vB6c7FfBi/zlwdTOuwgtYv24zi/1kR53AVDSujMrzgkPXpO/0U3SVg5RmN BhEA== 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:in-reply-to :references; bh=sv6/h7x/NmF7XfuUIA8S+IsfmqQeFIIKBuQ/k1w1ZZ4=; b=lsZq7K+arVMPyMksLpdf1I4Nudkl0bV+RYPnxqTEL7nRktUEHpldKFZIDbwxAqygEZ oxl5tFx/9UJrHdE9JM2RnRit1iWPw1mHXGgeSxlA0B9oxbrz45eqLcq49usgDh4fGUqn elWAugWzPgAiqV9bqi1SxDFjxHeET1CRq2+k33m9yMsjJJk2en67s+kVjqSQKAMBeA/e s3tgAZoptpfS6yHL7uiI18tUCKMrjdaIvNna9DQxn3o5p8IIto+TLpISGdVVqkms++fz 6vwd+AvbdnDiGdRwYQkKi0dae02bUmKEruiSGEvZdqufwiCKICa+AkgIolrAPnV6Hb+O Kpgg== X-Gm-Message-State: AOAM530ceXQoWOP2wMuxV6PRa4CPw9CQFTr9fuUXD/KZl1UgLPwtffo6 qNs3FmdL07s2BKWIQYmwoLjDo7PgVDg= X-Received: by 2002:a63:5b1c:: with SMTP id p28mr1215848pgb.227.1644882267693; Mon, 14 Feb 2022 15:44:27 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id mi7sm492304pjb.21.2022.02.14.15.44.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Feb 2022 15:44:27 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Feb 2022 07:44:19 +0800 Message-Id: <1644882260-8559-3-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1644882260-8559-1-git-send-email-lance.lmwang@gmail.com> References: <1644882260-8559-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 3/4] avfilter: support for CUVA HDR Vivid metadata 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: 11+p1LV8V+Ej From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/vf_showinfo.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index 71728bc..bee84b2 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -32,6 +32,7 @@ #include "libavutil/internal.h" #include "libavutil/film_grain_params.h" #include "libavutil/hdr_dynamic_metadata.h" +#include "libavutil/hdr_dynamic_vivid_metadata.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/spherical.h" @@ -307,6 +308,88 @@ static void dump_dynamic_hdr_plus(AVFilterContext *ctx, AVFrameSideData *sd) } } +static void dump_dynamic_hdr_vivid(AVFilterContext *ctx, AVFrameSideData *sd) +{ + AVDynamicHDRVivid *hdr_vivid; + + av_log(ctx, AV_LOG_INFO, "HDR Vivid metadata: "); + if (sd->size < sizeof(*hdr_vivid)) { + av_log(ctx, AV_LOG_ERROR, "invalid hdr vivid data\n"); + return; + } + + hdr_vivid = (AVDynamicHDRVivid *)sd->data; + av_log(ctx, AV_LOG_INFO, "system_start_code: %d, ", hdr_vivid->system_start_code); + av_log(ctx, AV_LOG_INFO, "num_windows: %d, ", hdr_vivid->num_windows); + for (int w = 0; w < hdr_vivid->num_windows; w++) { + const AVHDRVividColorTransformParams *params = &hdr_vivid->params[w]; + + av_log(ctx, AV_LOG_INFO, "minimum_maxrgb[%d]: %.4f, ", w, av_q2d(params->minimum_maxrgb)); + av_log(ctx, AV_LOG_INFO, "average_maxrgb[%d]: %.4f, ", w, av_q2d(params->average_maxrgb)); + av_log(ctx, AV_LOG_INFO, "variance_maxrgb[%d]:%.4f, ", w, av_q2d(params->variance_maxrgb)); + av_log(ctx, AV_LOG_INFO, "maximum_maxrgb[%d]: %.4f, ", w, av_q2d(params->maximum_maxrgb)); + } + + for (int w = 0; w < hdr_vivid->num_windows; w++) { + const AVHDRVividColorTransformParams *params = &hdr_vivid->params[w]; + + av_log(ctx, AV_LOG_INFO, "tone_mapping_mode_flag[%d]: %d, ", w, params->tone_mapping_mode_flag); + av_log(ctx, AV_LOG_INFO, "tone_mapping_param_num[%d]: %d, ", w, params->tone_mapping_param_num); + if (params->tone_mapping_mode_flag) { + for (int i = 0; i < params->tone_mapping_param_num; i++) { + const AVHDRVividColorToneMappingParams *tm_params = ¶ms->tm_params[i]; + + av_log(ctx, AV_LOG_INFO, "targeted_system_display_maximum_luminance[%d][%d]: %.4f, ", + w, i, av_q2d(tm_params->targeted_system_display_maximum_luminance)); + av_log(ctx, AV_LOG_INFO, "base_enable_flag[%d][%d]: %d, ", + w, i, tm_params->base_enable_flag); + if (tm_params->base_enable_flag) { + av_log(ctx, AV_LOG_INFO, "base_param_m_p[%d][%d]: %.4f, ", w, i, av_q2d(tm_params->base_param_m_p)); + av_log(ctx, AV_LOG_INFO, "base_param_m_m[%d][%d]: %.4f, ", w, i, av_q2d(tm_params->base_param_m_m)); + av_log(ctx, AV_LOG_INFO, "base_param_m_a[%d][%d]: %.4f, ", w, i, av_q2d(tm_params->base_param_m_a)); + av_log(ctx, AV_LOG_INFO, "base_param_m_b[%d][%d]: %.4f, ", w, i, av_q2d(tm_params->base_param_m_b)); + av_log(ctx, AV_LOG_INFO, "base_param_m_n[%d][%d]: %.4f, ", w, i, av_q2d(tm_params->base_param_m_n)); + av_log(ctx, AV_LOG_INFO, "base_param_k1[%d][%d]: %d, ", w, i, tm_params->base_param_k1); + av_log(ctx, AV_LOG_INFO, "base_param_k2[%d][%d]: %d, ", w, i, tm_params->base_param_k2); + av_log(ctx, AV_LOG_INFO, "base_param_k3[%d][%d]: %d, ", w, i, tm_params->base_param_k3); + av_log(ctx, AV_LOG_INFO, "base_param_Delta_enable_mode[%d][%d]: %d, ", w, i, + tm_params->base_param_Delta_enable_mode); + av_log(ctx, AV_LOG_INFO, "base_param_Delta[%d][%d]: %.4f, ", w, i, av_q2d(tm_params->base_param_Delta)); + } + if (tm_params->three_Spline_flag) { + av_log(ctx, AV_LOG_INFO, "3Spline_flag[%d][%d]: %d, ", w, i, tm_params->three_Spline_flag); + av_log(ctx, AV_LOG_INFO, "3Spline_TH_mode[%d][%d]: %d, ", w, i, tm_params->three_Spline_TH_mode); + + for (int j = 0; j < tm_params->three_Spline_num; j++) { + av_log(ctx, AV_LOG_INFO, "3Spline_TH_enable_MB[%d][%d][%d]: %.4f, ", + w, i, j, av_q2d(tm_params->three_Spline_TH_enable_MB)); + av_log(ctx, AV_LOG_INFO, "3Spline_TH[%d][%d][%d]: %.4f, ", + w, i, j, av_q2d(tm_params->three_Spline_TH)); + av_log(ctx, AV_LOG_INFO, "3Spline_TH_Delta1[%d][%d][%d]: %.4f, ", + w, i, j, av_q2d(tm_params->three_Spline_TH_Delta1)); + av_log(ctx, AV_LOG_INFO, "3Spline_TH_Delta2[%d][%d][%d]: %.4f, ", + w, i, j, av_q2d(tm_params->three_Spline_TH_Delta2)); + av_log(ctx, AV_LOG_INFO, "3Spline_enable_Strength[%d][%d][%d]: %.4f, ", + w, i, j, av_q2d(tm_params->three_Spline_enable_Strength)); + } + } + } + } + + av_log(ctx, AV_LOG_INFO, "color_saturation_mapping_flag[%d]: %d", + w, params->color_saturation_mapping_flag); + if (params->color_saturation_mapping_flag) { + av_log(ctx, AV_LOG_INFO, ", color_saturation_num[%d]: %d", + w, params->color_saturation_num); + for (int i = 0; i < params->color_saturation_num; i++) { + av_log(ctx, AV_LOG_INFO, ", color_saturation_gain[%d][%d]: %.4f", + w, i, av_q2d(params->color_saturation_gain[i])); + } + } + } +} + + static void dump_content_light_metadata(AVFilterContext *ctx, AVFrameSideData *sd) { const AVContentLightMetadata *metadata = (const AVContentLightMetadata *)sd->data; @@ -704,6 +787,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: dump_dynamic_hdr_plus(ctx, sd); break; + case AV_FRAME_DATA_DYNAMIC_HDR_VIVID: + dump_dynamic_hdr_vivid(ctx, sd); + break; case AV_FRAME_DATA_CONTENT_LIGHT_LEVEL: dump_content_light_metadata(ctx, sd); break; From patchwork Mon Feb 14 23:44:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 34298 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:14aa:0:0:0:0 with SMTP id bz10csp5960364nkb; Mon, 14 Feb 2022 15:45:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDiT9doVJQqR5T29WYmXQU2VHA1xzOK0JMzQlnFDENgt4yAYOWAlVw1HyTschllomHoMLu X-Received: by 2002:a05:6402:27c9:: with SMTP id c9mr1324882ede.178.1644882309455; Mon, 14 Feb 2022 15:45:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644882309; cv=none; d=google.com; s=arc-20160816; b=XKNuRlgkPssgxB3Wjqv2idv6SuMRuZUlKTN2ol4MYmE+vmU72Nl9+THpPydHgxvYzF V7TnkqJfSRSiDXgsH7nlbbfck56q5hVMy41UT0pl7QqL6bSGry3tRIlQstADzTM2Tfp1 kk6qD9lZlEgydvrK2YPX8YdoPlIf16MO6bSrdztNW7fAPkpCJebRPGpg1e1w5nTBghAv cl3fujcfBgVRMYU6JqG/P5vUhndP4AEqHY5CkGZR9+rbccETD2H2VaKPpAY/lhDqriEI eb26bPrC7gQAemGO5+OA9TZGQwrIEKwNx20xeq46VNLL0dE2TkGYT7YQJQTVFGDAR/T2 lLMA== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=ihp6rkXtqPDbgZ3DEN8lPLFc2l8cgvqk7ZypYl8TyUY=; b=cqpvIBblcElJu1jtnSjA7bgGzQlCqACGlEWVtChzohxkgoFl+1Cnx/sylZVCEskhx2 HTO+lsl2hM4h8fy5ZBLEwoLpHHbrvwTZ0rLgje2NZs0g3wBFt6L8sD/zKd+QPUW5weQ3 Z8toE3AJjLrFPLLQsjecvruP84eBoNg/dJLAhUHiji8saRn7XKnfk6N/Q6uhpbnPld7A hM1J1fGSoZ2JWOdPM0uRnNoaatFmS7Ojb/GNhxf1ZuuXdoORxtoSQSwRsbKYmU7DzC3J FKwfoDSoLhlo7XIi8A9eDuhK/JMzeeE5tg27m9EQL2d3PPWqhi60DnB5tHO3+eiGjqtI 4+Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=FncOwkXZ; 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 g3si72946edb.131.2022.02.14.15.45.09; Mon, 14 Feb 2022 15:45:09 -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=FncOwkXZ; 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 4D7A768B1BA; Tue, 15 Feb 2022 01:44:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A892568B1BC for ; Tue, 15 Feb 2022 01:44:30 +0200 (EET) Received: by mail-pf1-f175.google.com with SMTP id l19so26103290pfu.2 for ; Mon, 14 Feb 2022 15:44:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CaQDlR9nQ1W2t574aByN1KEC6oiPebq2pwUK9q6vsMM=; b=FncOwkXZsVPU641X3LevsH4NWnxhkSw3WTsI8Med4DnAMBsLBTbp+C4RdMeDW6c6VL ddd6mUK+Cbu7C6G/fsyyGEKg6qoVpMUoNnU+E3jwVo/jMyN3YWtEA8HLV0vwnb7rmJi5 vne8753gRY2bxc32PpuBswB0qong0RZwejWNSiPRuhQGc3oItEKlXAwCoAS2K6R75F7B pPxTGnuoVIoWWHHuxwkRhkf0pzabLEEX8zVehN72TPpg5xiN3ogbdqcVVji7EMsfaaGR dSG/FEMYROw0KrzImxL5+cK6Ol+kbH9pRQsrjXedcagKiCxbomp6N4zL38wqMXrqlKFu z3xw== 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:in-reply-to :references; bh=CaQDlR9nQ1W2t574aByN1KEC6oiPebq2pwUK9q6vsMM=; b=AtneJe10HcyXpgAmBElSfbieRjK7rzJiTB/UaPshV4v+NWdIZFmxmhLLDFXacongN/ FYIcv+PEK2xFLLmeqF4dZfFEpli1bfG8xVKwiNnJKygc2hTjLEpwx1vBBUvLQgsSt1zu uKTj8Q5j5ORyWgvWABygzdvKDvAEikZg/kMYl2X9qSCv1Mige/jz9UPowiGcAz+esNva C2C+MkxsUFepEepi/WZ2B46mEA6EJXAsMeIQTyc41xBLFafaawCxhp5/3LXX993+xcr6 YCtb9EedkoX59/V84mojJhzd4zGM32W61eGcu0Z4dcNLjw+oNQi3c5W49Is1CBpM/DXm wChA== X-Gm-Message-State: AOAM530Qulfxxm0FgSrPK9JRvLMCLv/V7r7FNu7faP3sg7wqB7n5TyE1 CE9Ae+MHPLAUnuDGyoftzEM1tg2GH6E= X-Received: by 2002:a05:6a00:22d1:: with SMTP id f17mr1142778pfj.13.1644882268839; Mon, 14 Feb 2022 15:44:28 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id mi7sm492304pjb.21.2022.02.14.15.44.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Feb 2022 15:44:28 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Feb 2022 07:44:20 +0800 Message-Id: <1644882260-8559-4-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1644882260-8559-1-git-send-email-lance.lmwang@gmail.com> References: <1644882260-8559-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 4/4] fftool/ffprobe: support for CUVA HDR Vivid metadata 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: Z+Yc+ZCJvPMd From: Limin Wang Signed-off-by: Limin Wang --- fftools/ffprobe.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 8a8e3de..0e8f1d5 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -38,6 +38,7 @@ #include "libavutil/hash.h" #include "libavutil/hdr_dynamic_metadata.h" #include "libavutil/mastering_display_metadata.h" +#include "libavutil/hdr_dynamic_vivid_metadata.h" #include "libavutil/dovi_meta.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" @@ -2118,6 +2119,72 @@ static void print_dynamic_hdr10_plus(WriterContext *w, const AVDynamicHDRPlus *m } } +static void print_dynamic_hdr_vivid(WriterContext *w, const AVDynamicHDRVivid *metadata) +{ + if (!metadata) + return; + print_int("system_start_code", metadata->system_start_code); + print_int("num_windows", metadata->num_windows); + + for (int n = 0; n < metadata->num_windows; n++) { + const AVHDRVividColorTransformParams *params = &metadata->params[n]; + + print_q("minimum_maxrgb", params->minimum_maxrgb, '/'); + print_q("average_maxrgb", params->average_maxrgb, '/'); + print_q("variance_maxrgb", params->variance_maxrgb, '/'); + print_q("maximum_maxrgb", params->maximum_maxrgb, '/'); + } + + for (int n = 0; n < metadata->num_windows; n++) { + const AVHDRVividColorTransformParams *params = &metadata->params[n]; + + print_int("tone_mapping_mode_flag", params->tone_mapping_mode_flag); + print_int("tone_mapping_param_num", params->tone_mapping_param_num); + if (params->tone_mapping_mode_flag) { + for (int i = 0; i < params->tone_mapping_param_num; i++) { + const AVHDRVividColorToneMappingParams *tm_params = ¶ms->tm_params[i]; + + print_q("targeted_system_display_maximum_luminance", + tm_params->targeted_system_display_maximum_luminance, '/'); + if (tm_params->base_enable_flag) { + print_q("base_param_m_p", tm_params->base_param_m_p, '/'); + print_q("base_param_m_m", tm_params->base_param_m_m, '/'); + print_q("base_param_m_a", tm_params->base_param_m_a, '/'); + print_q("base_param_m_b", tm_params->base_param_m_b, '/'); + print_q("base_param_m_n", tm_params->base_param_m_n, '/'); + + print_int("base_param_k1", tm_params->base_param_k1); + print_int("base_param_k2", tm_params->base_param_k2); + print_int("base_param_k3", tm_params->base_param_k3); + print_int("base_param_Delta_enable_mode", + tm_params->base_param_Delta_enable_mode); + print_q("base_param_Delta", tm_params->base_param_Delta, '/'); + } + if (tm_params->three_Spline_flag) { + print_int("3Spline_num", tm_params->three_Spline_num); + print_int("3Spline_TH_mode", tm_params->three_Spline_TH_mode); + + for (int j = 0; j < tm_params->three_Spline_num; j++) { + print_q("3Spline_TH_enable_MB", tm_params->three_Spline_TH_enable_MB, '/'); + print_q("3Spline_TH", tm_params->three_Spline_TH, '/'); + print_q("3Spline_TH_Delta1", tm_params->three_Spline_TH_Delta1, '/'); + print_q("3Spline_TH_Delta2", tm_params->three_Spline_TH_Delta2, '/'); + print_q("3Spline_enable_Strength", tm_params->three_Spline_enable_Strength, '/'); + } + } + } + } + + print_int("color_saturation_mapping_flag", params->color_saturation_mapping_flag); + if (params->color_saturation_mapping_flag) { + print_int("color_saturation_num", params->color_saturation_num); + for (int i = 0; i < params->color_saturation_num; i++) { + print_q("color_saturation_gain", params->color_saturation_gain[i], '/'); + } + } + } +} + static void print_pkt_side_data(WriterContext *w, AVCodecParameters *par, const AVPacketSideData *side_data, @@ -2537,6 +2604,9 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, print_int("size", sd->size); } else if (sd->type == AV_FRAME_DATA_DOVI_METADATA) { print_dovi_metadata(w, (const AVDOVIMetadata *)sd->data); + } else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_VIVID) { + AVDynamicHDRVivid *metadata = (AVDynamicHDRVivid *)sd->data; + print_dynamic_hdr_vivid(w, metadata); } writer_print_section_footer(w); }