[FFmpeg-devel] [PATCH] Detect DTS in wav (issue70) ?+?about?ac3-in-wav
Michael Niedermayer
michaelni
Wed Aug 11 17:41:59 CEST 2010
On Tue, Aug 10, 2010 at 08:32:01PM +0300, Anssi Hannula wrote:
> Michael Niedermayer kirjoitti keskiviikko, 4. elokuuta 2010 16:10:51:
> > On Sat, Jul 24, 2010 at 06:15:23AM +0300, Anssi Hannula wrote:
> > > Michael Niedermayer kirjoitti perjantai, 23. hein?kuuta 2010 23:53:08:
> > > > On Fri, Jul 23, 2010 at 10:42:53PM +0300, Anssi Hannula wrote:
> > > > > Michael Niedermayer kirjoitti perjantai, 23. hein?kuuta 2010 21:29:38:
> > > > > > On Fri, Jul 23, 2010 at 06:40:30AM +0300, Anssi Hannula wrote:
> > > > > > > Anssi Hannula kirjoitti torstai, 22. hein?kuuta 2010 06:15:17:
> > > > > > > > Hi!
> > > > > > > >
> > > > > > > > Attached are patches that fix issue70 (detection of DTS in
> > > > > > > > wav).
> > > > > > > >
> > > > > > > > Two new fields are added to AVStream that allow demuxers to set
> > > > > > > > a fallback codec to a stream, which gets used if no codec is
> > > > > > > > probed in a defined number of bytes.
> > > > > > > > Please comment if you think this should be done in some better
> > > > > > > > way
> > > > > > > >
> > > > > > > > :)
> > > > > > > >
> > > > > > > > I made the wav demuxer do the probing only for PCM_S16LE, as
> > > > > > > > all my dts/ac3- in-wav samples are like that. If people are
> > > > > > > > aware of other kind of files, it could be changed to cover
> > > > > > > > more/all PCM codecs if necessary.
> > > > > > > >
> > > > > > > >
> > > > > > > > This works fine for DTS (issue70)
> > > > > > >
> > > > > > > The first patch added a warning (mixed code and declarations),
> > > > > > > attached is a fixed one. The second patch was ok.
> > > > > >
> > > > > > i dont think this code will work reliable like this as the chances
> > > > > > are pretty high that mp3 or ac3 will be detected in random data
> > > > > > with a very low score
> > > > >
> > > > > That won't happen, since set_codec_from_probe_data() gets called with
> > > > > score AVPROBE_SCORE_MAX / 4 (i.e. any score <= AVPROBE_SCORE_MAX / 4
> > > > > is ignored), except in the very last iteration (st->probe_packet ==
> > > > > 0), which we do not actually reach due to s->probe_fallback_bytes.
> > > >
> > > > that is if probe_packets is "larger" than probe_fallback_bytes
> > > > this feels quite hackish and it depends on how many bytes there
> > > > are per packet
> > >
> > > Indeed.
> > >
> > > And I guess it would be nice to avoid probing the full 80 kB if there are
> > > no DTS start codes in the first wav "packet" (4 kB)..
> > >
> > > > I think it should be fallback_codec_id and fallback_score
> > >
> > > Sounds better.. but do you have an idea of good semantics for
> > > fallback_score?
> > >
> > > I can only think of this: Assume a fallback_score of AVPROBE_SCORE_MAX/4.
> > > dts_probe could set AVPROBE_SCORE_MAX/4 if it detects marker(s) but the
> > > probe buffer was too small to make a proper decision. After being called
> > > with a big enough buffer, it can return 1 or AVPROBE_SCORE_MAX/2 + 1,
> > > depending if there were enough markers or not.
> > > I.e. score < AVPROBE_SCORE_MAX / 4 => fallback selected
> > >
> > > score ==AVPROBE_SCORE_MAX / 4 => probe continued
> > > score > AVPROBE_SCORE_MAX / 4 => probed codec selected
> > >
> > > Actually, we could maybe just use always AVPROBE_SCORE_MAX/4 as the
> > > "unsure" value, no need for the demuxer to select one..
> >
> > yes
> >
> > > Is the above anything like you were thinking?
> >
> > yes
>
> OK, revised patches attached.
>
> --
> Anssi Hannula
> avformat.h | 12 +++++++++++-
> utils.c | 33 +++++++++++++++++++++++++++++++--
> 2 files changed, 42 insertions(+), 3 deletions(-)
> 986103b86d109755c74be69150b9bb1351d08200 0001-avformat-add-support-for-codecs-to-set-probe-fallbac.patch
> From e9be327abc3785ac1c5cf65b6918c0302da62e18 Mon Sep 17 00:00:00 2001
> 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
}
?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Everything should be made as simple as possible, but not simpler.
-- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100811/5a6fa9f8/attachment.pgp>
More information about the ffmpeg-devel
mailing list