[FFmpeg-devel] [PATCH] Fix partially hidden macroblocks for 10-bit DNxHD

Joseph Artsimovich joseph at mirriad.com
Thu Aug 23 16:42:37 CEST 2012


Hello,

The attached patch fixes "mirroring" artifacts at the bottom of a frame 
when encoding 10-bit DNxHD in interlaced (-flags +ildct) mode.
The problem was in dnxhd_10bit_get_pixels_8x4_sym(). In addition to 
producing the above mentioned "mirroring", it was also assuming 
sizeof(DCTELEM) == 2, which might be correct now, but should not be 
relied upon.
The new version is very close to dnxhd_8bit_get_pixels_8x4_sym().

Progressive mode wasn't affected because 1080 and 720 are both multiples 
of 8,  meaning that partially hidden blocks would never happen.

-- 
Joseph Artsimovich
Senior C++ Applications Developer
MirriAd Ltd

-------------- next part --------------
>From 924c4a00935aa435e923587257e939366d926580 Mon Sep 17 00:00:00 2001
From: Joseph Artsimovich <joseph at mirriad.com>
Date: Thu, 23 Aug 2012 14:51:28 +0100
Subject: [PATCH] Fix partially hidden macroblocks for 10-bit DNxHD.

---
 libavcodec/dnxhdenc.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 04284e3..97013f6 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -71,13 +71,21 @@ static void dnxhd_8bit_get_pixels_8x4_sym(DCTELEM *restrict block, const uint8_t
 static av_always_inline void dnxhd_10bit_get_pixels_8x4_sym(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
 {
     int i;
-
-    block += 32;
+    const uint16_t* pixels16 = pixels;
+    line_size >>= 1;
 
     for (i = 0; i < 4; i++) {
-        memcpy(block + i     * 8, pixels + i * line_size, 8 * sizeof(*block));
-        memcpy(block - (i+1) * 8, pixels + i * line_size, 8 * sizeof(*block));
+        block[0] = pixels16[0]; block[1] = pixels16[1];
+        block[2] = pixels16[2]; block[3] = pixels16[3];
+        block[4] = pixels16[4]; block[5] = pixels16[5];
+        block[6] = pixels16[6]; block[7] = pixels16[7];
+        pixels16 += line_size;
+        block += 8;
     }
+    memcpy(block,      block -  8, sizeof(*block) * 8);
+    memcpy(block +  8, block - 16, sizeof(*block) * 8);
+    memcpy(block + 16, block - 24, sizeof(*block) * 8);
+    memcpy(block + 24, block - 32, sizeof(*block) * 8);
 }
 
 static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, DCTELEM *block,
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list