00001 /***************************************************************************** 00002 * vlc_es.h: Elementary stream formats descriptions 00003 ***************************************************************************** 00004 * Copyright (C) 1999-2001 the VideoLAN team 00005 * $Id: 556b4143f10582ce6caa5b359c71da07f04af316 $ 00006 * 00007 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00022 *****************************************************************************/ 00023 00024 #ifndef VLC_ES_H 00025 #define VLC_ES_H 1 00026 00027 #include <vlc_fourcc.h> 00028 00029 /** 00030 * \file 00031 * This file defines the elementary streams format types 00032 */ 00033 00034 /** 00035 * video palette data 00036 * \see video_format_t 00037 * \see subs_format_t 00038 */ 00039 struct video_palette_t 00040 { 00041 int i_entries; /**< to keep the compatibility with ffmpeg's palette */ 00042 uint8_t palette[256][4]; /**< 4-byte RGBA/YUVA palette */ 00043 }; 00044 00045 /** 00046 * audio replay gain description 00047 */ 00048 #define AUDIO_REPLAY_GAIN_MAX (2) 00049 #define AUDIO_REPLAY_GAIN_TRACK (0) 00050 #define AUDIO_REPLAY_GAIN_ALBUM (1) 00051 typedef struct 00052 { 00053 /* true if we have the peak value */ 00054 bool pb_peak[AUDIO_REPLAY_GAIN_MAX]; 00055 /* peak value where 1.0 means full sample value */ 00056 float pf_peak[AUDIO_REPLAY_GAIN_MAX]; 00057 00058 /* true if we have the gain value */ 00059 bool pb_gain[AUDIO_REPLAY_GAIN_MAX]; 00060 /* gain value in dB */ 00061 float pf_gain[AUDIO_REPLAY_GAIN_MAX]; 00062 } audio_replay_gain_t; 00063 00064 /** 00065 * audio format description 00066 */ 00067 struct audio_format_t 00068 { 00069 vlc_fourcc_t i_format; /**< audio format fourcc */ 00070 unsigned int i_rate; /**< audio sample-rate */ 00071 00072 /* Describes the channels configuration of the samples (ie. number of 00073 * channels which are available in the buffer, and positions). */ 00074 uint32_t i_physical_channels; 00075 00076 /* Describes from which original channels, before downmixing, the 00077 * buffer is derived. */ 00078 uint32_t i_original_channels; 00079 00080 /* Optional - for A/52, SPDIF and DTS types : */ 00081 /* Bytes used by one compressed frame, depends on bitrate. */ 00082 unsigned int i_bytes_per_frame; 00083 00084 /* Number of sampleframes contained in one compressed frame. */ 00085 unsigned int i_frame_length; 00086 /* Please note that it may be completely arbitrary - buffers are not 00087 * obliged to contain a integral number of so-called "frames". It's 00088 * just here for the division : 00089 * buffer_size = i_nb_samples * i_bytes_per_frame / i_frame_length 00090 */ 00091 00092 /* FIXME ? (used by the codecs) */ 00093 unsigned i_bitspersample; 00094 unsigned i_blockalign; 00095 uint8_t i_channels; /* must be <=32 */ 00096 }; 00097 00098 /** 00099 * video format description 00100 */ 00101 struct video_format_t 00102 { 00103 vlc_fourcc_t i_chroma; /**< picture chroma */ 00104 00105 unsigned int i_width; /**< picture width */ 00106 unsigned int i_height; /**< picture height */ 00107 unsigned int i_x_offset; /**< start offset of visible area */ 00108 unsigned int i_y_offset; /**< start offset of visible area */ 00109 unsigned int i_visible_width; /**< width of visible area */ 00110 unsigned int i_visible_height; /**< height of visible area */ 00111 00112 unsigned int i_bits_per_pixel; /**< number of bits per pixel */ 00113 00114 unsigned int i_sar_num; /**< sample/pixel aspect ratio */ 00115 unsigned int i_sar_den; 00116 00117 unsigned int i_frame_rate; /**< frame rate numerator */ 00118 unsigned int i_frame_rate_base; /**< frame rate denominator */ 00119 00120 uint32_t i_rmask, i_gmask, i_bmask; /**< color masks for RGB chroma */ 00121 int i_rrshift, i_lrshift; 00122 int i_rgshift, i_lgshift; 00123 int i_rbshift, i_lbshift; 00124 video_palette_t *p_palette; /**< video palette from demuxer */ 00125 }; 00126 00127 /** 00128 * Initialize a video_format_t structure with chroma 'i_chroma' 00129 * \param p_src pointer to video_format_t structure 00130 * \param i_chroma chroma value to use 00131 */ 00132 static inline void video_format_Init( video_format_t *p_src, vlc_fourcc_t i_chroma ) 00133 { 00134 memset( p_src, 0, sizeof( video_format_t ) ); 00135 p_src->i_chroma = i_chroma; 00136 p_src->i_sar_num = p_src->i_sar_den = 1; 00137 p_src->p_palette = NULL; 00138 } 00139 00140 /** 00141 * Copy video_format_t including the palette 00142 * \param p_dst video_format_t to copy to 00143 * \param p_src video_format_t to copy from 00144 */ 00145 static inline int video_format_Copy( video_format_t *p_dst, const video_format_t *p_src ) 00146 { 00147 memcpy( p_dst, p_src, sizeof( *p_dst ) ); 00148 if( p_src->p_palette ) 00149 { 00150 p_dst->p_palette = (video_palette_t *) malloc( sizeof( video_palette_t ) ); 00151 if( !p_dst->p_palette ) 00152 return VLC_ENOMEM; 00153 memcpy( p_dst->p_palette, p_src->p_palette, sizeof( *p_dst->p_palette ) ); 00154 } 00155 return VLC_SUCCESS; 00156 } 00157 00158 /** 00159 * Cleanup and free palette of this video_format_t 00160 * \param p_src video_format_t structure to clean 00161 */ 00162 static inline void video_format_Clean( video_format_t *p_src ) 00163 { 00164 free( p_src->p_palette ); 00165 memset( p_src, 0, sizeof( video_format_t ) ); 00166 p_src->p_palette = NULL; 00167 } 00168 00169 /** 00170 * It will fill up a video_format_tvideo_format_t using the given arguments. 00171 * Becarefull that the video_format_t must already be initialized. 00172 */ 00173 VLC_EXPORT( void, video_format_Setup, ( video_format_t *, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den ) ); 00174 00175 /** 00176 * This function will check if the first video format is similar 00177 * to the second one. 00178 */ 00179 VLC_EXPORT( bool, video_format_IsSimilar, ( const video_format_t *, const video_format_t * ) ); 00180 00181 /** 00182 * It prints details about the given video_format_t 00183 */ 00184 VLC_EXPORT( void, video_format_Print, ( vlc_object_t *, const char *, const video_format_t * ) ); 00185 00186 /** 00187 * subtitles format description 00188 */ 00189 struct subs_format_t 00190 { 00191 /* the character encoding of the text of the subtitle. 00192 * all gettext recognized shorts can be used */ 00193 char *psz_encoding; 00194 00195 00196 int i_x_origin; /**< x coordinate of the subtitle. 0 = left */ 00197 int i_y_origin; /**< y coordinate of the subtitle. 0 = top */ 00198 00199 struct 00200 { 00201 /* */ 00202 uint32_t palette[16+1]; 00203 00204 /* the width of the original movie the spu was extracted from */ 00205 int i_original_frame_width; 00206 /* the height of the original movie the spu was extracted from */ 00207 int i_original_frame_height; 00208 } spu; 00209 00210 struct 00211 { 00212 int i_id; 00213 } dvb; 00214 struct 00215 { 00216 int i_magazine; 00217 int i_page; 00218 } teletext; 00219 }; 00220 00221 /** 00222 * ES language definition 00223 */ 00224 typedef struct extra_languages_t 00225 { 00226 char *psz_language; 00227 char *psz_description; 00228 } extra_languages_t; 00229 00230 /** 00231 * ES format definition 00232 */ 00233 struct es_format_t 00234 { 00235 int i_cat; /**< ES category @see es_format_category_e */ 00236 vlc_fourcc_t i_codec; /**< FOURCC value as used in vlc */ 00237 vlc_fourcc_t i_original_fourcc; /**< original FOURCC from the container */ 00238 00239 int i_id; /**< es identifier, where means 00240 -1: let the core mark the right id 00241 >=0: valid id */ 00242 int i_group; /**< group identifier, where means: 00243 -1 : standalone 00244 >= 0 then a "group" (program) is created 00245 for each value */ 00246 int i_priority; /**< priority, where means: 00247 -2 : mean not selectable by the users 00248 -1 : mean not selected by default even 00249 when no other stream 00250 >=0: priority */ 00251 00252 char *psz_language; /**< human readible language name */ 00253 char *psz_description; /**< human readible description of language */ 00254 int i_extra_languages; /**< length in bytes of extra language data pointer */ 00255 extra_languages_t *p_extra_languages; /**< extra language data needed by some decoders */ 00256 00257 audio_format_t audio; /**< description of audio format */ 00258 audio_replay_gain_t audio_replay_gain; /*< audio replay gain information */ 00259 video_format_t video; /**< description of video format */ 00260 subs_format_t subs; /**< description of subtitle format */ 00261 00262 unsigned int i_bitrate; /**< bitrate of this ES */ 00263 int i_profile; /**< codec specific information (like real audio flavor, mpeg audio layer, h264 profile ...) */ 00264 int i_level; /**< codec specific information: indicates maximum restrictions on the stream (resolution, bitrate, codec features ...) */ 00265 00266 bool b_packetized; /**< wether the data is packetized (ie. not truncated) */ 00267 int i_extra; /**< length in bytes of extra data pointer */ 00268 void *p_extra; /**< extra data needed by some decoders or muxers */ 00269 00270 }; 00271 00272 /** ES Categories */ 00273 enum es_format_category_e 00274 { 00275 UNKNOWN_ES = 0x00, 00276 VIDEO_ES = 0x01, 00277 AUDIO_ES = 0x02, 00278 SPU_ES = 0x03, 00279 NAV_ES = 0x04, 00280 }; 00281 00282 /** 00283 * This function will fill all RGB shift from RGB masks. 00284 */ 00285 VLC_EXPORT( void, video_format_FixRgb, ( video_format_t * ) ); 00286 00287 /** 00288 * This function will initialize a es_format_t structure. 00289 */ 00290 VLC_EXPORT( void, es_format_Init, ( es_format_t *, int i_cat, vlc_fourcc_t i_codec ) ); 00291 00292 /** 00293 * This function will initialize a es_format_t structure from a video_format_t. 00294 */ 00295 VLC_EXPORT( void, es_format_InitFromVideo, ( es_format_t *, const video_format_t * ) ); 00296 00297 /** 00298 * This functions will copy a es_format_t. 00299 */ 00300 VLC_EXPORT( int, es_format_Copy, ( es_format_t *p_dst, const es_format_t *p_src ) ); 00301 00302 /** 00303 * This function will clean up a es_format_t and relasing all associated 00304 * resources. 00305 * You can call it multiple times on the same structure. 00306 */ 00307 VLC_EXPORT( void, es_format_Clean, ( es_format_t *fmt ) ); 00308 00309 /** 00310 * This function will check if the first ES format is similar 00311 * to the second one. 00312 * 00313 * All descriptive fields are ignored. 00314 */ 00315 VLC_EXPORT( bool, es_format_IsSimilar, ( const es_format_t *, const es_format_t * ) ); 00316 00317 #endif
1.5.6