00001 /***************************************************************************** 00002 * vlc_es.h: Elementary stream formats descriptions 00003 ***************************************************************************** 00004 * Copyright (C) 1999-2001 the VideoLAN team 00005 * $Id: b5be71ecf02c37157bbeebc19f7958c34fcef206 $ 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 /* FIXME: i'm not too sure about this include but it fixes compilation of 00028 * video chromas -- dionoea */ 00029 #include "vlc_common.h" 00030 #include <vlc_fourcc.h> 00031 00032 /** 00033 * \file 00034 * This file defines the elementary streams format types 00035 */ 00036 00037 /** 00038 * video palette data 00039 * \see video_format_t 00040 * \see subs_format_t 00041 */ 00042 struct video_palette_t 00043 { 00044 int i_entries; /**< to keep the compatibility with ffmpeg's palette */ 00045 uint8_t palette[256][4]; /**< 4-byte RGBA/YUVA palette */ 00046 }; 00047 00048 /** 00049 * audio replay gain description 00050 */ 00051 #define AUDIO_REPLAY_GAIN_MAX (2) 00052 #define AUDIO_REPLAY_GAIN_TRACK (0) 00053 #define AUDIO_REPLAY_GAIN_ALBUM (1) 00054 typedef struct 00055 { 00056 /* true if we have the peak value */ 00057 bool pb_peak[AUDIO_REPLAY_GAIN_MAX]; 00058 /* peak value where 1.0 means full sample value */ 00059 float pf_peak[AUDIO_REPLAY_GAIN_MAX]; 00060 00061 /* true if we have the gain value */ 00062 bool pb_gain[AUDIO_REPLAY_GAIN_MAX]; 00063 /* gain value in dB */ 00064 float pf_gain[AUDIO_REPLAY_GAIN_MAX]; 00065 } audio_replay_gain_t; 00066 00067 /** 00068 * audio format description 00069 */ 00070 struct audio_format_t 00071 { 00072 vlc_fourcc_t i_format; /**< audio format fourcc */ 00073 unsigned int i_rate; /**< audio sample-rate */ 00074 00075 /* Describes the channels configuration of the samples (ie. number of 00076 * channels which are available in the buffer, and positions). */ 00077 uint32_t i_physical_channels; 00078 00079 /* Describes from which original channels, before downmixing, the 00080 * buffer is derived. */ 00081 uint32_t i_original_channels; 00082 00083 /* Optional - for A/52, SPDIF and DTS types : */ 00084 /* Bytes used by one compressed frame, depends on bitrate. */ 00085 unsigned int i_bytes_per_frame; 00086 00087 /* Number of sampleframes contained in one compressed frame. */ 00088 unsigned int i_frame_length; 00089 /* Please note that it may be completely arbitrary - buffers are not 00090 * obliged to contain a integral number of so-called "frames". It's 00091 * just here for the division : 00092 * buffer_size = i_nb_samples * i_bytes_per_frame / i_frame_length 00093 */ 00094 00095 /* FIXME ? (used by the codecs) */ 00096 unsigned i_bitspersample; 00097 unsigned i_blockalign; 00098 uint8_t i_channels; /* must be <=32 */ 00099 uint8_t i_flavor; 00100 }; 00101 00102 /** 00103 * video format description 00104 */ 00105 struct video_format_t 00106 { 00107 vlc_fourcc_t i_chroma; /**< picture chroma */ 00108 unsigned int i_aspect; /**< aspect ratio */ 00109 00110 unsigned int i_width; /**< picture width */ 00111 unsigned int i_height; /**< picture height */ 00112 unsigned int i_x_offset; /**< start offset of visible area */ 00113 unsigned int i_y_offset; /**< start offset of visible area */ 00114 unsigned int i_visible_width; /**< width of visible area */ 00115 unsigned int i_visible_height; /**< height of visible area */ 00116 00117 unsigned int i_bits_per_pixel; /**< number of bits per pixel */ 00118 00119 unsigned int i_sar_num; /**< sample/pixel aspect ratio */ 00120 unsigned int i_sar_den; 00121 00122 unsigned int i_frame_rate; /**< frame rate numerator */ 00123 unsigned int i_frame_rate_base; /**< frame rate denominator */ 00124 00125 uint32_t i_rmask, i_gmask, i_bmask; /**< color masks for RGB chroma */ 00126 int i_rrshift, i_lrshift; 00127 int i_rgshift, i_lgshift; 00128 int i_rbshift, i_lbshift; 00129 video_palette_t *p_palette; /**< video palette from demuxer */ 00130 }; 00131 00132 /** 00133 * Initialize a video_format_t structure with chroma 'i_chroma' 00134 * \param p_src pointer to video_format_t structure 00135 * \param i_chroma chroma value to use 00136 */ 00137 static inline void video_format_Init( video_format_t *p_src, vlc_fourcc_t i_chroma ) 00138 { 00139 memset( p_src, 0, sizeof( video_format_t ) ); 00140 p_src->i_chroma = i_chroma; 00141 p_src->i_sar_num = p_src->i_sar_den = 1; 00142 p_src->p_palette = NULL; 00143 } 00144 00145 /** 00146 * Copy video_format_t including the palette 00147 * \param p_dst video_format_t to copy to 00148 * \param p_src video_format_t to copy from 00149 */ 00150 static inline int video_format_Copy( video_format_t *p_dst, const video_format_t *p_src ) 00151 { 00152 memcpy( p_dst, p_src, sizeof( *p_dst ) ); 00153 if( p_src->p_palette ) 00154 { 00155 p_dst->p_palette = (video_palette_t *) malloc( sizeof( video_palette_t ) ); 00156 if( !p_dst->p_palette ) 00157 return VLC_ENOMEM; 00158 memcpy( p_dst->p_palette, p_src->p_palette, sizeof( *p_dst->p_palette ) ); 00159 } 00160 return VLC_SUCCESS; 00161 }; 00162 00163 /** 00164 * Cleanup and free palette of this video_format_t 00165 * \param p_src video_format_t structure to clean 00166 */ 00167 static inline void video_format_Clean( video_format_t *p_src ) 00168 { 00169 free( p_src->p_palette ); 00170 memset( p_src, 0, sizeof( video_format_t ) ); 00171 p_src->p_palette = NULL; 00172 } 00173 00174 /** 00175 * It will fill up a video_format_tvideo_format_t using the given arguments. 00176 * Becarefull that the video_format_t must already be initialized. 00177 */ 00178 VLC_EXPORT( void, video_format_Setup, ( video_format_t *, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_aspect ) ); 00179 00180 /** 00181 * This function will check if the first video format is similar 00182 * to the second one. 00183 */ 00184 VLC_EXPORT( bool, video_format_IsSimilar, ( const video_format_t *, 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 00264 bool b_packetized; /**< wether the data is packetized (ie. not truncated) */ 00265 int i_extra; /**< length in bytes of extra data pointer */ 00266 void *p_extra; /**< extra data needed by some decoders or muxers */ 00267 00268 }; 00269 00270 /** ES Categories */ 00271 enum es_format_category_e 00272 { 00273 UNKNOWN_ES = 0x00, 00274 VIDEO_ES = 0x01, 00275 AUDIO_ES = 0x02, 00276 SPU_ES = 0x03, 00277 NAV_ES = 0x04, 00278 }; 00279 00280 /** 00281 * This function will fill all RGB shift from RGB masks. 00282 */ 00283 VLC_EXPORT( void, video_format_FixRgb, ( video_format_t * ) ); 00284 00285 /** 00286 * This function will initialize a es_format_t structure. 00287 */ 00288 VLC_EXPORT( void, es_format_Init, ( es_format_t *, int i_cat, vlc_fourcc_t i_codec ) ); 00289 00290 /** 00291 * This function will initialize a es_format_t structure from a video_format_t. 00292 */ 00293 VLC_EXPORT( void, es_format_InitFromVideo, ( es_format_t *, const video_format_t * ) ); 00294 00295 /** 00296 * This functions will copy a es_format_t. 00297 */ 00298 VLC_EXPORT( int, es_format_Copy, ( es_format_t *p_dst, const es_format_t *p_src ) ); 00299 00300 /** 00301 * This function will clean up a es_format_t and relasing all associated 00302 * resources. 00303 * You can call it multiple times on the same structure. 00304 */ 00305 VLC_EXPORT( void, es_format_Clean, ( es_format_t *fmt ) ); 00306 00307 /** 00308 * This function will check if the first ES format is similar 00309 * to the second one. 00310 * 00311 * All descriptive fields are ignored. 00312 */ 00313 VLC_EXPORT( bool, es_format_IsSimilar, ( const es_format_t *, const es_format_t * ) ); 00314 00315 #endif
1.5.6