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

Reimar Döffinger Reimar.Doeffinger
Fri Sep 18 15:37:38 CEST 2009


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);
     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);
 }
 
 static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg)




More information about the ffmpeg-devel mailing list