Path: blob/master/dep/ffmpeg/include/libavutil/hdr_dynamic_metadata.h
4216 views
/*1* Copyright (c) 2018 Mohammad Izadi <moh.izadi at gmail.com>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#ifndef AVUTIL_HDR_DYNAMIC_METADATA_H21#define AVUTIL_HDR_DYNAMIC_METADATA_H2223#include "frame.h"24#include "rational.h"2526/**27* Option for overlapping elliptical pixel selectors in an image.28*/29enum AVHDRPlusOverlapProcessOption {30AV_HDR_PLUS_OVERLAP_PROCESS_WEIGHTED_AVERAGING = 0,31AV_HDR_PLUS_OVERLAP_PROCESS_LAYERING = 1,32};3334/**35* Represents the percentile at a specific percentage in36* a distribution.37*/38typedef struct AVHDRPlusPercentile {39/**40* The percentage value corresponding to a specific percentile linearized41* RGB value in the processing window in the scene. The value shall be in42* the range of 0 to100, inclusive.43*/44uint8_t percentage;4546/**47* The linearized maxRGB value at a specific percentile in the processing48* window in the scene. The value shall be in the range of 0 to 1, inclusive49* and in multiples of 0.00001.50*/51AVRational percentile;52} AVHDRPlusPercentile;5354/**55* Color transform parameters at a processing window in a dynamic metadata for56* SMPTE 2094-40.57*/58typedef struct AVHDRPlusColorTransformParams {59/**60* The relative x coordinate of the top left pixel of the processing61* window. The value shall be in the range of 0 and 1, inclusive and62* in multiples of 1/(width of Picture - 1). The value 1 corresponds63* to the absolute coordinate of width of Picture - 1. The value for64* first processing window shall be 0.65*/66AVRational window_upper_left_corner_x;6768/**69* The relative y coordinate of the top left pixel of the processing70* window. The value shall be in the range of 0 and 1, inclusive and71* in multiples of 1/(height of Picture - 1). The value 1 corresponds72* to the absolute coordinate of height of Picture - 1. The value for73* first processing window shall be 0.74*/75AVRational window_upper_left_corner_y;7677/**78* The relative x coordinate of the bottom right pixel of the processing79* window. The value shall be in the range of 0 and 1, inclusive and80* in multiples of 1/(width of Picture - 1). The value 1 corresponds81* to the absolute coordinate of width of Picture - 1. The value for82* first processing window shall be 1.83*/84AVRational window_lower_right_corner_x;8586/**87* The relative y coordinate of the bottom right pixel of the processing88* window. The value shall be in the range of 0 and 1, inclusive and89* in multiples of 1/(height of Picture - 1). The value 1 corresponds90* to the absolute coordinate of height of Picture - 1. The value for91* first processing window shall be 1.92*/93AVRational window_lower_right_corner_y;9495/**96* The x coordinate of the center position of the concentric internal and97* external ellipses of the elliptical pixel selector in the processing98* window. The value shall be in the range of 0 to (width of Picture - 1),99* inclusive and in multiples of 1 pixel.100*/101uint16_t center_of_ellipse_x;102103/**104* The y coordinate of the center position of the concentric internal and105* external ellipses of the elliptical pixel selector in the processing106* window. The value shall be in the range of 0 to (height of Picture - 1),107* inclusive and in multiples of 1 pixel.108*/109uint16_t center_of_ellipse_y;110111/**112* The clockwise rotation angle in degree of arc with respect to the113* positive direction of the x-axis of the concentric internal and external114* ellipses of the elliptical pixel selector in the processing window. The115* value shall be in the range of 0 to 180, inclusive and in multiples of 1.116*/117uint8_t rotation_angle;118119/**120* The semi-major axis value of the internal ellipse of the elliptical pixel121* selector in amount of pixels in the processing window. The value shall be122* in the range of 1 to 65535, inclusive and in multiples of 1 pixel.123*/124uint16_t semimajor_axis_internal_ellipse;125126/**127* The semi-major axis value of the external ellipse of the elliptical pixel128* selector in amount of pixels in the processing window. The value129* shall not be less than semimajor_axis_internal_ellipse of the current130* processing window. The value shall be in the range of 1 to 65535,131* inclusive and in multiples of 1 pixel.132*/133uint16_t semimajor_axis_external_ellipse;134135/**136* The semi-minor axis value of the external ellipse of the elliptical pixel137* selector in amount of pixels in the processing window. The value shall be138* in the range of 1 to 65535, inclusive and in multiples of 1 pixel.139*/140uint16_t semiminor_axis_external_ellipse;141142/**143* Overlap process option indicates one of the two methods of combining144* rendered pixels in the processing window in an image with at least one145* elliptical pixel selector. For overlapping elliptical pixel selectors146* in an image, overlap_process_option shall have the same value.147*/148enum AVHDRPlusOverlapProcessOption overlap_process_option;149150/**151* The maximum of the color components of linearized RGB values in the152* processing window in the scene. The values should be in the range of 0 to153* 1, inclusive and in multiples of 0.00001. maxscl[ 0 ], maxscl[ 1 ], and154* maxscl[ 2 ] are corresponding to R, G, B color components respectively.155*/156AVRational maxscl[3];157158/**159* The average of linearized maxRGB values in the processing window in the160* scene. The value should be in the range of 0 to 1, inclusive and in161* multiples of 0.00001.162*/163AVRational average_maxrgb;164165/**166* The number of linearized maxRGB values at given percentiles in the167* processing window in the scene. The maximum value shall be 15.168*/169uint8_t num_distribution_maxrgb_percentiles;170171/**172* The linearized maxRGB values at given percentiles in the173* processing window in the scene.174*/175AVHDRPlusPercentile distribution_maxrgb[15];176177/**178* The fraction of selected pixels in the image that contains the brightest179* pixel in the scene. The value shall be in the range of 0 to 1, inclusive180* and in multiples of 0.001.181*/182AVRational fraction_bright_pixels;183184/**185* This flag indicates that the metadata for the tone mapping function in186* the processing window is present (for value of 1).187*/188uint8_t tone_mapping_flag;189190/**191* The x coordinate of the separation point between the linear part and the192* curved part of the tone mapping function. The value shall be in the range193* of 0 to 1, excluding 0 and in multiples of 1/4095.194*/195AVRational knee_point_x;196197/**198* The y coordinate of the separation point between the linear part and the199* curved part of the tone mapping function. The value shall be in the range200* of 0 to 1, excluding 0 and in multiples of 1/4095.201*/202AVRational knee_point_y;203204/**205* The number of the intermediate anchor parameters of the tone mapping206* function in the processing window. The maximum value shall be 15.207*/208uint8_t num_bezier_curve_anchors;209210/**211* The intermediate anchor parameters of the tone mapping function in the212* processing window in the scene. The values should be in the range of 0213* to 1, inclusive and in multiples of 1/1023.214*/215AVRational bezier_curve_anchors[15];216217/**218* This flag shall be equal to 0 in bitstreams conforming to this version of219* this Specification. Other values are reserved for future use.220*/221uint8_t color_saturation_mapping_flag;222223/**224* The color saturation gain in the processing window in the scene. The225* value shall be in the range of 0 to 63/8, inclusive and in multiples of226* 1/8. The default value shall be 1.227*/228AVRational color_saturation_weight;229} AVHDRPlusColorTransformParams;230231/**232* This struct represents dynamic metadata for color volume transform -233* application 4 of SMPTE 2094-40:2016 standard.234*235* To be used as payload of a AVFrameSideData or AVPacketSideData with the236* appropriate type.237*238* @note The struct should be allocated with239* av_dynamic_hdr_plus_alloc() and its size is not a part of240* the public ABI.241*/242typedef struct AVDynamicHDRPlus {243/**244* Country code by Rec. ITU-T T.35 Annex A. The value shall be 0xB5.245*/246uint8_t itu_t_t35_country_code;247248/**249* Application version in the application defining document in ST-2094250* suite. The value shall be set to 0.251*/252uint8_t application_version;253254/**255* The number of processing windows. The value shall be in the range256* of 1 to 3, inclusive.257*/258uint8_t num_windows;259260/**261* The color transform parameters for every processing window.262*/263AVHDRPlusColorTransformParams params[3];264265/**266* The nominal maximum display luminance of the targeted system display,267* in units of 0.0001 candelas per square metre. The value shall be in268* the range of 0 to 10000, inclusive.269*/270AVRational targeted_system_display_maximum_luminance;271272/**273* This flag shall be equal to 0 in bit streams conforming to this version274* of this Specification. The value 1 is reserved for future use.275*/276uint8_t targeted_system_display_actual_peak_luminance_flag;277278/**279* The number of rows in the targeted system_display_actual_peak_luminance280* array. The value shall be in the range of 2 to 25, inclusive.281*/282uint8_t num_rows_targeted_system_display_actual_peak_luminance;283284/**285* The number of columns in the286* targeted_system_display_actual_peak_luminance array. The value shall be287* in the range of 2 to 25, inclusive.288*/289uint8_t num_cols_targeted_system_display_actual_peak_luminance;290291/**292* The normalized actual peak luminance of the targeted system display. The293* values should be in the range of 0 to 1, inclusive and in multiples of294* 1/15.295*/296AVRational targeted_system_display_actual_peak_luminance[25][25];297298/**299* This flag shall be equal to 0 in bitstreams conforming to this version of300* this Specification. The value 1 is reserved for future use.301*/302uint8_t mastering_display_actual_peak_luminance_flag;303304/**305* The number of rows in the mastering_display_actual_peak_luminance array.306* The value shall be in the range of 2 to 25, inclusive.307*/308uint8_t num_rows_mastering_display_actual_peak_luminance;309310/**311* The number of columns in the mastering_display_actual_peak_luminance312* array. The value shall be in the range of 2 to 25, inclusive.313*/314uint8_t num_cols_mastering_display_actual_peak_luminance;315316/**317* The normalized actual peak luminance of the mastering display used for318* mastering the image essence. The values should be in the range of 0 to 1,319* inclusive and in multiples of 1/15.320*/321AVRational mastering_display_actual_peak_luminance[25][25];322} AVDynamicHDRPlus;323324/**325* Allocate an AVDynamicHDRPlus structure and set its fields to326* default values. The resulting struct can be freed using av_freep().327*328* @return An AVDynamicHDRPlus filled with default values or NULL329* on failure.330*/331AVDynamicHDRPlus *av_dynamic_hdr_plus_alloc(size_t *size);332333/**334* Allocate a complete AVDynamicHDRPlus and add it to the frame.335* @param frame The frame which side data is added to.336*337* @return The AVDynamicHDRPlus structure to be filled by caller or NULL338* on failure.339*/340AVDynamicHDRPlus *av_dynamic_hdr_plus_create_side_data(AVFrame *frame);341342/**343* Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRPlus).344* The T.35 buffer must begin with the application mode, skipping the345* country code, terminal provider codes, and application identifier.346* @param s A pointer containing the decoded AVDynamicHDRPlus structure.347* @param data The byte array containing the raw ITU-T T.35 data.348* @param size Size of the data array in bytes.349*350* @return >= 0 on success. Otherwise, returns the appropriate AVERROR.351*/352int av_dynamic_hdr_plus_from_t35(AVDynamicHDRPlus *s, const uint8_t *data,353size_t size);354355#define AV_HDR_PLUS_MAX_PAYLOAD_SIZE 907356357/**358* Serialize dynamic HDR10+ metadata to a user data registered ITU-T T.35 buffer,359* excluding the first 48 bytes of the header, and beginning with the application mode.360* @param s A pointer containing the decoded AVDynamicHDRPlus structure.361* @param[in,out] data A pointer to pointer to a byte buffer to be filled with the362* serialized metadata.363* If *data is NULL, a buffer be will be allocated and a pointer to364* it stored in its place. The caller assumes ownership of the buffer.365* May be NULL, in which case the function will only store the366* required buffer size in *size.367* @param[in,out] size A pointer to a size to be set to the returned buffer's size.368* If *data is not NULL, *size must contain the size of the input369* buffer. May be NULL only if *data is NULL.370*371* @return >= 0 on success. Otherwise, returns the appropriate AVERROR.372*/373int av_dynamic_hdr_plus_to_t35(const AVDynamicHDRPlus *s, uint8_t **data, size_t *size);374375#endif /* AVUTIL_HDR_DYNAMIC_METADATA_H */376377378