VLC  4.0.0-dev
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 
34 /**
35  * \defgroup subpicture Video sub-pictures
36  * \ingroup video_output
37  * Subpictures are pictures that should be displayed on top of the video, like
38  * subtitles and OSD
39  * @{
40  * \file
41  * Subpictures functions
42  */
43 
44 /**
45  * Video subtitle region spu core private
46  */
49 typedef struct filter_t vlc_blender_t;
50 
51 /**
52  * Video subtitle region
53  *
54  * A subtitle region is defined by a picture (graphic) and its rendering
55  * coordinates.
56  * Subtitles contain a list of regions.
57  */
59 {
60  video_format_t fmt; /**< format of the picture */
61  picture_t *p_picture; /**< picture comprising this region */
62 
63  int i_x; /**< position of region, relative to alignment */
64  int i_y; /**< position of region, relative to alignment */
65  int i_align; /**< alignment flags of region */
66  int i_alpha; /**< transparency */
67 
68  /* Parameters for text regions (p_picture to be rendered) */
69  text_segment_t *p_text; /**< subtitle text, made of a list of segments */
70  int i_text_align; /**< alignment flags of region content */
71  bool b_noregionbg; /**< render background under text only */
72  bool b_gridmode; /** if the decoder sends row/cols based output */
73  bool b_balanced_text; /** try to balance wrapped text lines */
74  int i_max_width; /** horizontal rendering/cropping target/limit */
75  int i_max_height; /** vertical rendering/cropping target/limit */
76 
79 
80  subpicture_region_t *p_next; /**< next region in the list */
81  subpicture_region_private_t *p_private; /**< Private data for spu_t *only* */
82 };
83 
85 {
86  int x_start;
87  int x_end;
88  int y_start;
89  int y_end;
91 };
92 
93 /* Subpicture region position flags */
94 #define SUBPICTURE_ALIGN_LEFT 0x1
95 #define SUBPICTURE_ALIGN_RIGHT 0x2
96 #define SUBPICTURE_ALIGN_TOP 0x4
97 #define SUBPICTURE_ALIGN_BOTTOM 0x8
98 #define SUBPICTURE_ALIGN_MASK ( SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT| \
99  SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM )
100 /**
101  * This function will create a new subpicture region.
102  *
103  * You must use subpicture_region_Delete to destroy it.
104  */
106 
107 /**
108  * This function will destroy a subpicture region allocated by
109  * subpicture_region_New.
110  *
111  * You may give it NULL.
112  */
114 
115 /**
116  * This function will destroy a list of subpicture regions allocated by
117  * subpicture_region_New.
118  *
119  * Provided for convenience.
120  */
122 
123 /**
124  * This function will copy a subpicture region to a new allocated one
125  * and transfer all the properties
126  *
127  * Provided for convenience.
128  */
130 
131 /**
132  *
133  */
134 typedef struct
135 {
136  /** Optional pre update callback, usually useful on video format change.
137  * Will skip pf_update on VLC_SUCCESS, or will delete every region before
138  * the call to pf_update */
139  int (*pf_validate)( subpicture_t *,
140  bool has_src_changed, const video_format_t *p_fmt_src,
141  bool has_dst_changed, const video_format_t *p_fmt_dst,
142  vlc_tick_t);
143  /** Mandatory callback called after pf_validate and doing
144  * the main job of creating the subpicture regions for the
145  * current video_format */
146  void (*pf_update) ( subpicture_t *,
147  const video_format_t *p_fmt_src,
148  const video_format_t *p_fmt_dst,
149  vlc_tick_t );
150  /** Optional callback for subpicture private data cleanup */
151  void (*pf_destroy) ( subpicture_t * );
152  void *p_sys;
154 
156 
157 /**
158  * Video subtitle
159  *
160  * Any subtitle destined to be displayed by a video output thread should
161  * be stored in this structure from it's creation to it's effective display.
162  * Subtitle type and flags should only be modified by the output thread. Note
163  * that an empty subtitle MUST have its flags set to 0.
164  */
165 struct subpicture_t
166 {
167  /** \name Channel ID */
168  /**@{*/
169  ssize_t i_channel; /**< subpicture channel ID */
170  /**@}*/
171 
172  /** \name Type and flags
173  Should NOT be modified except by the vout thread */
174  /**@{*/
175  int64_t i_order; /** an increasing unique number */
176  subpicture_t * p_next; /**< next subtitle to be displayed */
177  /**@}*/
178 
179  subpicture_region_t *p_region; /**< region list composing this subtitle */
180 
181  /** \name Date properties */
182  /**@{*/
183  vlc_tick_t i_start; /**< beginning of display date */
184  vlc_tick_t i_stop; /**< end of display date */
185  bool b_ephemer; /**< If this flag is set to true the subtitle
186  will be displayed until the next one appear */
187  bool b_fade; /**< enable fading */
188  /**@}*/
189 
190  /** \name Display properties
191  * These properties are only indicative and may be
192  * changed by the video output thread, or simply ignored depending of the
193  * subtitle type. */
194  /**@{*/
195  bool b_subtitle; /**< the picture is a movie subtitle */
196  bool b_absolute; /**< position is absolute */
197  int i_original_picture_width; /**< original width of the movie */
198  int i_original_picture_height;/**< original height of the movie */
199  int i_alpha; /**< transparency */
200  /**@}*/
201 
203 
204  subpicture_private_t *p_private; /* Reserved to the core */
205 };
206 
207 /**
208  * This function create a new empty subpicture.
209  *
210  * You must use subpicture_Delete to destroy it.
211  */
213 
214 /**
215  * This function delete a subpicture created by subpicture_New.
216  * You may give it NULL.
217  */
218 VLC_API void subpicture_Delete( subpicture_t *p_subpic );
219 
220 /**
221  * This function will create a subpicture having one region in the requested
222  * chroma showing the given picture.
223  *
224  * The picture_t given is not released nor used inside the
225  * returned subpicture_t.
226  */
228 
229 /**
230  * This function will update the content of a subpicture created with
231  * a non NULL subpicture_updater_t.
232  */
234 
235 /**
236  * This function will blend a given subpicture onto a picture.
237  *
238  * The subpicture and all its region must:
239  * - be absolute.
240  * - not be ephemere.
241  * - not have the fade flag.
242  * - contains only picture (no text rendering).
243  * \return the number of region(s) successfully blent
244  */
246 
247 /**@}*/
248 
249 #endif /* _VLC_SUBPICTURE_H */
#define VLC_API
Definition: fourcc_gen.c:31
uint32_t vlc_fourcc_t
Definition: fourcc_gen.c:33
void subpicture_Delete(subpicture_t *p_subpic)
This function delete a subpicture created by subpicture_New.
Definition: subpicture.c:82
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:100
void subpicture_region_Delete(subpicture_region_t *p_region)
This function will destroy a subpicture region allocated by subpicture_region_New.
Definition: subpicture.c:261
void subpicture_region_ChainDelete(subpicture_region_t *p_head)
This function will destroy a list of subpicture regions allocated by subpicture_region_New.
Definition: subpicture.c:277
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:149
subpicture_region_t * subpicture_region_New(const video_format_t *p_fmt)
This function will create a new subpicture region.
Definition: subpicture.c:240
unsigned picture_BlendSubpicture(picture_t *, vlc_blender_t *, subpicture_t *)
This function will blend a given subpicture onto a picture.
Definition: subpicture.c:291
subpicture_t * subpicture_New(const subpicture_updater_t *)
This function create a new empty subpicture.
Definition: subpicture.c:43
subpicture_region_t * subpicture_region_Copy(subpicture_region_t *p_region)
This function will copy a subpicture region to a new allocated one and transfer all the properties.
Definition: subpicture.c:313
Structure describing a filter.
Definition: vlc_filter.h:216
Video picture.
Definition: vlc_picture.h:124
Definition: subpicture.c:38
Definition: subpicture.h:23
Video subtitle region.
Definition: vlc_subpicture.h:60
subpicture_region_t * p_next
next region in the list
Definition: vlc_subpicture.h:81
int i_y
position of region, relative to alignment
Definition: vlc_subpicture.h:65
int i_align
alignment flags of region
Definition: vlc_subpicture.h:66
vlc_rational_t zoom_h
vertical rendering/cropping target/limit
Definition: vlc_subpicture.h:78
int i_x
position of region, relative to alignment
Definition: vlc_subpicture.h:64
vlc_rational_t zoom_v
Definition: vlc_subpicture.h:79
bool b_gridmode
Definition: vlc_subpicture.h:73
bool b_balanced_text
if the decoder sends row/cols based output
Definition: vlc_subpicture.h:74
video_format_t fmt
format of the picture
Definition: vlc_subpicture.h:61
bool b_noregionbg
render background under text only
Definition: vlc_subpicture.h:72
picture_t * p_picture
picture comprising this region
Definition: vlc_subpicture.h:62
int i_text_align
alignment flags of region content
Definition: vlc_subpicture.h:71
subpicture_region_private_t * p_private
Private data for spu_t only
Definition: vlc_subpicture.h:82
int i_max_width
try to balance wrapped text lines
Definition: vlc_subpicture.h:75
int i_alpha
transparency
Definition: vlc_subpicture.h:67
int i_max_height
horizontal rendering/cropping target/limit
Definition: vlc_subpicture.h:76
text_segment_t * p_text
subtitle text, made of a list of segments
Definition: vlc_subpicture.h:70
Video subtitle.
Definition: vlc_subpicture.h:167
vlc_tick_t i_start
beginning of display date
Definition: vlc_subpicture.h:184
subpicture_t * p_next
an increasing unique number
Definition: vlc_subpicture.h:177
bool b_ephemer
If this flag is set to true the subtitle will be displayed until the next one appear.
Definition: vlc_subpicture.h:186
bool b_fade
enable fading
Definition: vlc_subpicture.h:188
subpicture_private_t * p_private
Definition: vlc_subpicture.h:205
int i_alpha
transparency
Definition: vlc_subpicture.h:200
bool b_subtitle
the picture is a movie subtitle
Definition: vlc_subpicture.h:196
int64_t i_order
Definition: vlc_subpicture.h:176
int i_original_picture_height
original height of the movie
Definition: vlc_subpicture.h:199
ssize_t i_channel
subpicture channel ID
Definition: vlc_subpicture.h:170
vlc_tick_t i_stop
end of display date
Definition: vlc_subpicture.h:185
subpicture_updater_t updater
Definition: vlc_subpicture.h:203
subpicture_region_t * p_region
region list composing this subtitle
Definition: vlc_subpicture.h:180
bool b_absolute
position is absolute
Definition: vlc_subpicture.h:197
int i_original_picture_width
original width of the movie
Definition: vlc_subpicture.h:198
Definition: vlc_subpicture.h:136
Text segment for subtitles.
Definition: vlc_text_style.h:140
video format description
Definition: vlc_es.h:352
Definition: vlc_es.h:44
VLC object common members.
Definition: vlc_objects.h:45
Definition: fourcc_gen.c:34
Definition: vlc_subpicture.h:86
video_palette_t palette
Definition: vlc_subpicture.h:91
int x_start
Definition: vlc_subpicture.h:87
int y_end
Definition: vlc_subpicture.h:90
int x_end
Definition: vlc_subpicture.h:88
int y_start
Definition: vlc_subpicture.h:89
This file defines picture structures and functions in vlc.
int64_t vlc_tick_t
High precision date or time interval.
Definition: vlc_tick.h:45