changeset 23552:ba9e664dbbaa

More accurate seeking for demuxers lacking DEMUXER_CTRL_GET_TIME_LENGTH control
author zuxy
date Sun, 17 Jun 2007 13:28:52 +0000
parents 63d9b7032bf3
children d890d68a92dc
files libmpdemux/demuxer.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demuxer.c	Sun Jun 17 12:18:13 2007 +0000
+++ b/libmpdemux/demuxer.c	Sun Jun 17 13:28:52 2007 +0000
@@ -1038,7 +1038,9 @@
     sh_audio_t *sh_audio = demuxer->audio->sh;
     // <= 0 means DEMUXER_CTRL_NOTIMPL or DEMUXER_CTRL_DONTKNOW
     if (demux_control(demuxer, DEMUXER_CTRL_GET_TIME_LENGTH,(void *)&get_time_ans)<=0)  {
-      if (sh_video && sh_video->i_bps)
+      if (sh_video && sh_video->i_bps && sh_audio && sh_audio->i_bps)
+        get_time_ans = (double)(demuxer->movi_end-demuxer->movi_start)/(sh_video->i_bps+sh_audio->i_bps);
+      else if (sh_video && sh_video->i_bps)
         get_time_ans = (double)(demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps;
       else if (sh_audio && sh_audio->i_bps)
         get_time_ans = (double)(demuxer->movi_end-demuxer->movi_start)/sh_audio->i_bps;