1 /*****************************************************************************
2 * vlc_subpicture.h: subpicture definitions
3 *****************************************************************************
4 * Copyright (C) 1999 - 2009 VLC authors and VideoLAN
7 * Authors: Vincent Seguin <seguin@via.ecp.fr>
8 * Samuel Hocevar <sam@via.ecp.fr>
9 * Olivier Aubert <oaubert 47 videolan d07 org>
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.
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.
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 *****************************************************************************/
26 #ifndef VLC_SUBPICTURE_H
27 #define VLC_SUBPICTURE_H 1
32 #include <vlc_picture.h>
33 #include <vlc_text_style.h>
36 * \defgroup subpicture Video sub-pictures
37 * \ingroup video_output
38 * Subpictures are pictures that should be displayed on top of the video, like
42 * Subpictures functions
46 * Video subtitle region spu core private
48 typedef struct subpicture_region_private_t subpicture_region_private_t
;
49 typedef struct vlc_spu_highlight_t vlc_spu_highlight_t
;
52 * Video subtitle region
54 * A subtitle region is defined by a picture (graphic) and its rendering
56 * Subtitles contain a list of regions.
58 struct subpicture_region_t
60 video_format_t fmt
; /**< format of the picture */
61 picture_t
*p_picture
; /**< picture comprising this region */
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 */
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 */
77 subpicture_region_t
*p_next
; /**< next region in the list */
78 subpicture_region_private_t
*p_private
; /**< Private data for spu_t *only* */
81 struct vlc_spu_highlight_t
87 video_palette_t palette
;
90 /* Subpicture region position flags */
91 #define SUBPICTURE_ALIGN_LEFT 0x1
92 #define SUBPICTURE_ALIGN_RIGHT 0x2
93 #define SUBPICTURE_ALIGN_TOP 0x4
94 #define SUBPICTURE_ALIGN_BOTTOM 0x8
95 #define SUBPICTURE_ALIGN_MASK ( SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT| \
96 SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM )
98 * This function will create a new subpicture region.
100 * You must use subpicture_region_Delete to destroy it.
102 VLC_API subpicture_region_t
* subpicture_region_New( const video_format_t
*p_fmt
);
105 * This function will destroy a subpicture region allocated by
106 * subpicture_region_New.
108 * You may give it NULL.
110 VLC_API
void subpicture_region_Delete( subpicture_region_t
*p_region
);
113 * This function will destroy a list of subpicture regions allocated by
114 * subpicture_region_New.
116 * Provided for convenience.
118 VLC_API
void subpicture_region_ChainDelete( subpicture_region_t
*p_head
);
121 * This function will copy a subpicture region to a new allocated one
122 * and transfer all the properties
124 * Provided for convenience.
126 VLC_API subpicture_region_t
*subpicture_region_Copy( subpicture_region_t
*p_region
);
133 /** Optional pre update callback, usually useful on video format change.
134 * Will skip pf_update on VLC_SUCCESS, or will delete every region before
135 * the call to pf_update */
136 int (*pf_validate
)( subpicture_t
*,
137 bool has_src_changed
, const video_format_t
*p_fmt_src
,
138 bool has_dst_changed
, const video_format_t
*p_fmt_dst
,
140 /** Mandatory callback called after pf_validate and doing
141 * the main job of creating the subpicture regions for the
142 * current video_format */
143 void (*pf_update
) ( subpicture_t
*,
144 const video_format_t
*p_fmt_src
,
145 const video_format_t
*p_fmt_dst
,
147 /** Optional callback for subpicture private data cleanup */
148 void (*pf_destroy
) ( subpicture_t
* );
150 } subpicture_updater_t
;
152 typedef struct subpicture_private_t subpicture_private_t
;
157 * Any subtitle destined to be displayed by a video output thread should
158 * be stored in this structure from it's creation to it's effective display.
159 * Subtitle type and flags should only be modified by the output thread. Note
160 * that an empty subtitle MUST have its flags set to 0.
164 /** \name Channel ID */
166 int i_channel
; /**< subpicture channel ID */
169 /** \name Type and flags
170 Should NOT be modified except by the vout thread */
172 int64_t i_order
; /** an increasing unique number */
173 subpicture_t
* p_next
; /**< next subtitle to be displayed */
176 subpicture_region_t
*p_region
; /**< region list composing this subtitle */
178 /** \name Date properties */
180 vlc_tick_t i_start
; /**< beginning of display date */
181 vlc_tick_t i_stop
; /**< end of display date */
182 bool b_ephemer
; /**< If this flag is set to true the subtitle
183 will be displayed until the next one appear */
184 bool b_fade
; /**< enable fading */
187 /** \name Display properties
188 * These properties are only indicative and may be
189 * changed by the video output thread, or simply ignored depending of the
192 bool b_subtitle
; /**< the picture is a movie subtitle */
193 bool b_absolute
; /**< position is absolute */
194 int i_original_picture_width
; /**< original width of the movie */
195 int i_original_picture_height
;/**< original height of the movie */
196 int i_alpha
; /**< transparency */
199 subpicture_updater_t updater
;
201 subpicture_private_t
*p_private
; /* Reserved to the core */
205 * This function create a new empty subpicture.
207 * You must use subpicture_Delete to destroy it.
209 VLC_API subpicture_t
* subpicture_New( const subpicture_updater_t
* );
212 * This function delete a subpicture created by subpicture_New.
213 * You may give it NULL.
215 VLC_API
void subpicture_Delete( subpicture_t
*p_subpic
);
218 * This function will create a subpicture having one region in the requested
219 * chroma showing the given picture.
221 * The picture_t given is not released nor used inside the
222 * returned subpicture_t.
224 VLC_API subpicture_t
* subpicture_NewFromPicture( vlc_object_t
*, picture_t
*, vlc_fourcc_t i_chroma
);
227 * This function will update the content of a subpicture created with
228 * a non NULL subpicture_updater_t.
230 VLC_API
void subpicture_Update( subpicture_t
*, const video_format_t
*src
, const video_format_t
*, vlc_tick_t
);
233 * This function will blend a given subpicture onto a picture.
235 * The subpicture and all its region must:
238 * - not have the fade flag.
239 * - contains only picture (no text rendering).
240 * \return the number of region(s) successfully blent
242 VLC_API
unsigned picture_BlendSubpicture( picture_t
*, filter_t
*p_blend
, subpicture_t
* );
246 #endif /* _VLC_SUBPICTURE_H */