]> git.sesse.net Git - vlc/blob - include/video.h
038420fcafee4867469e757c86924124da37a5ed
[vlc] / include / video.h
1 /*****************************************************************************
2  * video.h: common video definitions
3  * (c)1999 VideoLAN
4  *****************************************************************************
5  * This header is required by all modules which have to handle pictures. It
6  * includes all common video types and constants.
7  *****************************************************************************
8  * Requires:
9  *  "config.h"
10  *  "common.h"
11  *  "mtime.h"
12  *****************************************************************************/
13
14 /*****************************************************************************
15  * yuv_data_t: type for storing one Y, U or V sample.
16  *****************************************************************************/
17 typedef u8 yuv_data_t;
18
19 /*****************************************************************************
20  * picture_t: video picture
21  *****************************************************************************
22  * Any picture destined to be displayed by a video output thread should be
23  * stored in this structure from it's creation to it's effective display.
24  * Picture type and flags should only be modified by the output thread. Note
25  * that an empty picture MUST have its flags set to 0.
26  *****************************************************************************/
27 typedef struct picture_s
28 {
29     /* Type and flags - should NOT be modified except by the vout thread */
30     int             i_type;                                  /* picture type */
31     int             i_status;                               /* picture flags */
32     int             i_matrix_coefficients;     /* in YUV type, encoding type */
33
34     /* Picture management properties - these properties can be modified using
35      * the video output thread API, but should ne be written directly */
36     int             i_refcount;                    /* link reference counter */
37     mtime_t         date;                                    /* display date */
38
39     /* Picture static properties - those properties are fixed at initialization
40      * and should NOT be modified */
41     int             i_width;                                /* picture width */
42     int             i_height;                              /* picture height */
43     int             i_chroma_width;                          /* chroma width */
44
45     /* Picture dynamic properties - those properties can be changed by the
46      * decoder */
47     int             i_display_horizontal_offset;   /* ISO/IEC 13818-2 6.3.12 */
48     int             i_display_vertical_offset;     /* ISO/IEC 13818-2 6.3.12 */
49     int             i_display_width;                 /* useful picture width */
50     int             i_display_height;               /* useful picture height */
51     int             i_aspect_ratio;                          /* aspect ratio */
52
53     /* Macroblock counter - the decoder use it to verify if it has
54      * decoded all the macroblocks of the picture */
55     int             i_deccount;
56     vlc_mutex_t     lock_deccount;
57
58     /* Picture data - data can always be freely modified. p_data itself
59      * (the pointer) should NEVER be modified. In YUV format, the p_y, p_u and
60      * p_v data pointers refers to different areas of p_data, and should not
61      * be freed */
62     void *          p_data;                                  /* picture data */
63     yuv_data_t *    p_y;        /* pointer to beginning of Y image in p_data */
64     yuv_data_t *    p_u;        /* pointer to beginning of U image in p_data */
65     yuv_data_t *    p_v;        /* pointer to beginning of V image in p_data */
66 } picture_t;
67
68 /* Pictures types */
69 #define EMPTY_PICTURE           0     /* picture slot is empty and available */
70 #define YUV_420_PICTURE         100                     /* 4:2:0 YUV picture */
71 #define YUV_422_PICTURE         101                     /* 4:2:2 YUV picture */
72 #define YUV_444_PICTURE         102                     /* 4:4:4 YUV picture */
73
74 /* Pictures status */
75 #define FREE_PICTURE            0       /* picture is free and not allocated */
76 #define RESERVED_PICTURE        1       /* picture is allocated and reserved */
77 #define RESERVED_DATED_PICTURE  2   /* picture is waiting for DisplayPicture */
78 #define RESERVED_DISP_PICTURE   3    /* picture is waiting for a DatePixture */
79 #define READY_PICTURE           4            /* picture is ready for display */
80 #define DISPLAYED_PICTURE       5/* picture has been displayed but is linked */
81 #define DESTROYED_PICTURE       6   /* picture is allocated but no more used */
82
83 /* Aspect ratios (ISO/IEC 13818-2 section 6.3.3, table 6-3) */
84 #define AR_SQUARE_PICTURE       1                           /* square pixels */
85 #define AR_3_4_PICTURE          2                        /* 3:4 picture (TV) */
86 #define AR_16_9_PICTURE         3              /* 16:9 picture (wide screen) */
87 #define AR_221_1_PICTURE        4                  /* 2.21:1 picture (movie) */
88
89 /*****************************************************************************
90  * subpicture_t: video sub picture unit
91  *****************************************************************************
92  * Any sub picture unit destined to be displayed by a video output thread should
93  * be stored in this structure from it's creation to it's effective display.
94  * Subtitle type and flags should only be modified by the output thread. Note
95  * that an empty subtitle MUST have its flags set to 0.
96  *****************************************************************************/
97 typedef struct subpicture_s
98 {
99     /* Type and flags - should NOT be modified except by the vout thread */
100     int             i_type;                                          /* type */
101     int             i_status;                                       /* flags */
102     int             i_size;                                     /* data size */
103
104     /* Other properties */
105     mtime_t         begin_date;                 /* beginning of display date */
106     mtime_t         end_date;                         /* end of display date */
107
108     /* Display properties - these properties are only indicative and may be
109      * changed by the video output thread, or simply ignored depending of the
110      * subpicture type. */
111     int             i_x;                   /* offset from alignment position */
112     int             i_y;                   /* offset from alignment position */
113     int             i_width;                                /* picture width */
114     int             i_height;                              /* picture height */
115     int             i_horizontal_align;              /* horizontal alignment */
116     int             i_vertical_align;                  /* vertical alignment */
117
118     /* Additionnal properties depending of the subpicture type */
119     union
120     {
121         /* Text subpictures properties - text is stored in data area, in ASCIIZ
122          * format */
123         struct
124         {
125             p_vout_font_t       p_font;            /* font, NULL for default */
126             int                 i_style;                       /* text style */
127             u32                 i_char_color;             /* character color */
128             u32                 i_border_color;              /* border color */
129             u32                 i_bg_color;              /* background color */
130         } text;
131     } type;
132
133     /* Subpicture data, format depends of type - data can always be freely
134      * modified. p_data itself (the pointer) should NEVER be modified. */
135     void *          p_data;                               /* subpicture data */
136 } subpicture_t;
137
138 /* Subpicture type */
139 #define EMPTY_SUBPICTURE        0    /* subtitle slot is empty and available */
140 #define RLE_SUBPICTURE          100                  /* RLE encoded subtitle */
141 #define TEXT_SUBPICTURE         200                      /* single line text */
142
143 /* Subpicture status */
144 #define FREE_SUBPICTURE         0    /* subpicture is free and not allocated */
145 #define RESERVED_SUBPICTURE     1    /* subpicture is allocated and reserved */
146 #define READY_SUBPICTURE        2         /* subpicture is ready for display */
147 #define DESTROYED_SUBPICTURE    3/* subpicture is allocated but no more used */
148
149 /* Alignment types */
150 #define RIGHT_ALIGN             10                /* x is absolute for right */
151 #define LEFT_ALIGN              11                 /* x is absolute for left */
152 #define RIGHT_RALIGN            12     /* x is relative for right from right */
153 #define LEFT_RALIGN             13       /* x is relative for left from left */
154
155 #define CENTER_ALIGN            20           /* x, y are absolute for center */
156 #define CENTER_RALIGN           21 /* x, y are relative for center from center */
157
158 #define BOTTOM_ALIGN            30               /* y is absolute for bottom */
159 #define TOP_ALIGN               31                  /* y is absolute for top */
160 #define BOTTOM_RALIGN           32   /* y is relative for bottom from bottom */
161 #define TOP_RALIGN              33         /* y is relative for top from top */
162 #define SUBTITLE_RALIGN         34 /* y is relative for center from subtitle */
163
164