VLC 4.0.0-dev
Loading...
Searching...
No Matches
vlc_ancillary.h
Go to the documentation of this file.
1/*****************************************************************************
2 * vlc_ancillary.h: ancillary management functions
3 *****************************************************************************
4 * Copyright (C) 2021 VLC authors and VideoLAN
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
10 *
11 * This program 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
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
20
21#ifndef VLC_ANCILLARY_H
22#define VLC_ANCILLARY_H 1
23
24#include <vlc_vector.h>
25#include <stdint.h>
26
27/**
28 * \defgroup ancillary Ancillary
29 * \ingroup input
30 *
31 * Ancillary that can be attached to any vlc_frame_t or picture_t.
32 *
33 * Ancillaries can be created from:
34 * - packetized demuxer modules,
35 * - packetizer modules,
36 * - decoder modules.
37 *
38 * @warning Ancillaries should not be attached from a non packetized demuxer
39 * module since the attachment to the vlc_frame will be lost by the packetizer
40 * module that will be automatically inserted.
41 *
42 * Ancillaries are automatically forwarded from a vlc_frame_t to an other
43 * vlc_frame_t and from a picture_t to an other picture_t. This allow to keep
44 * ancillaries untouched when audio filters or video filters are used (these
45 * filters don't have to know about the ancillary).
46 *
47 * Ancillary readers can be either:
48 * - A decoder module,
49 * - An audio output,
50 * - A video output,
51 * - A video or audio filter.
52 *
53 * @{
54 * \file
55 * Ancillary definition and functions
56 * \defgroup ancillary_api Ancillary API
57 * @{
58 */
59
60/**
61 * Ancillary opaque struct, refcounted struct that hold user data with a free
62 * callback.
63 */
64struct vlc_ancillary;
65
66typedef struct VLC_VECTOR(struct vlc_ancillary *) vlc_ancillary_array;
67#define VLC_ANCILLARY_ARRAY_INITIALIZER VLC_VECTOR_INITIALIZER
69/**
70 * ID of an ancillary. Each ancillary user can create its own unique ID via
71 * VLC_ANCILLARY_ID.
72 */
73typedef uint32_t vlc_ancillary_id;
74#define VLC_ANCILLARY_ID(a,b,c,d) VLC_FOURCC(a,b,c,d)
76/**
77 * Callback to free an ancillary data
78 */
79typedef void (*vlc_ancillary_free_cb)(void *data);
81/**
82 * Create an ancillary
83 *
84 * @param data an opaque ancillary, can't be NULL
85 * @param id id of ancillary
86 * @param free_cb callback to release the data, can be NULL
87 * @return a valid vlc_ancillary pointer or NULL in case of allocation error
88 */
92
93/**
94 * Helper to create an ancillary holding an allocated data
95 */
96static inline struct vlc_ancillary *
99 return vlc_ancillary_CreateWithFreeCb(data, id, free);
100}
101
102/**
103 * Release an ancillary
104 *
105 * If the refcount reaches 0, the free_cb provided by
106 * vlc_ancillary_CreateWithFreeCb() is called.
107 *
108 * @param ancillary ancillary to release
109 */
110VLC_API void
111vlc_ancillary_Release(struct vlc_ancillary *ancillary);
112
113/**
114 * Hold an ancillary
115 *
116 * @param ancillary ancillary to hold
117 * @return the same ancillary
118 */
119VLC_API struct vlc_ancillary *
120vlc_ancillary_Hold(struct vlc_ancillary *ancillary);
121
122/**
123 * Get the data of the ancillary
124 *
125 * @param ancillary ancillary to get data from
126 * @return data used when created the ancillary, same lifetime than the ancillary
127 */
128VLC_API void *
129vlc_ancillary_GetData(const struct vlc_ancillary *ancillary);
130
131/**
132 * @}
133 * \defgroup ancillary_array Ancillary array API
134 * @{
135 */
136
137/**
138 * Init an ancillary array
139 *
140 * @param array pointer to the ancillary array to initialize
141 */
142static inline void
145 vlc_vector_init(array);
146}
147
148/**
149 * Clear an ancillary array
150 *
151 * This will release the refcount on all ancillaries and free the vector data
152 *
153 * @param array pointer to the ancillary array to clear
154 */
155VLC_API void
157
158/**
159 * Merge two ancillary arrays
160 *
161 * Copy all ancillaries from src_array to dst_array, preserving all previous
162 * ancillaries. In case of ancillary id conflict, the one from src_array will
163 * have precedence.
164 *
165 * @param dst_array pointer to an initialized ancillary array, if not empty,
166 * previous ancillaries will be preserved.
167 * @param src_array pointer to the source ancillary array
168 * @return VLC_SUCCESS in case of success, VLC_ENOMEM in case of alloc error
169 */
170VLC_API int
172 const vlc_ancillary_array *src_array);
173
174/**
175 * Merge and clear two ancillary arrays
176 *
177 * The src array will be moved to the dst array if the dst array is empty (fast
178 * path). Otherwise, both arrays will be merged into dst_array and the
179 * src_array will be cleared afterward.
180 *
181 * @param dst_array pointer to a valid ancillary array, if not empty, previous
182 * ancillaries will be preserved.
183 * @param src_array pointer to the source ancillary array, will point to empty
184 * data after this call.
185 * @return VLC_SUCCESS in case of success, VLC_ENOMEM in case of alloc error
186 */
187VLC_API int
189 vlc_ancillary_array *src_array);
190
191/**
192 * Insert a new ancillary in the array
193 *
194 * @note Several ancillaries can be attached to an array, but if two ancillaries
195 * are identified by the same ID, only the last one take precedence.
196 *
197 * @param array pointer to the ancillary array
198 * @param ancillary pointer to the ancillary to add
199 * @return VLC_SUCCESS in case of success, VLC_ENOMEM in case of alloc error
200 */
201VLC_API int
203 struct vlc_ancillary *ancillary);
204
205/**
206 * Get a specific ancillary from the array
207 *
208 * @param array pointer to the ancillary array
209 * @param id id of the ancillary
210 * @return a valid ancillary or NULL if not found, no need to release it.
211 */
212VLC_API struct vlc_ancillary *
215
216/**
217 * @}
218 * \defgroup ancillary_data Ancillary IDs and data
219 * @{
220 */
221
222/**
223 * Dolby Vision metadata description
224 */
237#define VLC_ANCILLARY_ID_DOVI VLC_FOURCC('D','o','V','i')
239typedef struct vlc_video_dovi_metadata_t
241 /* Common header fields */
242 uint8_t coef_log2_denom;
247 /* Colorspace metadata */
248 float nonlinear_offset[3];
251 uint16_t source_min_pq; /* 12-bit PQ values */
254 /**
255 * Do not reorder or modify the following structs, they are intentionally
256 * specified to be identical to AVDOVIReshapingCurve / AVDOVINLQParams.
257 */
258 struct vlc_dovi_reshape_t {
259 uint8_t num_pivots;
260 uint16_t pivots[9];
262 uint8_t poly_order[8];
263 int64_t poly_coef[8][3];
264 uint8_t mmr_order[8];
265 int64_t mmr_constant[8];
266 int64_t mmr_coef[8][3][7];
267 } curves[3];
269 struct vlc_dovi_nlq_t {
270 uint8_t offset_depth; /* bit depth of offset value */
271 uint16_t offset;
272 uint64_t hdr_in_max;
273 uint64_t dz_slope;
274 uint64_t dz_threshold;
275 } nlq[3];
278/**
279 * HDR10+ Dynamic metadata (based on ATSC A/341 Amendment 2094-40)
280 *
281 * This is similar to SMPTE ST2094-40:2016, but omits the mastering display and
282 * target display actual peak luminance LUTs, the rectangular boundaries and
283 * ellipse coefficients, and support for multiple processing windows, as these
284 * are intentionally left unused in this version of the specification.
285 */
286
287#define VLC_ANCILLARY_ID_HDR10PLUS VLC_FOURCC('H','D','R','+')
291 uint8_t country_code; /* ITU-T T.35 Annex A */
293 float targeted_luminance; /* in cd/m² */
295 /* parameters for the first processing window (encompassing the frame) */
296 float maxscl[3]; /* in linearized range [0,1] */
297 float average_maxrgb; /* in linearized range [0,1] */
298 uint8_t num_histogram; /* in range [0,15] */
299 struct {
300 uint8_t percentage; /* in range [1,100] */
301 float percentile; /* in linearized range [0,1] */
303 float fraction_bright_pixels;/* in range [0,1] */
305 float knee_point_x; /* in ootf range [0,1] */
306 float knee_point_y; /* in ootf range [0,1] */
307 uint8_t num_bezier_anchors; /* in range [1,15] */
308 float bezier_curve_anchors[15]; /* in range [0,1] */
311/**
312 * Embedded ICC profiles
313 */
314
315#define VLC_ANCILLARY_ID_ICC VLC_FOURCC('i','C','C','P')
317typedef struct vlc_icc_profile_t
319 size_t size;
320 uint8_t data[]; /* binary profile data, see ICC.1:2022 (or later) */
323/**
324 * VPx alpha data
325 */
326
327#define VLC_ANCILLARY_ID_VPX_ALPHA VLC_FOURCC('v','p','x','A')
329typedef struct vlc_vpx_alpha_t
331 size_t size;
332 uint8_t *data;
335/**
336 * @}
337 * @}
338 */
339#endif /* VLC_ANCILLARY_H */
#define VLC_API
Definition fourcc_gen.c:31
void vlc_ancillary_Release(struct vlc_ancillary *ancillary)
Release an ancillary.
Definition ancillary.c:58
struct vlc_ancillary * vlc_ancillary_Hold(struct vlc_ancillary *ancillary)
Hold an ancillary.
Definition ancillary.c:69
void * vlc_ancillary_GetData(const struct vlc_ancillary *ancillary)
Get the data of the ancillary.
Definition ancillary.c:76
void(* vlc_ancillary_free_cb)(void *data)
Callback to free an ancillary data.
Definition vlc_ancillary.h:80
struct vlc_ancillary * vlc_ancillary_CreateWithFreeCb(void *data, vlc_ancillary_id id, vlc_ancillary_free_cb free_cb)
Create an ancillary.
Definition ancillary.c:40
static struct vlc_ancillary * vlc_ancillary_Create(void *data, vlc_ancillary_id id)
Helper to create an ancillary holding an allocated data.
Definition vlc_ancillary.h:98
uint32_t vlc_ancillary_id
ID of an ancillary.
Definition vlc_ancillary.h:74
int vlc_ancillary_array_Insert(vlc_ancillary_array *array, struct vlc_ancillary *ancillary)
Insert a new ancillary in the array.
Definition ancillary.c:122
int vlc_ancillary_array_Merge(vlc_ancillary_array *dst_array, const vlc_ancillary_array *src_array)
Merge two ancillary arrays.
Definition ancillary.c:91
int vlc_ancillary_array_MergeAndClear(vlc_ancillary_array *dst_array, vlc_ancillary_array *src_array)
Merge and clear two ancillary arrays.
Definition ancillary.c:105
struct vlc_ancillary * vlc_ancillary_array_Get(const vlc_ancillary_array *array, vlc_ancillary_id id)
Get a specific ancillary from the array.
Definition ancillary.c:147
void vlc_ancillary_array_Clear(vlc_ancillary_array *array)
Clear an ancillary array.
Definition ancillary.c:82
static void vlc_ancillary_array_Init(vlc_ancillary_array *array)
Init an ancillary array.
Definition vlc_ancillary.h:144
vlc_dovi_reshape_method_t
Dolby Vision metadata description.
Definition vlc_ancillary.h:227
vlc_dovi_nlq_method_t
Definition vlc_ancillary.h:233
@ VLC_DOVI_RESHAPE_POLYNOMIAL
Definition vlc_ancillary.h:228
@ VLC_DOVI_RESHAPE_MMR
Definition vlc_ancillary.h:229
@ VLC_DOVI_NLQ_LINEAR_DZ
Definition vlc_ancillary.h:235
@ VLC_DOVI_NLQ_NONE
Definition vlc_ancillary.h:234
#define VLC_VECTOR(type)
Vector struct body.
Definition vlc_vector.h:66
#define vlc_vector_init(pv)
Initialize an empty vector.
Definition vlc_vector.h:81
Definition vlc_ancillary.h:67
Definition ancillary.c:31
vlc_ancillary_free_cb free_cb
Definition ancillary.c:36
void * data
Definition ancillary.c:35
Definition vlc_ancillary.h:319
size_t size
Definition vlc_ancillary.h:320
uint8_t data[]
Definition vlc_ancillary.h:321
Definition vlc_ancillary.h:270
uint64_t dz_slope
Definition vlc_ancillary.h:274
uint64_t dz_threshold
Definition vlc_ancillary.h:275
uint64_t hdr_in_max
Definition vlc_ancillary.h:273
uint8_t offset_depth
Definition vlc_ancillary.h:271
uint16_t offset
Definition vlc_ancillary.h:272
Do not reorder or modify the following structs, they are intentionally specified to be identical to A...
Definition vlc_ancillary.h:259
int64_t mmr_constant[8]
Definition vlc_ancillary.h:266
enum vlc_dovi_reshape_method_t mapping_idc[8]
Definition vlc_ancillary.h:262
int64_t poly_coef[8][3]
Definition vlc_ancillary.h:264
int64_t mmr_coef[8][3][7]
Definition vlc_ancillary.h:267
uint8_t num_pivots
Definition vlc_ancillary.h:260
uint16_t pivots[9]
Definition vlc_ancillary.h:261
uint8_t mmr_order[8]
Definition vlc_ancillary.h:265
uint8_t poly_order[8]
Definition vlc_ancillary.h:263
Definition vlc_ancillary.h:241
float nonlinear_matrix[9]
Definition vlc_ancillary.h:250
uint8_t el_bit_depth
Definition vlc_ancillary.h:245
uint16_t source_max_pq
Definition vlc_ancillary.h:253
float linear_matrix[9]
Definition vlc_ancillary.h:251
enum vlc_dovi_nlq_method_t nlq_method_idc
Definition vlc_ancillary.h:246
uint8_t coef_log2_denom
Definition vlc_ancillary.h:243
uint8_t bl_bit_depth
Definition vlc_ancillary.h:244
uint16_t source_min_pq
Definition vlc_ancillary.h:252
struct vlc_video_dovi_metadata_t::vlc_dovi_reshape_t curves[3]
float nonlinear_offset[3]
Definition vlc_ancillary.h:249
struct vlc_video_dovi_metadata_t::vlc_dovi_nlq_t nlq[3]
Definition vlc_ancillary.h:291
float maxscl[3]
Definition vlc_ancillary.h:297
float average_maxrgb
Definition vlc_ancillary.h:298
uint8_t percentage
Definition vlc_ancillary.h:301
float percentile
Definition vlc_ancillary.h:302
float knee_point_x
Definition vlc_ancillary.h:306
float targeted_luminance
Definition vlc_ancillary.h:294
float fraction_bright_pixels
Definition vlc_ancillary.h:304
uint8_t tone_mapping_flag
Definition vlc_ancillary.h:305
uint8_t num_bezier_anchors
Definition vlc_ancillary.h:308
float bezier_curve_anchors[15]
Definition vlc_ancillary.h:309
uint8_t num_histogram
Definition vlc_ancillary.h:299
uint8_t country_code
Definition vlc_ancillary.h:292
struct vlc_video_hdr_dynamic_metadata_t::@191 histogram[15]
uint8_t application_version
Definition vlc_ancillary.h:293
float knee_point_y
Definition vlc_ancillary.h:307
Definition vlc_ancillary.h:331
uint8_t * data
Definition vlc_ancillary.h:333
size_t size
Definition vlc_ancillary.h:332
This file is a collection of common definitions and types.
This provides convenience helpers for vectors.