00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef VLC_ES_H
00025 #define VLC_ES_H 1
00026
00027
00028
00029 #include "vlc_common.h"
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 struct video_palette_t
00042 {
00043 int i_entries;
00044 uint8_t palette[256][4];
00045 };
00046
00047
00048
00049
00050 #define AUDIO_REPLAY_GAIN_MAX (2)
00051 #define AUDIO_REPLAY_GAIN_TRACK (0)
00052 #define AUDIO_REPLAY_GAIN_ALBUM (1)
00053 typedef struct
00054 {
00055
00056 bool pb_peak[AUDIO_REPLAY_GAIN_MAX];
00057
00058 float pf_peak[AUDIO_REPLAY_GAIN_MAX];
00059
00060
00061 bool pb_gain[AUDIO_REPLAY_GAIN_MAX];
00062
00063 float pf_gain[AUDIO_REPLAY_GAIN_MAX];
00064 } audio_replay_gain_t;
00065
00066
00067
00068
00069 struct audio_format_t
00070 {
00071 vlc_fourcc_t i_format;
00072 unsigned int i_rate;
00073
00074
00075
00076 uint32_t i_physical_channels;
00077
00078
00079
00080 uint32_t i_original_channels;
00081
00082
00083
00084 unsigned int i_bytes_per_frame;
00085
00086
00087 unsigned int i_frame_length;
00088
00089
00090
00091
00092
00093
00094
00095 unsigned i_bitspersample;
00096 unsigned i_blockalign;
00097 uint8_t i_channels;
00098 uint8_t i_flavor;
00099 };
00100
00101 #ifdef WORDS_BIGENDIAN
00102 # define AUDIO_FMT_S16_NE VLC_FOURCC('s','1','6','b')
00103 # define AUDIO_FMT_U16_NE VLC_FOURCC('u','1','6','b')
00104 #else
00105 # define AUDIO_FMT_S16_NE VLC_FOURCC('s','1','6','l')
00106 # define AUDIO_FMT_U16_NE VLC_FOURCC('u','1','6','l')
00107 #endif
00108
00109
00110
00111
00112 struct video_format_t
00113 {
00114 vlc_fourcc_t i_chroma;
00115 unsigned int i_aspect;
00116
00117 unsigned int i_width;
00118 unsigned int i_height;
00119 unsigned int i_x_offset;
00120 unsigned int i_y_offset;
00121 unsigned int i_visible_width;
00122 unsigned int i_visible_height;
00123
00124 unsigned int i_bits_per_pixel;
00125
00126 unsigned int i_sar_num;
00127 unsigned int i_sar_den;
00128
00129 unsigned int i_frame_rate;
00130 unsigned int i_frame_rate_base;
00131
00132 int i_rmask, i_gmask, i_bmask;
00133 int i_rrshift, i_lrshift;
00134 int i_rgshift, i_lgshift;
00135 int i_rbshift, i_lbshift;
00136 video_palette_t *p_palette;
00137 };
00138
00139
00140
00141
00142 struct subs_format_t
00143 {
00144
00145
00146 char *psz_encoding;
00147
00148
00149 int i_x_origin;
00150 int i_y_origin;
00151
00152 struct
00153 {
00154
00155 uint32_t palette[16+1];
00156
00157
00158 int i_original_frame_width;
00159
00160 int i_original_frame_height;
00161 } spu;
00162
00163 struct
00164 {
00165 int i_id;
00166 } dvb;
00167 };
00168
00169
00170
00171
00172 typedef struct extra_languages_t
00173 {
00174 char *psz_language;
00175 char *psz_description;
00176 } extra_languages_t;
00177
00178
00179 struct es_format_t
00180 {
00181 int i_cat;
00182 vlc_fourcc_t i_codec;
00183
00184 int i_id;
00185
00186 int i_group;
00187
00188
00189 int i_priority;
00190
00191
00192
00193
00194 char *psz_language;
00195 char *psz_description;
00196 int i_extra_languages;
00197 extra_languages_t *p_extra_languages;
00198
00199 audio_format_t audio;
00200 audio_replay_gain_t audio_replay_gain;
00201 video_format_t video;
00202 subs_format_t subs;
00203
00204 unsigned int i_bitrate;
00205
00206 bool b_packetized;
00207
00208 int i_extra;
00209 void *p_extra;
00210
00211 };
00212
00213
00214 #define UNKNOWN_ES 0x00
00215 #define VIDEO_ES 0x01
00216 #define AUDIO_ES 0x02
00217 #define SPU_ES 0x03
00218 #define NAV_ES 0x04
00219
00220 static inline void es_format_Init( es_format_t *fmt,
00221 int i_cat, vlc_fourcc_t i_codec )
00222 {
00223 fmt->i_cat = i_cat;
00224 fmt->i_codec = i_codec;
00225 fmt->i_id = -1;
00226 fmt->i_group = 0;
00227 fmt->i_priority = 0;
00228 fmt->psz_language = NULL;
00229 fmt->psz_description = NULL;
00230
00231 fmt->i_extra_languages = 0;
00232 fmt->p_extra_languages = NULL;
00233
00234 memset( &fmt->audio, 0, sizeof(audio_format_t) );
00235 memset( &fmt->audio_replay_gain, 0, sizeof(audio_replay_gain_t) );
00236 memset( &fmt->video, 0, sizeof(video_format_t) );
00237 memset( &fmt->subs, 0, sizeof(subs_format_t) );
00238
00239 fmt->b_packetized = true;
00240 fmt->i_bitrate = 0;
00241 fmt->i_extra = 0;
00242 fmt->p_extra = NULL;
00243 }
00244
00245 static inline int es_format_Copy( es_format_t *dst, const es_format_t *src )
00246 {
00247 int i;
00248 memcpy( dst, src, sizeof( es_format_t ) );
00249 if( src->psz_language )
00250 dst->psz_language = strdup( src->psz_language );
00251 if( src->psz_description )
00252 dst->psz_description = strdup( src->psz_description );
00253 if( src->i_extra > 0 )
00254 {
00255 dst->i_extra = src->i_extra;
00256 dst->p_extra = malloc( src->i_extra );
00257 memcpy( dst->p_extra, src->p_extra, src->i_extra );
00258 }
00259 else
00260 {
00261 dst->i_extra = 0;
00262 dst->p_extra = NULL;
00263 }
00264
00265 if( src->subs.psz_encoding )
00266 dst->subs.psz_encoding = strdup( src->subs.psz_encoding );
00267
00268 if( src->video.p_palette )
00269 {
00270 dst->video.p_palette =
00271 (video_palette_t*)malloc( sizeof( video_palette_t ) );
00272 memcpy( dst->video.p_palette, src->video.p_palette,
00273 sizeof( video_palette_t ) );
00274 }
00275
00276 dst->i_extra_languages = src->i_extra_languages;
00277 if( dst->i_extra_languages )
00278 dst->p_extra_languages = (extra_languages_t*)
00279 malloc(dst->i_extra_languages * sizeof(*dst->p_extra_languages ));
00280 for( i = 0; i < dst->i_extra_languages; i++ ) {
00281 if( src->p_extra_languages[i].psz_language )
00282 dst->p_extra_languages[i].psz_language = strdup( src->p_extra_languages[i].psz_language );
00283 else
00284 dst->p_extra_languages[i].psz_language = NULL;
00285 if( src->p_extra_languages[i].psz_description )
00286 dst->p_extra_languages[i].psz_description = strdup( src->p_extra_languages[i].psz_description );
00287 else
00288 dst->p_extra_languages[i].psz_description = NULL;
00289 }
00290 return VLC_SUCCESS;
00291 }
00292
00293 static inline void es_format_Clean( es_format_t *fmt )
00294 {
00295 free( fmt->psz_language );
00296 free( fmt->psz_description );
00297
00298 if( fmt->i_extra > 0 ) free( fmt->p_extra );
00299
00300 free( fmt->video.p_palette );
00301 free( fmt->subs.psz_encoding );
00302
00303 if( fmt->i_extra_languages > 0 && fmt->p_extra_languages )
00304 {
00305 int i;
00306 for( i = 0; i < fmt->i_extra_languages; i++ )
00307 {
00308 free( fmt->p_extra_languages[i].psz_language );
00309 free( fmt->p_extra_languages[i].psz_description );
00310 }
00311 free( fmt->p_extra_languages );
00312 }
00313
00314
00315 memset( fmt, 0, sizeof(*fmt) );
00316 }
00317 #endif