[FFmpeg-devel] [PATCH] avformat/flacdec: support fast-seek

Ching-Yi Chan chingyichan.tw at gmail.com
Fri Oct 2 15:56:22 CEST 2015


I found the problem is no seektable in our test sample acodec-flac.flac,
but application will append the new index entry to AVStream.

So, I need to a variable or some place to mark "no seektable, don't use
fast-seek method", some choices:

1. disable AVFMT_FLAG_FAST_SEEK flag when no seektable
2. use priv_class and keep the state in it
3. use a static varible to keep the state in flacdec.c

Need a suggestion for implementation.

2015-10-01 20:31 GMT+08:00 Michael Niedermayer <michaelni at gmx.at>:

> On Fri, Sep 25, 2015 at 11:58:31AM +0800, Ching-Yi Chan wrote:
> > Thanks for checking.
> >
> > I also check the AVFMT_FLAG_FAST_SEEK flag with parsing headers,
> > to fill the seektable into index entries only if AVFMT_FLAG_FAST_SEEK
> flag
> > is on.
> >
> > If the AVFMT_FLAG_FAST_SEEK flag is not enabled, it will seek in original
> > way.
>
> i think we misunderstand us somehow
>
> your code does not work for me
> seeking to  1.894167 results in a seek to
> pts: 0.000000 pos:   8256
>
> seeking to  1.470835 results in a seek to
> pts: 0.809796 pos:  27366
>
> you notice that moving the target to a later point moves the result
> to a earlier one.
>
> please see below for further comments
>
> [...]
>
> > +#define SEEKPOINT_SIZE 18
> > +
> > +static void ff_reset_index_position(int64_t metadata_head_size,
> AVStream *st)
>
> the ff_ prefix is for non static functions
>
>
> [...9
>
> > @@ -249,12 +277,30 @@ static av_unused int64_t
> flac_read_timestamp(AVFormatContext *s, int stream_inde
> >      return pts;
> >  }
> >
> > +static int flac_seek(AVFormatContext *s, int stream_index, int64_t
> timestamp, int flags) {
> > +    if (!(s->flags&AVFMT_FLAG_FAST_SEEK)) {
> > +        return -1;
> > +    }
> > +
> > +    int index = av_index_search_timestamp(s->streams[0], timestamp,
> flags);
>
> libavformat/flacdec.c:285:5: warning: ISO C90 forbids mixed declarations
> and code [-Wdeclaration-after-statement]
> libavformat/flacdec.c:289:5: warning: ISO C90 forbids mixed declarations
> and code [-Wdeclaration-after-statement]
>
> please make sure your patch adds no compiler warnings
>
>
> > +    if(index<0 || index >= s->streams[0]->nb_index_entries)
> > +        return -1;
> > +
> > +    AVIndexEntry e = s->streams[0]->index_entries[index];
>
> > +    int ret = avio_seek(s->pb, e.pos, SEEK_SET);
>
> this is wrong and must use int64_t otherwise the following >= 0 check
> can be wrong
>
> [...]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Democracy is the form of government in which you can choose your dictator
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>


More information about the ffmpeg-devel mailing list