comparison mpeg.c @ 496:112057e05179 libavformat

libdts support by (Benjamin Zores <ben at geexbox dot org>)
author michael
date Wed, 14 Jul 2004 01:32:14 +0000
parents f4e9e55f703c
children 558a093b04db
comparison
equal deleted inserted replaced
495:d33ce0cfc81c 496:112057e05179
75 75
76 76
77 #define AUDIO_ID 0xc0 77 #define AUDIO_ID 0xc0
78 #define VIDEO_ID 0xe0 78 #define VIDEO_ID 0xe0
79 #define AC3_ID 0x80 79 #define AC3_ID 0x80
80 #define DTS_ID 0x8a
80 #define LPCM_ID 0xa0 81 #define LPCM_ID 0xa0
81 82
82 static const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 }; 83 static const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 };
83 84
84 #ifdef CONFIG_ENCODERS 85 #ifdef CONFIG_ENCODERS
233 } 234 }
234 235
235 static int mpeg_mux_init(AVFormatContext *ctx) 236 static int mpeg_mux_init(AVFormatContext *ctx)
236 { 237 {
237 MpegMuxContext *s = ctx->priv_data; 238 MpegMuxContext *s = ctx->priv_data;
238 int bitrate, i, mpa_id, mpv_id, ac3_id, lpcm_id, j; 239 int bitrate, i, mpa_id, mpv_id, ac3_id, dts_id, lpcm_id, j;
239 AVStream *st; 240 AVStream *st;
240 StreamInfo *stream; 241 StreamInfo *stream;
241 int audio_bitrate; 242 int audio_bitrate;
242 int video_bitrate; 243 int video_bitrate;
243 244
256 257
257 s->audio_bound = 0; 258 s->audio_bound = 0;
258 s->video_bound = 0; 259 s->video_bound = 0;
259 mpa_id = AUDIO_ID; 260 mpa_id = AUDIO_ID;
260 ac3_id = AC3_ID; 261 ac3_id = AC3_ID;
262 dts_id = DTS_ID;
261 mpv_id = VIDEO_ID; 263 mpv_id = VIDEO_ID;
262 lpcm_id = LPCM_ID; 264 lpcm_id = LPCM_ID;
263 s->scr_stream_index = -1; 265 s->scr_stream_index = -1;
264 for(i=0;i<ctx->nb_streams;i++) { 266 for(i=0;i<ctx->nb_streams;i++) {
265 st = ctx->streams[i]; 267 st = ctx->streams[i];
270 272
271 switch(st->codec.codec_type) { 273 switch(st->codec.codec_type) {
272 case CODEC_TYPE_AUDIO: 274 case CODEC_TYPE_AUDIO:
273 if (st->codec.codec_id == CODEC_ID_AC3) { 275 if (st->codec.codec_id == CODEC_ID_AC3) {
274 stream->id = ac3_id++; 276 stream->id = ac3_id++;
277 } else if (st->codec.codec_id == CODEC_ID_DTS) {
278 stream->id = dts_id++;
275 } else if (st->codec.codec_id == CODEC_ID_PCM_S16BE) { 279 } else if (st->codec.codec_id == CODEC_ID_PCM_S16BE) {
276 stream->id = lpcm_id++; 280 stream->id = lpcm_id++;
277 for(j = 0; j < 4; j++) { 281 for(j = 0; j < 4; j++) {
278 if (lpcm_freq_tab[j] == st->codec.sample_rate) 282 if (lpcm_freq_tab[j] == st->codec.sample_rate)
279 break; 283 break;
1302 type = CODEC_TYPE_VIDEO; 1306 type = CODEC_TYPE_VIDEO;
1303 codec_id = CODEC_ID_MPEG2VIDEO; 1307 codec_id = CODEC_ID_MPEG2VIDEO;
1304 } else if (startcode >= 0x1c0 && startcode <= 0x1df) { 1308 } else if (startcode >= 0x1c0 && startcode <= 0x1df) {
1305 type = CODEC_TYPE_AUDIO; 1309 type = CODEC_TYPE_AUDIO;
1306 codec_id = CODEC_ID_MP2; 1310 codec_id = CODEC_ID_MP2;
1307 } else if (startcode >= 0x80 && startcode <= 0x9f) { 1311 } else if (startcode >= 0x80 && startcode <= 0x89) {
1308 type = CODEC_TYPE_AUDIO; 1312 type = CODEC_TYPE_AUDIO;
1309 codec_id = CODEC_ID_AC3; 1313 codec_id = CODEC_ID_AC3;
1314 } else if (startcode >= 0x8a && startcode <= 0x9f) {
1315 type = CODEC_TYPE_AUDIO;
1316 codec_id = CODEC_ID_DTS;
1310 } else if (startcode >= 0xa0 && startcode <= 0xbf) { 1317 } else if (startcode >= 0xa0 && startcode <= 0xbf) {
1311 type = CODEC_TYPE_AUDIO; 1318 type = CODEC_TYPE_AUDIO;
1312 codec_id = CODEC_ID_PCM_S16BE; 1319 codec_id = CODEC_ID_PCM_S16BE;
1313 } else { 1320 } else {
1314 skip: 1321 skip: