]> git.sesse.net Git - vlc/blob - include/vlc_video.h
bbbe2594610e8eb8fe28807755ff123525b283b7
[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 */
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_pitch;            /**< How many visible pixels are there ? */
46
47 } plane_t;
48
49 /**
50  * Video picture
51  *
52  * Any picture destined to be displayed by a video output thread should be
53  * stored in this structure from it's creation to it's effective display.
54  * Picture type and flags should only be modified by the output thread. Note
55  * that an empty picture MUST have its flags set to 0.
56  */
57 struct picture_t
58 {
59     /** \name Picture format
60      * Describes the properties of the picture
61      * @{*/
62     video_frame_format_t format;
63     /**@}*/
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     int             i_matrix_coefficients;   /**< in YUV type, encoding type */
79     /**@}*/
80
81     /** \name Picture management properties
82      * These properties can be modified using the video output thread API,
83      * but should never be written directly */
84     /**@{*/
85     int             i_refcount;                  /**< link reference counter */
86     mtime_t         date;                                  /**< display date */
87     vlc_bool_t      b_force;
88     /**@}*/
89
90     /** \name Picture dynamic properties
91      * Those properties can be changed by the decoder
92      * @{
93      */
94     vlc_bool_t      b_progressive;          /**< is it a progressive frame ? */
95     unsigned int    i_nb_fields;                  /**< # of displayed fields */
96     vlc_bool_t      b_top_field_first;             /**< which field is first */
97     /**@}*/
98
99     /** The picture heap we are attached to */
100     picture_heap_t* p_heap;
101
102     /* Some vouts require the picture to be locked before it can be modified */
103     int (* pf_lock) ( vout_thread_t *, picture_t * );
104     int (* pf_unlock) ( vout_thread_t *, picture_t * );
105
106     /** Private data - the video output plugin might want to put stuff here to
107      * keep track of the picture */
108     picture_sys_t * p_sys;
109 };
110
111 /**
112  * Video picture heap, either render (to store pictures used
113  * by the decoder) or output (to store pictures displayed by the vout plugin)
114  */
115 struct picture_heap_t
116 {
117     int i_pictures;                                   /**< current heap size */
118
119     /* \name Picture static properties
120      * Those properties are fixed at initialization and should NOT be modified
121      * @{
122      */
123     unsigned int i_width;                                 /**< picture width */
124     unsigned int i_height;                               /**< picture height */
125     vlc_fourcc_t i_chroma;                               /**< picture chroma */
126     unsigned int i_aspect;                                 /**< aspect ratio */
127     /**@}*/
128
129     /* Real pictures */
130     picture_t*      pp_picture[VOUT_MAX_PICTURES];             /**< pictures */
131     int             i_last_used_pic;              /**< last used pic in heap */
132     vlc_bool_t      b_allow_modify_pics;
133
134     /* Stuff used for truecolor RGB planes */
135     int i_rmask, i_rrshift, i_lrshift;
136     int i_gmask, i_rgshift, i_lgshift;
137     int i_bmask, i_rbshift, i_lbshift;
138
139     /** Stuff used for palettized RGB planes */
140     void (* pf_setpalette) ( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );
141 };
142
143 /*****************************************************************************
144  * Flags used to describe the status of a picture
145  *****************************************************************************/
146
147 /* Picture type */
148 #define EMPTY_PICTURE           0                            /* empty buffer */
149 #define MEMORY_PICTURE          100                 /* heap-allocated buffer */
150 #define DIRECT_PICTURE          200                         /* direct buffer */
151
152 /* Picture status */
153 #define FREE_PICTURE            0                  /* free and not allocated */
154 #define RESERVED_PICTURE        1                  /* allocated and reserved */
155 #define RESERVED_DATED_PICTURE  2              /* waiting for DisplayPicture */
156 #define RESERVED_DISP_PICTURE   3               /* waiting for a DatePicture */
157 #define READY_PICTURE           4                       /* ready for display */
158 #define DISPLAYED_PICTURE       5            /* been displayed but is linked */
159 #define DESTROYED_PICTURE       6              /* allocated but no more used */
160
161 /*****************************************************************************
162  * Shortcuts to access image components
163  *****************************************************************************/
164
165 /* Plane indices */
166 #define Y_PLANE      0
167 #define U_PLANE      1
168 #define V_PLANE      2
169
170 /* Shortcuts */
171 #define Y_PIXELS     p[Y_PLANE].p_pixels
172 #define Y_PITCH      p[Y_PLANE].i_pitch
173 #define U_PIXELS     p[U_PLANE].p_pixels
174 #define U_PITCH      p[U_PLANE].i_pitch
175 #define V_PIXELS     p[V_PLANE].p_pixels
176 #define V_PITCH      p[V_PLANE].i_pitch
177
178 /**
179  * \defgroup subpicture Video Subpictures
180  * Subpictures are pictures that should be displayed on top of the video, like
181  * subtitles and OSD
182  * \ingroup video_output
183  * @{
184  */
185
186 /**
187  * Video subtitle
188  *
189  * Any subtitle destined to be displayed by a video output thread should
190  * be stored in this structure from it's creation to it's effective display.
191  * Subtitle type and flags should only be modified by the output thread. Note
192  * that an empty subtitle MUST have its flags set to 0.
193  */
194 struct subpicture_t
195 {
196     /** \name Channel and content type */
197     /**@{*/
198     int             i_channel;                      /**< subpicture channel */
199     int             i_content;                            /**< content type */
200     /**@}*/
201
202     /** \name Type and flags
203        Should NOT be modified except by the vout thread */
204     /**@{*/
205     int             i_type;                                        /**< type */
206     int             i_status;                                     /**< flags */
207     subpicture_t *  p_next;               /**< next subtitle to be displayed */
208     /**@}*/
209
210     /** \name Date properties */
211     /**@{*/
212     mtime_t         i_start;                  /**< beginning of display date */
213     mtime_t         i_stop;                         /**< end of display date */
214     vlc_bool_t      b_ephemer;     /**< If this flag is set to true
215                                       the subtitle will be displayed
216                                       untill the next one appear */
217     /**@}*/
218
219     /** \name Display properties
220      * These properties are only indicative and may be
221      * changed by the video output thread, or simply ignored depending of the
222      * subtitle type. */
223     /**@{*/
224     int             i_x;                 /**< offset from alignment position */
225     int             i_y;                 /**< offset from alignment position */
226     int             i_width;                              /**< picture width */
227     int             i_height;                            /**< picture height */
228     /**@}*/
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 /* Subpicture channel */
250 #define SUBT1_CHAN             1
251 #define SUBT2_CHAN             2
252 #define BEGIN_EXCLUSIVE_CHAN   3           /* exclusive subpic-channels list */
253 #define POSITION_CHAN          3
254 #define VOLUME_CHAN            4
255 #define SOLO_CHAN              5
256 #define END_EXCLUSIVE_CHAN     5                               /*end of list */
257
258 /* Subpicture content type */
259 #define TEXT_CONTENT           0
260 #define GRAPH_CONTENT          1             /* used for OSD icon, slider... */
261
262 /*****************************************************************************
263  * Prototypes
264  *****************************************************************************/
265 /**
266  * vout_AspectRatio
267  *
268  * Set the i_aspect_x and i_aspect_y from the encoded aspect ratio i_aspect.
269  * \param i_aspect the encoded aspect ratio
270  * \param i_aspect_x the decoded x-axis portion of i_aspect. This is set.
271  * \param i_aspect_y the decoded y-axis portion of i_aspect  This is set.
272  */
273 VLC_EXPORT( void,  vout_AspectRatio, ( unsigned int i_aspect, unsigned int *i_aspect_x, unsigned int *i_aspect_y ) );
274
275 /**@}*/
276
277 #endif /* _VLC_VIDEO_H */