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