Path: blob/a-new-beginning/libavutil.xcframework/ios-arm64/libavutil.framework/Headers/dovi_meta.h
2 views
/*1* Copyright (c) 2020 Vacing Fang <[email protected]>2*3* This file is part of FFmpeg.4*5* FFmpeg is free software; you can redistribute it and/or6* modify it under the terms of the GNU Lesser General Public7* License as published by the Free Software Foundation; either8* version 2.1 of the License, or (at your option) any later version.9*10* FFmpeg is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13* Lesser General Public License for more details.14*15* You should have received a copy of the GNU Lesser General Public16* License along with FFmpeg; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/1920/**21* @file22* DOVI configuration23*/242526#ifndef AVUTIL_DOVI_META_H27#define AVUTIL_DOVI_META_H2829#include <stdint.h>30#include <stddef.h>31#include "rational.h"3233/*34* DOVI configuration35* ref: dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2.1.236dolby-vision-bitstreams-in-mpeg-2-transport-stream-multiplex-v1.237* @code38* uint8_t dv_version_major, the major version number that the stream complies with39* uint8_t dv_version_minor, the minor version number that the stream complies with40* uint8_t dv_profile, the Dolby Vision profile41* uint8_t dv_level, the Dolby Vision level42* uint8_t rpu_present_flag43* uint8_t el_present_flag44* uint8_t bl_present_flag45* uint8_t dv_bl_signal_compatibility_id46* @endcode47*48* @note The struct must be allocated with av_dovi_alloc() and49* its size is not a part of the public ABI.50*/51typedef struct AVDOVIDecoderConfigurationRecord {52uint8_t dv_version_major;53uint8_t dv_version_minor;54uint8_t dv_profile;55uint8_t dv_level;56uint8_t rpu_present_flag;57uint8_t el_present_flag;58uint8_t bl_present_flag;59uint8_t dv_bl_signal_compatibility_id;60} AVDOVIDecoderConfigurationRecord;6162/**63* Allocate a AVDOVIDecoderConfigurationRecord structure and initialize its64* fields to default values.65*66* @return the newly allocated struct or NULL on failure67*/68AVDOVIDecoderConfigurationRecord *av_dovi_alloc(size_t *size);6970/**71* Dolby Vision RPU data header.72*73* @note sizeof(AVDOVIRpuDataHeader) is not part of the public ABI.74*/75typedef struct AVDOVIRpuDataHeader {76uint8_t rpu_type;77uint16_t rpu_format;78uint8_t vdr_rpu_profile;79uint8_t vdr_rpu_level;80uint8_t chroma_resampling_explicit_filter_flag;81uint8_t coef_data_type; /* informative, lavc always converts to fixed */82uint8_t coef_log2_denom;83uint8_t vdr_rpu_normalized_idc;84uint8_t bl_video_full_range_flag;85uint8_t bl_bit_depth; /* [8, 16] */86uint8_t el_bit_depth; /* [8, 16] */87uint8_t vdr_bit_depth; /* [8, 16] */88uint8_t spatial_resampling_filter_flag;89uint8_t el_spatial_resampling_filter_flag;90uint8_t disable_residual_flag;91} AVDOVIRpuDataHeader;9293enum AVDOVIMappingMethod {94AV_DOVI_MAPPING_POLYNOMIAL = 0,95AV_DOVI_MAPPING_MMR = 1,96};9798/**99* Coefficients of a piece-wise function. The pieces of the function span the100* value ranges between two adjacent pivot values.101*/102#define AV_DOVI_MAX_PIECES 8103typedef struct AVDOVIReshapingCurve {104uint8_t num_pivots; /* [2, 9] */105uint16_t pivots[AV_DOVI_MAX_PIECES + 1]; /* sorted ascending */106enum AVDOVIMappingMethod mapping_idc[AV_DOVI_MAX_PIECES];107/* AV_DOVI_MAPPING_POLYNOMIAL */108uint8_t poly_order[AV_DOVI_MAX_PIECES]; /* [1, 2] */109int64_t poly_coef[AV_DOVI_MAX_PIECES][3]; /* x^0, x^1, x^2 */110/* AV_DOVI_MAPPING_MMR */111uint8_t mmr_order[AV_DOVI_MAX_PIECES]; /* [1, 3] */112int64_t mmr_constant[AV_DOVI_MAX_PIECES];113int64_t mmr_coef[AV_DOVI_MAX_PIECES][3/* order - 1 */][7];114} AVDOVIReshapingCurve;115116enum AVDOVINLQMethod {117AV_DOVI_NLQ_NONE = -1,118AV_DOVI_NLQ_LINEAR_DZ = 0,119};120121/**122* Coefficients of the non-linear inverse quantization. For the interpretation123* of these, see ETSI GS CCM 001.124*/125typedef struct AVDOVINLQParams {126uint16_t nlq_offset;127uint64_t vdr_in_max;128/* AV_DOVI_NLQ_LINEAR_DZ */129uint64_t linear_deadzone_slope;130uint64_t linear_deadzone_threshold;131} AVDOVINLQParams;132133/**134* Dolby Vision RPU data mapping parameters.135*136* @note sizeof(AVDOVIDataMapping) is not part of the public ABI.137*/138typedef struct AVDOVIDataMapping {139uint8_t vdr_rpu_id;140uint8_t mapping_color_space;141uint8_t mapping_chroma_format_idc;142AVDOVIReshapingCurve curves[3]; /* per component */143144/* Non-linear inverse quantization */145enum AVDOVINLQMethod nlq_method_idc;146uint32_t num_x_partitions;147uint32_t num_y_partitions;148AVDOVINLQParams nlq[3]; /* per component */149} AVDOVIDataMapping;150151/**152* Dolby Vision RPU colorspace metadata parameters.153*154* @note sizeof(AVDOVIColorMetadata) is not part of the public ABI.155*/156typedef struct AVDOVIColorMetadata {157uint8_t dm_metadata_id;158uint8_t scene_refresh_flag;159160/**161* Coefficients of the custom Dolby Vision IPT-PQ matrices. These are to be162* used instead of the matrices indicated by the frame's colorspace tags.163* The output of rgb_to_lms_matrix is to be fed into a BT.2020 LMS->RGB164* matrix based on a Hunt-Pointer-Estevez transform, but without any165* crosstalk. (See the definition of the ICtCp colorspace for more166* information.)167*/168AVRational ycc_to_rgb_matrix[9]; /* before PQ linearization */169AVRational ycc_to_rgb_offset[3]; /* input offset of neutral value */170AVRational rgb_to_lms_matrix[9]; /* after PQ linearization */171172/**173* Extra signal metadata (see Dolby patents for more info).174*/175uint16_t signal_eotf;176uint16_t signal_eotf_param0;177uint16_t signal_eotf_param1;178uint32_t signal_eotf_param2;179uint8_t signal_bit_depth;180uint8_t signal_color_space;181uint8_t signal_chroma_format;182uint8_t signal_full_range_flag; /* [0, 3] */183uint16_t source_min_pq;184uint16_t source_max_pq;185uint16_t source_diagonal;186} AVDOVIColorMetadata;187188/**189* Combined struct representing a combination of header, mapping and color190* metadata, for attaching to frames as side data.191*192* @note The struct must be allocated with av_dovi_metadata_alloc() and193* its size is not a part of the public ABI.194*/195196typedef struct AVDOVIMetadata {197/**198* Offset in bytes from the beginning of this structure at which the199* respective structs start.200*/201size_t header_offset; /* AVDOVIRpuDataHeader */202size_t mapping_offset; /* AVDOVIDataMapping */203size_t color_offset; /* AVDOVIColorMetadata */204} AVDOVIMetadata;205206static av_always_inline AVDOVIRpuDataHeader *207av_dovi_get_header(const AVDOVIMetadata *data)208{209return (AVDOVIRpuDataHeader *)((uint8_t *) data + data->header_offset);210}211212static av_always_inline AVDOVIDataMapping *213av_dovi_get_mapping(const AVDOVIMetadata *data)214{215return (AVDOVIDataMapping *)((uint8_t *) data + data->mapping_offset);216}217218static av_always_inline AVDOVIColorMetadata *219av_dovi_get_color(const AVDOVIMetadata *data)220{221return (AVDOVIColorMetadata *)((uint8_t *) data + data->color_offset);222}223224/**225* Allocate an AVDOVIMetadata structure and initialize its226* fields to default values.227*228* @param size If this parameter is non-NULL, the size in bytes of the229* allocated struct will be written here on success230*231* @return the newly allocated struct or NULL on failure232*/233AVDOVIMetadata *av_dovi_metadata_alloc(size_t *size);234235#endif /* AVUTIL_DOVI_META_H */236237238