]> git.sesse.net Git - vlc/blob - include/vlc_video.h
* include/vlc_video.h: added an i_visible_lines field to plane_t.
[vlc] / include / vlc_video.h
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$
8  *
9  * Authors: Vincent Seguin <seguin@via.ecp.fr>
10  *
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.
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 General Public License for more details.
20  *
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  *****************************************************************************/
25 #ifndef _VLC_VIDEO_H
26 #define _VLC_VIDEO_H 1
27
28 #include "vlc_es.h"
29
30 /**
31  * Description of a planar graphic field
32  */
33 typedef struct plane_t
34 {
35     uint8_t *p_pixels;                        /**< Start of the plane's data */
36
37     /* Variables used for fast memcpy operations */
38     int i_lines;           /**< Number of lines, including margins */
39     int i_pitch;           /**< Number of bytes in a line, including margins */
40
41     /** Size of a macropixel, defaults to 1 */
42     int i_pixel_pitch;
43
44     /* Variables used for pictures with margins */
45     int i_visible_lines;            /**< How many visible lines are there ? */
46     int i_visible_pitch;            /**< How many visible pixels are there ? */
47
48 } plane_t;
49
50 /**
51  * Video picture
52  *
53  * Any picture destined to be displayed by a video output thread should be
54  * stored in this structure from it's creation to it's effective display.
55  * Picture type and flags should only be modified by the output thread. Note
56  * that an empty picture MUST have its flags set to 0.
57  */
58 struct picture_t
59 {
60     /** 
61      * The properties of the picture
62      */
63     video_frame_format_t format;
64
65     /** Picture data - data can always be freely modified, but p_data may
66      * NEVER be modified. A direct buffer can be handled as the plugin
67      * wishes, it can even swap p_pixels buffers. */
68     uint8_t        *p_data;
69     void           *p_data_orig;                /**< pointer before memalign */
70     plane_t         p[ VOUT_MAX_PLANES ];     /**< description of the planes */
71     int             i_planes;                /**< number of allocated planes */
72
73     /** \name Type and flags
74      * Should NOT be modified except by the vout thread
75      * @{*/
76     int             i_status;                             /**< picture flags */
77     int             i_type;                /**< is picture a direct buffer ? */
78     vlc_bool_t      b_slow;                 /**< is picture in slow memory ? */
79     int             i_matrix_coefficients;   /**< in YUV type, encoding type */
80     /**@}*/
81
82     /** \name Picture management properties
83      * These properties can be modified using the video output thread API,
84      * but should never be written directly */
85     /**@{*/
86     int             i_refcount;                  /**< link reference counter */
87     mtime_t         date;                                  /**< display date */
88     vlc_bool_t      b_force;
89     /**@}*/
90
91     /** \name Picture dynamic properties
92      * Those properties can be changed by the decoder
93      * @{
94      */
95     vlc_bool_t      b_progressive;          /**< is it a progressive frame ? */
96     unsigned int    i_nb_fields;                  /**< # of displayed fields */
97     vlc_bool_t      b_top_field_first;             /**< which field is first */
98     /**@}*/
99
100     /** The picture heap we are attached to */
101     picture_heap_t* p_heap;
102
103     /* Some vouts require the picture to be locked before it can be modified */
104     int (* pf_lock) ( vout_thread_t *, picture_t * );
105     int (* pf_unlock) ( vout_thread_t *, picture_t * );
106
107     /** Private data - the video output plugin might want to put stuff here to
108      * keep track of the picture */
109     picture_sys_t * p_sys;
110
111     /** This way the picture_Release can be overloaded */
112     void (*pf_release)( picture_t * );
113 };
114
115 /**
116  * Video picture heap, either render (to store pictures used
117  * by the decoder) or output (to store pictures displayed by the vout plugin)
118  */
119 struct picture_heap_t
120 {
121     int i_pictures;                                   /**< current heap size */
122
123     /* \name Picture static properties
124      * Those properties are fixed at initialization and should NOT be modified
125      * @{
126      */
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 */
131     /**@}*/
132
133     /* Real pictures */
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;
137
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;
142
143     /** Stuff used for palettized RGB planes */
144     void (* pf_setpalette) ( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );
145 };
146
147 /*****************************************************************************
148  * Flags used to describe the status of a picture
149  *****************************************************************************/
150
151 /* Picture type */
152 #define EMPTY_PICTURE           0                            /* empty buffer */
153 #define MEMORY_PICTURE          100                 /* heap-allocated buffer */
154 #define DIRECT_PICTURE          200                         /* direct buffer */
155
156 /* Picture status */
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 */
164
165 /*****************************************************************************
166  * Shortcuts to access image components
167  *****************************************************************************/
168
169 /* Plane indices */
170 #define Y_PLANE      0
171 #define U_PLANE      1
172 #define V_PLANE      2
173 #define A_PLANE      3
174
175 /* Shortcuts */
176 #define Y_PIXELS     p[Y_PLANE].p_pixels
177 #define Y_PITCH      p[Y_PLANE].i_pitch
178 #define U_PIXELS     p[U_PLANE].p_pixels
179 #define U_PITCH      p[U_PLANE].i_pitch
180 #define V_PIXELS     p[V_PLANE].p_pixels
181 #define V_PITCH      p[V_PLANE].i_pitch
182 #define A_PIXELS     p[A_PLANE].p_pixels
183 #define A_PITCH      p[A_PLANE].i_pitch
184
185 /**
186  * \defgroup subpicture Video Subpictures
187  * Subpictures are pictures that should be displayed on top of the video, like
188  * subtitles and OSD
189  * \ingroup video_output
190  * @{
191  */
192
193 /**
194  * Video subtitle region
195  *
196  * A subtitle region is defined by a picture (graphic) and its rendering
197  * coordinates.
198  * Subtitles contain a list of regions.
199  */
200 struct subpicture_region_t
201 {
202     /** \name Region properties */
203     /**@{*/
204     video_format_t  fmt;                          /**< format of the picture */
205     picture_t       picture;             /**< picture comprising this region */
206
207     int             i_x;                             /**< position of region */
208     int             i_y;                             /**< position of region */
209
210     subpicture_region_t *p_next;                /**< next region in the list */
211     /**@}*/
212
213 };
214
215 /**
216  * Video subtitle
217  *
218  * Any subtitle destined to be displayed by a video output thread should
219  * be stored in this structure from it's creation to it's effective display.
220  * Subtitle type and flags should only be modified by the output thread. Note
221  * that an empty subtitle MUST have its flags set to 0.
222  */
223 struct subpicture_t
224 {
225     /** \name Channel ID */
226     /**@{*/
227     int             i_channel;                    /**< subpicture channel ID */
228     /**@}*/
229
230     /** \name Type and flags
231        Should NOT be modified except by the vout thread */
232     /**@{*/
233     int             i_type;                                        /**< type */
234     int             i_status;                                     /**< flags */
235     subpicture_t *  p_next;               /**< next subtitle to be displayed */
236     /**@}*/
237
238     /** \name Date properties */
239     /**@{*/
240     mtime_t         i_start;                  /**< beginning of display date */
241     mtime_t         i_stop;                         /**< end of display date */
242     vlc_bool_t      b_ephemer;     /**< If this flag is set to true
243                                       the subtitle will be displayed
244                                       untill the next one appear */
245     /**@}*/
246
247     subpicture_region_t *p_region;  /**< region list composing this subtitle */
248
249     /** \name Display properties
250      * These properties are only indicative and may be
251      * changed by the video output thread, or simply ignored depending of the
252      * subtitle type. */
253     /**@{*/
254     int             i_x;                 /**< offset from alignment position */
255     int             i_y;                 /**< offset from alignment position */
256     int             i_width;                              /**< picture width */
257     int             i_height;                            /**< picture height */
258     int             b_absolute;                    /**< position is absolute */
259     int             i_flags;                             /**< position flags */
260      /**@}*/
261
262     /** Pointer to function that renders this subtitle in a picture */
263     void ( *pf_render )  ( vout_thread_t *, picture_t *, const subpicture_t * );
264     /** Pointer to function that cleans up the private data of this subtitle */
265     void ( *pf_destroy ) ( subpicture_t * );
266
267     /** Pointer to functions for region management */
268     subpicture_region_t * ( *pf_create_region ) ( vlc_object_t *,
269                                                   video_format_t * );
270     void ( *pf_destroy_region ) ( vlc_object_t *, subpicture_region_t * );
271
272     /** Private data - the subtitle plugin might want to put stuff here to
273      * keep track of the subpicture */
274     subpicture_sys_t *p_sys;                              /* subpicture data */
275 };
276
277 /* Subpicture type */
278 #define EMPTY_SUBPICTURE       0     /* subtitle slot is empty and available */
279 #define MEMORY_SUBPICTURE      100            /* subpicture stored in memory */
280
281 /* Default subpicture channel ID */
282 #define DEFAULT_CHAN           1
283
284 /* Subpicture status */
285 #define FREE_SUBPICTURE        0                   /* free and not allocated */
286 #define RESERVED_SUBPICTURE    1                   /* allocated and reserved */
287 #define READY_SUBPICTURE       2                        /* ready for display */
288
289 /*****************************************************************************
290  * Prototypes
291  *****************************************************************************/
292 /**
293  * vout_AspectRatio
294  *
295  * Set the i_aspect_x and i_aspect_y from the encoded aspect ratio i_aspect.
296  * \param i_aspect the encoded aspect ratio
297  * \param i_aspect_x the decoded x-axis portion of i_aspect. This is set.
298  * \param i_aspect_y the decoded y-axis portion of i_aspect  This is set.
299  */
300 VLC_EXPORT( void,  vout_AspectRatio, ( unsigned int i_aspect, unsigned int *i_aspect_x, unsigned int *i_aspect_y ) );
301
302 /**@}*/
303
304 #endif /* _VLC_VIDEO_H */