]> git.sesse.net Git - vlc/blob - include/video.h
* Fixed detection of the esd plugin.
[vlc] / include / video.h
1 /*****************************************************************************
2  * 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: video.h,v 1.37 2001/12/31 04:53:33 sam 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  * plane_t: description of a planar graphic field
28  *****************************************************************************/
29 typedef u8 pixel_data_t;
30
31 typedef struct plane_s
32 {
33     pixel_data_t *p_data;                       /* Start of the plane's data */
34
35     /* Variables used for fast memcpy operations */
36     int i_bytes;                       /* Total number of bytes in the plane */
37     int i_line_bytes;                     /* Total number of bytes in a line */
38
39     /* Variables used for RGB planes */
40     int i_red_mask;
41     int i_green_mask;
42     int i_blue_mask;
43
44 } plane_t;
45
46 /*****************************************************************************
47  * picture_t: video picture
48  *****************************************************************************
49  * Any picture destined to be displayed by a video output thread should be
50  * stored in this structure from it's creation to it's effective display.
51  * Picture type and flags should only be modified by the output thread. Note
52  * that an empty picture MUST have its flags set to 0.
53  *****************************************************************************/
54 typedef struct picture_s
55 {
56     /* Picture data - data can always be freely modified, but no pointer
57      * may EVER be modified. A direct buffer can be handled as the plugin
58      * wishes, but for internal video output pictures the allocated pointer
59      * MUST be planes[0].p_data */
60     plane_t         planes[ VOUT_MAX_PLANES ];  /* description of the planes */
61     int             i_planes;                  /* number of allocated planes */
62
63     /* Type and flags - should NOT be modified except by the vout thread */
64     int             i_status;                               /* picture flags */
65     int             i_type;                  /* is picture a direct buffer ? */
66     int             i_matrix_coefficients;     /* in YUV type, encoding type */
67
68     /* Picture management properties - these properties can be modified using
69      * the video output thread API, but should never be written directly */
70     int             i_refcount;                    /* link reference counter */
71     mtime_t         date;                                    /* display date */
72
73     /* Picture margins - needed because of possible padding issues */
74     int             i_left_margin;
75     int             i_right_margin;
76     int             i_top_margin;
77     int             i_bottom_margin;
78
79     /* Picture dynamic properties - those properties can be changed by the
80      * decoder */
81     boolean_t       b_progressive;            /* is it a progressive frame ? */
82     boolean_t       b_repeat_first_field;                         /* RFF bit */
83     boolean_t       b_top_field_first;               /* which field is first */
84
85     /* Macroblock counter - the decoder uses it to verify if it has
86      * decoded all the macroblocks of the picture */
87     int             i_deccount;
88     vlc_mutex_t     lock_deccount;
89
90     /* Private data - the video output plugin might want to put stuff here to
91      * keep track of the picture */
92     struct picture_sys_s *p_sys;
93
94 } picture_t;
95
96 /*****************************************************************************
97  * picture_heap_t: video picture heap, either render (to store pictures used
98  * by the decoder) or output (to store pictures displayed by the vout plugin)
99  *****************************************************************************/
100 typedef struct picture_heap_s
101 {
102     int             i_pictures;                         /* current heap size */
103
104     /* Picture static properties - those properties are fixed at initialization
105      * and should NOT be modified */
106     int             i_width;                                /* picture width */
107     int             i_height;                              /* picture height */
108     int             i_chroma;                              /* picture chroma */
109     int             i_aspect;                                /* aspect ratio */
110
111     /* Real pictures */
112     picture_t*      pp_picture[VOUT_MAX_PICTURES];               /* pictures */
113
114 } picture_heap_t;
115
116 /* Picture type */
117 #define EMPTY_PICTURE           0                            /* empty buffer */
118 #define MEMORY_PICTURE          100                 /* heap-allocated buffer */
119 #define DIRECT_PICTURE          200                         /* direct buffer */
120
121 /* Picture status */
122 #define FREE_PICTURE            0                  /* free and not allocated */
123 #define RESERVED_PICTURE        1                  /* allocated and reserved */
124 #define RESERVED_DATED_PICTURE  2              /* waiting for DisplayPicture */
125 #define RESERVED_DISP_PICTURE   3               /* waiting for a DatePicture */
126 #define READY_PICTURE           4                       /* ready for display */
127 #define DISPLAYED_PICTURE       5            /* been displayed but is linked */
128 #define DESTROYED_PICTURE       6              /* allocated but no more used */
129
130 /* Picture chroma */
131 #define EMPTY_PICTURE           0     /* picture slot is empty and available */
132 #define YUV_420_PICTURE         100                     /* 4:2:0 YUV picture */
133 #define YUV_422_PICTURE         101                     /* 4:2:2 YUV picture */
134 #define YUV_444_PICTURE         102                     /* 4:4:4 YUV picture */
135 #define RGB_8BPP_PICTURE        200                      /* RGB 8bpp picture */
136 #define RGB_16BPP_PICTURE       201                     /* RGB 16bpp picture */
137 #define RGB_32BPP_PICTURE       202                     /* RGB 32bpp picture */
138
139 /* Aspect ratio (ISO/IEC 13818-2 section 6.3.3, table 6-3) */
140 #define AR_SQUARE_PICTURE       1                           /* square pixels */
141 #define AR_3_4_PICTURE          2                        /* 3:4 picture (TV) */
142 #define AR_16_9_PICTURE         3              /* 16:9 picture (wide screen) */
143 #define AR_221_1_PICTURE        4                  /* 2.21:1 picture (movie) */
144
145 /* Plane indices */
146 #define YUV_PLANE               0
147 #define RGB_PLANE               0
148 #define Y_PLANE                 0
149 #define U_PLANE                 1
150 #define V_PLANE                 2
151 #define Cb_PLANE                1
152 #define Cr_PLANE                2
153 #define R_PLANE                 0
154 #define G_PLANE                 1
155 #define B_PLANE                 2
156
157 /* Shortcuts */
158 #define P_Y planes[ Y_PLANE ].p_data
159 #define P_U planes[ U_PLANE ].p_data
160 #define P_V planes[ V_PLANE ].p_data
161
162 /*****************************************************************************
163  * subpicture_t: video subtitle
164  *****************************************************************************
165  * Any subtitle destined to be displayed by a video output thread should
166  * be stored in this structure from it's creation to it's effective display.
167  * Subtitle type and flags should only be modified by the output thread. Note
168  * that an empty subtitle MUST have its flags set to 0.
169  *****************************************************************************/
170 typedef struct subpicture_s
171 {
172     /* Type and flags - should NOT be modified except by the vout thread */
173     int             i_type;                                          /* type */
174     int             i_status;                                       /* flags */
175     int             i_size;                                     /* data size */
176     struct subpicture_s *   p_next;         /* next subtitle to be displayed */
177
178     /* Date properties */
179     mtime_t         i_start;                    /* beginning of display date */
180     mtime_t         i_stop;                           /* end of display date */
181     boolean_t       b_ephemer;             /* does the subtitle have a TTL ? */
182
183     /* Display properties - these properties are only indicative and may be
184      * changed by the video output thread, or simply ignored depending of the
185      * subtitle type. */
186     int             i_x;                   /* offset from alignment position */
187     int             i_y;                   /* offset from alignment position */
188     int             i_width;                                /* picture width */
189     int             i_height;                              /* picture height */
190     int             i_horizontal_align;              /* horizontal alignment */
191     int             i_vertical_align;                  /* vertical alignment */
192
193     /* Additionnal properties depending of the subpicture type */
194     union
195     {
196         /* Text subpictures properties - text is stored in data area, in ASCIIZ
197          * format */
198         struct
199         {
200             p_vout_font_t       p_font;            /* font, NULL for default */
201             int                 i_style;                       /* text style */
202             u32                 i_char_color;             /* character color */
203             u32                 i_border_color;              /* border color */
204             u32                 i_bg_color;              /* background color */
205         } text;
206         /* DVD subpicture units properties */
207         struct
208         {
209             int                 i_offset[2];         /* byte offsets to data */
210         } spu;
211     } type;
212
213     /* Subpicture data, format depends of type - data can always be freely
214      * modified. p_data itself (the pointer) should NEVER be modified. */
215     void *          p_data;                               /* subpicture data */
216 } subpicture_t;
217
218 /* Subpicture type */
219 #define EMPTY_SUBPICTURE       0     /* subtitle slot is empty and available */
220 #define DVD_SUBPICTURE         100                    /* DVD subpicture unit */
221 #define TEXT_SUBPICTURE        200                       /* single line text */
222
223 /* Subpicture status */
224 #define FREE_SUBPICTURE        0                   /* free and not allocated */
225 #define RESERVED_SUBPICTURE    1                   /* allocated and reserved */
226 #define READY_SUBPICTURE       2                        /* ready for display */
227 #define DESTROYED_SUBPICTURE   3           /* allocated but not used anymore */
228
229 /* Alignment types */
230 #define RIGHT_ALIGN            10                 /* x is absolute for right */
231 #define LEFT_ALIGN             11                  /* x is absolute for left */
232 #define RIGHT_RALIGN           12      /* x is relative for right from right */
233 #define LEFT_RALIGN            13        /* x is relative for left from left */
234
235 #define CENTER_ALIGN           20            /* x, y are absolute for center */
236 #define CENTER_RALIGN          21 /* x,y are relative for center from center */
237
238 #define BOTTOM_ALIGN           30                /* y is absolute for bottom */
239 #define TOP_ALIGN              31                   /* y is absolute for top */
240 #define BOTTOM_RALIGN          32    /* y is relative for bottom from bottom */
241 #define TOP_RALIGN             33          /* y is relative for top from top */
242 #define SUBTITLE_RALIGN        34  /* y is relative for center from subtitle */
243
244