Mercurial > mplayer.hg
changeset 12168:44f33fb19acf
seeking
author | michael |
---|---|
date | Sun, 11 Apr 2004 17:20:52 +0000 |
parents | 6421ebfc0018 |
children | 71c49bf6dcac |
files | libmpdemux/demux_lavf.c |
diffstat | 1 files changed, 13 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_lavf.c Sun Apr 11 16:48:48 2004 +0000 +++ b/libmpdemux/demux_lavf.c Sun Apr 11 17:20:52 2004 +0000 @@ -41,6 +41,7 @@ ByteIOContext pb; int audio_streams; int video_streams; + int64_t last_pts; }lavf_priv_t; extern void print_wave_header(WAVEFORMATEX *h); @@ -305,6 +306,8 @@ av_free_packet(&pkt); } + priv->last_pts= pkt.pts; + dp->pts=pkt.pts / (float)AV_TIME_BASE; dp->pos=demux->filepos; dp->flags= !!(pkt.flags&PKT_FLAG_KEY); @@ -314,7 +317,10 @@ } void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, int flags){ - mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_seek_lavf()\n"); + lavf_priv_t *priv = demuxer->priv; + mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_seek_lavf(%p, %f, %d)\n", demuxer, rel_seek_secs, flags); + + av_seek_frame(priv->avfc, -1, priv->last_pts + rel_seek_secs*AV_TIME_BASE); } int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg) @@ -322,19 +328,19 @@ lavf_priv_t *priv = demuxer->priv; switch (cmd) { -/* case DEMUXER_CTRL_GET_TIME_LENGTH: - if (priv->duration == 0) + case DEMUXER_CTRL_GET_TIME_LENGTH: + if (priv->avfc->duration == 0) return DEMUXER_CTRL_DONTKNOW; - *((unsigned long *)arg) = priv->duration; + *((unsigned long *)arg) = priv->avfc->duration / AV_TIME_BASE; return DEMUXER_CTRL_OK; case DEMUXER_CTRL_GET_PERCENT_POS: - if (priv->duration == 0) + if (priv->avfc->duration == 0) return DEMUXER_CTRL_DONTKNOW; - *((int *)arg) = (int)(100 * lastpts / priv->duration); - return DEMUXER_CTRL_OK;*/ + *((int *)arg) = (int)(priv->last_pts*100 / priv->avfc->duration); + return DEMUXER_CTRL_OK; default: return DEMUXER_CTRL_NOTIMPL;