http: psz_dir is not meant to be a const
[vlc.git] / include / vlc_es.h
blobde43864f5a31562924f1b8beabf1ecd258c38f12
1 /*****************************************************************************
2 * vlc_es.h: Elementary stream formats descriptions
3 *****************************************************************************
4 * Copyright (C) 1999-2001 the VideoLAN team
5 * $Id$
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #if !defined( __LIBVLC__ )
25 #error You are not libvlc or one of its plugins. You cannot include this file
26 #endif
28 #ifndef _VLC_ES_H
29 #define _VLC_ES_H 1
31 /**
32 * \file
33 * This file defines the elementary streams format types
36 /**
37 * video palette data
38 * \see video_format_t
39 * \see subs_format_t
41 struct video_palette_t
43 int i_entries; /**< to keep the compatibility with ffmpeg's palette */
44 uint8_t palette[256][4]; /**< 4-byte RGBA/YUVA palette */
47 /**
48 * audio replay gain description
50 #define AUDIO_REPLAY_GAIN_MAX (2)
51 #define AUDIO_REPLAY_GAIN_TRACK (0)
52 #define AUDIO_REPLAY_GAIN_ALBUM (1)
53 typedef struct
55 /* true if we have the peak value */
56 vlc_bool_t pb_peak[AUDIO_REPLAY_GAIN_MAX];
57 /* peak value where 1.0 means full sample value */
58 float pf_peak[AUDIO_REPLAY_GAIN_MAX];
60 /* true if we have the gain value */
61 vlc_bool_t pb_gain[AUDIO_REPLAY_GAIN_MAX];
62 /* gain value in dB */
63 float pf_gain[AUDIO_REPLAY_GAIN_MAX];
64 } audio_replay_gain_t;
66 /**
67 * audio format description
69 struct audio_format_t
71 vlc_fourcc_t i_format; /**< audio format fourcc */
72 unsigned int i_rate; /**< audio sample-rate */
74 /* Describes the channels configuration of the samples (ie. number of
75 * channels which are available in the buffer, and positions). */
76 uint32_t i_physical_channels;
78 /* Describes from which original channels, before downmixing, the
79 * buffer is derived. */
80 uint32_t i_original_channels;
82 /* Optional - for A/52, SPDIF and DTS types : */
83 /* Bytes used by one compressed frame, depends on bitrate. */
84 unsigned int i_bytes_per_frame;
86 /* Number of sampleframes contained in one compressed frame. */
87 unsigned int i_frame_length;
88 /* Please note that it may be completely arbitrary - buffers are not
89 * obliged to contain a integral number of so-called "frames". It's
90 * just here for the division :
91 * buffer_size = i_nb_samples * i_bytes_per_frame / i_frame_length
94 /* FIXME ? (used by the codecs) */
95 unsigned i_bitspersample;
96 unsigned i_blockalign;
97 uint8_t i_channels; /* must be <=32 */
100 #ifdef WORDS_BIGENDIAN
101 # define AUDIO_FMT_S16_NE VLC_FOURCC('s','1','6','b')
102 # define AUDIO_FMT_U16_NE VLC_FOURCC('u','1','6','b')
103 #else
104 # define AUDIO_FMT_S16_NE VLC_FOURCC('s','1','6','l')
105 # define AUDIO_FMT_U16_NE VLC_FOURCC('u','1','6','l')
106 #endif
109 * video format description
111 struct video_format_t
113 vlc_fourcc_t i_chroma; /**< picture chroma */
114 unsigned int i_aspect; /**< aspect ratio */
116 unsigned int i_width; /**< picture width */
117 unsigned int i_height; /**< picture height */
118 unsigned int i_x_offset; /**< start offset of visible area */
119 unsigned int i_y_offset; /**< start offset of visible area */
120 unsigned int i_visible_width; /**< width of visible area */
121 unsigned int i_visible_height; /**< height of visible area */
123 unsigned int i_bits_per_pixel; /**< number of bits per pixel */
125 unsigned int i_sar_num; /**< sample/pixel aspect ratio */
126 unsigned int i_sar_den;
128 unsigned int i_frame_rate; /**< frame rate numerator */
129 unsigned int i_frame_rate_base; /**< frame rate denominator */
131 int i_rmask, i_gmask, i_bmask; /**< color masks for RGB chroma */
132 video_palette_t *p_palette; /**< video palette from demuxer */
136 * subtitles format description
138 struct subs_format_t
140 /* the character encoding of the text of the subtitle.
141 * all gettext recognized shorts can be used */
142 char *psz_encoding;
145 int i_x_origin; /**< x coordinate of the subtitle. 0 = left */
146 int i_y_origin; /**< y coordinate of the subtitle. 0 = top */
148 struct
150 /* */
151 uint32_t palette[16+1];
153 /* the width of the original movie the spu was extracted from */
154 int i_original_frame_width;
155 /* the height of the original movie the spu was extracted from */
156 int i_original_frame_height;
157 } spu;
159 struct
161 int i_id;
162 } dvb;
166 * ES definition
168 typedef struct extra_languages_t
170 char *psz_language;
171 char *psz_description;
172 } extra_languages_t;
175 struct es_format_t
177 int i_cat;
178 vlc_fourcc_t i_codec;
180 int i_id; /* -1: let the core mark the right id
181 >=0: valid id */
182 int i_group; /* -1 : standalone
183 >= 0 then a "group" (program) is created
184 for each value */
185 int i_priority; /* -2 : mean not selectable by the users
186 -1 : mean not selected by default even
187 when no other stream
188 >=0: priority */
190 char *psz_language;
191 char *psz_description;
192 int i_extra_languages;
193 extra_languages_t *p_extra_languages;
195 audio_format_t audio;
196 audio_replay_gain_t audio_replay_gain;
197 video_format_t video;
198 subs_format_t subs;
200 unsigned int i_bitrate;
202 vlc_bool_t b_packetized; /* wether the data is packetized
203 (ie. not truncated) */
204 int i_extra;
205 void *p_extra;
209 /* ES Categories */
210 #define UNKNOWN_ES 0x00
211 #define VIDEO_ES 0x01
212 #define AUDIO_ES 0x02
213 #define SPU_ES 0x03
214 #define NAV_ES 0x04
216 static inline void es_format_Init( es_format_t *fmt,
217 int i_cat, vlc_fourcc_t i_codec )
219 fmt->i_cat = i_cat;
220 fmt->i_codec = i_codec;
221 fmt->i_id = -1;
222 fmt->i_group = 0;
223 fmt->i_priority = 0;
224 fmt->psz_language = NULL;
225 fmt->psz_description = NULL;
227 fmt->i_extra_languages = 0;
228 fmt->p_extra_languages = NULL;
230 memset( &fmt->audio, 0, sizeof(audio_format_t) );
231 memset( &fmt->audio_replay_gain, 0, sizeof(audio_replay_gain_t) );
232 memset( &fmt->video, 0, sizeof(video_format_t) );
233 memset( &fmt->subs, 0, sizeof(subs_format_t) );
235 fmt->b_packetized = VLC_TRUE;
236 fmt->i_bitrate = 0;
237 fmt->i_extra = 0;
238 fmt->p_extra = NULL;
241 static inline void es_format_Copy( es_format_t *dst, es_format_t *src )
243 int i;
244 memcpy( dst, src, sizeof( es_format_t ) );
245 if( src->psz_language )
246 dst->psz_language = strdup( src->psz_language );
247 if( src->psz_description )
248 dst->psz_description = strdup( src->psz_description );
249 if( src->i_extra > 0 )
251 dst->i_extra = src->i_extra;
252 dst->p_extra = malloc( src->i_extra );
253 memcpy( dst->p_extra, src->p_extra, src->i_extra );
255 else
257 dst->i_extra = 0;
258 dst->p_extra = NULL;
261 if( src->subs.psz_encoding )
262 dst->subs.psz_encoding = strdup( src->subs.psz_encoding );
264 if( src->video.p_palette )
266 dst->video.p_palette =
267 (video_palette_t*)malloc( sizeof( video_palette_t ) );
268 memcpy( dst->video.p_palette, src->video.p_palette,
269 sizeof( video_palette_t ) );
272 dst->i_extra_languages = src->i_extra_languages;
273 if( dst->i_extra_languages )
274 dst->p_extra_languages = (extra_languages_t*)
275 malloc(dst->i_extra_languages * sizeof(*dst->p_extra_languages ));
276 for( i = 0; i < dst->i_extra_languages; i++ ) {
277 if( src->p_extra_languages[i].psz_language )
278 dst->p_extra_languages[i].psz_language = strdup(src->p_extra_languages[i].psz_language);
279 else
280 dst->p_extra_languages[i].psz_language = NULL;
281 if( src->p_extra_languages[i].psz_description )
282 dst->p_extra_languages[i].psz_description = strdup(src->p_extra_languages[i].psz_description);
283 else
284 dst->p_extra_languages[i].psz_description = NULL;
288 static inline void es_format_Clean( es_format_t *fmt )
290 if( fmt->psz_language ) free( fmt->psz_language );
292 if( fmt->psz_description ) free( fmt->psz_description );
294 if( fmt->i_extra > 0 ) free( fmt->p_extra );
296 if( fmt->video.p_palette )
297 free( fmt->video.p_palette );
299 if( fmt->subs.psz_encoding ) free( fmt->subs.psz_encoding );
301 if( fmt->i_extra_languages > 0 && fmt->p_extra_languages )
303 int i;
304 for( i = 0; i < fmt->i_extra_languages; i++ )
306 if( fmt->p_extra_languages[i].psz_language )
307 free( fmt->p_extra_languages[i].psz_language );
308 if( fmt->p_extra_languages[i].psz_description )
309 free( fmt->p_extra_languages[i].psz_description );
311 free(fmt->p_extra_languages);
314 /* es_format_Clean can be called multiple times */
315 memset( fmt, 0, sizeof(*fmt) );
317 #endif