summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavutil/Makefile2
-rw-r--r--libavutil/frame.c1
-rw-r--r--libavutil/frame.h7
-rw-r--r--libavutil/hdr_dynamic_vivid_metadata.c47
-rw-r--r--libavutil/hdr_dynamic_vivid_metadata.h285
-rw-r--r--libavutil/version.h2
6 files changed, 343 insertions, 1 deletions
diff --git a/libavutil/Makefile b/libavutil/Makefile
index b867d3b362..737eb98bd4 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 \
@@ -129,6 +130,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 8997c85e35..b035e282ad 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 18e239f870..9f8012bbc3 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -201,6 +201,13 @@ enum AVFrameSideDataType {
* libavutil/dovi_meta.h.
*/
AV_FRAME_DATA_DOVI_METADATA,
+
+ /**
+ * 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,
};
enum AVActiveFormatDescription {
diff --git a/libavutil/hdr_dynamic_vivid_metadata.c b/libavutil/hdr_dynamic_vivid_metadata.c
new file mode 100644
index 0000000000..32da01f587
--- /dev/null
+++ b/libavutil/hdr_dynamic_vivid_metadata.c
@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) 2021 Limin Wang <lance.lmwang at gmail.com>
+ *
+ * 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 0000000000..a34f83072c
--- /dev/null
+++ b/libavutil/hdr_dynamic_vivid_metadata.h
@@ -0,0 +1,285 @@
+/*
+ * Copyright (c) 2021 Limin Wang <lance.lmwang at gmail.com>
+ *
+ * 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_enable_flag in the base parameter,
+ * This flag indicates that transfer three Spline of base paramter(for value of 1)
+ */
+ int three_Spline_enable_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_enable;
+
+ /**
+ * 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.0, 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 72f55ef3b3..c7004601c8 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, \