VLC  3.0.21
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  * $Id$
6  *
7  * Authors: Vincent Seguin <seguin@via.ecp.fr>
8  * Samuel Hocevar <sam@via.ecp.fr>
9  * Olivier Aubert <oaubert 47 videolan d07 org>
10  *
11  * This program is free software; you can redistribute it and/or modify it
12  * under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation; either version 2.1 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25 
26 #ifndef VLC_SUBPICTURE_H
27 #define VLC_SUBPICTURE_H 1
28 
29 /**
30  */
31 
32 #include <vlc_picture.h>
33 #include <vlc_text_style.h>
34 
35 /**
36  * \defgroup subpicture Video sub-pictures
37  * \ingroup video_output
38  * Subpictures are pictures that should be displayed on top of the video, like
39  * subtitles and OSD
40  * @{
41  * \file
42  * Subpictures functions
43  */
44 
45 /**
46  * Video subtitle region spu core private
47  */
49 
50 /**
51  * Video subtitle region
52  *
53  * A subtitle region is defined by a picture (graphic) and its rendering
54  * coordinates.
55  * Subtitles contain a list of regions.
56  */
58 {
59  video_format_t fmt; /**< format of the picture */
60  picture_t *p_picture; /**< picture comprising this region */
61 
62  int i_x; /**< position of region, relative to alignment */
63  int i_y; /**< position of region, relative to alignment */
64  int i_align; /**< alignment flags of region */
65  int i_alpha; /**< transparency */
66 
67  /* Parameters for text regions (p_picture to be rendered) */
68  text_segment_t *p_text; /**< subtitle text, made of a list of segments */
69  int i_text_align; /**< alignment flags of region content */
70  bool b_noregionbg; /**< render background under text only */
71  bool b_gridmode; /** if the decoder sends row/cols based output */
72  bool b_balanced_text; /** try to balance wrapped text lines */
73  int i_max_width; /** horizontal rendering/cropping target/limit */
74  int i_max_height; /** vertical rendering/cropping target/limit */
75 
76  subpicture_region_t *p_next; /**< next region in the list */
77  subpicture_region_private_t *p_private; /**< Private data for spu_t *only* */
78 };
79 
80 /* Subpicture region position flags */
81 #define SUBPICTURE_ALIGN_LEFT 0x1
82 #define SUBPICTURE_ALIGN_RIGHT 0x2
83 #define SUBPICTURE_ALIGN_TOP 0x4
84 #define SUBPICTURE_ALIGN_BOTTOM 0x8
85 #define SUBPICTURE_ALIGN_MASK ( SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT| \
86  SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM )
87 /**
88  * This function will create a new subpicture region.
89  *
90  * You must use subpicture_region_Delete to destroy it.
91  */
93 
94 /**
95  * This function will destroy a subpicture region allocated by
96  * subpicture_region_New.
97  *
98  * You may give it NULL.
99  */
101 
102 /**
103  * This function will destroy a list of subpicture regions allocated by
104  * subpicture_region_New.
105  *
106  * Provided for convenience.
107  */
109 
110 /**
111  * This function will copy a subpicture region to a new allocated one
112  * and transfer all the properties
113  *
114  * Provided for convenience.
115  */
117 
118 /**
119  *
120  */
122 typedef struct
123 {
124  /** Optional pre update callback, usually useful on video format change.
125  * Will skip pf_update on VLC_SUCCESS, or will delete every region before
126  * the call to pf_update */
127  int (*pf_validate)( subpicture_t *,
128  bool has_src_changed, const video_format_t *p_fmt_src,
129  bool has_dst_changed, const video_format_t *p_fmt_dst,
130  vlc_tick_t);
131  /** Mandatory callback called after pf_validate and doing
132  * the main job of creating the subpicture regions for the
133  * current video_format */
134  void (*pf_update) ( subpicture_t *,
135  const video_format_t *p_fmt_src,
136  const video_format_t *p_fmt_dst,
137  vlc_tick_t );
138  /** Optional callback for subpicture private data cleanup */
139  void (*pf_destroy) ( subpicture_t * );
142 
144 
145 /**
146  * Video subtitle
147  *
148  * Any subtitle destined to be displayed by a video output thread should
149  * be stored in this structure from it's creation to it's effective display.
150  * Subtitle type and flags should only be modified by the output thread. Note
151  * that an empty subtitle MUST have its flags set to 0.
152  */
154 {
155  /** \name Channel ID */
156  /**@{*/
157  int i_channel; /**< subpicture channel ID */
158  /**@}*/
159 
160  /** \name Type and flags
161  Should NOT be modified except by the vout thread */
162  /**@{*/
163  int64_t i_order; /** an increasing unique number */
164  subpicture_t * p_next; /**< next subtitle to be displayed */
165  /**@}*/
166 
167  subpicture_region_t *p_region; /**< region list composing this subtitle */
168 
169  /** \name Date properties */
170  /**@{*/
171  vlc_tick_t i_start; /**< beginning of display date */
172  vlc_tick_t i_stop; /**< end of display date */
173  bool b_ephemer; /**< If this flag is set to true the subtitle
174  will be displayed until the next one appear */
175  bool b_fade; /**< enable fading */
176  /**@}*/
177 
178  /** \name Display properties
179  * These properties are only indicative and may be
180  * changed by the video output thread, or simply ignored depending of the
181  * subtitle type. */
182  /**@{*/
183  bool b_subtitle; /**< the picture is a movie subtitle */
184  bool b_absolute; /**< position is absolute */
185  int i_original_picture_width; /**< original width of the movie */
186  int i_original_picture_height;/**< original height of the movie */
187  int i_alpha; /**< transparency */
188  /**@}*/
189 
191 
192  subpicture_private_t *p_private; /* Reserved to the core */
193 };
194 
195 /**
196  * This function create a new empty subpicture.
197  *
198  * You must use subpicture_Delete to destroy it.
199  */
201 
202 /**
203  * This function delete a subpicture created by subpicture_New.
204  * You may give it NULL.
205  */
206 VLC_API void subpicture_Delete( subpicture_t *p_subpic );
207 
208 /**
209  * This function will create a subpicture having one region in the requested
210  * chroma showing the given picture.
211  *
212  * The picture_t given is not released nor used inside the
213  * returned subpicture_t.
214  */
216 
217 /**
218  * This function will update the content of a subpicture created with
219  * a non NULL subpicture_updater_t.
220  */
222 
223 /**
224  * This function will blend a given subpicture onto a picture.
225  *
226  * The subpicture and all its region must:
227  * - be absolute.
228  * - not be ephemere.
229  * - not have the fade flag.
230  * - contains only picture (no text rendering).
231  * \return the number of region(s) successfully blent
232  */
234 
235 /**@}*/
236 
237 #endif /* _VLC_VIDEO_H */
VLC_API
#define VLC_API
Definition: fourcc_gen.c:30
subpicture_t::p_next
subpicture_t * p_next
an increasing unique number
Definition: vlc_subpicture.h:164
text_segment_t
Text segment for subtitles.
Definition: vlc_text_style.h:131
subpicture_region_t::i_max_width
int i_max_width
try to balance wrapped text lines
Definition: vlc_subpicture.h:73
subpicture_region_New
subpicture_region_t * subpicture_region_New(const video_format_t *p_fmt)
This function will create a new subpicture region.
Definition: subpicture.c:206
subpicture_updater_sys_t
Definition: video_epg.c:69
subpicture_region_t::b_noregionbg
bool b_noregionbg
render background under text only
Definition: vlc_subpicture.h:70
vlc_common.h
subpicture_updater_t
Definition: vlc_subpicture.h:122
subpicture_region_t::i_y
int i_y
position of region, relative to alignment
Definition: vlc_subpicture.h:63
subpicture_t::updater
subpicture_updater_t updater
Definition: vlc_subpicture.h:190
subpicture_region_t::p_text
text_segment_t * p_text
subtitle text, made of a list of segments
Definition: vlc_subpicture.h:68
vlc_tick_t
int64_t vlc_tick_t
High precision date or time interval.
Definition: vlc_common.h:150
subpicture_t::i_original_picture_height
int i_original_picture_height
original height of the movie
Definition: vlc_subpicture.h:186
picture_BlendSubpicture
unsigned picture_BlendSubpicture(picture_t *, filter_t *p_blend, subpicture_t *)
This function will blend a given subpicture onto a picture.
Definition: subpicture.c:279
video_format_t
video format description
Definition: vlc_es.h:325
subpicture_region_t::b_balanced_text
bool b_balanced_text
if the decoder sends row/cols based output
Definition: vlc_subpicture.h:72
subpicture_region_t::p_private
subpicture_region_private_t * p_private
Private data for spu_t only
Definition: vlc_subpicture.h:77
subpicture_region_t::i_x
int i_x
position of region, relative to alignment
Definition: vlc_subpicture.h:62
subpicture_region_t::b_gridmode
bool b_gridmode
Definition: vlc_subpicture.h:71
subpicture_t::i_start
vlc_tick_t i_start
beginning of display date
Definition: vlc_subpicture.h:171
subpicture_Update
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:150
subpicture_t::b_absolute
bool b_absolute
position is absolute
Definition: vlc_subpicture.h:184
subpicture_NewFromPicture
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:101
picture_t
Video picture.
Definition: vlc_picture.h:68
subpicture_region_t::i_text_align
int i_text_align
alignment flags of region content
Definition: vlc_subpicture.h:69
subpicture_t::i_alpha
int i_alpha
transparency
Definition: vlc_subpicture.h:187
subpicture_t::i_channel
int i_channel
subpicture channel ID
Definition: vlc_subpicture.h:157
subpicture_Delete
void subpicture_Delete(subpicture_t *p_subpic)
This function delete a subpicture created by subpicture_New.
Definition: subpicture.c:83
filter_t
Structure describing a filter.
Definition: vlc_filter.h:65
subpicture_t
Video subtitle.
Definition: vlc_subpicture.h:153
subpicture_t::p_region
subpicture_region_t * p_region
region list composing this subtitle
Definition: vlc_subpicture.h:167
subpicture_region_Delete
void subpicture_region_Delete(subpicture_region_t *p_region)
This function will destroy a subpicture region allocated by subpicture_region_New.
Definition: subpicture.c:249
subpicture_region_t::i_align
int i_align
alignment flags of region
Definition: vlc_subpicture.h:64
subpicture_region_t
Video subtitle region.
Definition: vlc_subpicture.h:57
subpicture_t::i_original_picture_width
int i_original_picture_width
original width of the movie
Definition: vlc_subpicture.h:185
subpicture_region_t::p_next
subpicture_region_t * p_next
vertical rendering/cropping target/limit
Definition: vlc_subpicture.h:76
subpicture_t::b_subtitle
bool b_subtitle
the picture is a movie subtitle
Definition: vlc_subpicture.h:183
subpicture_t::p_private
subpicture_private_t * p_private
Definition: vlc_subpicture.h:192
vlc_object_t
The main vlc_object_t structure.
Definition: vlc_objects.h:39
subpicture_t::b_ephemer
bool b_ephemer
If this flag is set to true the subtitle will be displayed until the next one appear.
Definition: vlc_subpicture.h:173
subpicture_region_ChainDelete
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:265
subpicture_t::b_fade
bool b_fade
enable fading
Definition: vlc_subpicture.h:175
vlc_picture.h
subpicture_region_t::p_picture
picture_t * p_picture
picture comprising this region
Definition: vlc_subpicture.h:60
subpicture_t::i_stop
vlc_tick_t i_stop
end of display date
Definition: vlc_subpicture.h:172
subpicture_region_t::i_alpha
int i_alpha
transparency
Definition: vlc_subpicture.h:65
subpicture_New
subpicture_t * subpicture_New(const subpicture_updater_t *)
This function create a new empty subpicture.
Definition: subpicture.c:44
subpicture_private_t
Definition: subpicture.c:38
subpicture_region_t::fmt
video_format_t fmt
format of the picture
Definition: vlc_subpicture.h:59
vlc_text_style.h
subpicture_region_t::i_max_height
int i_max_height
horizontal rendering/cropping target/limit
Definition: vlc_subpicture.h:74
subpicture_region_private_t
Definition: subpicture.h:23
subpicture_updater_t::p_sys
subpicture_updater_sys_t * p_sys
Definition: vlc_subpicture.h:140
subpicture_t::i_order
int64_t i_order
Definition: vlc_subpicture.h:163
vlc_fourcc_t
uint32_t vlc_fourcc_t
Definition: fourcc_gen.c:32
subpicture_region_Copy
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:301