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