diff options
author | 2004-01-31 09:38:01 +0000 | |
---|---|---|
committer | 2004-01-31 09:38:01 +0000 | |
commit | c4105bb7318eebd9368de2420071a90e90a5f1e1 (patch) | |
tree | 6b7fd45951ac1eb8f8c11358d7baead4972d51db /libmpdemux | |
parent | 40ae58f649bd77b5a443a3e6965448832594d341 (diff) |
Cleanup and small improvement in seeking if the final_granulepos is known. Patch by Michael Behrisch <behrisch@informatik.hu-berlin.de>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11899 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/demux_ogg.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/libmpdemux/demux_ogg.c b/libmpdemux/demux_ogg.c index 5b7ace9f4d..f6abbe46ab 100644 --- a/libmpdemux/demux_ogg.c +++ b/libmpdemux/demux_ogg.c @@ -1090,20 +1090,14 @@ void demux_ogg_seek(demuxer_t *demuxer,float rel_seek_secs,int flags) { oss = &os->stream; if(ogg_d->syncpoints) { - float time_pos = flags & 1 ? 0 : os->lastpos/ rate; - if(flags & 2) { - if(ogg_d->syncpoints) - time_pos += ogg_d->syncpoints[ogg_d->num_syncpoint].granulepos / rate * rel_seek_secs; + gp = flags & 1 ? 0 : os->lastpos; + if(flags & 2) + gp += ogg_d->syncpoints[ogg_d->num_syncpoint].granulepos * rel_seek_secs; else - time_pos += (demuxer->movi_end - demuxer->movi_start) * rel_seek_secs; - } else - time_pos += rel_seek_secs; - - gp = time_pos * rate; + gp += rel_seek_secs * rate; for(sp = 0; sp < ogg_d->num_syncpoint ; sp++) { - if(ogg_d->syncpoints[sp].granulepos >= gp) - break; + if(ogg_d->syncpoints[sp].granulepos >= gp) break; } if(sp >= ogg_d->num_syncpoint) @@ -1114,8 +1108,12 @@ void demux_ogg_seek(demuxer_t *demuxer,float rel_seek_secs,int flags) { pos = flags & 1 ? 0 : ogg_d->pos; if(flags & 2) pos += (demuxer->movi_end - demuxer->movi_start) * rel_seek_secs; + else { + if (ogg_d->final_granulepos > 0) + pos += rel_seek_secs * (demuxer->movi_end - demuxer->movi_start) / (ogg_d->final_granulepos / rate); else pos += rel_seek_secs * ogg_d->pos / (os->lastpos / rate); + } if (pos < 0) pos = 0; else if (pos > (demuxer->movi_end - demuxer->movi_start)) |