[FFmpeg-devel] [PATCH] dts probe

Benjamin Larsson banan
Sat May 3 15:19:42 CEST 2008


Michael Niedermayer wrote:
> 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()
> 

Hi, I tried that but it didn't work so well, one problem is how to
detect regular pcm from a probe when the stream is marked with
CODEC_ID_NONE. One thing that did work was to increase the wav probe
buffer size so the dts probe would kick in first.

Patch attached.

MvH
Benjamin Larsson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dtsinwavfix.diff
Type: text/x-diff
Size: 433 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080503/04e2c1ca/attachment.diff>



More information about the ffmpeg-devel mailing list