[FFmpeg-devel] [PATCH] stricter dnxhd test
Reimar Döffinger
Reimar.Doeffinger
Mon Sep 14 23:07:25 CEST 2009
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, 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?). 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?
> > 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
More information about the ffmpeg-devel
mailing list