comparison libmpdemux/demux_avi.c @ 6871:88953ff93743

count blocks by rounded-up chunksizes instead of chunks - we need full emulation of dshow avi demuxer bugs :( fixes silly nandub-style a-v delaying in avi with vbr mp3...
author arpi
date Fri, 02 Aug 2002 17:44:16 +0000
parents f01e5cefb828
children 37946a0a155a
comparison
equal deleted inserted replaced
6870:dad5f8b3e8a0 6871:88953ff93743
31 31
32 if(stream_id==demux->audio->id){ 32 if(stream_id==demux->audio->id){
33 if(!demux->audio->sh){ 33 if(!demux->audio->sh){
34 demux->audio->sh=demux->a_streams[stream_id]; 34 demux->audio->sh=demux->a_streams[stream_id];
35 mp_msg(MSGT_DEMUX,MSGL_V,"Auto-selected AVI audio ID = %d\n",demux->audio->id); 35 mp_msg(MSGT_DEMUX,MSGL_V,"Auto-selected AVI audio ID = %d\n",demux->audio->id);
36 demux->audio->block_size=((sh_audio_t*)(demux->audio->sh))->wf->nBlockAlign;
37 //printf("&&&&& setting blocksize to %d &&&&&\n",demux->audio->block_size);
36 } 38 }
37 return demux->audio; 39 return demux->audio;
38 } 40 }
39 if(stream_id==demux->video->id){ 41 if(stream_id==demux->video->id){
40 if(!demux->video->sh){ 42 if(!demux->video->sh){
600 mp_msg(MSGT_SEEK,MSGL_DBG2,"V_SEEK: pack=%d pts=%5.3f chunk=%d \n",d_video->pack_no,priv->avi_video_pts,video_chunk_pos); 602 mp_msg(MSGT_SEEK,MSGL_DBG2,"V_SEEK: pack=%d pts=%5.3f chunk=%d \n",d_video->pack_no,priv->avi_video_pts,video_chunk_pos);
601 603
602 // ------------ STEP 2: seek audio, find the right chunk & pos ------------ 604 // ------------ STEP 2: seek audio, find the right chunk & pos ------------
603 605
604 d_audio->pack_no=0; 606 d_audio->pack_no=0;
607 d_audio->block_no=0;
605 d_audio->dpos=0; 608 d_audio->dpos=0;
606 609
607 if(sh_audio){ 610 if(sh_audio){
608 int i; 611 int i;
609 // int apos=0; 612 // int apos=0;
634 for(i=0;i<chunk_max;i++){ 637 for(i=0;i<chunk_max;i++){
635 int id=((AVIINDEXENTRY *)priv->idx)[i].ckid; 638 int id=((AVIINDEXENTRY *)priv->idx)[i].ckid;
636 if(avi_stream_id(id)==d_audio->id){ 639 if(avi_stream_id(id)==d_audio->id){
637 len=((AVIINDEXENTRY *)priv->idx)[i].dwChunkLength; 640 len=((AVIINDEXENTRY *)priv->idx)[i].dwChunkLength;
638 ++d_audio->pack_no; 641 ++d_audio->pack_no;
642 d_audio->block_no+=(len+d_audio->block_size-1)/d_audio->block_size;
639 if(d_audio->dpos<=curr_audio_pos && curr_audio_pos<(d_audio->dpos+len)){ 643 if(d_audio->dpos<=curr_audio_pos && curr_audio_pos<(d_audio->dpos+len)){
640 break; 644 break;
641 } 645 }
642 d_audio->dpos+=len; 646 d_audio->dpos+=len;
643 } 647 }
660 len=((AVIINDEXENTRY *)priv->idx)[i].dwChunkLength; 664 len=((AVIINDEXENTRY *)priv->idx)[i].dwChunkLength;
661 if(i>chunk_max){ 665 if(i>chunk_max){
662 skip_audio_bytes+=len; 666 skip_audio_bytes+=len;
663 } else { 667 } else {
664 ++d_audio->pack_no; 668 ++d_audio->pack_no;
669 d_audio->block_no+=(len+d_audio->block_size-1)/d_audio->block_size;
665 d_audio->dpos+=len; 670 d_audio->dpos+=len;
666 audio_chunk_pos=i; 671 audio_chunk_pos=i;
667 } 672 }
668 --chunks; 673 // --chunks;
674 chunks-=(len+d_audio->block_size-1)/d_audio->block_size;
669 } 675 }
670 } 676 }
671 //if(audio_chunk_pos>chunk_max) audio_chunk_pos=chunk_max; 677 //if(audio_chunk_pos>chunk_max) audio_chunk_pos=chunk_max;
672 678
673 // printf("VBR seek: %5.3f -> chunk_no %d -> chunk_idx %d + skip %d \n", 679 // printf("VBR seek: %5.3f -> chunk_no %d -> chunk_idx %d + skip %d \n",