[FFmpeg-devel] [PATCH] stricter dnxhd test

Baptiste Coudurier baptiste.coudurier
Mon Sep 14 23:13:13 CEST 2009


On 09/14/2009 02:07 PM, Reimar D?ffinger wrote:
> On Mon, Sep 14, 2009 at 02:00:10PM -0700, Baptiste Coudurier wrote:
>> On 09/14/2009 01:54 PM, Reimar D?ffinger wrote:
>>> I believe this to be correct in so far as our decoder should fail for
>>> any formats this rejects.
>>> Unfortunately I was not able to find any samples for raw DNxHD (I thought
>>> there were some in the samples archive, but I didn't find any), so it is
>>> untested...
>>
>> We have a dnxhd encoder :)
>
> Not really a good substitute for real-world data.

It produces valid streams working with all decoders around, sounds like 
real-world data to me. There are only 2 encoders available, AVID's and 
FFmpeg's :)

> not to mention that I just haven't had the motivation to figure out how
 > to use it (it's yet
> another format where you have to get everything right, size, frame rate,
> ..., isn't it?).

It only supports HD, 720 or 1080 and you need the specify the bitrate 
since it cannot be infered.

-b 120Mb or -b 185Mb in 1080 should do it.

> I checked if "make test" is so kind to leave a file
> behind, but it seems it is not hooked up to regression tests? Why?

No reason I think, it could be done, picture needs to be scaled.

>>> Index: libavformat/raw.c
>>> ===================================================================
>>> --- libavformat/raw.c   (revision 19844)
>>> +++ libavformat/raw.c   (working copy)
>>> @@ -558,10 +558,17 @@
>>>    static int dnxhd_probe(AVProbeData *p)
>>>    {
>>>        static const uint8_t header[] = {0x00,0x00,0x02,0x80,0x01};
>>> -    if (!memcmp(p->buf, header, 5))
>>> -        return AVPROBE_SCORE_MAX;
>>> -    else
>>> +    int w, h, compression_id;
>>> +    if (memcmp(p->buf, header, 5))
>>>            return 0;
>>> +    h = AV_RB16(p->buf + 0x18);
>>> +    w = AV_RB16(p->buf + 0x1a);
>>> +    if (!w || !h)
>>> +        return 0;
>>> +    compression_id = AV_RB32(p->buf + 0x28);
>>> +    if (compression_id<   1237 || compression_id>   1253)
>>> +        return 0;
>>> +    return AVPROBE_SCORE_MAX;
>>
>> Missing p->buf_size check ? AVPROBE_PADDING_SIZE is 32.
>
> Yes, it's too late already, I remembered to do it when I started coding
> the checks, by the time I finished I had forgotten :-)
>
> Index: libavformat/raw.c
> ===================================================================
> --- libavformat/raw.c   (revision 19844)
> +++ libavformat/raw.c   (working copy)
> @@ -558,10 +558,19 @@
>   static int dnxhd_probe(AVProbeData *p)
>   {
>       static const uint8_t header[] = {0x00,0x00,0x02,0x80,0x01};
> -    if (!memcmp(p->buf, header, 5))
> -        return AVPROBE_SCORE_MAX;
> -    else
> +    int w, h, compression_id;
> +    if (p->buf_size<  0x2c)
>           return 0;
> +    if (memcmp(p->buf, header, 5))
> +        return 0;
> +    h = AV_RB16(p->buf + 0x18);
> +    w = AV_RB16(p->buf + 0x1a);
> +    if (!w || !h)
> +        return 0;
> +    compression_id = AV_RB32(p->buf + 0x28);
> +    if (compression_id<  1237 || compression_id>  1253)
> +        return 0;
> +    return AVPROBE_SCORE_MAX;
>   }
>   #endif

Looks reasonable if it works.

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list