]> git.sesse.net Git - vlc/blob - include/video.h
* demuxes: Worked around a bug in old VLC and VLS by changing TS stream types
[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.56 2002/07/23 00:39:16 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 struct plane_t
30 {
31     u8 *p_pixels;                               /* Start of the plane's data */
32
33     /* Variables used for fast memcpy operations */
34     int i_lines;                                          /* Number of lines */
35     int i_pitch;             /* Number of bytes in a line, including margins */
36
37     /* Size of a macropixel, defaults to 1 */
38     int i_pixel_pitch;
39
40     /* Variables used for pictures with margins */
41     int i_visible_pitch;              /* How many visible pixels are there ? */
42
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 struct picture_t
54 {
55     /* Picture data - data can always be freely modified, but p_data may
56      * NEVER be modified. A direct buffer can be handled as the plugin
57      * wishes, it can even swap p_pixels buffers. */
58     u8             *p_data;
59     void           *p_data_orig;                  /* pointer before memalign */
60     plane_t         p[ 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     vlc_bool_t      b_force;
73
74     /* Picture dynamic properties - those properties can be changed by the
75      * decoder */
76     vlc_bool_t      b_progressive;            /* is it a progressive frame ? */
77     vlc_bool_t      b_repeat_first_field;                         /* RFF bit */
78     vlc_bool_t      b_top_field_first;               /* which field is first */
79
80     /* The picture heap we are attached to */
81     picture_heap_t* p_heap;
82
83     /* Private data - the video output plugin might want to put stuff here to
84      * keep track of the picture */
85     picture_sys_t * p_sys;
86 };
87
88 /*****************************************************************************
89  * picture_heap_t: video picture heap, either render (to store pictures used
90  * by the decoder) or output (to store pictures displayed by the vout plugin)
91  *****************************************************************************/
92 struct picture_heap_t
93 {
94     int i_pictures;                                     /* current heap size */
95
96     /* Picture static properties - those properties are fixed at initialization
97      * and should NOT be modified */
98     int          i_width;                                   /* picture width */
99     int          i_height;                                 /* picture height */
100     vlc_fourcc_t i_chroma;                                 /* picture chroma */
101     int          i_aspect;                                   /* aspect ratio */
102
103     /* Real pictures */
104     picture_t*      pp_picture[VOUT_MAX_PICTURES];               /* pictures */
105
106     /* Stuff used for truecolor RGB planes */
107     int i_rmask, i_rrshift, i_lrshift;
108     int i_gmask, i_rgshift, i_lgshift;
109     int i_bmask, i_rbshift, i_lbshift;
110
111     /* Stuff used for palettized RGB planes */
112     void (* pf_setpalette) ( vout_thread_t *, u16 *, u16 *, u16 * );
113 };
114
115 /* RGB2PIXEL: assemble RGB components to a pixel value, returns a u32 */
116 #define RGB2PIXEL( p_vout, i_r, i_g, i_b )                                    \
117     (((((u32)i_r) >> p_vout->output.i_rrshift) << p_vout->output.i_lrshift) | \
118      ((((u32)i_g) >> p_vout->output.i_rgshift) << p_vout->output.i_lgshift) | \
119      ((((u32)i_b) >> p_vout->output.i_rbshift) << p_vout->output.i_lbshift))
120
121 /*****************************************************************************
122  * Flags used to describe the status of a picture
123  *****************************************************************************/
124
125 /* Picture type */
126 #define EMPTY_PICTURE           0                            /* empty buffer */
127 #define MEMORY_PICTURE          100                 /* heap-allocated buffer */
128 #define DIRECT_PICTURE          200                         /* direct buffer */
129
130 /* Picture status */
131 #define FREE_PICTURE            0                  /* free and not allocated */
132 #define RESERVED_PICTURE        1                  /* allocated and reserved */
133 #define RESERVED_DATED_PICTURE  2              /* waiting for DisplayPicture */
134 #define RESERVED_DISP_PICTURE   3               /* waiting for a DatePicture */
135 #define READY_PICTURE           4                       /* ready for display */
136 #define DISPLAYED_PICTURE       5            /* been displayed but is linked */
137 #define DESTROYED_PICTURE       6              /* allocated but no more used */
138
139 /*****************************************************************************
140  * Shortcuts to access image components
141  *****************************************************************************/
142
143 /* Plane indices */
144 #define Y_PLANE      0
145 #define U_PLANE      1
146 #define V_PLANE      2
147
148 /* Shortcuts */
149 #define Y_PIXELS     p[Y_PLANE].p_pixels
150 #define Y_PITCH      p[Y_PLANE].i_pitch
151 #define U_PIXELS     p[U_PLANE].p_pixels
152 #define U_PITCH      p[U_PLANE].i_pitch
153 #define V_PIXELS     p[V_PLANE].p_pixels
154 #define V_PITCH      p[V_PLANE].i_pitch
155
156 /*****************************************************************************
157  * subpicture_t: video subtitle
158  *****************************************************************************
159  * Any subtitle destined to be displayed by a video output thread should
160  * be stored in this structure from it's creation to it's effective display.
161  * Subtitle type and flags should only be modified by the output thread. Note
162  * that an empty subtitle MUST have its flags set to 0.
163  *****************************************************************************/
164 struct subpicture_t
165 {
166     /* Type and flags - should NOT be modified except by the vout thread */
167     int             i_type;                                          /* type */
168     int             i_status;                                       /* flags */
169     int             i_size;                                     /* data size */
170     subpicture_t *  p_next;                 /* next subtitle to be displayed */
171
172     /* Date properties */
173     mtime_t         i_start;                    /* beginning of display date */
174     mtime_t         i_stop;                           /* end of display date */
175     vlc_bool_t      b_ephemer;             /* does the subtitle have a TTL ? */
176
177     /* Display properties - these properties are only indicative and may be
178      * changed by the video output thread, or simply ignored depending of the
179      * subtitle type. */
180     int             i_x;                   /* offset from alignment position */
181     int             i_y;                   /* offset from alignment position */
182     int             i_width;                                /* picture width */
183     int             i_height;                              /* picture height */
184
185 #if 0
186     /* Additionnal properties depending of the subpicture type */
187     union
188     {
189         /* Text subpictures properties - text is stored in data area, in ASCIIZ
190          * format */
191         struct
192         {
193             vout_font_t *       p_font;            /* font, NULL for default */
194             int                 i_style;                       /* text style */
195             u32                 i_char_color;             /* character color */
196             u32                 i_border_color;              /* border color */
197             u32                 i_bg_color;              /* background color */
198         } text;
199     } type;
200 #endif
201
202     /* The subpicture rendering routine */
203     void ( *pf_render ) ( vout_thread_t *, picture_t *, const subpicture_t * );
204
205     /* Private data - the subtitle plugin might want to put stuff here to
206      * keep track of the subpicture */
207     subpicture_sys_t *p_sys;                              /* subpicture data */
208     void             *p_sys_orig;                 /* pointer before memalign */
209 };
210
211 /* Subpicture type */
212 #define EMPTY_SUBPICTURE       0     /* subtitle slot is empty and available */
213 #define MEMORY_SUBPICTURE      100            /* subpicture stored in memory */
214
215 /* Subpicture status */
216 #define FREE_SUBPICTURE        0                   /* free and not allocated */
217 #define RESERVED_SUBPICTURE    1                   /* allocated and reserved */
218 #define READY_SUBPICTURE       2                        /* ready for display */
219 #define DESTROYED_SUBPICTURE   3           /* allocated but not used anymore */
220