]> git.sesse.net Git - vlc/blob - include/video.h
16d248a624b5e171caf814ec7e38012a84b93948
[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.38 2002/01/02 14:37:42 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     u64             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 /*****************************************************************************
117  * Flags used to describe the status of a picture
118  *****************************************************************************/
119
120 /* Picture type */
121 #define EMPTY_PICTURE           0                            /* empty buffer */
122 #define MEMORY_PICTURE          100                 /* heap-allocated buffer */
123 #define DIRECT_PICTURE          200                         /* direct buffer */
124
125 /* Picture status */
126 #define FREE_PICTURE            0                  /* free and not allocated */
127 #define RESERVED_PICTURE        1                  /* allocated and reserved */
128 #define RESERVED_DATED_PICTURE  2              /* waiting for DisplayPicture */
129 #define RESERVED_DISP_PICTURE   3               /* waiting for a DatePicture */
130 #define READY_PICTURE           4                       /* ready for display */
131 #define DISPLAYED_PICTURE       5            /* been displayed but is linked */
132 #define DESTROYED_PICTURE       6              /* allocated but no more used */
133
134 /*****************************************************************************
135  * Flags used to describe the format of a picture
136  *****************************************************************************/
137
138 #define ONLY_FOURCC(i_chroma)   ((i_chroma)&0x00000000ffffffff)
139 #define ONLY_EXTRA(i_chroma)    ((i_chroma)&0xffffffff00000000)
140
141 /* Picture chroma - see http://www.webartz.com/fourcc/ */
142 #define FOURCC_BI_RGB           0x00000000           /* Planar RGB, for 8bpp */
143 #define FOURCC_RGB              0x32424752               /* alias for BI_RGB */
144 #define FOURCC_BI_BITFIELDS     0x00000003  /* Planar RGB, for 16, 24, 32bpp */
145 #define FOURCC_I420             0x30323449            /* Planar 4:2:0, Y:U:V */
146 #define FOURCC_IYUV             0x56555949                 /* alias for I420 */
147 #define FOURCC_YV12             0x32315659            /* Planar 4:2:0, Y:V:U */
148
149 /* Custom formats which we use but which don't exist in the fourcc database */
150 #define FOURCC_I422             0x32323449
151 #define FOURCC_I444             0x34343449
152
153 /* Picture format - gives more precise information than the chroma */
154 #define DEPTH_8BPP              ((u64)0x00000008<<32)
155 #define DEPTH_15BPP             ((u64)0x00000015<<32)
156 #define DEPTH_16BPP             ((u64)0x00000016<<32)
157 #define DEPTH_24BPP             ((u64)0x00000024<<32)
158 #define DEPTH_32BPP             ((u64)0x00000032<<32)
159
160 /* Plane indices */
161 #define MAIN_PLANE              0
162 #define Y_PLANE                 0
163 #define U_PLANE                 1
164 #define V_PLANE                 2
165 #define Cb_PLANE                1
166 #define Cr_PLANE                2
167 #define R_PLANE                 0
168 #define G_PLANE                 1
169 #define B_PLANE                 2
170
171 /* Shortcuts */
172 #define P_MAIN planes[ MAIN_PLANE ].p_data
173 #define P_Y planes[ Y_PLANE ].p_data
174 #define P_U planes[ U_PLANE ].p_data
175 #define P_V planes[ V_PLANE ].p_data
176
177 /*****************************************************************************
178  * subpicture_t: video subtitle
179  *****************************************************************************
180  * Any subtitle destined to be displayed by a video output thread should
181  * be stored in this structure from it's creation to it's effective display.
182  * Subtitle type and flags should only be modified by the output thread. Note
183  * that an empty subtitle MUST have its flags set to 0.
184  *****************************************************************************/
185 typedef struct subpicture_s
186 {
187     /* Type and flags - should NOT be modified except by the vout thread */
188     int             i_type;                                          /* type */
189     int             i_status;                                       /* flags */
190     int             i_size;                                     /* data size */
191     struct subpicture_s *   p_next;         /* next subtitle to be displayed */
192
193     /* Date properties */
194     mtime_t         i_start;                    /* beginning of display date */
195     mtime_t         i_stop;                           /* end of display date */
196     boolean_t       b_ephemer;             /* does the subtitle have a TTL ? */
197
198     /* Display properties - these properties are only indicative and may be
199      * changed by the video output thread, or simply ignored depending of the
200      * subtitle type. */
201     int             i_x;                   /* offset from alignment position */
202     int             i_y;                   /* offset from alignment position */
203     int             i_width;                                /* picture width */
204     int             i_height;                              /* picture height */
205     int             i_horizontal_align;              /* horizontal alignment */
206     int             i_vertical_align;                  /* vertical alignment */
207
208     /* Additionnal properties depending of the subpicture type */
209     union
210     {
211         /* Text subpictures properties - text is stored in data area, in ASCIIZ
212          * format */
213         struct
214         {
215             p_vout_font_t       p_font;            /* font, NULL for default */
216             int                 i_style;                       /* text style */
217             u32                 i_char_color;             /* character color */
218             u32                 i_border_color;              /* border color */
219             u32                 i_bg_color;              /* background color */
220         } text;
221         /* DVD subpicture units properties */
222         struct
223         {
224             int                 i_offset[2];         /* byte offsets to data */
225         } spu;
226     } type;
227
228     /* Subpicture data, format depends of type - data can always be freely
229      * modified. p_data itself (the pointer) should NEVER be modified. */
230     void *          p_data;                               /* subpicture data */
231 } subpicture_t;
232
233 /* Subpicture type */
234 #define EMPTY_SUBPICTURE       0     /* subtitle slot is empty and available */
235 #define DVD_SUBPICTURE         100                    /* DVD subpicture unit */
236 #define TEXT_SUBPICTURE        200                       /* single line text */
237
238 /* Subpicture status */
239 #define FREE_SUBPICTURE        0                   /* free and not allocated */
240 #define RESERVED_SUBPICTURE    1                   /* allocated and reserved */
241 #define READY_SUBPICTURE       2                        /* ready for display */
242 #define DESTROYED_SUBPICTURE   3           /* allocated but not used anymore */
243
244 /* Alignment types */
245 #define RIGHT_ALIGN            10                 /* x is absolute for right */
246 #define LEFT_ALIGN             11                  /* x is absolute for left */
247 #define RIGHT_RALIGN           12      /* x is relative for right from right */
248 #define LEFT_RALIGN            13        /* x is relative for left from left */
249
250 #define CENTER_ALIGN           20            /* x, y are absolute for center */
251 #define CENTER_RALIGN          21 /* x,y are relative for center from center */
252
253 #define BOTTOM_ALIGN           30                /* y is absolute for bottom */
254 #define TOP_ALIGN              31                   /* y is absolute for top */
255 #define BOTTOM_RALIGN          32    /* y is relative for bottom from bottom */
256 #define TOP_RALIGN             33          /* y is relative for top from top */
257 #define SUBTITLE_RALIGN        34  /* y is relative for center from subtitle */
258
259