On Tue, 21 Apr 2015 23:04:32 +0200 wm4 <nfx...@googlemail.com> wrote:
> --- > Proposal. Is not mp3-specific, and can be reused for other formats. > --- > doc/APIchanges | 4 ++++ > doc/formats.texi | 2 ++ > libavformat/avformat.h | 1 + > libavformat/mp3dec.c | 4 ++-- > libavformat/options_table.h | 1 + > 5 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index b422e29..b65fd62 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -15,6 +15,10 @@ libavutil: 2014-08-09 > > API changes, most recent first: > > +2015-xx-xx - xxxxxxx - lavf 56.xx.xxx - avformat.h > + Add AVFMT_FLAG_FAST_SEEK flag. Some formats (initially mp3) use it to > enable > + fast, but inaccurate seeking. > + > 2015-xx-xx - xxxxxxx - lavu 54.12.0 > Add AV_LOG_TRACE for extremely verbose debugging. > > diff --git a/doc/formats.texi b/doc/formats.texi > index cbbdc10..aa39d4b 100644 > --- a/doc/formats.texi > +++ b/doc/formats.texi > @@ -37,6 +37,8 @@ Possible values: > @table @samp > @item ignidx > Ignore index. > +@item fastseek > +Enable fast, but inaccurate seeks for some formats. > @item genpts > Generate PTS. > @item nofillin > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index 93cfb20..85b5a1a 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -1390,6 +1390,7 @@ typedef struct AVFormatContext { > #define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted > packets by dts (using this flag can slow demuxing down) > #define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by > delaying codec open (this could be made default once all code is converted) > #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Don't merge side data but > keep it separate. > +#define AVFMT_FLAG_FAST_SEEK 0x8000 ///< Enable fast, but inaccurate seeks > for some formats > > /** > * @deprecated deprecated in favor of probesize2 > diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c > index 2227428..8c17776 100644 > --- a/libavformat/mp3dec.c > +++ b/libavformat/mp3dec.c > @@ -337,7 +337,7 @@ static int mp3_read_header(AVFormatContext *s) > int i; > > if (mp3->usetoc < 0) > - mp3->usetoc = 0; > + mp3->usetoc = (s->flags & AVFMT_FLAG_FAST_SEEK) ? 0 : 2; > > st = avformat_new_stream(s, NULL); > if (!st) > @@ -504,7 +504,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, > int64_t timestamp, > } > > static const AVOption options[] = { > - { "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), > AV_OPT_TYPE_INT, {.i64 = 2}, -1, 2, AV_OPT_FLAG_DECODING_PARAM}, > + { "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), > AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, AV_OPT_FLAG_DECODING_PARAM}, > { NULL }, > }; > > diff --git a/libavformat/options_table.h b/libavformat/options_table.h > index 40f1e0a..58670b0 100644 > --- a/libavformat/options_table.h > +++ b/libavformat/options_table.h > @@ -49,6 +49,7 @@ static const AVOption avformat_options[] = { > {"discardcorrupt", "discard corrupted frames", 0, AV_OPT_TYPE_CONST, {.i64 = > AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"}, > {"sortdts", "try to interleave outputted packets by dts", 0, > AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, > "fflags"}, > {"keepside", "don't merge side data", 0, AV_OPT_TYPE_CONST, {.i64 = > AVFMT_FLAG_KEEP_SIDE_DATA }, INT_MIN, INT_MAX, D, "fflags"}, > +{"fastseek", "fast but inaccurate seeks", 0, AV_OPT_TYPE_CONST, {.i64 = > AVFMT_FLAG_FAST_SEEK }, INT_MIN, INT_MAX, D, "fflags"}, > {"latm", "enable RTP MP4A-LATM payload", 0, AV_OPT_TYPE_CONST, {.i64 = > AVFMT_FLAG_MP4A_LATM }, INT_MIN, INT_MAX, E, "fflags"}, > {"nobuffer", "reduce the latency introduced by optional buffering", 0, > AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_NOBUFFER }, 0, INT_MAX, D, "fflags"}, > {"seek2any", "allow seeking to non-keyframes on demuxer level when > supported", OFFSET(seek2any), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, D}, What also should be up to discussion: should this maybe be a flag to the seek API call instead? It would be slightly harder to implement though (in the case of mp3 - have to add the xing index lazily). _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel