[FFmpeg-devel] [PATCH] dts probe

Michael Niedermayer michaelni
Sat May 3 04:11:38 CEST 2008


On Sat, May 03, 2008 at 02:14:26AM +0200, Benjamin Larsson wrote:
> Michael Niedermayer wrote:
> > On Sat, May 03, 2008 at 01:59:31AM +0200, Benjamin Larsson wrote:
> >> Michael Niedermayer wrote:
> >>> On Sat, May 03, 2008 at 12:42:05AM +0200, Benjamin Larsson wrote:
> >>>> $topic
> >>>>
> >>>> MvH
> >>>> Benjamin Larsson
> >>>> Index: libavformat/raw.c
> >>>> ===================================================================
> >>>> --- libavformat/raw.c	(revision 12892)
> >>>> +++ libavformat/raw.c	(working copy)
> >>>> @@ -22,6 +22,7 @@
> >>>>  #include "avformat.h"
> >>>>  #include "ac3_parser.h"
> >>>>  #include "raw.h"
> >>>> +#include "bytestream.h"
> >>>>  
> >>>>  #ifdef CONFIG_MUXERS
> >>>>  /* simple formats */
> >>>> @@ -413,6 +414,40 @@
> >>>>      return 0;
> >>>>  }
> >>>>  
> >>>> +
> >>>> +#define DCA_MARKER_14B_BE 0x1FFFE800
> >>>> +#define DCA_MARKER_14B_LE 0xFF1F00E8
> >>>> +#define DCA_MARKER_RAW_BE 0x7FFE8001
> >>>> +#define DCA_MARKER_RAW_LE 0xFE7F0180
> >>>> +static int dts_probe(AVProbeData *p)
> >>>> +{
> >>>> +    const uint8_t *buf, *bufp;
> >>>> +    uint32_t state = -1;
> >>>> +
> >>>> +    buf = p->buf;
> >>>> +
> >>>> +    for(; buf < (buf+p->buf_size)-2; buf+=2) {
> >>>> +        bufp = buf;
> >>>> +        state = (state << 16) | bytestream_get_be16(&bufp);
> >>>> +
> >>>> +        /* Regular bitstream */
> >>>> +        if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE)
> >>>> +            return AVPROBE_SCORE_MAX;
> >>>> +
> >>>> +        /* 14 bits big endian bitstream */
> >>>> +        if (state == DCA_MARKER_14B_BE)
> >>>> +            if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
> >>>> +                return AVPROBE_SCORE_MAX;
> >>>> +
> >>>> +        /* 14 bits little endian bitstream */
> >>>> +        if (state == DCA_MARKER_14B_LE)
> >>>> +            if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
> >>>> +                return AVPROBE_SCORE_MAX;
> >>>> +    }
> >>>> +
> >>>> +    return 0;
> >>>> +}
> >>> AVPROBE_SCORE_MAX is a little big for a single 4 byte marker found at
> >>> an arbitrary position.
> >>> The score for a single header at arbitrary position must at least be
> >>> smaller than mpeg-ps/ts or they will be missdetected. Yeah
> >>> dts+mpeg2 in mpeg-ps must be detected as mpeg-ps not dts.
> >> Will AVPROBE_SCORE_MAX/8 work ?
> > 
> > now you overdo it in the other direction :)
> > try AVPROBE_SCORE_MAX/2+1 like mpeg-ES
> > 
> 
> Committed, and now how do I use this to probe dts in wav files? I never
> understood the logic.

You have to set codec_id to CODEC_ID_NONE in wav if you arent sure what codec
it is.
And add a line for dts to set_codec_from_probe_data()

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No snowflake in an avalanche ever feels responsible. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080503/7a97b793/attachment.pgp>



More information about the ffmpeg-devel mailing list