1 /*****************************************************************************
2 * vlc_es.h: Elementary stream formats descriptions
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VideoLAN
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
29 * This file defines the elementary streams format types
37 struct video_palette_t
39 int i_dummy; /**< to keep the compatibility with ffmpeg's palette */
41 uint32_t palette[256]; /**< 4-byte ARGB palette entries, stored in native
46 * audio format description
50 vlc_fourcc_t i_format; /**< audio format fourcc */
51 unsigned int i_rate; /**< audio sample-rate */
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;
57 /* Describes from which original channels, before downmixing, the
58 * buffer is derived. */
59 uint32_t i_original_channels;
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;
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
73 /* FIXME ? (used by the codecs) */
80 * video format description
84 vlc_fourcc_t i_chroma; /**< picture chroma */
85 unsigned int i_aspect; /**< aspect ratio */
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 */
94 unsigned int i_bits_per_pixel; /**< number of bits per pixel */
96 unsigned int i_frame_rate; /**< frame rate numerator */
97 unsigned int i_frame_rate_base; /**< frame rate denominator */
99 video_palette_t *p_palette; /**< video palette from demuxer */
103 * subtitles format description
112 uint32_t palette[16+1];
127 vlc_fourcc_t i_codec;
129 int i_id; /* -1: let the core mark the right id
131 int i_group; /* -1 : standalone
132 >= 0 then a "group" (program) is created
134 int i_priority; /* -2 : mean not selectable by the users
135 -1 : mean not selected by default even
139 char *psz_description;
141 audio_format_t audio;
142 video_format_t video;
147 vlc_bool_t b_packetized; /* wether the data is packetized
148 (ie. not truncated) */
155 #define UNKNOWN_ES 0x00
156 #define VIDEO_ES 0x01
157 #define AUDIO_ES 0x02
161 static inline void es_format_Init( es_format_t *fmt,
162 int i_cat, vlc_fourcc_t i_codec )
165 fmt->i_codec = i_codec;
169 fmt->psz_language = NULL;
170 fmt->psz_description = NULL;
172 memset( &fmt->audio, 0, sizeof(audio_format_t) );
173 memset( &fmt->video, 0, sizeof(video_format_t) );
174 memset( &fmt->subs, 0, sizeof(subs_format_t) );
176 fmt->b_packetized = VLC_TRUE;
182 static inline void es_format_Copy( es_format_t *dst, es_format_t *src )
184 memcpy( dst, src, sizeof( es_format_t ) );
185 if( src->psz_language )
186 dst->psz_language = strdup( src->psz_language );
187 if( src->psz_description )
188 dst->psz_description = strdup( src->psz_description );
189 if( src->i_extra > 0 )
191 dst->i_extra = src->i_extra;
192 dst->p_extra = malloc( src->i_extra );
193 memcpy( dst->p_extra, src->p_extra, src->i_extra );
201 if( src->subs.psz_encoding )
202 dst->subs.psz_encoding = strdup( src->subs.psz_encoding );
204 if( src->video.p_palette )
206 dst->video.p_palette = malloc( sizeof( video_palette_t ) );
207 memcpy( dst->video.p_palette, src->video.p_palette, sizeof( video_palette_t ) );
211 static inline void es_format_Clean( es_format_t *fmt )
213 if( fmt->psz_language ) free( fmt->psz_language );
214 fmt->psz_language = NULL;
216 if( fmt->psz_description ) free( fmt->psz_description );
217 fmt->psz_description = NULL;
219 if( fmt->i_extra > 0 ) free( fmt->p_extra );
220 fmt->i_extra = 0; fmt->p_extra = NULL;
222 if( fmt->video.p_palette ) free( fmt->video.p_palette );
223 fmt->video.p_palette = NULL;
225 if( fmt->subs.psz_encoding ) free( fmt->subs.psz_encoding );
226 fmt->subs.psz_encoding = NULL;