Mercurial > mplayer.hg
comparison libmpdemux/demux_avi.c @ 8208:ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
asf, avi, mpeg demuxers.
patch by Balatoni Denes <pnis@coder.hu>
author | arpi |
---|---|
date | Sat, 16 Nov 2002 03:42:14 +0000 |
parents | 9fc45fe0d444 |
children | 772d6d27fd66 |
comparison
equal
deleted
inserted
replaced
8207:467ffae428b0 | 8208:ae5a2ae1c349 |
---|---|
550 // calculating video bitrate: | 550 // calculating video bitrate: |
551 sh_video->i_bps=demuxer->movi_end-demuxer->movi_start-priv->idx_size*8; | 551 sh_video->i_bps=demuxer->movi_end-demuxer->movi_start-priv->idx_size*8; |
552 if(sh_audio) sh_video->i_bps-=sh_audio->audio.dwLength; | 552 if(sh_audio) sh_video->i_bps-=sh_audio->audio.dwLength; |
553 mp_msg(MSGT_DEMUX,MSGL_V,"AVI video length=%lu\n",(unsigned long)sh_video->i_bps); | 553 mp_msg(MSGT_DEMUX,MSGL_V,"AVI video length=%lu\n",(unsigned long)sh_video->i_bps); |
554 sh_video->i_bps=((float)sh_video->i_bps/(float)sh_video->video.dwLength)*sh_video->fps; | 554 sh_video->i_bps=((float)sh_video->i_bps/(float)sh_video->video.dwLength)*sh_video->fps; |
555 | |
556 if((priv->numberofframes=sh_video->video.dwLength)<=1) | |
557 // bad video header, try to get number of frames from audio | |
558 if(sh_audio && sh_audio->wf->nAvgBytesPerSec) priv->numberofframes=sh_video->fps*sh_audio->audio.dwLength/sh_audio->wf->nAvgBytesPerSec; | |
559 if(priv->numberofframes<=1){ | |
560 mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CouldntDetFNo); | |
561 priv->numberofframes=0; | |
562 } | |
563 | |
555 mp_msg(MSGT_DEMUX,MSGL_INFO,"VIDEO: [%.4s] %ldx%ld %dbpp %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n", | 564 mp_msg(MSGT_DEMUX,MSGL_INFO,"VIDEO: [%.4s] %ldx%ld %dbpp %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n", |
556 (char *)&sh_video->bih->biCompression, | 565 (char *)&sh_video->bih->biCompression, |
557 sh_video->bih->biWidth, | 566 sh_video->bih->biWidth, |
558 sh_video->bih->biHeight, | 567 sh_video->bih->biHeight, |
559 sh_video->bih->biBitCount, | 568 sh_video->bih->biBitCount, |
586 // seek absolute | 595 // seek absolute |
587 video_chunk_pos=0; | 596 video_chunk_pos=0; |
588 } | 597 } |
589 | 598 |
590 if(flags&2){ | 599 if(flags&2){ |
591 // float 0..1 | 600 rel_seek_frames=rel_seek_secs*priv->numberofframes; |
592 int total=sh_video->video.dwLength; | |
593 if(total<=1){ | |
594 // bad video header, try to get it from audio | |
595 if(sh_audio) total=sh_video->fps*sh_audio->audio.dwLength/sh_audio->wf->nAvgBytesPerSec; | |
596 if(total<=1){ | |
597 mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CouldntDetFNo); | |
598 total=0; | |
599 } | |
600 } | |
601 rel_seek_frames=rel_seek_secs*total; | |
602 } | 601 } |
603 | 602 |
604 priv->skip_video_frames=0; | 603 priv->skip_video_frames=0; |
605 priv->avi_audio_pts=0; | 604 priv->avi_audio_pts=0; |
606 | 605 |
783 | 782 |
784 if(priv->idx_size > 0) | 783 if(priv->idx_size > 0) |
785 free(priv->idx); | 784 free(priv->idx); |
786 free(priv); | 785 free(priv); |
787 } | 786 } |
787 | |
788 | |
789 int demux_avi_control(demuxer_t *demuxer,int cmd, void *arg){ | |
790 avi_priv_t *priv=demuxer->priv; | |
791 demux_stream_t *d_audio=demuxer->audio; | |
792 demux_stream_t *d_video=demuxer->video; | |
793 sh_audio_t *sh_audio=d_audio->sh; | |
794 sh_video_t *sh_video=d_video->sh; | |
795 | |
796 | |
797 | |
798 switch(cmd) { | |
799 case DEMUXER_CTRL_GET_TIME_LENGTH: | |
800 if (!priv->numberofframes) return DEMUXER_CTRL_DONTKNOW; | |
801 *((unsigned long *)arg)=priv->numberofframes/sh_video->fps; | |
802 if (sh_video->video.dwLength<=1) return DEMUXER_CTRL_GUESS; | |
803 return DEMUXER_CTRL_OK; | |
804 | |
805 case DEMUXER_CTRL_GET_PERCENT_POS: | |
806 if (!priv->numberofframes) { | |
807 if (demuxer->movi_end==demuxer->movi_start) return DEMUXER_CTRL_DONTKNOW; | |
808 *((int *)arg)=(int)((demuxer->filepos-demuxer->movi_start)/((demuxer->movi_end-demuxer->movi_start)/100)); | |
809 return DEMUXER_CTRL_OK; | |
810 } | |
811 *((int *)arg)=(int)(priv->video_pack_no*100/priv->numberofframes); | |
812 if (sh_video->video.dwLength<=1) return DEMUXER_CTRL_GUESS; | |
813 return DEMUXER_CTRL_OK; | |
814 | |
815 default: | |
816 return DEMUXER_CTRL_NOTIMPL; | |
817 } | |
818 } |