[FFmpeg-devel] [RFC] Seeking in PVA files
Ivo
ivop
Sat Jan 5 11:46:02 CET 2008
On Saturday 05 January 2008 02:13, Michael Niedermayer wrote:
> On Fri, Jan 04, 2008 at 12:52:19PM +0100, Ivo wrote:
> > With the attached patch, seeking works for all samples files and it
> > works just as well as MPlayer's native demuxer. I have one problem
> > though. I cannot discern keyframes from non-keyframes, so it might seek
> > to somewhere in the middle of a GOP (the old demuxer had the same
> > problem). The only way I see to fix that would be for the demuxer to
> > check the MPEG-ES packet before adding it to the index. Or is there a
> > way I could instruct the decoder to drop all frames leading up to the
> > next keyframe without decoding and/or printing warning/error messages?
> > Or another solution I am overlooking?
>
> ive just fixed the deoceder, i wonder why noone complained about this
> years ago
Great! It works correctly now.
> > +static inline int64_t get_pes_pts(int pes_flags, uint8_t
> > *pes_header_data) { + int64_t res = AV_NOPTS_VALUE;
> > +
> > + if (pes_flags & 0x80 && (pes_header_data[0] & 0xf0) == 0x20) {
> > + res = ((long long) *pes_header_data & 0x0e) << 29;
> > + res += (AV_RB16(pes_header_data+1) >> 1) << 15;
> > + res += AV_RB16(pes_header_data+3) >> 1;
> > + }
> > +
> > + return res;
> > +}
>
> duplicate of get_pts() from mpeg.c
> and i suspect this is not the only one
Yes, though they are not 100% identical as get_pts() from mpeg.c reads from
a ByteIOContext and this one does not. But I'll see if I can find a way to
merge the code.
> > +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?
--Ivo
More information about the ffmpeg-devel
mailing list