1 /*****************************************************************************
2 * vlc_video.h: common video definitions
3 * This header is required by all modules which have to handle pictures. It
4 * includes all common video types and constants.
5 *****************************************************************************
6 * Copyright (C) 1999, 2000 VideoLAN
7 * $Id: vlc_video.h,v 1.4 2003/10/08 21:01:07 gbazin Exp $
9 * Authors: Vincent Seguin <seguin@via.ecp.fr>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 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 General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 #define _VLC_VIDEO_H 1
29 * Description of a video frame
31 typedef struct video_frame_format_t
33 unsigned int i_width; /**< picture width */
34 unsigned int i_height; /**< picture height */
35 vlc_fourcc_t i_chroma; /**< picture chroma */
36 unsigned int i_aspect; /**< aspect ratio */
38 } video_frame_format_t;
41 * Description of a planar graphic field
43 typedef struct plane_t
45 uint8_t *p_pixels; /**< Start of the plane's data */
47 /* Variables used for fast memcpy operations */
48 int i_lines; /**< Number of lines */
49 int i_pitch; /**< Number of bytes in a line, including margins */
51 /** Size of a macropixel, defaults to 1 */
54 /* Variables used for pictures with margins */
55 int i_visible_pitch; /**< How many visible pixels are there ? */
62 * Any picture destined to be displayed by a video output thread should be
63 * stored in this structure from it's creation to it's effective display.
64 * Picture type and flags should only be modified by the output thread. Note
65 * that an empty picture MUST have its flags set to 0.
69 /** Picture data - data can always be freely modified, but p_data may
70 * NEVER be modified. A direct buffer can be handled as the plugin
71 * wishes, it can even swap p_pixels buffers. */
73 void *p_data_orig; /**< pointer before memalign */
74 plane_t p[ VOUT_MAX_PLANES ]; /**< description of the planes */
75 int i_planes; /**< number of allocated planes */
77 /** \name Type and flags
78 * Should NOT be modified except by the vout thread
80 int i_status; /**< picture flags */
81 int i_type; /**< is picture a direct buffer ? */
82 int i_matrix_coefficients; /**< in YUV type, encoding type */
85 /** \name Picture management properties
86 * These properties can be modified using the video output thread API,
87 * but should never be written directly */
89 int i_refcount; /**< link reference counter */
90 mtime_t date; /**< display date */
94 /** \name Picture dynamic properties
95 * Those properties can be changed by the decoder
98 vlc_bool_t b_progressive; /**< is it a progressive frame ? */
99 unsigned int i_nb_fields; /**< # of displayed fields */
100 vlc_bool_t b_top_field_first; /**< which field is first */
103 /** The picture heap we are attached to */
104 picture_heap_t* p_heap;
106 /* Some vouts require the picture to be locked before it can be modified */
107 int (* pf_lock) ( vout_thread_t *, picture_t * );
108 int (* pf_unlock) ( vout_thread_t *, picture_t * );
110 /** Private data - the video output plugin might want to put stuff here to
111 * keep track of the picture */
112 picture_sys_t * p_sys;
116 * Video picture heap, either render (to store pictures used
117 * by the decoder) or output (to store pictures displayed by the vout plugin)
119 struct picture_heap_t
121 int i_pictures; /**< current heap size */
123 /* \name Picture static properties
124 * Those properties are fixed at initialization and should NOT be modified
127 unsigned int i_width; /**< picture width */
128 unsigned int i_height; /**< picture height */
129 vlc_fourcc_t i_chroma; /**< picture chroma */
130 unsigned int i_aspect; /**< aspect ratio */
134 picture_t* pp_picture[VOUT_MAX_PICTURES]; /**< pictures */
135 int i_last_used_pic; /**< last used pic in heap */
136 vlc_bool_t b_allow_modify_pics;
138 /* Stuff used for truecolor RGB planes */
139 int i_rmask, i_rrshift, i_lrshift;
140 int i_gmask, i_rgshift, i_lgshift;
141 int i_bmask, i_rbshift, i_lbshift;
143 /** Stuff used for palettized RGB planes */
144 void (* pf_setpalette) ( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );
147 /*****************************************************************************
148 * Flags used to describe the status of a picture
149 *****************************************************************************/
152 #define EMPTY_PICTURE 0 /* empty buffer */
153 #define MEMORY_PICTURE 100 /* heap-allocated buffer */
154 #define DIRECT_PICTURE 200 /* direct buffer */
157 #define FREE_PICTURE 0 /* free and not allocated */
158 #define RESERVED_PICTURE 1 /* allocated and reserved */
159 #define RESERVED_DATED_PICTURE 2 /* waiting for DisplayPicture */
160 #define RESERVED_DISP_PICTURE 3 /* waiting for a DatePicture */
161 #define READY_PICTURE 4 /* ready for display */
162 #define DISPLAYED_PICTURE 5 /* been displayed but is linked */
163 #define DESTROYED_PICTURE 6 /* allocated but no more used */
165 /*****************************************************************************
166 * Shortcuts to access image components
167 *****************************************************************************/
175 #define Y_PIXELS p[Y_PLANE].p_pixels
176 #define Y_PITCH p[Y_PLANE].i_pitch
177 #define U_PIXELS p[U_PLANE].p_pixels
178 #define U_PITCH p[U_PLANE].i_pitch
179 #define V_PIXELS p[V_PLANE].p_pixels
180 #define V_PITCH p[V_PLANE].i_pitch
183 * \defgroup subpicture Video Subpictures
184 * Subpictures are pictures that should be displayed on top of the video, like
186 * \ingroup video_output
193 * Any subtitle destined to be displayed by a video output thread should
194 * be stored in this structure from it's creation to it's effective display.
195 * Subtitle type and flags should only be modified by the output thread. Note
196 * that an empty subtitle MUST have its flags set to 0.
200 /** \name Type and flags
201 Should NOT be modified except by the vout thread */
203 int i_type; /**< type */
204 int i_status; /**< flags */
205 subpicture_t * p_next; /**< next subtitle to be displayed */
208 /** \name Date properties */
210 mtime_t i_start; /**< beginning of display date */
211 mtime_t i_stop; /**< end of display date */
212 vlc_bool_t b_ephemer; /**< If this flag is set to true
213 the subtitle will be displayed
214 untill the next one appear */
217 /** \name Display properties
218 * These properties are only indicative and may be
219 * changed by the video output thread, or simply ignored depending of the
222 int i_x; /**< offset from alignment position */
223 int i_y; /**< offset from alignment position */
224 int i_width; /**< picture width */
225 int i_height; /**< picture height */
228 /* Additionnal properties depending of the subpicture type */
231 /* Text subpictures properties - text is stored in data area, in ASCIIZ
235 vout_font_t * p_font; /* font, NULL for default */
236 int i_style; /* text style */
237 uint32_t i_char_color; /* character color */
238 uint32_t i_border_color; /* border color */
239 uint32_t i_bg_color; /* background color */
244 /** Pointer to function that renders this subtitle in a picture */
245 void ( *pf_render ) ( vout_thread_t *, picture_t *, const subpicture_t * );
246 /** Pointer to function that cleans up the private data of this subtitle */
247 void ( *pf_destroy ) ( subpicture_t * );
249 /** Private data - the subtitle plugin might want to put stuff here to
250 * keep track of the subpicture */
251 subpicture_sys_t *p_sys; /* subpicture data */
254 /* Subpicture type */
255 #define EMPTY_SUBPICTURE 0 /* subtitle slot is empty and available */
256 #define MEMORY_SUBPICTURE 100 /* subpicture stored in memory */
258 /* Subpicture status */
259 #define FREE_SUBPICTURE 0 /* free and not allocated */
260 #define RESERVED_SUBPICTURE 1 /* allocated and reserved */
261 #define READY_SUBPICTURE 2 /* ready for display */
265 #endif /* _VLC_VIDEO_H */