[FFmpeg-devel] [PATCH] avformat/flacdec: support fast-seek
Michael Niedermayer
michaelni at gmx.at
Thu Oct 1 14:31:04 CEST 2015
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151001/63bc8369/attachment.sig>
More information about the ffmpeg-devel
mailing list