[FFmpeg-devel] [RFC] Seeking in PVA files

Ivo ivop
Sat Jan 5 18:29:27 CET 2008


On Saturday 05 January 2008 18:06, Michael Niedermayer wrote:
> On Sat, Jan 05, 2008 at 11:46:02AM +0100, Ivo wrote:
> > > > +static int pva_read_seek(struct AVFormatContext *s, int
> > > > stream_index, +                         int64_t timestamp, int
> > > > flags) {
> > > > +    AVStream *st = s->streams[stream_index];
> > > > +    PVAContext *pvactx = s->priv_data;
> > > > +    int index = av_index_search_timestamp(st, timestamp, flags);
> > > > +
> > > > +    if (index < 0) return -1;
> > > > +
> > > > +    url_fseek(s->pb, st->index_entries[index].pos, SEEK_SET);
> > > > +    pvactx->continue_pes = 0;
> > > > +
> > > > +    return 0;
> > > > +}
> > >
> > > i have some doubt that this works. av_index_search_timestamp() just
> > > looks in the index
> > >
> > > you should try av_seek_frame_binary() if the default (read_seek=NULL)
> > > doesnt do
> >
> > The default read_seek does work, except for the fact the
> > pvactx->continue_pes is not reset. That's why I mimic the default
> > behaviour and then reset the variable. I saw other demuxers with some
> > private seek-dependant variables do the same. Is there a better/shorter
> > way to achieve the same that I overlooked?
>
> continue_pes=0;
> return -1;
>
> or
>
> ret= av_seek_frame_binary(s, stream_index, timestamp, flags);
> continue_pes=0;
> return ret;
>
> maybe?

That's what av_seek_frame (util.c) does after read_seek failed, which is 
almost always when seeking forward.

This is how I understand the logic:

util.c: av_seek_frame()
	...
	try pva.c: read_seek()
		try a fast seek via build-up index
		succes: continue_pes = 0, return ok
		fail: return failure
	if failed, try av_seek_frame_binary() which uses pva.c: read_timestamp()

[if there's no read_timestamp, av_seek_frame_generic() is called, but that's 
not the case here]

If the speed-increase of read_seek via an index is marginally or 
non-existant, I could remove all the index building code and just rely on 
read_timestamp (which also resets continue_pes anyway). read_seek can be 
removed entirely too. Should I do that?

--Ivo




More information about the ffmpeg-devel mailing list