FFmpeg
Loading...
Searching...
No Matches
hdr_dynamic_metadata.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Mohammad Izadi <moh.izadi at gmail.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVUTIL_HDR_DYNAMIC_METADATA_H
22#define AVUTIL_HDR_DYNAMIC_METADATA_H
23
24#include "frame.h"
25#include "rational.h"
26
27/**
28 * Option for overlapping elliptical pixel selectors in an image.
29 */
34
35/**
36 * Represents the percentile at a specific percentage in
37 * a distribution.
38 */
39typedef struct AVHDRPlusPercentile {
40 /**
41 * The percentage value corresponding to a specific percentile linearized
42 * RGB value in the processing window in the scene. The value shall be in
43 * the range of 0 to100, inclusive.
44 */
45 uint8_t percentage;
46
47 /**
48 * The linearized maxRGB value at a specific percentile in the processing
49 * window in the scene. The value shall be in the range of 0 to 1, inclusive
50 * and in multiples of 0.00001.
51 */
54
55/**
56 * Color transform parameters at a processing window in a dynamic metadata for
57 * SMPTE 2094-40.
58 */
60 /**
61 * The relative x coordinate of the top left pixel of the processing
62 * window. The value shall be in the range of 0 and 1, inclusive and
63 * in multiples of 1/(width of Picture - 1). The value 1 corresponds
64 * to the absolute coordinate of width of Picture - 1. The value for
65 * first processing window shall be 0.
66 */
68
69 /**
70 * The relative y coordinate of the top left pixel of the processing
71 * window. The value shall be in the range of 0 and 1, inclusive and
72 * in multiples of 1/(height of Picture - 1). The value 1 corresponds
73 * to the absolute coordinate of height of Picture - 1. The value for
74 * first processing window shall be 0.
75 */
77
78 /**
79 * The relative x coordinate of the bottom right pixel of the processing
80 * window. The value shall be in the range of 0 and 1, inclusive and
81 * in multiples of 1/(width of Picture - 1). The value 1 corresponds
82 * to the absolute coordinate of width of Picture - 1. The value for
83 * first processing window shall be 1.
84 */
86
87 /**
88 * The relative y coordinate of the bottom right pixel of the processing
89 * window. The value shall be in the range of 0 and 1, inclusive and
90 * in multiples of 1/(height of Picture - 1). The value 1 corresponds
91 * to the absolute coordinate of height of Picture - 1. The value for
92 * first processing window shall be 1.
93 */
95
96 /**
97 * The x coordinate of the center position of the concentric internal and
98 * external ellipses of the elliptical pixel selector in the processing
99 * window. The value shall be in the range of 0 to (width of Picture - 1),
100 * inclusive and in multiples of 1 pixel.
101 */
103
104 /**
105 * The y coordinate of the center position of the concentric internal and
106 * external ellipses of the elliptical pixel selector in the processing
107 * window. The value shall be in the range of 0 to (height of Picture - 1),
108 * inclusive and in multiples of 1 pixel.
109 */
111
112 /**
113 * The clockwise rotation angle in degree of arc with respect to the
114 * positive direction of the x-axis of the concentric internal and external
115 * ellipses of the elliptical pixel selector in the processing window. The
116 * value shall be in the range of 0 to 180, inclusive and in multiples of 1.
117 */
119
120 /**
121 * The semi-major axis value of the internal ellipse of the elliptical pixel
122 * selector in amount of pixels in the processing window. The value shall be
123 * in the range of 1 to 65535, inclusive and in multiples of 1 pixel.
124 */
126
127 /**
128 * The semi-major axis value of the external ellipse of the elliptical pixel
129 * selector in amount of pixels in the processing window. The value
130 * shall not be less than semimajor_axis_internal_ellipse of the current
131 * processing window. The value shall be in the range of 1 to 65535,
132 * inclusive and in multiples of 1 pixel.
133 */
135
136 /**
137 * The semi-minor axis value of the external ellipse of the elliptical pixel
138 * selector in amount of pixels in the processing window. The value shall be
139 * in the range of 1 to 65535, inclusive and in multiples of 1 pixel.
140 */
142
143 /**
144 * Overlap process option indicates one of the two methods of combining
145 * rendered pixels in the processing window in an image with at least one
146 * elliptical pixel selector. For overlapping elliptical pixel selectors
147 * in an image, overlap_process_option shall have the same value.
148 */
150
151 /**
152 * The maximum of the color components of linearized RGB values in the
153 * processing window in the scene. The values should be in the range of 0 to
154 * 1, inclusive and in multiples of 0.00001. maxscl[ 0 ], maxscl[ 1 ], and
155 * maxscl[ 2 ] are corresponding to R, G, B color components respectively.
156 */
158
159 /**
160 * The average of linearized maxRGB values in the processing window in the
161 * scene. The value should be in the range of 0 to 1, inclusive and in
162 * multiples of 0.00001.
163 */
165
166 /**
167 * The number of linearized maxRGB values at given percentiles in the
168 * processing window in the scene. The maximum value shall be 15.
169 */
171
172 /**
173 * The linearized maxRGB values at given percentiles in the
174 * processing window in the scene.
175 */
177
178 /**
179 * The fraction of selected pixels in the image that contains the brightest
180 * pixel in the scene. The value shall be in the range of 0 to 1, inclusive
181 * and in multiples of 0.001.
182 */
184
185 /**
186 * This flag indicates that the metadata for the tone mapping function in
187 * the processing window is present (for value of 1).
188 */
190
191 /**
192 * The x coordinate of the separation point between the linear part and the
193 * curved part of the tone mapping function. The value shall be in the range
194 * of 0 to 1, excluding 0 and in multiples of 1/4095.
195 */
197
198 /**
199 * The y coordinate of the separation point between the linear part and the
200 * curved part of the tone mapping function. The value shall be in the range
201 * of 0 to 1, excluding 0 and in multiples of 1/4095.
202 */
204
205 /**
206 * The number of the intermediate anchor parameters of the tone mapping
207 * function in the processing window. The maximum value shall be 15.
208 */
210
211 /**
212 * The intermediate anchor parameters of the tone mapping function in the
213 * processing window in the scene. The values should be in the range of 0
214 * to 1, inclusive and in multiples of 1/1023.
215 */
217
218 /**
219 * This flag shall be equal to 0 in bitstreams conforming to this version of
220 * this Specification. Other values are reserved for future use.
221 */
223
224 /**
225 * The color saturation gain in the processing window in the scene. The
226 * value shall be in the range of 0 to 63/8, inclusive and in multiples of
227 * 1/8. The default value shall be 1.
228 */
231
232/**
233 * This struct represents dynamic metadata for color volume transform -
234 * application 4 of SMPTE 2094-40:2016 standard.
235 *
236 * To be used as payload of a AVFrameSideData or AVPacketSideData with the
237 * appropriate type.
238 *
239 * @note The struct should be allocated with
240 * av_dynamic_hdr_plus_alloc() and its size is not a part of
241 * the public ABI.
242 */
243typedef struct AVDynamicHDRPlus {
244 /**
245 * Country code by Rec. ITU-T T.35 Annex A. The value shall be 0xB5.
246 */
248
249 /**
250 * Application version in the application defining document in ST-2094
251 * suite. CTA-861-H sets this to 1 for the HDR10+ payload carried in a
252 * Rec. ITU-T T.35 message.
253 *
254 * av_dynamic_hdr_plus_from_t35() sets this field from the parsed payload.
255 * av_dynamic_hdr_plus_to_t35() ignores it and always writes 1.
256 */
258
259 /**
260 * The number of processing windows. The value shall be in the range
261 * of 1 to 3, inclusive.
262 */
263 uint8_t num_windows;
264
265 /**
266 * The color transform parameters for every processing window.
267 */
269
270 /**
271 * The nominal maximum display luminance of the targeted system display,
272 * in units of 0.0001 candelas per square metre. The value shall be in
273 * the range of 0 to 10000, inclusive.
274 */
276
277 /**
278 * This flag shall be equal to 0 in bit streams conforming to this version
279 * of this Specification. The value 1 is reserved for future use.
280 */
282
283 /**
284 * The number of rows in the targeted system_display_actual_peak_luminance
285 * array. The value shall be in the range of 2 to 25, inclusive.
286 */
288
289 /**
290 * The number of columns in the
291 * targeted_system_display_actual_peak_luminance array. The value shall be
292 * in the range of 2 to 25, inclusive.
293 */
295
296 /**
297 * The normalized actual peak luminance of the targeted system display. The
298 * values should be in the range of 0 to 1, inclusive and in multiples of
299 * 1/15.
300 */
302
303 /**
304 * This flag shall be equal to 0 in bitstreams conforming to this version of
305 * this Specification. The value 1 is reserved for future use.
306 */
308
309 /**
310 * The number of rows in the mastering_display_actual_peak_luminance array.
311 * The value shall be in the range of 2 to 25, inclusive.
312 */
314
315 /**
316 * The number of columns in the mastering_display_actual_peak_luminance
317 * array. The value shall be in the range of 2 to 25, inclusive.
318 */
320
321 /**
322 * The normalized actual peak luminance of the mastering display used for
323 * mastering the image essence. The values should be in the range of 0 to 1,
324 * inclusive and in multiples of 1/15.
325 */
328
329/**
330 * Allocate an AVDynamicHDRPlus structure and set its fields to
331 * default values. The resulting struct can be freed using av_freep().
332 *
333 * @return An AVDynamicHDRPlus filled with default values or NULL
334 * on failure.
335 */
337
338/**
339 * Allocate a complete AVDynamicHDRPlus and add it to the frame.
340 * @param frame The frame which side data is added to.
341 *
342 * @return The AVDynamicHDRPlus structure to be filled by caller or NULL
343 * on failure.
344 */
346
347/**
348 * Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRPlus).
349 * The T.35 buffer must begin with the application mode, skipping the
350 * country code, terminal provider codes, and application identifier.
351 * @param s A pointer containing the decoded AVDynamicHDRPlus structure.
352 * @param data The byte array containing the raw ITU-T T.35 data.
353 * @param size Size of the data array in bytes.
354 *
355 * @return >= 0 on success. Otherwise, returns the appropriate AVERROR.
356 */
358 size_t size);
359
360#define AV_HDR_PLUS_MAX_PAYLOAD_SIZE 907
361
362/**
363 * Serialize dynamic HDR10+ metadata to a user data registered ITU-T T.35 buffer,
364 * excluding the first 48 bytes of the header, and beginning with the application mode.
365 * @param s A pointer containing the decoded AVDynamicHDRPlus structure.
366 * @param[in,out] data A pointer to pointer to a byte buffer to be filled with the
367 * serialized metadata.
368 * If *data is NULL, a buffer be will be allocated and a pointer to
369 * it stored in its place. The caller assumes ownership of the buffer.
370 * May be NULL, in which case the function will only store the
371 * required buffer size in *size.
372 * @param[in,out] size A pointer to a size to be set to the returned buffer's size.
373 * If *data is not NULL, *size must contain the size of the input
374 * buffer. May be NULL only if *data is NULL.
375 *
376 * @return >= 0 on success. Otherwise, returns the appropriate AVERROR.
377 */
378int av_dynamic_hdr_plus_to_t35(const AVDynamicHDRPlus *s, uint8_t **data, size_t *size);
379
380/**
381 * This struct represents dynamic metadata for color volume transform as
382 * specified in the SMPTE 2094-50 standard.
383 *
384 * To be used as payload of a AVFrameSideData or AVPacketSideData with the
385 * appropriate type.
386 *
387 * @note The struct should be allocated with
388 * av_dynamic_smpte2094_app5_alloc() and its size is not a part of
389 * the public ABI.
390 */
392 /**
393 * Section C.2.1. smpte_st_2094_50_application_info()
394 */
397
398 /**
399 * Section C.2.2 smpte_st_2094_50_color_volume_transform()
400 */
404
405 /**
406 * Section C.2.3 smpte_st_2094_50_adaptive_tone_map()
407 */
416
417 /**
418 * Section C.2.4 smpte_st_2094_50_component_mixing()
419 */
423
424 /**
425 * Section C.2.5 smpte_st_2094_50_gain_curve()
426 */
433
434/**
435 * Allocate an AVDynamicHDRSmpte2094App5 structure and set its fields to
436 * default values. The resulting struct can be freed using av_freep().
437 *
438 * @return An AVDynamicHDRSmpte2094App5 filled with default values or NULL
439 * on failure.
440 */
442
443/**
444 * Allocate a complete AVDynamicHDRSmpte2094App5 and add it to the frame.
445 *
446 * @param frame The frame which side data is added to.
447 *
448 * @return The AVDynamicHDRSmpte2094App5 structure to be filled by caller or
449 * NULL on failure.
450 */
452
453/**
454 * Parse the user data formatted as ITU-T T.35 message to AVDynamicHDRSmpte2094App5.
455 *
456 * @param s A pointer containing the decoded AVDynamicHDRSmpte2094App5 structure.
457 * @param data The byte array containing the raw ITU-T T.35 data.
458 * @param size Size of the data array in bytes.
459 *
460 * @return >= 0 on success. Otherwise, returns the appropriate AVERROR.
461 */
463 size_t size);
464
465/**
466 * Serialize dynamic SMPTE-2094-50 metadata to a ITU-T T.35 message. Excluding
467 * the country_code, provider_code and provider_oriented_code.
468 *
469 * @param s A pointer containing the AVDynamicHDRSmpte2094App5 data.
470 * @param[in,out] data A pointer to pointer to a byte buffer to be filled with
471 * the serialized metadata. If *data is NULL, a buffer be will be allocated and
472 * a pointer to it stored in its place. The caller assumes ownership of the
473 * buffer. May be NULL, in which case the function will only store the required
474 * buffer size in *size.
475 * @param[in,out] size A pointer to a size to be set to the returned buffer's
476 * size. If *data is not NULL, *size must contain the size of the input buffer.
477 * May be NULL only if *data is NULL.
478 *
479 * @return >= 0 on success. Otherwise, returns the appropriate AVERROR.
480 */
482 size_t* size);
483
484#endif /* AVUTIL_HDR_DYNAMIC_METADATA_H */
#define s(width, name)
Definition cbs_vp9.c:198
static AVFrame * frame
reference-counted frame API
AVDynamicHDRPlus * av_dynamic_hdr_plus_alloc(size_t *size)
Allocate an AVDynamicHDRPlus structure and set its fields to default values.
AVDynamicHDRPlus * av_dynamic_hdr_plus_create_side_data(AVFrame *frame)
Allocate a complete AVDynamicHDRPlus and add it to the frame.
AVDynamicHDRSmpte2094App5 * av_dynamic_hdr_smpte2094_app5_alloc(size_t *size)
Allocate an AVDynamicHDRSmpte2094App5 structure and set its fields to default values.
AVHDRPlusOverlapProcessOption
Option for overlapping elliptical pixel selectors in an image.
@ AV_HDR_PLUS_OVERLAP_PROCESS_LAYERING
@ AV_HDR_PLUS_OVERLAP_PROCESS_WEIGHTED_AVERAGING
int av_dynamic_hdr_smpte2094_app5_to_t35(const AVDynamicHDRSmpte2094App5 *s, uint8_t **data, size_t *size)
Serialize dynamic SMPTE-2094-50 metadata to a ITU-T T.35 message.
int av_dynamic_hdr_plus_from_t35(AVDynamicHDRPlus *s, const uint8_t *data, size_t size)
Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRPlus).
int av_dynamic_hdr_plus_to_t35(const AVDynamicHDRPlus *s, uint8_t **data, size_t *size)
Serialize dynamic HDR10+ metadata to a user data registered ITU-T T.35 buffer, excluding the first 48...
int av_dynamic_hdr_smpte2094_app5_from_t35(AVDynamicHDRSmpte2094App5 *s, const uint8_t *data, size_t size)
Parse the user data formatted as ITU-T T.35 message to AVDynamicHDRSmpte2094App5.
AVDynamicHDRSmpte2094App5 * av_dynamic_hdr_smpte2094_app5_create_side_data(AVFrame *frame)
Allocate a complete AVDynamicHDRSmpte2094App5 and add it to the frame.
const char data[16]
Definition mxf.c:149
Utilities for rational number calculation.
This struct represents dynamic metadata for color volume transform - application 4 of SMPTE 2094-40:2...
uint8_t targeted_system_display_actual_peak_luminance_flag
This flag shall be equal to 0 in bit streams conforming to this version of this Specification.
uint8_t num_cols_targeted_system_display_actual_peak_luminance
The number of columns in the targeted_system_display_actual_peak_luminance array.
AVRational targeted_system_display_maximum_luminance
The nominal maximum display luminance of the targeted system display, in units of 0....
uint8_t mastering_display_actual_peak_luminance_flag
This flag shall be equal to 0 in bitstreams conforming to this version of this Specification.
AVHDRPlusColorTransformParams params[3]
The color transform parameters for every processing window.
uint8_t itu_t_t35_country_code
Country code by Rec.
uint8_t num_rows_targeted_system_display_actual_peak_luminance
The number of rows in the targeted system_display_actual_peak_luminance array.
uint8_t application_version
Application version in the application defining document in ST-2094 suite.
AVRational targeted_system_display_actual_peak_luminance[25][25]
The normalized actual peak luminance of the targeted system display.
uint8_t num_cols_mastering_display_actual_peak_luminance
The number of columns in the mastering_display_actual_peak_luminance array.
AVRational mastering_display_actual_peak_luminance[25][25]
The normalized actual peak luminance of the mastering display used for mastering the image essence.
uint8_t num_windows
The number of processing windows.
uint8_t num_rows_mastering_display_actual_peak_luminance
The number of rows in the mastering_display_actual_peak_luminance array.
This struct represents dynamic metadata for color volume transform as specified in the SMPTE 2094-50 ...
uint8_t application_version
Section C.2.1.
uint8_t gain_curve_num_control_points_minus_1[4]
Section C.2.5 smpte_st_2094_50_gain_curve()
uint16_t gain_curve_control_points_x[4][32]
uint8_t component_mixing_type[4]
Section C.2.4 smpte_st_2094_50_component_mixing()
uint16_t gain_curve_control_points_theta[4][32]
uint16_t gain_curve_control_points_y[4][32]
uint16_t baseline_hdr_headroom
Section C.2.3 smpte_st_2094_50_adaptive_tone_map()
uint16_t gain_application_space_chromaticities[8]
uint16_t component_mixing_coefficient[4][6]
uint8_t has_custom_hdr_reference_white_flag
Section C.2.2 smpte_st_2094_50_color_volume_transform()
uint8_t has_component_mixing_coefficient_flag[4][6]
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
Color transform parameters at a processing window in a dynamic metadata for SMPTE 2094-40.
uint8_t tone_mapping_flag
This flag indicates that the metadata for the tone mapping function in the processing window is prese...
AVRational window_lower_right_corner_y
The relative y coordinate of the bottom right pixel of the processing window.
AVRational fraction_bright_pixels
The fraction of selected pixels in the image that contains the brightest pixel in the scene.
uint8_t rotation_angle
The clockwise rotation angle in degree of arc with respect to the positive direction of the x-axis of...
AVRational knee_point_y
The y coordinate of the separation point between the linear part and the curved part of the tone mapp...
uint16_t semimajor_axis_internal_ellipse
The semi-major axis value of the internal ellipse of the elliptical pixel selector in amount of pixel...
AVRational average_maxrgb
The average of linearized maxRGB values in the processing window in the scene.
uint16_t center_of_ellipse_x
The x coordinate of the center position of the concentric internal and external ellipses of the ellip...
AVRational maxscl[3]
The maximum of the color components of linearized RGB values in the processing window in the scene.
uint16_t semimajor_axis_external_ellipse
The semi-major axis value of the external ellipse of the elliptical pixel selector in amount of pixel...
AVHDRPlusPercentile distribution_maxrgb[15]
The linearized maxRGB values at given percentiles in the processing window in the scene.
AVRational window_lower_right_corner_x
The relative x coordinate of the bottom right pixel of the processing window.
uint8_t color_saturation_mapping_flag
This flag shall be equal to 0 in bitstreams conforming to this version of this Specification.
uint8_t num_distribution_maxrgb_percentiles
The number of linearized maxRGB values at given percentiles in the processing window in the scene.
AVRational window_upper_left_corner_y
The relative y coordinate of the top left pixel of the processing window.
AVRational window_upper_left_corner_x
The relative x coordinate of the top left pixel of the processing window.
uint8_t num_bezier_curve_anchors
The number of the intermediate anchor parameters of the tone mapping function in the processing windo...
uint16_t semiminor_axis_external_ellipse
The semi-minor axis value of the external ellipse of the elliptical pixel selector in amount of pixel...
AVRational knee_point_x
The x coordinate of the separation point between the linear part and the curved part of the tone mapp...
uint16_t center_of_ellipse_y
The y coordinate of the center position of the concentric internal and external ellipses of the ellip...
enum AVHDRPlusOverlapProcessOption overlap_process_option
Overlap process option indicates one of the two methods of combining rendered pixels in the processin...
AVRational color_saturation_weight
The color saturation gain in the processing window in the scene.
AVRational bezier_curve_anchors[15]
The intermediate anchor parameters of the tone mapping function in the processing window in the scene...
Represents the percentile at a specific percentage in a distribution.
AVRational percentile
The linearized maxRGB value at a specific percentile in the processing window in the scene.
uint8_t percentage
The percentage value corresponding to a specific percentile linearized RGB value in the processing wi...
Rational number (pair of numerator and denominator).
Definition rational.h:58
int size