]> git.sesse.net Git - vlc/blob - include/video.h
* Borrowed config.guess and config.sub from SDL [MacOS X port] ;
[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  *
8  * Authors: Vincent Seguin <seguin@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  * 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Requires:
27  *  "config.h"
28  *  "common.h"
29  *  "mtime.h"
30  *****************************************************************************/
31
32 /*****************************************************************************
33  * yuv_data_t: type for storing one Y, U or V sample.
34  *****************************************************************************/
35 typedef u8 yuv_data_t;
36
37 /*****************************************************************************
38  * picture_t: video picture
39  *****************************************************************************
40  * Any picture destined to be displayed by a video output thread should be
41  * stored in this structure from it's creation to it's effective display.
42  * Picture type and flags should only be modified by the output thread. Note
43  * that an empty picture MUST have its flags set to 0.
44  *****************************************************************************/
45 typedef struct picture_s
46 {
47     /* Type and flags - should NOT be modified except by the vout thread */
48     int             i_type;                                  /* picture type */
49     int             i_status;                               /* picture flags */
50     int             i_matrix_coefficients;     /* in YUV type, encoding type */
51
52     /* Picture management properties - these properties can be modified using
53      * the video output thread API, but should ne be written directly */
54     int             i_refcount;                    /* link reference counter */
55     mtime_t         date;                                    /* display date */
56
57     /* Picture static properties - those properties are fixed at initialization
58      * and should NOT be modified */
59     int             i_width;                                /* picture width */
60     int             i_chroma_width;                          /* chroma width */
61     int             i_height;                              /* picture height */
62     int             i_size;                                /* number of pels */
63     int             i_chroma_size;                  /* number of chroma pels */
64
65     /* Picture dynamic properties - those properties can be changed by the
66      * decoder */
67     int             i_display_horizontal_offset;   /* ISO/IEC 13818-2 6.3.12 */
68     int             i_display_vertical_offset;     /* ISO/IEC 13818-2 6.3.12 */
69     int             i_display_width;                 /* useful picture width */
70     int             i_display_height;               /* useful picture height */
71     int             i_aspect_ratio;                          /* aspect ratio */
72
73     /* Macroblock counter - the decoder use it to verify if it has
74      * decoded all the macroblocks of the picture */
75     int             i_deccount;
76     vlc_mutex_t     lock_deccount;
77
78     /* Picture data - data can always be freely modified. p_data itself
79      * (the pointer) should NEVER be modified. In YUV format, the p_y, p_u and
80      * p_v data pointers refers to different areas of p_data, and should not
81      * be freed */
82     void *          p_data;                                  /* picture data */
83     yuv_data_t *    p_y;        /* pointer to beginning of Y image in p_data */
84     yuv_data_t *    p_u;        /* pointer to beginning of U image in p_data */
85     yuv_data_t *    p_v;        /* pointer to beginning of V image in p_data */
86 } picture_t;
87
88 /* Pictures types */
89 #define EMPTY_PICTURE           0     /* picture slot is empty and available */
90 #define YUV_420_PICTURE         100                     /* 4:2:0 YUV picture */
91 #define YUV_422_PICTURE         101                     /* 4:2:2 YUV picture */
92 #define YUV_444_PICTURE         102                     /* 4:4:4 YUV picture */
93
94 /* Pictures status */
95 #define FREE_PICTURE            0                  /* free and not allocated */
96 #define RESERVED_PICTURE        1                  /* allocated and reserved */
97 #define RESERVED_DATED_PICTURE  2              /* waiting for DisplayPicture */
98 #define RESERVED_DISP_PICTURE   3               /* waiting for a DatePicture */
99 #define READY_PICTURE           4                       /* ready for display */
100 #define DISPLAYED_PICTURE       5            /* been displayed but is linked */
101 #define DESTROYED_PICTURE       6              /* allocated but no more used */
102
103 /* Aspect ratios (ISO/IEC 13818-2 section 6.3.3, table 6-3) */
104 #define AR_SQUARE_PICTURE       1                           /* square pixels */
105 #define AR_3_4_PICTURE          2                        /* 3:4 picture (TV) */
106 #define AR_16_9_PICTURE         3              /* 16:9 picture (wide screen) */
107 #define AR_221_1_PICTURE        4                  /* 2.21:1 picture (movie) */
108
109 /*****************************************************************************
110  * subpicture_t: video subtitle
111  *****************************************************************************
112  * Any subtitle destined to be displayed by a video output thread should
113  * be stored in this structure from it's creation to it's effective display.
114  * Subtitle type and flags should only be modified by the output thread. Note
115  * that an empty subtitle MUST have its flags set to 0.
116  *****************************************************************************/
117 typedef struct subpicture_s
118 {
119     /* Type and flags - should NOT be modified except by the vout thread */
120     int             i_type;                                          /* type */
121     int             i_status;                                       /* flags */
122     int             i_size;                                     /* data size */
123     struct subpicture_s *   p_next;         /* next subtitle to be displayed */
124
125     /* Other properties */
126     mtime_t         begin_date;                 /* beginning of display date */
127     mtime_t         end_date;                         /* end of display date */
128
129     /* Display properties - these properties are only indicative and may be
130      * changed by the video output thread, or simply ignored depending of the
131      * subtitle type. */
132     int             i_x;                   /* offset from alignment position */
133     int             i_y;                   /* offset from alignment position */
134     int             i_width;                                /* picture width */
135     int             i_height;                              /* picture height */
136     int             i_horizontal_align;              /* horizontal alignment */
137     int             i_vertical_align;                  /* vertical alignment */
138
139     /* Additionnal properties depending of the subpicture type */
140     union
141     {
142         /* Text subpictures properties - text is stored in data area, in ASCIIZ
143          * format */
144         struct
145         {
146             p_vout_font_t       p_font;            /* font, NULL for default */
147             int                 i_style;                       /* text style */
148             u32                 i_char_color;             /* character color */
149             u32                 i_border_color;              /* border color */
150             u32                 i_bg_color;              /* background color */
151         } text;
152         /* DVD subpicture units properties */
153         struct
154         {
155             int                 i_offset[2];         /* byte offsets to data */
156         } spu;
157     } type;
158
159     /* Subpicture data, format depends of type - data can always be freely
160      * modified. p_data itself (the pointer) should NEVER be modified. */
161     void *          p_data;                               /* subpicture data */
162 } subpicture_t;
163
164 /* Subpicture type */
165 #define EMPTY_SUBPICTURE       0     /* subtitle slot is empty and available */
166 #define DVD_SUBPICTURE         100                    /* DVD subpicture unit */
167 #define TEXT_SUBPICTURE        200                       /* single line text */
168
169 /* Subpicture status */
170 #define FREE_SUBPICTURE        0                   /* free and not allocated */
171 #define RESERVED_SUBPICTURE    1                   /* allocated and reserved */
172 #define READY_SUBPICTURE       2                        /* ready for display */
173 #define DESTROYED_SUBPICTURE   3           /* allocated but not used anymore */
174
175 /* Alignment types */
176 #define RIGHT_ALIGN            10                 /* x is absolute for right */
177 #define LEFT_ALIGN             11                  /* x is absolute for left */
178 #define RIGHT_RALIGN           12      /* x is relative for right from right */
179 #define LEFT_RALIGN            13        /* x is relative for left from left */
180
181 #define CENTER_ALIGN           20            /* x, y are absolute for center */
182 #define CENTER_RALIGN          21 /* x,y are relative for center from center */
183
184 #define BOTTOM_ALIGN           30                /* y is absolute for bottom */
185 #define TOP_ALIGN              31                   /* y is absolute for top */
186 #define BOTTOM_RALIGN          32    /* y is relative for bottom from bottom */
187 #define TOP_RALIGN             33          /* y is relative for top from top */
188 #define SUBTITLE_RALIGN        34  /* y is relative for center from subtitle */
189
190