On Tue, May 17, 2011 at 05:30:05PM +0200, Vladimir Pantelic wrote: > Uoti Urpala wrote: > > >> the other one introduces a new > >> flag that prevents util.c from doing so. > > > >But it still calls av_seek_frame_generic(). Is that really any more > >appropriate, even if it doesn't happen to trigger visible problems now? > > > >How many demuxers are there that define their own seek method but do > >still rely on the general code executing the fallbacks? > > new patch attached that prevents both fallback methods to be used. >
> From 3472d798dd62a871b6f82f5697450453b414e83e Mon Sep 17 00:00:00 2001 > From: Vladimir Pantelic <[email protected]> > Date: Tue, 10 May 2011 14:54:21 +0200 > Subject: [PATCH] fix asf demuxer to not fall back to binary/generic search > > asf_read_seek() inside the asf demuxer already does the > right thing, it tries the index and if that fails it uses > binary search. If binary search is called from outside of asfdec.c > it will fail because the asf code cannot clean up after itself. > Therefore introduce AVFMT_NOBINSEARCH that prevents the seek > code to fallback to binary search and AVFMT_NOGENSEARCH that > prevents the seek code to fallback to generic search. > --- > libavformat/asfdec.c | 1 + > libavformat/avformat.h | 2 ++ > libavformat/utils.c | 6 ++++-- > 3 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c > index f0c746a..e9a3995 100644 > --- a/libavformat/asfdec.c > +++ b/libavformat/asfdec.c > @@ -1299,4 +1299,5 @@ AVInputFormat ff_asf_demuxer = { > asf_read_close, > asf_read_seek, > asf_read_pts, > + .flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH, > }; > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index 7327562..aca246d 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -258,6 +258,8 @@ typedef struct AVFormatParameters { > #define AVFMT_VARIABLE_FPS 0x0400 /**< Format allows variable fps. */ > #define AVFMT_NODIMENSIONS 0x0800 /**< Format does not need width/height */ > #define AVFMT_NOSTREAMS 0x1000 /**< Format does not require any streams > */ > +#define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fallback to > binary search via read_timestamp */ > +#define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fallback to > generic search */ > > typedef struct AVOutputFormat { > const char *name; > diff --git a/libavformat/utils.c b/libavformat/utils.c > index 67aa76a..ad22601 100644 > --- a/libavformat/utils.c > +++ b/libavformat/utils.c > @@ -1713,10 +1713,12 @@ int av_seek_frame(AVFormatContext *s, int > stream_index, int64_t timestamp, int f > return 0; > } > > - if(s->iformat->read_timestamp) > + if(s->iformat->read_timestamp && !(s->iformat->flags & > AVFMT_NOBINSEARCH)) > return av_seek_frame_binary(s, stream_index, timestamp, flags); > - else > + else if (!(s->iformat->flags & AVFMT_NOGENSEARCH)) > return av_seek_frame_generic(s, stream_index, timestamp, flags); > + else > + return -1; > } > > int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, > int64_t ts, int64_t max_ts, int flags) > -- ensured that testsuite and fate still passes, and explanation makes sense to me. Queued locally regards, Reinhard _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
