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 <stdint.h>
25
26/**
27 * \defgroup ancillary Ancillary
28 * \ingroup input
29 *
30 * Ancillary that can be attached to any vlc_frame_t or picture_t.
31 *
32 * Ancillaries can be created from:
33 * - packetized demuxer modules,
34 * - packetizer modules,
35 * - decoder modules.
36 *
37 * @warning Ancillaries should not be attached from a non packetized demuxer
38 * module since the attachment to the vlc_frame will be lost by the packetizer
39 * module that will be automatically inserted.
40 *
41 * Ancillaries are automatically forwarded from a vlc_frame_t to an other
42 * vlc_frame_t and from a picture_t to an other picture_t. This allow to keep
43 * ancillaries untouched when audio filters or video filters are used (these
44 * filters don't have to know about the ancillary).
45 *
46 * Ancillary readers can be either:
47 * - A decoder module,
48 * - An audio output,
49 * - A video output,
50 * - A video or audio filter.
51 *
52 * @{
53 * \file
54 * Ancillary definition and functions
55 */
56
57/**
58 * Ancillary opaque struct, refcounted struct that hold user data with a free
59 * callback.
60 */
61struct vlc_ancillary;
62
63/**
64 * ID of an ancillary. Each ancillary user can create its own unique ID via
65 * VLC_ANCILLARY_ID.
66 */
67typedef uint32_t vlc_ancillary_id;
68#define VLC_ANCILLARY_ID(a,b,c,d) VLC_FOURCC(a,b,c,d)
70/**
71 * Callback to free an ancillary data
72 */
73typedef void (*vlc_ancillary_free_cb)(void *data);
75/**
76 * Create an ancillary
77 *
78 * @param data an opaque ancillary, can't be NULL
79 * @param id id of ancillary
80 * @param free_cb callback to release the data, can be NULL
81 * @return a valid vlc_ancillary pointer or NULL in case of allocation error
82 */
86
87/**
88 * Helper to create an ancillary holding an allocated data
89 */
90static inline struct vlc_ancillary *
93 return vlc_ancillary_CreateWithFreeCb(data, id, free);
94}
95
96/**
97 * Release an ancillary
98 *
99 * If the refcount reaches 0, the free_cb provided by
100 * vlc_ancillary_CreateWithFreeCb() is called.
101 *
102 * @param ancillary ancillary to release
103 */
104VLC_API void
105vlc_ancillary_Release(struct vlc_ancillary *ancillary);
106
107/**
108 * Hold an ancillary
109 *
110 * @param ancillary ancillary to hold
111 * @return the same ancillary
112 */
113VLC_API struct vlc_ancillary *
114vlc_ancillary_Hold(struct vlc_ancillary *ancillary);
115
116VLC_API void *
117vlc_ancillary_GetData(const struct vlc_ancillary *ancillary);
118
119/**
120 * Dolby Vision metadata description
121 */
134#define VLC_ANCILLARY_ID_DOVI VLC_FOURCC('D','o','V','i')
136typedef struct vlc_video_dovi_metadata_t
138 /* Common header fields */
139 uint8_t coef_log2_denom;
144 /* Colorspace metadata */
145 float nonlinear_offset[3];
148 uint16_t source_min_pq; /* 12-bit PQ values */
151 /**
152 * Do not reorder or modify the following structs, they are intentionally
153 * specified to be identical to AVDOVIReshapingCurve / AVDOVINLQParams.
154 */
155 struct vlc_dovi_reshape_t {
156 uint8_t num_pivots;
157 uint16_t pivots[9];
159 uint8_t poly_order[8];
160 int64_t poly_coef[8][3];
161 uint8_t mmr_order[8];
162 int64_t mmr_constant[8];
163 int64_t mmr_coef[8][3][7];
164 } curves[3];
166 struct vlc_dovi_nlq_t {
167 uint8_t offset_depth; /* bit depth of offset value */
168 uint16_t offset;
169 uint64_t hdr_in_max;
170 uint64_t dz_slope;
171 uint64_t dz_threshold;
172 } nlq[3];
175/**
176 * HDR10+ Dynamic metadata (based on ATSC A/341 Amendment 2094-40)
177 *
178 * This is similar to SMPTE ST2094-40:2016, but omits the mastering display and
179 * target display actual peak luminance LUTs, the rectangular boundaries and
180 * ellipse coefficients, and support for multiple processing windows, as these
181 * are intentionally left unused in this version of the specification.
182 */
183
184#define VLC_ANCILLARY_ID_HDR10PLUS VLC_FOURCC('H','D','R','+')
188 uint8_t country_code; /* ITU-T T.35 Annex A */
190 float targeted_luminance; /* in cd/m² */
192 /* parameters for the first processing window (encompassing the frame) */
193 float maxscl[3]; /* in linearized range [0,1] */
194 float average_maxrgb; /* in linearized range [0,1] */
195 uint8_t num_histogram; /* in range [0,15] */
196 struct {
197 uint8_t percentage; /* in range [1,100] */
198 float percentile; /* in linearized range [0,1] */
200 float fraction_bright_pixels;/* in range [0,1] */
202 float knee_point_x; /* in ootf range [0,1] */
203 float knee_point_y; /* in ootf range [0,1] */
204 uint8_t num_bezier_anchors; /* in range [1,15] */
205 float bezier_curve_anchors[15]; /* in range [0,1] */
208/**
209 * Embedded ICC profiles
210 */
211
212#define VLC_ANCILLARY_ID_ICC VLC_FOURCC('i','C','C','P')
214typedef struct vlc_icc_profile_t
216 size_t size;
217 uint8_t data[]; /* binary profile data, see ICC.1:2022 (or later) */
220/**
221 * VPx alpha data
222 */
223
224#define VLC_ANCILLARY_ID_VPX_ALPHA VLC_FOURCC('v','p','x','A')
226typedef struct vlc_vpx_alpha_t
228 size_t size;
229 uint8_t *data;
232/** @} */
233#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
vlc_dovi_reshape_method_t
Dolby Vision metadata description.
Definition vlc_ancillary.h:124
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)
Definition ancillary.c:76
void(* vlc_ancillary_free_cb)(void *data)
Callback to free an ancillary data.
Definition vlc_ancillary.h:74
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:92
vlc_dovi_nlq_method_t
Definition vlc_ancillary.h:130
uint32_t vlc_ancillary_id
ID of an ancillary.
Definition vlc_ancillary.h:68
@ VLC_DOVI_RESHAPE_POLYNOMIAL
Definition vlc_ancillary.h:125
@ VLC_DOVI_RESHAPE_MMR
Definition vlc_ancillary.h:126
@ VLC_DOVI_NLQ_LINEAR_DZ
Definition vlc_ancillary.h:132
@ VLC_DOVI_NLQ_NONE
Definition vlc_ancillary.h:131
Definition ancillary.c:31
vlc_ancillary_free_cb free_cb
Definition ancillary.c:36
void * data
Definition ancillary.c:35
Definition vlc_ancillary.h:216
size_t size
Definition vlc_ancillary.h:217
uint8_t data[]
Definition vlc_ancillary.h:218
Definition vlc_ancillary.h:167
uint64_t dz_slope
Definition vlc_ancillary.h:171
uint64_t dz_threshold
Definition vlc_ancillary.h:172
uint64_t hdr_in_max
Definition vlc_ancillary.h:170
uint8_t offset_depth
Definition vlc_ancillary.h:168
uint16_t offset
Definition vlc_ancillary.h:169
Do not reorder or modify the following structs, they are intentionally specified to be identical to A...
Definition vlc_ancillary.h:156
int64_t mmr_constant[8]
Definition vlc_ancillary.h:163
enum vlc_dovi_reshape_method_t mapping_idc[8]
Definition vlc_ancillary.h:159
int64_t poly_coef[8][3]
Definition vlc_ancillary.h:161
int64_t mmr_coef[8][3][7]
Definition vlc_ancillary.h:164
uint8_t num_pivots
Definition vlc_ancillary.h:157
uint16_t pivots[9]
Definition vlc_ancillary.h:158
uint8_t mmr_order[8]
Definition vlc_ancillary.h:162
uint8_t poly_order[8]
Definition vlc_ancillary.h:160
Definition vlc_ancillary.h:138
float nonlinear_matrix[9]
Definition vlc_ancillary.h:147
uint8_t el_bit_depth
Definition vlc_ancillary.h:142
uint16_t source_max_pq
Definition vlc_ancillary.h:150
float linear_matrix[9]
Definition vlc_ancillary.h:148
enum vlc_dovi_nlq_method_t nlq_method_idc
Definition vlc_ancillary.h:143
uint8_t coef_log2_denom
Definition vlc_ancillary.h:140
uint8_t bl_bit_depth
Definition vlc_ancillary.h:141
uint16_t source_min_pq
Definition vlc_ancillary.h:149
struct vlc_video_dovi_metadata_t::vlc_dovi_reshape_t curves[3]
float nonlinear_offset[3]
Definition vlc_ancillary.h:146
struct vlc_video_dovi_metadata_t::vlc_dovi_nlq_t nlq[3]
Definition vlc_ancillary.h:188
float maxscl[3]
Definition vlc_ancillary.h:194
float average_maxrgb
Definition vlc_ancillary.h:195
uint8_t percentage
Definition vlc_ancillary.h:198
float percentile
Definition vlc_ancillary.h:199
float knee_point_x
Definition vlc_ancillary.h:203
float targeted_luminance
Definition vlc_ancillary.h:191
float fraction_bright_pixels
Definition vlc_ancillary.h:201
uint8_t tone_mapping_flag
Definition vlc_ancillary.h:202
uint8_t num_bezier_anchors
Definition vlc_ancillary.h:205
float bezier_curve_anchors[15]
Definition vlc_ancillary.h:206
uint8_t num_histogram
Definition vlc_ancillary.h:196
uint8_t country_code
Definition vlc_ancillary.h:189
uint8_t application_version
Definition vlc_ancillary.h:190
struct vlc_video_hdr_dynamic_metadata_t::@189 histogram[15]
float knee_point_y
Definition vlc_ancillary.h:204
Definition vlc_ancillary.h:228
uint8_t * data
Definition vlc_ancillary.h:230
size_t size
Definition vlc_ancillary.h:229
This file is a collection of common definitions and types.