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