[FFmpeg-devel] [PATCH] fix uninitialized data in dnxhd encoder

Reimar Döffinger Reimar.Doeffinger
Fri Sep 18 21:34:01 CEST 2009


On Fri, Sep 18, 2009 at 12:04:55PM -0700, Baptiste Coudurier wrote:
> On 09/18/2009 06:37 AM, Reimar D?ffinger wrote:
> > Index: libavcodec/dnxhdenc.c
> > ===================================================================
> > --- libavcodec/dnxhdenc.c       (revision 19894)
> > +++ libavcodec/dnxhdenc.c       (working copy)
> > @@ -237,6 +237,7 @@
> >       DNXHDEncContext *ctx = avctx->priv_data;
> >       const uint8_t header_prefix[5] = { 0x00,0x00,0x02,0x80,0x01 };
> >
> > +    memset(buf, 0, 0x170);
> 
> According to specs header is always 640 and in 720p mode, the slices 
> indexes area must be padded.

Indeed.

> >       memcpy(buf, header_prefix, 5);
> >       buf[5] = ctx->interlaced ? ctx->cur_field+2 : 0x01;
> >       buf[6] = 0x80; // crc flag off
> > @@ -483,7 +484,7 @@
> >   static void dnxhd_setup_threads_slices(DNXHDEncContext *ctx, uint8_t *buf)
> >   {
> >       int mb_y, mb_x;
> > -    int i, offset = 0;
> > +    int i, offset = 640;
> >       for (i = 0; i<  ctx->m.avctx->thread_count; i++) {
> >           int thread_size = 0;
> >           for (mb_y = ctx->thread[i]->m.start_mb_y; mb_y<  ctx->thread[i]->m.end_mb_y; mb_y++) {
> > @@ -496,9 +497,11 @@
> >               ctx->slice_size[mb_y]>>= 3;
> >               thread_size += ctx->slice_size[mb_y];
> >           }
> > -        init_put_bits(&ctx->thread[i]->m.pb, buf + 640 + offset, thread_size);
> > +        init_put_bits(&ctx->thread[i]->m.pb, buf + offset, thread_size);
> >           offset += thread_size;
> >       }
> > +    if (offset<  ctx->cid_table->frame_size)
> > +        memset(buf + offset, 0, ctx->cid_table->frame_size - offset);
> >   }
> 
> This will not work for interlaced more.

Hm. How about this patch to test 1080i and 720p instead for better test
coverage?

Index: tests/codec-regression.sh
===================================================================
--- tests/codec-regression.sh   (revision 19912)
+++ tests/codec-regression.sh   (working copy)
@@ -371,8 +371,11 @@
 fi
 
 if [ -n "$do_dnxhd" ] ; then
-do_video_encoding dnxhd.dnxhd "" "-s hd1080 -b 120Mb -pix_fmt yuv422p -an -sws_flags neighbor+bitexact"
+do_video_encoding 1080i.dnxhd "" "-flags +ildct -s hd1080 -b 120Mb -pix_fmt yuv422p -an -sws_flags neighbor+bitexact"
 do_video_decoding "-r 25" "-s cif -pix_fmt yuv420p -sws_flags neighbor+bitexact"
+
+do_video_encoding 720p.dnxhd "" "-s hd720 -b 220Mb -pix_fmt yuv422p -an -sws_flags neighbor+bitexact"
+do_video_decoding "-r 25" "-s cif -pix_fmt yuv420p -sws_flags neighbor+bitexact"
 fi
 
 if [ -n "$do_svq1" ] ; then


Of course the regression test checksums need to be update, but for me
decoding of the file encoded with
./ffmpeg_g -y -flags +bitexact -dct fastint -idct simple -sws_flags +accurate_rnd+bitexact -f image2 -vcodec pgmyuv -i ./tests/vsynth2/%02d.pgm -flags +ildct -s hd1080 -b 120Mb -pix_fmt yuv422p -an -sws_flags neighbor+bitexact ././tests/data/a-1080i.dnxhd

does not work, it seem to be due to the "-flags +ildct" mode...
Or is it a know issue that the dnxhd decoder can not handle interlaced
data?



More information about the ffmpeg-devel mailing list