Mercurial > mplayer.hg
changeset 11898:41efae8120b6
Cleanup and small improvement in seeking if the final_granulepos is known. Patch by Michael Behrisch <behrisch@informatik.hu-berlin.de>
author | mosu |
---|---|
date | Sat, 31 Jan 2004 09:38:01 +0000 |
parents | b3aea2d77cbe |
children | 18bd28454ef6 |
files | libmpdemux/demux_ogg.c |
diffstat | 1 files changed, 9 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_ogg.c Sat Jan 31 09:29:35 2004 +0000 +++ b/libmpdemux/demux_ogg.c Sat Jan 31 09:38:01 2004 +0000 @@ -1090,20 +1090,14 @@ 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 @@ 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))