[MPlayer-dev-eng] [PATCH] stream aided seeking (dvd precise seeking)

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Nov 7 18:12:36 CET 2006


Hello,
On Tue, Nov 07, 2006 at 01:30:36AM +0100, Nico Sabbi wrote:
> This patch overcomes one of the most hideous limitations in mplayer:
> the impossibility to precisely seek in dvds (and in the future possibly 
> other streams
> such as [s]vcd).
> 
> I modified demux_seek() so as to try to ask the stream layer to seek to 
> the specified position
> (if possible), and in order to make it work with relative seeking I also 
> added a method to ask the
> stream layer the current time.

Hmm... I don't like too much seeking the stream without the demuxer
having the slightest clue.
Maybe adding something similar to
ADCTRL_RESYNC_STREAM/VDCTRL_RESYNC_STREAM but for demuxers would be a
good idea?

> +        case STREAM_CTRL_GET_CURRENT_TIME:
> +        {
> +            float tm = dvd_get_current_time(stream, 0);
> +            if(tm != -1) {
> +              tm *= 1000.0f;
> +              *((unsigned int *)arg) = (unsigned int) tm;
> +              return 1;
> +            }
> +        }
> +	case STREAM_CTRL_SEEK_TO_TIME:
> +	{
> +            dvd_priv_t *d = stream->priv;
> +            if(dvd_seek_to_time(stream, d->vts_file, arg))
> +              return 1;
> +        }


tabs vs. spaces messup.

> +    if(flags & 2) { //percentage seek
> +        int msec;
> +        float pts;
> +        if(stream_control(demuxer->stream, STREAM_CTRL_GET_TIME_LENGTH, &msec) != STREAM_UNSUPORTED) {
> +            pts = (float)(msec / 1000);
> +            pts *= rel_seek_secs;
> +            if(stream_control(demuxer->stream, STREAM_CTRL_SEEK_TO_TIME, &pts) != STREAM_UNSUPORTED)
> +                return 1;
> +        }
> +    } else { //relative
> +        unsigned int newpts;
> +        if(stream_control(demuxer->stream, STREAM_CTRL_GET_CURRENT_TIME, &newpts) != STREAM_UNSUPORTED) {
> +            float pts = ((float) newpts)/1000.0f;
> +            pts += rel_seek_secs;
> +            if(stream_control(demuxer->stream, STREAM_CTRL_SEEK_TO_TIME, &pts) != STREAM_UNSUPORTED)
> +                return 1;
> +        }
> +    }

That does not look right. There is percentage-based and second-based
seek, and both exist in relative and absolute variants.
And if done similar to e.g. demux_lavf.c, line 432 you shouldn't need to
duplicate the STREAM_CTRL_SEEK_TO_TIME control.



> +int demuxer_get_current_time(demuxer_t *demuxer){
> +    double get_time_ans = 0;
> +    unsigned tm;
> +    sh_video_t *sh_video = demuxer->video->sh;
> +    // <= 0 means DEMUXER_CTRL_NOTIMPL or DEMUXER_CTRL_DONTKNOW
> +    if(stream_control(demuxer->stream, STREAM_CTRL_GET_CURRENT_TIME,(void *)&tm)!=STREAM_UNSUPORTED) {
> +        get_time_ans = (double) tm / 1000.0f;
> +    } else if(sh_video) get_time_ans = sh_video->pts;
> +    return (int) get_time_ans;
> +}

The function name and the comment both confuse me quite a bit.

Greetings,
Reimar Döffinger



More information about the MPlayer-dev-eng mailing list