]> git.sesse.net Git - vlc/blob - include/vlc_es.h
* include/vlc_common.h, include/vlc_es.h: new video_palette_t structure.
[vlc] / include / vlc_es.h
1 /*****************************************************************************
2  * vlc_es.h: Elementary stream formats descriptions
3  *****************************************************************************
4  * Copyright (C) 1999-2001 VideoLAN
5  * $Id: vlc_es.h,v 1.7 2004/01/25 21:39:37 gbazin 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  * \file
29  * This file defines the elementary streams format types
30  */
31
32 /**
33  * video palette data
34  * \see viedo_format_t
35  * \see subs_format_t
36  */
37 struct video_palette_t
38 {
39     int i_dummy; /**< to keep the compatibility with ffmpeg's palette */
40
41     uint32_t palette[256]; /**< 4-byte ARGB palette entries, stored in native
42                             * byte order */
43 };
44
45 /**
46  * audio format description
47  */
48 struct audio_format_t
49 {
50     vlc_fourcc_t i_format;                          /**< audio format fourcc */
51     unsigned int i_rate;                              /**< audio sample-rate */
52
53     /* Describes the channels configuration of the samples (ie. number of
54      * channels which are available in the buffer, and positions). */
55     uint32_t     i_physical_channels;
56
57     /* Describes from which original channels, before downmixing, the
58      * buffer is derived. */
59     uint32_t     i_original_channels;
60
61     /* Optional - for A/52, SPDIF and DTS types : */
62     /* Bytes used by one compressed frame, depends on bitrate. */
63     unsigned int i_bytes_per_frame;
64
65     /* Number of sampleframes contained in one compressed frame. */
66     unsigned int        i_frame_length;
67     /* Please note that it may be completely arbitrary - buffers are not
68      * obliged to contain a integral number of so-called "frames". It's
69      * just here for the division :
70      * buffer_size = i_nb_samples * i_bytes_per_frame / i_frame_length
71      */
72
73     /* FIXME ? (used by the codecs) */
74     int i_channels;
75     int i_blockalign;
76     int i_bitspersample;
77 };
78
79 /**
80  * video format description
81  */
82 struct video_format_t
83 {
84     vlc_fourcc_t i_chroma;                               /**< picture chroma */
85     unsigned int i_aspect;                                 /**< aspect ratio */
86
87     unsigned int i_width;                                 /**< picture width */
88     unsigned int i_height;                               /**< picture height */
89     unsigned int i_x_offset;               /**< start offset of visible area */
90     unsigned int i_y_offset;               /**< start offset of visible area */
91     unsigned int i_visible_width;                 /**< width of visible area */
92     unsigned int i_visible_height;               /**< height of visible area */
93
94     unsigned int i_bits_per_pixel;             /**< number of bits per pixel */
95
96     unsigned int i_frame_rate;                     /**< frame rate numerator */
97     unsigned int i_frame_rate_base;              /**< frame rate denominator */
98
99     video_palette_t *p_palette;              /**< video palette from demuxer */
100 };
101
102 /**
103  * subtitles format description
104  */
105 struct subs_format_t
106 {
107     char *psz_encoding;
108
109     struct
110     {
111         /* FIXME */
112         uint32_t palette[16+1];
113     } spu;
114
115     struct
116     {
117         int i_id;
118     } dvb;
119 };
120
121 /**
122  * ES definition
123  */
124 struct es_format_t
125 {
126     int             i_cat;
127     vlc_fourcc_t    i_codec;
128
129     int             i_id;       /* -1: let the core mark the right id
130                                    >=0: valid id */
131     int             i_group;    /* -1 : standalone
132                                    >= 0 then a "group" (program) is created
133                                         for each value */
134     int             i_priority; /*  -2 : mean not selectable by the users
135                                     -1 : mean not selected by default even
136                                         when no other stream
137                                     >=0: priority */
138     char            *psz_language;
139     char            *psz_description;
140
141     audio_format_t audio;
142     video_format_t video;
143     subs_format_t  subs;
144
145     int     i_bitrate;
146
147     int     i_extra;
148     void    *p_extra;
149
150 };
151
152 /* ES Categories */
153 #define UNKNOWN_ES      0x00
154 #define VIDEO_ES        0x01
155 #define AUDIO_ES        0x02
156 #define SPU_ES          0x03
157 #define NAV_ES          0x04
158
159 static inline void es_format_Init( es_format_t *fmt,
160                                    int i_cat, vlc_fourcc_t i_codec )
161 {
162     fmt->i_cat                  = i_cat;
163     fmt->i_codec                = i_codec;
164     fmt->i_id                   = -1;
165     fmt->i_group                = 0;
166     fmt->i_priority             = 0;
167     fmt->psz_language           = NULL;
168     fmt->psz_description        = NULL;
169
170     memset( &fmt->audio, 0, sizeof(audio_format_t) );
171     memset( &fmt->video, 0, sizeof(video_format_t) );
172     memset( &fmt->subs, 0, sizeof(subs_format_t) );
173
174     fmt->i_bitrate              = 0;
175     fmt->i_extra                = 0;
176     fmt->p_extra                = NULL;
177 }
178
179 static inline void es_format_Copy( es_format_t *dst, es_format_t *src )
180 {
181     memcpy( dst, src, sizeof( es_format_t ) );
182     if( src->i_extra > 0 )
183     {
184         dst->p_extra = malloc( src->i_extra );
185         memcpy( dst->p_extra, src->p_extra,
186                 src->i_extra );
187     }
188     else
189     {
190         dst->i_extra = 0;
191         dst->p_extra = NULL;
192     }
193 }
194
195 #endif