[FFmpeg-devel] [PATCH] Fix 10-bit DNxHD quant matrices

Joseph Artsimovich joseph at mirriad.com
Fri Jul 20 12:31:06 CEST 2012


When I was adding support for 10-bit DNxHD, I just copy-pasted the 
missing quant matrices from the spec. Now it turns out the existing 
matrices in dnxhddata.c were in zigzag order. This resulted in wrong 
quantization for 10-bit DNxHD. The attached patch fixes the problem by 
converting 10-bit quant matrices to zigzag order.

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

-------------- next part --------------
>From ea01c3dda8cffecd266c433415675fee158c9fc6 Mon Sep 17 00:00:00 2001
From: Joseph Artsimovich <joseph at mirriad.com>
Date: Fri, 20 Jul 2012 11:05:39 +0100
Subject: [PATCH] Fix DNxHD 10-bit quant tables.

Convert them to zigzag order, as the rest of them are.
---
 libavcodec/dnxhddata.c |   66 ++++++++++++++++++++++++-----------------------
 1 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c
index 2652df1..8cb58b3 100644
--- a/libavcodec/dnxhddata.c
+++ b/libavcodec/dnxhddata.c
@@ -22,26 +22,28 @@
 #include "avcodec.h"
 #include "dnxhddata.h"
 
+/* The quantization tables below are in zigzag order! */
+
 static const uint8_t dnxhd_1235_luma_weight[] = {
-     0, 32, 32, 32, 33, 35, 38, 39,
-    32, 33, 32, 33, 36, 36, 39, 42,
-    32, 32, 33, 36, 35, 37, 41, 43,
-    31, 33, 34, 36, 36, 40, 42, 48,
-    32, 34, 36, 37, 39, 42, 46, 51,
-    36, 37, 37, 39, 41, 46, 51, 55,
-    37, 39, 41, 41, 47, 50, 55, 56,
-    41, 42, 41, 44, 50, 53, 60, 60
+     0, 32, 32, 32, 33, 32, 32, 32,
+    32, 31, 32, 33, 33, 33, 33, 35,
+    36, 36, 34, 34, 36, 37, 37, 36,
+    36, 35, 36, 38, 39, 39, 37, 36,
+    37, 37, 39, 41, 42, 41, 39, 39,
+    40, 41, 42, 43, 42, 42, 41, 41,
+    41, 44, 47, 46, 46, 48, 51, 51,
+    50, 50, 53, 55, 55, 56, 60, 60,
 };
 
 static const uint8_t dnxhd_1235_chroma_weight[] = {
-     0, 32, 33, 34, 39, 41, 54, 59,
-    33, 34, 35, 38, 43, 49, 58, 84,
-    34, 37, 39, 44, 46, 55, 74, 87,
-    40, 42, 47, 48, 58, 70, 87, 86,
-    43, 50, 56, 63, 72, 94, 91, 82,
-    55, 63, 65, 75, 93, 89, 85, 73,
-    61, 67, 82, 81, 83, 90, 79, 73,
-    74, 84, 75, 78, 90, 85, 73, 73
+     0, 32, 33, 34, 34, 33, 34, 35,
+    37, 40, 43, 42, 39, 38, 39, 41,
+    43, 44, 47, 50, 55, 61, 63, 56,
+    48, 46, 49, 54, 59, 58, 55, 58,
+    63, 65, 67, 74, 84, 82, 75, 72,
+    70, 74, 84, 87, 87, 94, 93, 81,
+    75, 78, 83, 89, 91, 86, 82, 85,
+    90, 90, 85, 79, 73, 73, 73, 73,
 };
 
 static const uint8_t dnxhd_1237_luma_weight[] = {
@@ -155,25 +157,25 @@ static const uint8_t dnxhd_1243_chroma_weight[] = {
 };
 
 static const uint8_t dnxhd_1250_luma_weight[] = {
-     0, 32, 35, 35, 36, 36, 41, 43,
-    32, 34, 35, 36, 37, 39, 43, 47,
-    33, 34, 36, 38, 38, 42, 42, 50,
-    34, 36, 38, 38, 41, 40, 47, 54,
-    35, 38, 39, 40, 39, 45, 49, 58,
-    38, 39, 40, 39, 46, 47, 54, 60,
-    38, 39, 41, 46, 46, 48, 57, 62,
-    40, 41, 44, 45, 49, 54, 63, 63
+     0, 32, 32, 33, 34, 35, 35, 35,
+    34, 34, 35, 36, 36, 36, 36, 36,
+    37, 38, 38, 38, 38, 38, 39, 39,
+    38, 38, 39, 41, 43, 43, 42, 41,
+    40, 40, 39, 40, 41, 41, 39, 39,
+    40, 42, 47, 50, 47, 45, 46, 46,
+    44, 45, 46, 47, 49, 54, 58, 54,
+    48, 49, 54, 57, 60, 62, 63, 63,
 };
 
 static const uint8_t dnxhd_1250_chroma_weight[] = {
-     0, 32, 35, 36, 40, 42, 51, 51,
-    35, 36, 39, 39, 43, 51, 52, 55,
-    36, 41, 41, 43, 51, 53, 54, 56,
-    43, 44, 45, 50, 54, 54, 55, 57,
-    45, 48, 50, 51, 55, 58, 59, 58,
-    49, 52, 49, 57, 58, 62, 58, 60,
-    51, 51, 56, 58, 62, 61, 59, 62,
-    52, 52, 60, 61, 59, 59, 63, 63
+     0, 32, 35, 36, 36, 35, 36, 39,
+    41, 43, 45, 44, 41, 39, 40, 42,
+    43, 43, 45, 48, 49, 51, 52, 50,
+    50, 51, 51, 51, 51, 52, 53, 54,
+    51, 49, 51, 52, 52, 56, 57, 55,
+    54, 54, 55, 56, 55, 58, 58, 58,
+    60, 61, 62, 62, 59, 57, 58, 58,
+    61, 59, 59, 59, 60, 62, 63, 63,
 };
 
 static const uint8_t dnxhd_1251_luma_weight[] = {
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list