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_entries; /**< to keep the compatibility with ffmpeg's palette */
40 uint8_t palette[256][4]; /**< 4-byte RGBA/YUVA palette */
44 * audio format description
48 vlc_fourcc_t i_format; /**< audio format fourcc */
49 unsigned int i_rate; /**< audio sample-rate */
51 /* Describes the channels configuration of the samples (ie. number of
52 * channels which are available in the buffer, and positions). */
53 uint32_t i_physical_channels;
55 /* Describes from which original channels, before downmixing, the
56 * buffer is derived. */
57 uint32_t i_original_channels;
59 /* Optional - for A/52, SPDIF and DTS types : */
60 /* Bytes used by one compressed frame, depends on bitrate. */
61 unsigned int i_bytes_per_frame;
63 /* Number of sampleframes contained in one compressed frame. */
64 unsigned int i_frame_length;
65 /* Please note that it may be completely arbitrary - buffers are not
66 * obliged to contain a integral number of so-called "frames". It's
67 * just here for the division :
68 * buffer_size = i_nb_samples * i_bytes_per_frame / i_frame_length
71 /* FIXME ? (used by the codecs) */
78 * video format description
82 vlc_fourcc_t i_chroma; /**< picture chroma */
83 unsigned int i_aspect; /**< aspect ratio */
85 unsigned int i_width; /**< picture width */
86 unsigned int i_height; /**< picture height */
87 unsigned int i_x_offset; /**< start offset of visible area */
88 unsigned int i_y_offset; /**< start offset of visible area */
89 unsigned int i_visible_width; /**< width of visible area */
90 unsigned int i_visible_height; /**< height of visible area */
92 unsigned int i_bits_per_pixel; /**< number of bits per pixel */
94 unsigned int i_frame_rate; /**< frame rate numerator */
95 unsigned int i_frame_rate_base; /**< frame rate denominator */
97 int i_rmask, i_rgmask, i_bmask; /**< color masks for RGB chroma */
98 video_palette_t *p_palette; /**< video palette from demuxer */
102 * subtitles format description
111 uint32_t palette[16+1];
126 vlc_fourcc_t i_codec;
128 int i_id; /* -1: let the core mark the right id
130 int i_group; /* -1 : standalone
131 >= 0 then a "group" (program) is created
133 int i_priority; /* -2 : mean not selectable by the users
134 -1 : mean not selected by default even
138 char *psz_description;
140 audio_format_t audio;
141 video_format_t video;
146 vlc_bool_t b_packetized; /* wether the data is packetized
147 (ie. not truncated) */
154 #define UNKNOWN_ES 0x00
155 #define VIDEO_ES 0x01
156 #define AUDIO_ES 0x02
160 static inline void es_format_Init( es_format_t *fmt,
161 int i_cat, vlc_fourcc_t i_codec )
164 fmt->i_codec = i_codec;
168 fmt->psz_language = NULL;
169 fmt->psz_description = NULL;
171 memset( &fmt->audio, 0, sizeof(audio_format_t) );
172 memset( &fmt->video, 0, sizeof(video_format_t) );
173 memset( &fmt->subs, 0, sizeof(subs_format_t) );
175 fmt->b_packetized = VLC_TRUE;
181 static inline void es_format_Copy( es_format_t *dst, es_format_t *src )
183 memcpy( dst, src, sizeof( es_format_t ) );
184 if( src->psz_language )
185 dst->psz_language = strdup( src->psz_language );
186 if( src->psz_description )
187 dst->psz_description = strdup( src->psz_description );
188 if( src->i_extra > 0 )
190 dst->i_extra = src->i_extra;
191 dst->p_extra = malloc( src->i_extra );
192 memcpy( dst->p_extra, src->p_extra, src->i_extra );
200 if( src->subs.psz_encoding )
201 dst->subs.psz_encoding = strdup( src->subs.psz_encoding );
203 if( src->video.p_palette )
205 dst->video.p_palette = (video_palette_t*)malloc( sizeof( video_palette_t ) );
206 memcpy( dst->video.p_palette, src->video.p_palette, sizeof( video_palette_t ) );
210 static inline void es_format_Clean( es_format_t *fmt )
212 if( fmt->psz_language ) free( fmt->psz_language );
213 fmt->psz_language = NULL;
215 if( fmt->psz_description ) free( fmt->psz_description );
216 fmt->psz_description = NULL;
218 if( fmt->i_extra > 0 ) free( fmt->p_extra );
219 fmt->i_extra = 0; fmt->p_extra = NULL;
221 if( fmt->video.p_palette ) free( fmt->video.p_palette );
222 fmt->video.p_palette = NULL;
224 if( fmt->subs.psz_encoding ) free( fmt->subs.psz_encoding );
225 fmt->subs.psz_encoding = NULL;