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

Michael Niedermayer michaelni
Sat Jan 5 18:44:02 CET 2008


On Sat, Jan 05, 2008 at 06:29:27PM +0100, Ivo wrote:
> 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?

av_seek_frame_binary() uses the index
av_index_search_timestamp() is not correct unless you have indexed the whole
file or at least a single continous area

if you read the first 10% then seek to the end end agaib read 10% then
av_index_search_timestamp() will not fail if you seek between these 2 but
it will neither give you a reasonable result

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080105/aebfb9f4/attachment.pgp>



More information about the ffmpeg-devel mailing list