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

Baptiste Coudurier baptiste.coudurier
Fri Sep 18 21:04:55 CEST 2009


Hi Reimar,

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.

>       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.

It should be fixed in svn.

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



More information about the ffmpeg-devel mailing list