]> git.sesse.net Git - vlc/blob - include/vlc_video.h
* modules/codec/mpeg_audio.c: fixes and improvements.
[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: vlc_video.h,v 1.3 2003/10/04 15:51:22 sigmunau Exp $
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
26 /**
27  * Description of a planar graphic field
28  */
29 typedef struct plane_t
30 {
31     uint8_t *p_pixels;                        /**< Start of the plane's data */
32
33     /* Variables used for fast memcpy operations */
34     int i_lines;                                        /**< Number of lines */
35     int i_pitch;           /**< Number of bytes in a line, including margins */
36
37     /** Size of a macropixel, defaults to 1 */
38     int i_pixel_pitch;
39
40     /* Variables used for pictures with margins */
41     int i_visible_pitch;            /**< How many visible pixels are there ? */
42
43 } plane_t;
44
45 /**
46  * Video picture
47  *
48  * Any picture destined to be displayed by a video output thread should be
49  * stored in this structure from it's creation to it's effective display.
50  * Picture type and flags should only be modified by the output thread. Note
51  * that an empty picture MUST have its flags set to 0.
52  */
53 struct picture_t
54 {
55     /** Picture data - data can always be freely modified, but p_data may
56      * NEVER be modified. A direct buffer can be handled as the plugin
57      * wishes, it can even swap p_pixels buffers. */
58     uint8_t        *p_data;
59     void           *p_data_orig;                /**< pointer before memalign */
60     plane_t         p[ VOUT_MAX_PLANES ];     /**< description of the planes */
61     int             i_planes;                /**< number of allocated planes */
62
63     /** \name Type and flags
64      * Should NOT be modified except by the vout thread
65      * @{*/
66     int             i_status;                             /**< picture flags */
67     int             i_type;                /**< is picture a direct buffer ? */
68     int             i_matrix_coefficients;   /**< in YUV type, encoding type */
69     /**@}*/
70
71     /** \name Picture management properties
72      * These properties can be modified using the video output thread API,
73      * but should never be written directly */
74     /**@{*/
75     int             i_refcount;                  /**< link reference counter */
76     mtime_t         date;                                  /**< display date */
77     vlc_bool_t      b_force;
78     /**@}*/
79
80     /** \name Picture dynamic properties
81      * Those properties can be changed by the decoder
82      * @{
83      */
84     vlc_bool_t      b_progressive;          /**< is it a progressive frame ? */
85     unsigned int    i_nb_fields;                  /**< # of displayed fields */
86     vlc_bool_t      b_top_field_first;             /**< which field is first */
87     /**@}*/
88     
89     /** The picture heap we are attached to */
90     picture_heap_t* p_heap;
91
92     /* Some vouts require the picture to be locked before it can be modified */
93     int (* pf_lock) ( vout_thread_t *, picture_t * );
94     int (* pf_unlock) ( vout_thread_t *, picture_t * );
95
96     /** Private data - the video output plugin might want to put stuff here to
97      * keep track of the picture */
98     picture_sys_t * p_sys;
99 };
100
101 /**
102  * Video picture heap, either render (to store pictures used
103  * by the decoder) or output (to store pictures displayed by the vout plugin)
104  */
105 struct picture_heap_t
106 {
107     int i_pictures;                                   /**< current heap size */
108
109     /* \name Picture static properties
110      * Those properties are fixed at initialization and should NOT be modified
111      * @{
112      */
113     unsigned int i_width;                                 /**< picture width */
114     unsigned int i_height;                               /**< picture height */
115     vlc_fourcc_t i_chroma;                               /**< picture chroma */
116     unsigned int i_aspect;                                 /**< aspect ratio */
117     /**@}*/
118
119     /* Real pictures */
120     picture_t*      pp_picture[VOUT_MAX_PICTURES];             /**< pictures */
121     int             i_last_used_pic;              /**< last used pic in heap */
122     vlc_bool_t      b_allow_modify_pics;
123
124     /* Stuff used for truecolor RGB planes */
125     int i_rmask, i_rrshift, i_lrshift;
126     int i_gmask, i_rgshift, i_lgshift;
127     int i_bmask, i_rbshift, i_lbshift;
128
129     /** Stuff used for palettized RGB planes */
130     void (* pf_setpalette) ( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );
131 };
132
133 /*****************************************************************************
134  * Flags used to describe the status of a picture
135  *****************************************************************************/
136
137 /* Picture type */
138 #define EMPTY_PICTURE           0                            /* empty buffer */
139 #define MEMORY_PICTURE          100                 /* heap-allocated buffer */
140 #define DIRECT_PICTURE          200                         /* direct buffer */
141
142 /* Picture status */
143 #define FREE_PICTURE            0                  /* free and not allocated */
144 #define RESERVED_PICTURE        1                  /* allocated and reserved */
145 #define RESERVED_DATED_PICTURE  2              /* waiting for DisplayPicture */
146 #define RESERVED_DISP_PICTURE   3               /* waiting for a DatePicture */
147 #define READY_PICTURE           4                       /* ready for display */
148 #define DISPLAYED_PICTURE       5            /* been displayed but is linked */
149 #define DESTROYED_PICTURE       6              /* allocated but no more used */
150
151 /*****************************************************************************
152  * Shortcuts to access image components
153  *****************************************************************************/
154
155 /* Plane indices */
156 #define Y_PLANE      0
157 #define U_PLANE      1
158 #define V_PLANE      2
159
160 /* Shortcuts */
161 #define Y_PIXELS     p[Y_PLANE].p_pixels
162 #define Y_PITCH      p[Y_PLANE].i_pitch
163 #define U_PIXELS     p[U_PLANE].p_pixels
164 #define U_PITCH      p[U_PLANE].i_pitch
165 #define V_PIXELS     p[V_PLANE].p_pixels
166 #define V_PITCH      p[V_PLANE].i_pitch
167
168 /**
169  * \defgroup subpicture Video Subpictures
170  * Subpictures are pictures that should be displayed on top of the video, like
171  * subtitles and OSD
172  * \ingroup video_output
173  * @{
174  */
175
176 /**
177  * Video subtitle
178  *
179  * Any subtitle destined to be displayed by a video output thread should
180  * be stored in this structure from it's creation to it's effective display.
181  * Subtitle type and flags should only be modified by the output thread. Note
182  * that an empty subtitle MUST have its flags set to 0.
183  */
184 struct subpicture_t
185 {
186     /** \name Type and flags
187        Should NOT be modified except by the vout thread */
188     /**@{*/
189     int             i_type;                                        /**< type */
190     int             i_status;                                     /**< flags */
191     subpicture_t *  p_next;               /**< next subtitle to be displayed */
192     /**@}*/
193
194     /** \name Date properties */
195     /**@{*/
196     mtime_t         i_start;                  /**< beginning of display date */
197     mtime_t         i_stop;                         /**< end of display date */
198     vlc_bool_t      b_ephemer;     /**< If this flag is set to true
199                                       the subtitle will be displayed
200                                       untill the next one appear */
201     /**@}*/
202
203     /** \name Display properties
204      * These properties are only indicative and may be
205      * changed by the video output thread, or simply ignored depending of the
206      * subtitle type. */
207     /**@{*/
208     int             i_x;                 /**< offset from alignment position */
209     int             i_y;                 /**< offset from alignment position */
210     int             i_width;                              /**< picture width */
211     int             i_height;                            /**< picture height */
212     /**@}*/
213 #if 0
214     /* Additionnal properties depending of the subpicture type */
215     union
216     {
217         /* Text subpictures properties - text is stored in data area, in ASCIIZ
218          * format */
219         struct
220         {
221             vout_font_t *       p_font;            /* font, NULL for default */
222             int                 i_style;                       /* text style */
223             uint32_t            i_char_color;             /* character color */
224             uint32_t            i_border_color;              /* border color */
225             uint32_t            i_bg_color;              /* background color */
226         } text;
227     } type;
228 #endif
229
230     /** Pointer to function that renders this subtitle in a picture */
231     void ( *pf_render )  ( vout_thread_t *, picture_t *, const subpicture_t * );
232     /** Pointer to function that cleans up the private data of this subtitle */
233     void ( *pf_destroy ) ( subpicture_t * );
234
235     /** Private data - the subtitle plugin might want to put stuff here to
236      * keep track of the subpicture */
237     subpicture_sys_t *p_sys;                              /* subpicture data */
238 };
239
240 /* Subpicture type */
241 #define EMPTY_SUBPICTURE       0     /* subtitle slot is empty and available */
242 #define MEMORY_SUBPICTURE      100            /* subpicture stored in memory */
243
244 /* Subpicture status */
245 #define FREE_SUBPICTURE        0                   /* free and not allocated */
246 #define RESERVED_SUBPICTURE    1                   /* allocated and reserved */
247 #define READY_SUBPICTURE       2                        /* ready for display */
248
249 /**@}*/