comparison libmpdemux/demux_lavf.c @ 31072:b8cccda750cf

uniformize handling of aid and vid with lavf so that it matches handling of sid aid and vid are now 0-based, instead of being a globally unique id. This matches the way sid is handled and the way other demuxers manage aid. As a side effect, it slightly simplifies demux_lavf.
author aurel
date Mon, 03 May 2010 22:19:52 +0000
parents d7c792ed942e
children c35d122852da
comparison
equal deleted inserted replaced
31071:adf57737978c 31072:b8cccda750cf
249 249
250 switch(codec->codec_type){ 250 switch(codec->codec_type){
251 case CODEC_TYPE_AUDIO:{ 251 case CODEC_TYPE_AUDIO:{
252 WAVEFORMATEX *wf; 252 WAVEFORMATEX *wf;
253 sh_audio_t* sh_audio; 253 sh_audio_t* sh_audio;
254 sh_audio=new_sh_audio(demuxer, i); 254 sh_audio = new_sh_audio_aid(demuxer, i, priv->audio_streams);
255 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "lavf", i); 255 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "lavf", priv->audio_streams);
256 if(!sh_audio) 256 if(!sh_audio)
257 break; 257 break;
258 priv->astreams[priv->audio_streams] = i; 258 priv->astreams[priv->audio_streams] = i;
259 priv->audio_streams++;
260 wf= calloc(sizeof(WAVEFORMATEX) + codec->extradata_size, 1); 259 wf= calloc(sizeof(WAVEFORMATEX) + codec->extradata_size, 1);
261 // mp4a tag is used for all mp4 files no matter what they actually contain 260 // mp4a tag is used for all mp4 files no matter what they actually contain
262 if(codec->codec_tag == MKTAG('m', 'p', '4', 'a')) 261 if(codec->codec_tag == MKTAG('m', 'p', '4', 'a'))
263 codec->codec_tag= 0; 262 codec->codec_tag= 0;
264 if(!codec->codec_tag) 263 if(!codec->codec_tag)
308 sh_audio->format = 0x7; 307 sh_audio->format = 0x7;
309 break; 308 break;
310 } 309 }
311 if (lang && lang->value) { 310 if (lang && lang->value) {
312 sh_audio->lang = strdup(lang->value); 311 sh_audio->lang = strdup(lang->value);
313 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", i, sh_audio->lang); 312 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", priv->audio_streams, sh_audio->lang);
314 } 313 }
315 if (st->disposition & AV_DISPOSITION_DEFAULT) 314 if (st->disposition & AV_DISPOSITION_DEFAULT)
316 sh_audio->default_track = 1; 315 sh_audio->default_track = 1;
317 if(mp_msg_test(MSGT_HEADER,MSGL_V) ) print_wave_header(sh_audio->wf, MSGL_V); 316 if(mp_msg_test(MSGT_HEADER,MSGL_V) ) print_wave_header(sh_audio->wf, MSGL_V);
318 // select the first audio stream 317 // select the first audio stream
319 if (!demuxer->audio->sh) { 318 if (!demuxer->audio->sh) {
320 demuxer->audio->id = i; 319 demuxer->audio->id = i;
321 demuxer->audio->sh= demuxer->a_streams[i]; 320 demuxer->audio->sh= demuxer->a_streams[i];
322 } else 321 } else
323 st->discard= AVDISCARD_ALL; 322 st->discard= AVDISCARD_ALL;
323 priv->audio_streams++;
324 break; 324 break;
325 } 325 }
326 case CODEC_TYPE_VIDEO:{ 326 case CODEC_TYPE_VIDEO:{
327 sh_video_t* sh_video; 327 sh_video_t* sh_video;
328 BITMAPINFOHEADER *bih; 328 BITMAPINFOHEADER *bih;
329 sh_video=new_sh_video(demuxer, i); 329 sh_video=new_sh_video_vid(demuxer, i, priv->audio_streams);
330 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_VideoID, "lavf", i); 330 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_VideoID, "lavf", priv->audio_streams);
331 if(!sh_video) break; 331 if(!sh_video) break;
332 priv->vstreams[priv->video_streams] = i; 332 priv->vstreams[priv->video_streams] = i;
333 priv->video_streams++;
334 bih=calloc(sizeof(BITMAPINFOHEADER) + codec->extradata_size,1); 333 bih=calloc(sizeof(BITMAPINFOHEADER) + codec->extradata_size,1);
335 334
336 if(codec->codec_id == CODEC_ID_RAWVIDEO) { 335 if(codec->codec_id == CODEC_ID_RAWVIDEO) {
337 switch (codec->pix_fmt) { 336 switch (codec->pix_fmt) {
338 case PIX_FMT_RGB24: 337 case PIX_FMT_RGB24:
386 st->discard= AVDISCARD_ALL; 385 st->discard= AVDISCARD_ALL;
387 else{ 386 else{
388 demuxer->video->id = i; 387 demuxer->video->id = i;
389 demuxer->video->sh= demuxer->v_streams[i]; 388 demuxer->video->sh= demuxer->v_streams[i];
390 } 389 }
390 priv->video_streams++;
391 break; 391 break;
392 } 392 }
393 case CODEC_TYPE_SUBTITLE:{ 393 case CODEC_TYPE_SUBTITLE:{
394 sh_sub_t* sh_sub; 394 sh_sub_t* sh_sub;
395 char type; 395 char type;
688 if (i >= 0) 688 if (i >= 0)
689 newid = pstreams[i]; 689 newid = pstreams[i];
690 } 690 }
691 else // select track by id 691 else // select track by id
692 { 692 {
693 for(i = 0; i < nstreams; i++) 693 if (id >= 0 && id < nstreams) {
694 { 694 i = id;
695 if(pstreams[i] == id) 695 newid = pstreams[i];
696 {
697 newid = id;
698 break;
699 }
700 } 696 }
701 } 697 }
702 if(i == curridx) 698 if(i == curridx)
703 return DEMUXER_CTRL_NOTIMPL; 699 return DEMUXER_CTRL_NOTIMPL;
704 else 700 else