[FFmpeg-devel] [PATCH] Detect DTS in wav (issue70) ??+?about?ac3-in-wav

Anssi Hannula anssi.hannula
Wed Aug 18 06:29:15 CEST 2010


On Tuesday 17 August 2010 15:26:52 Michael Niedermayer wrote:
> On Wed, Aug 11, 2010 at 10:17:36PM +0300, Anssi Hannula wrote:
> > Michael Niedermayer kirjoitti keskiviikko, 11. elokuuta 2010 18:41:59:
> > > On Tue, Aug 10, 2010 at 08:32:01PM +0300, Anssi Hannula wrote:
> > > > From: Anssi Hannula <anssi.hannula at iki.fi>
> > > > Date: Tue, 10 Aug 2010 18:02:02 +0300
> > > > Subject: [PATCH 1/3] avformat: add support for codecs to set probe
> > > > fallbacks
> > > > 
> > > > 
> > > > 
> > > > 
> > > > ---
> > > > 
> > > >  libavformat/avformat.h |   12 +++++++++++-
> > > >  libavformat/utils.c    |   33 +++++++++++++++++++++++++++++++--
> > > >  2 files changed, 42 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> > > > index 8ba2d81..45596a9 100644
> > > > --- a/libavformat/avformat.h
> > > > +++ b/libavformat/avformat.h
> > > > @@ -22,7 +22,7 @@
> > > > 
> > > >  #define AVFORMAT_AVFORMAT_H
> > > >  
> > > >  #define LIBAVFORMAT_VERSION_MAJOR 52
> > > > 
> > > > -#define LIBAVFORMAT_VERSION_MINOR 77
> > > > +#define LIBAVFORMAT_VERSION_MINOR 78
> > > > 
> > > >  #define LIBAVFORMAT_VERSION_MICRO  0
> > > >  
> > > >  #define LIBAVFORMAT_VERSION_INT
> > > >  AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
> > > > 
> > > > @@ -536,6 +536,16 @@ typedef struct AVStream {
> > > > 
> > > >       * Number of frames that have been demuxed during
> > > >       av_find_stream_info() */
> > > >      
> > > >      int codec_info_nb_frames;
> > > > 
> > > > +
> > > > +    /**
> > > > +     * Codec id to select if no codec is found by probe.
> > > > +     * When set, codec probe will select the fallback id immediately
> > > > when no +     * codec with score >= AVPROBE_SCORE_MAX / 4 is found,
> > > > or if the maximum +     * probe packet count is reached before any
> > > > codec with
> > > > +     * score > AVPROBE_SCORE_MAX / 4 is found.
> > > > +     * Not part of public API.
> > > > +     */
> > > > +    enum CodecID probe_fallback_codec_id;
> > > > 
> > > >  } AVStream;
> > > >  
> > > >  
> > > >  
> > > >  
> > > >  
> > > >  #define AV_PROGRAM_RUNNING 1
> > > > 
> > > > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > > > index 1aa965c..247cfec 100644
> > > > --- a/libavformat/utils.c
> > > > +++ b/libavformat/utils.c
> > > > @@ -387,7 +387,24 @@ static int
> > > > set_codec_from_probe_data(AVFormatContext *s, AVStream *st,
> > > > AVProbeDa
> > > > 
> > > >          { "mpegvideo", CODEC_ID_MPEG2VIDEO, AVMEDIA_TYPE_VIDEO },
> > > >          { 0 }
> > > >      
> > > >      };
> > > > 
> > > > -    AVInputFormat *fmt = av_probe_input_format2(pd, 1, &score);
> > > 
> > > if(score < X && probe_fallback_fmt){
> > > 
> > >     score= X;
> > >     fmt= probe_fallback_codec_fmt
> > > 
> > > }
> > > 
> > > ?
> > 
> > That would not be enough, score < X is never true here as the function is
> > called with score = X. Unless we change it to be called with score = 0 or
> > something when the fallback is set?
> 
> depends on X

Well, I thought it was agreed that X = AVPROBE_SCORE_MAX / 4.

> > Also, enum CodecID can certainly be replaced with AVInputFormat*, but I
> > don't really think it is a good idea, as it is CodecIDs (not
> > AVInputFormats) that are tied to AVStreams. IMHO the AVInputFormat stuff
> > is just a hack internal to set_codec_from_probe_data() function. (of
> > course if this is the way to do it, I'm fine with it, I'm not the
> > maintainer after all)
> > 
> > Or did I misunderstand what you meant? :)
> 
> i meant that the code is a mess and id like it to be simpler.

Attached is a completely different simpler approach, then.
Since we are about to do the lower-wav-score-for-s16le-files-if-small-buffer 
trick anyway for the spdif-in-wav files, attached patch does the same for dts-
in-wav, marking such files as raw dts.

Better?

> If using AVInputFormat makes it simpler please do it otherwise of course
> not.

Well, AFAICS it does not.

-- 
Anssi Hannula



More information about the ffmpeg-devel mailing list