]> git.sesse.net Git - vlc/blob - include/vlc_es.h
* all: removed decoder_fifo_t.
[vlc] / include / vlc_es.h
1 /*****************************************************************************
2  * vlc_es.h
3  *****************************************************************************
4  * Copyright (C) 1999-2001 VideoLAN
5  * $Id: vlc_es.h,v 1.4 2003/11/24 00:39:00 fenrir Exp $
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #ifndef _VLC_ES_H
25 #define _VLC_ES_H 1
26
27 /**
28  * Description of a audio frame
29  */
30 struct audio_format_t
31 {
32     vlc_fourcc_t        i_format;
33
34     unsigned int        i_rate;
35
36     /* Describes the channels configuration of the samples (ie. number of
37      * channels which are available in the buffer, and positions). */
38     uint32_t            i_physical_channels;
39
40     /* Describes from which original channels, before downmixing, the
41      * buffer is derived. */
42     uint32_t            i_original_channels;
43
44     /* Optional - for A/52, SPDIF and DTS types : */
45     /* Bytes used by one compressed frame, depends on bitrate. */
46     unsigned int        i_bytes_per_frame;
47
48     /* Number of sampleframes contained in one compressed frame. */
49     unsigned int        i_frame_length;
50     /* Please note that it may be completely arbitrary - buffers are not
51      * obliged to contain a integral number of so-called "frames". It's
52      * just here for the division :
53      * buffer_size = i_nb_samples * i_bytes_per_frame / i_frame_length
54      */
55
56     /* FIXME ? (used by the codecs) */
57     int i_channels;
58     int i_blockalign;
59     int i_bitspersample;
60 };
61
62 /**
63  * Description of a video frame
64  */
65 struct video_format_t
66 {
67     vlc_fourcc_t i_chroma;                               /**< picture chroma */
68     unsigned int i_aspect;                                 /**< aspect ratio */
69
70     unsigned int i_width;                                 /**< picture width */
71     unsigned int i_height;                               /**< picture height */
72     unsigned int i_x_offset;               /**< start offset of visible area */
73     unsigned int i_y_offset;               /**< start offset of visible area */
74     unsigned int i_visible_width;                 /**< width of visible area */
75     unsigned int i_visible_height;               /**< height of visible area */
76
77     unsigned int i_bits_per_pixel;             /**< number of bits per pixel */
78
79     unsigned int i_frame_rate;                     /**< frame rate numerator */
80     unsigned int i_frame_rate_base;              /**< frame rate denominator */
81 };
82
83 /**
84  * Description of subs
85  */
86 struct subs_format_t
87 {
88     char *psz_encoding;
89
90     struct
91     {
92         /* FIXME */
93         uint32_t palette[16+1];
94     } spu;
95 };
96
97 /**
98  * ES definition
99  */
100 struct es_format_t
101 {
102     int             i_cat;
103     vlc_fourcc_t    i_codec;
104
105     int             i_group;    /* -1 : standalone
106                                    >= 0 then a "group" (program) is created
107                                         for each value */
108     int             i_priority; /*  -2 : mean not selectable by the users
109                                     -1 : mean not selected by default even
110                                         when no other stream
111                                     >=0: priority */
112     char            *psz_language;
113     char            *psz_description;
114
115     audio_format_t audio;
116     video_format_t video;
117     subs_format_t  subs;
118
119     int     i_bitrate;
120
121     int     i_extra;
122     void    *p_extra;
123
124 };
125
126 /* ES Categories */
127 #define UNKNOWN_ES      0x00
128 #define VIDEO_ES        0x01
129 #define AUDIO_ES        0x02
130 #define SPU_ES          0x03
131 #define NAV_ES          0x04
132
133 static inline void es_format_Init( es_format_t *fmt,
134                                    int i_cat, vlc_fourcc_t i_codec )
135 {
136     fmt->i_cat                  = i_cat;
137     fmt->i_codec                = i_codec;
138     fmt->i_group                = 0;
139     fmt->i_priority             = 0;
140     fmt->psz_language           = NULL;
141     fmt->psz_description        = NULL;
142
143     memset( &fmt->audio, 0, sizeof(audio_format_t) );
144     memset( &fmt->video, 0, sizeof(video_format_t) );
145     memset( &fmt->subs, 0, sizeof(subs_format_t) );
146
147     fmt->i_bitrate              = 0;
148     fmt->i_extra                = 0;
149     fmt->p_extra                = NULL;
150 }
151
152 static inline void es_format_Copy( es_format_t *dst, es_format_t *src )
153 {
154     memcpy( dst, src, sizeof( es_format_t ) );
155     if( src->i_extra > 0 )
156     {
157         dst->p_extra = malloc( src->i_extra );
158         memcpy( dst->p_extra, src->p_extra,
159                 src->i_extra );
160     }
161     else
162     {
163         dst->i_extra = 0;
164         dst->p_extra = NULL;
165     }
166 }
167
168 #endif
169