VLC 4.0.0-dev
Loading...
Searching...
No Matches
vlc_subpicture.h
Go to the documentation of this file.
1/*****************************************************************************
2 * vlc_subpicture.h: subpicture definitions
3 *****************************************************************************
4 * Copyright (C) 1999 - 2009 VLC authors and VideoLAN
5 *
6 * Authors: Vincent Seguin <seguin@via.ecp.fr>
7 * Samuel Hocevar <sam@via.ecp.fr>
8 * Olivier Aubert <oaubert 47 videolan d07 org>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
24
25#ifndef VLC_SUBPICTURE_H
26#define VLC_SUBPICTURE_H 1
27
28/**
29 */
30
31#include <vlc_picture.h>
32#include <vlc_text_style.h>
33#include <vlc_list.h>
34#include <vlc_vector.h>
35#include <vlc_vout_display.h>
36
37/**
38 * \defgroup subpicture Video sub-pictures
39 * \ingroup video_output
40 * Subpictures are pictures that should be displayed on top of the video, like
41 * subtitles and OSD
42 * @{
43 * \file
44 * Subpictures functions
45 */
46
47/**
48 * Video subtitle region spu core private
49 */
51typedef struct filter_t vlc_blender_t;
53/**< render background under text only */
54#define VLC_SUBPIC_TEXT_FLAG_NO_REGION_BG (1 << 4)
55/** if the decoder sends row/cols based output */
56#define VLC_SUBPIC_TEXT_FLAG_GRID_MODE (1 << 5)
57/** don't try to balance wrapped text lines */
58#define VLC_SUBPIC_TEXT_FLAG_TEXT_NOT_BALANCED (1 << 6)
59/** mark the subpicture region as a text flag */
60#define VLC_SUBPIC_TEXT_FLAG_IS_TEXT (1 << 7)
62/**
63 * Video subtitle region
64 *
65 * A subtitle region is defined by a picture (graphic) and its rendering
66 * coordinates.
67 * Subtitles contain a list of regions.
68 */
71 video_format_t fmt; /**< format of the picture */
72 picture_t *p_picture; /**< picture comprising this region */
74 bool b_absolute; /**< position is absolute in the movie */
75 int i_x; /**< position of region, relative to alignment */
76 int i_y; /**< position of region, relative to alignment */
77 int i_align; /**< alignment flags of region */
78 int i_alpha; /**< transparency */
80 /* Parameters for text regions (p_picture to be rendered) */
81 text_segment_t *p_text; /**< subtitle text, made of a list of segments */
82 int text_flags; /**< VLC_SUBPIC_TEXT_FLAG_xxx and SUBPICTURE_ALIGN_xxx */
83 int i_max_width; /** horizontal rendering/cropping target/limit */
84 int i_max_height; /** vertical rendering/cropping target/limit */
86 struct vlc_list node; /**< for inclusion in a vlc_spu_regions */
87};
88
89typedef struct vlc_list vlc_spu_regions;
91#define vlc_spu_regions_init(p_rs) \
92 vlc_list_init((p_rs))
93#define vlc_spu_regions_push(p_rs,reg) \
94 vlc_list_append(&(reg)->node, (p_rs))
95#define vlc_spu_regions_foreach(reg,p_rs) \
96 vlc_list_foreach(reg, (p_rs), node)
97#define vlc_spu_regions_foreach_const(reg,p_rs) \
98 vlc_list_foreach_const(reg, (p_rs), node)
99#define vlc_spu_regions_is_empty(p_rs) \
100 vlc_list_is_empty((p_rs))
101#define vlc_spu_regions_first_or_null(p_rs) \
102 vlc_list_first_entry_or_null((p_rs), subpicture_region_t, node)
103#define vlc_spu_regions_remove(p_rs, reg) \
104 vlc_list_remove(&(reg)->node)
105
115/* Subpicture region position flags */
116#define SUBPICTURE_ALIGN_LEFT 0x1
117#define SUBPICTURE_ALIGN_RIGHT 0x2
118#define SUBPICTURE_ALIGN_TOP 0x4
119#define SUBPICTURE_ALIGN_BOTTOM 0x8
120#define SUBPICTURE_ALIGN_MASK ( SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT| \
121 SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM )
122/**
123 * This function will create a new subpicture region.
124 *
125 * You must use subpicture_region_Delete to destroy it.
126 *
127 * \note use subpicture_region_NewText() to create a text region
128 */
130
131/**
132 * This function will create a new text subpicture region.
133 *
134 * You must use subpicture_region_Delete to destroy it.
135 */
137
138/**
139 * Create a subpicture region containing the picture.
140 *
141 * A reference will be added to the picture on success.
142 *
143 * You must use subpicture_region_Delete to destroy it.
144 *
145 * The chroma of the format must match the one of the picture.
146 * The dimensions of the format should not exceed the ones of the picture. This
147 * is not checked explicitly in the function.
148 *
149 * \param p_fmt format for the subpicture cropping/SAR (may be NULL)
150 *
151 * \note if p_fmt is NULL, the format of the picture will be used.
152 */
154
155/**
156 * This function will destroy a subpicture region allocated by
157 * subpicture_region_New.
158 *
159 * You may give it NULL.
160 */
162
163/**
164 * This function will clear a list of subpicture regions allocated by
165 * subpicture_region_New.
166 *
167 * Provided for convenience.
168 */
170
173 // source video format of the video under the SPU
175 // scaled video format of the video under the SPU
177 // source video format of the previous vlc_spu_updater_ops.update call
179 // scaled video format of the previous vlc_spu_updater_ops.update call
181 // timestamp when the SPU will be displayed, between i_start and i_stop
182 // for subtitles
185
186/**
187 * Subpicture updater operation virtual table.
188 *
189 * This structure gathers the operations that are implemented by a
190 * subpicture_updater_t instance. */
193 /** Mandatory callback called after pf_validate and doing
194 * the main job of creating the subpicture regions for the
195 * current video_format */
196 void (*update)(subpicture_t *,
198
199 /** Optional callback for subpicture private data cleanup */
200 void (*destroy)(subpicture_t *);
202
203/**
204 * Tells if the region is a text-based region.
205 */
206#define subpicture_region_IsText(r) \
207 (((r)->text_flags & VLC_SUBPIC_TEXT_FLAG_IS_TEXT) != 0)
208
209/**
210 *
211 */
212typedef struct
214 void *sys;
215 const struct vlc_spu_updater_ops *ops;
217
222 picture_t *p_picture; /**< picture comprising this region */
223 vout_display_place_t place; /**< visible area in display coordinates */
224 int i_alpha; /**< transparency */
226
229 struct VLC_VECTOR(struct subpicture_region_rendered *) regions; /**< list of regions to render */
230 int64_t i_order; /** an increasing unique number */
232
235/**
236 * Video subtitle
237 *
238 * Any subtitle destined to be displayed by a video output thread should
239 * be stored in this structure from it's creation to it's effective display.
240 * Subtitle type and flags should only be modified by the output thread. Note
241 * that an empty subtitle MUST have its flags set to 0.
242 */
243struct subpicture_t
245 /** \name Channel ID */
246 /**@{*/
247 ssize_t i_channel; /**< subpicture channel ID */
248 /**@}*/
249
250 /** \name Type and flags
251 Should NOT be modified except by the vout thread */
252 /**@{*/
253 int64_t i_order; /** an increasing unique number */
254 subpicture_t * p_next; /**< next subtitle to be displayed */
255 /**@}*/
256
257 vlc_spu_regions regions; /**< region list composing this subtitle */
259 /** \name Date properties */
260 /**@{*/
261 vlc_tick_t i_start; /**< beginning of display date */
262 vlc_tick_t i_stop; /**< end of display date. Will be
263 considered invalid if set to TICK_INVALID
264 or less than i_start. See b_ephemer */
265 bool b_ephemer; /**< If this flag is set to true the subtitle
266 will be displayed until the next one appears
267 or if i_stop is reached when it is valid */
268 bool b_fade; /**< enable fading */
269 bool b_subtitle; /**< subtitle with timestamps relative to
270 the video */
271 /**@}*/
272
273 /** \name Display properties
274 * These properties are only indicative and may be
275 * changed by the video output thread, or simply ignored depending of the
276 * subtitle type. */
277 /**@{*/
278 unsigned i_original_picture_width; /**< original width of the movie */
279 unsigned i_original_picture_height;/**< original height of the movie */
280 int i_alpha; /**< transparency */
281 /**@}*/
282
285 subpicture_private_t *p_private; /* Reserved to the core */
287
288/**
289 * This function create a new empty subpicture.
290 *
291 * You must use subpicture_Delete to destroy it.
292 */
294
295/**
296 * This function delete a subpicture created by subpicture_New.
297 * You may give it NULL.
298 */
299VLC_API void subpicture_Delete( subpicture_t *p_subpic );
300
301/**
302 * This function will create a subpicture having one region in the requested
303 * chroma showing the given picture.
304 *
305 * The picture_t given is not released nor used inside the
306 * returned subpicture_t.
307 */
309
310/**
311 * This function will update the content of a subpicture created with
312 * a non NULL subpicture_updater_t.
313 */
315
316/**
317 * This function will blend a given subpicture onto a picture.
318 *
319 * The subpicture and all its region must:
320 * - be absolute.
321 * - not be ephemere.
322 * - not have the fade flag.
323 * - contains only picture (no text rendering).
324 * \return the number of region(s) successfully blent
325 */
327
328/**
329 * Create a vlc_render_subpicture.
330 *
331 * It should be released with \ref vlc_render_subpicture_Delete.
332 */
334
335/**
336 * Destroy a vlc_render_subpicture.
337 */
339
340/**@}*/
341
342#endif /* _VLC_SUBPICTURE_H */
#define VLC_API
Definition fourcc_gen.c:31
uint32_t vlc_fourcc_t
Definition fourcc_gen.c:33
vlc_render_subpicture * vlc_render_subpicture_New(void)
Create a vlc_render_subpicture.
Definition subpicture.c:100
void vlc_render_subpicture_Delete(vlc_render_subpicture *)
Destroy a vlc_render_subpicture.
Definition subpicture.c:109
subpicture_region_t * subpicture_region_New(const video_format_t *p_fmt)
This function will create a new subpicture region.
Definition subpicture.c:260
void subpicture_Delete(subpicture_t *p_subpic)
This function delete a subpicture created by subpicture_New.
Definition subpicture.c:80
void vlc_spu_regions_Clear(vlc_spu_regions *)
This function will clear a list of subpicture regions allocated by subpicture_region_New.
Definition subpicture.c:367
unsigned picture_BlendSubpicture(picture_t *, vlc_blender_t *, vlc_render_subpicture *)
This function will blend a given subpicture onto a picture.
Definition subpicture.c:379
void subpicture_region_Delete(subpicture_region_t *p_region)
This function will destroy a subpicture region allocated by subpicture_region_New.
Definition subpicture.c:350
subpicture_region_t * subpicture_region_NewText(void)
This function will create a new text subpicture region.
Definition subpicture.c:299
void subpicture_Update(subpicture_t *, const video_format_t *src, const video_format_t *, vlc_tick_t)
This function will update the content of a subpicture created with a non NULL subpicture_updater_t.
Definition subpicture.c:175
subpicture_region_t * subpicture_region_ForPicture(const video_format_t *p_fmt, picture_t *pic)
Create a subpicture region containing the picture.
Definition subpicture.c:312
subpicture_t * subpicture_New(const subpicture_updater_t *)
This function create a new empty subpicture.
Definition subpicture.c:45
subpicture_t * subpicture_NewFromPicture(vlc_object_t *, picture_t *, vlc_fourcc_t i_chroma)
This function will create a subpicture having one region in the requested chroma showing the given pi...
Definition subpicture.c:121
#define VLC_VECTOR(type)
Vector struct body.
Definition vlc_vector.h:66
Structure describing a filter.
Definition vlc_filter.h:213
Video picture.
Definition vlc_picture.h:130
Definition subpicture.c:40
Definition vlc_subpicture.h:222
picture_t * p_picture
picture comprising this region
Definition vlc_subpicture.h:223
int i_alpha
transparency
Definition vlc_subpicture.h:225
vout_display_place_t place
visible area in display coordinates
Definition vlc_subpicture.h:224
Video subtitle region.
Definition vlc_subpicture.h:71
int i_y
position of region, relative to alignment
Definition vlc_subpicture.h:77
int i_align
alignment flags of region
Definition vlc_subpicture.h:78
int i_x
position of region, relative to alignment
Definition vlc_subpicture.h:76
video_format_t fmt
format of the picture
Definition vlc_subpicture.h:72
picture_t * p_picture
picture comprising this region
Definition vlc_subpicture.h:73
int i_max_width
Definition vlc_subpicture.h:84
struct vlc_list node
vertical rendering/cropping target/limit
Definition vlc_subpicture.h:87
int i_alpha
transparency
Definition vlc_subpicture.h:79
int i_max_height
horizontal rendering/cropping target/limit
Definition vlc_subpicture.h:85
int text_flags
VLC_SUBPIC_TEXT_FLAG_xxx and SUBPICTURE_ALIGN_xxx.
Definition vlc_subpicture.h:83
text_segment_t * p_text
subtitle text, made of a list of segments
Definition vlc_subpicture.h:82
bool b_absolute
position is absolute in the movie
Definition vlc_subpicture.h:75
Video subtitle.
Definition vlc_subpicture.h:245
vlc_tick_t i_start
beginning of display date
Definition vlc_subpicture.h:262
subpicture_t * p_next
an increasing unique number
Definition vlc_subpicture.h:255
bool b_ephemer
If this flag is set to true the subtitle will be displayed until the next one appears or if i_stop is...
Definition vlc_subpicture.h:266
unsigned i_original_picture_height
original height of the movie
Definition vlc_subpicture.h:280
bool b_fade
enable fading
Definition vlc_subpicture.h:269
unsigned i_original_picture_width
original width of the movie
Definition vlc_subpicture.h:279
subpicture_private_t * p_private
Definition vlc_subpicture.h:286
int i_alpha
transparency
Definition vlc_subpicture.h:281
bool b_subtitle
subtitle with timestamps relative to the video
Definition vlc_subpicture.h:270
int64_t i_order
Definition vlc_subpicture.h:254
vlc_spu_regions regions
region list composing this subtitle
Definition vlc_subpicture.h:258
ssize_t i_channel
subpicture channel ID
Definition vlc_subpicture.h:248
vlc_tick_t i_stop
end of display date.
Definition vlc_subpicture.h:263
subpicture_updater_t updater
Definition vlc_subpicture.h:284
Definition vlc_subpicture.h:214
const struct vlc_spu_updater_ops * ops
Definition vlc_subpicture.h:216
void * sys
Definition vlc_subpicture.h:215
Text segment for subtitles.
Definition vlc_text_style.h:139
video format description
Definition vlc_es.h:356
Definition vlc_es.h:45
Doubly-linked list node.
Definition vlc_list.h:44
VLC object common members.
Definition vlc_objects.h:53
Definition vlc_subpicture.h:229
int64_t i_order
Definition vlc_subpicture.h:231
struct vlc_render_subpicture::@284 regions
list of regions to render
Definition vlc_subpicture.h:108
video_palette_t palette
Definition vlc_subpicture.h:113
int x_start
Definition vlc_subpicture.h:109
int y_end
Definition vlc_subpicture.h:112
int x_end
Definition vlc_subpicture.h:110
int y_start
Definition vlc_subpicture.h:111
Definition vlc_subpicture.h:173
const video_format_t * video_src
Definition vlc_subpicture.h:175
const video_format_t * prev_src
Definition vlc_subpicture.h:179
const video_format_t * video_dst
Definition vlc_subpicture.h:177
const video_format_t * prev_dst
Definition vlc_subpicture.h:181
vlc_tick_t pts
Definition vlc_subpicture.h:184
Subpicture updater operation virtual table.
Definition vlc_subpicture.h:193
void(* destroy)(subpicture_t *)
Optional callback for subpicture private data cleanup.
Definition vlc_subpicture.h:201
void(* update)(subpicture_t *, const struct vlc_spu_updater_configuration *)
Mandatory callback called after pf_validate and doing the main job of creating the subpicture regions...
Definition vlc_subpicture.h:197
Video placement.
Definition vlc_vout_display.h:361
This file is a collection of common definitions and types.
This provides convenience helpers for linked lists.
This file defines picture structures and functions in vlc.
int64_t vlc_tick_t
High precision date or time interval.
Definition vlc_tick.h:48
This provides convenience helpers for vectors.
Video output display modules interface.