[x265] DC only for HIGH_BIT_DEPTH

Satoshi Nakagawa nakagawa424 at oki.com
Mon Mar 17 11:38:46 CET 2014


# HG changeset patch
# User Satoshi Nakagawa <nakagawa424 at oki.com>
# Date 1394980676 -32400
#      Sun Mar 16 23:37:56 2014 +0900
# Node ID b134079762c9eec7c9e1ea657983ba95bd322a28
# Parent  ba3ddc1848fff0fb8e96ca8f0453dd84171f213f
DC only for HIGH_BIT_DEPTH

diff -r ba3ddc1848ff -r b134079762c9 source/Lib/TLibCommon/TComTrQuant.cpp
--- a/source/Lib/TLibCommon/TComTrQuant.cpp	Fri Mar 14 12:56:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp	Sun Mar 16 23:37:56 2014 +0900
@@ -397,18 +397,19 @@
 
         const uint32_t log2BlockSize = log2TrSize - 2;
 
-#if HIGH_BIT_DEPTH
-        lastPos = !lastPos; // prevent warning
-#else
         // DC only
         if (lastPos == 0 && !((trSize == 4) && (mode != REG_DCT)))
         {
-            int dc_val = (((m_tmpCoeff[0] * 64 + 64) >> 7) * 64 + 2048) >> 12;
+            const int shift_1st = 7;
+            const int add_1st = 1 << (shift_1st - 1);
+            const int shift_2nd = 12 - (X265_DEPTH - 8);
+            const int add_2nd = 1 << (shift_2nd - 1);
+
+            int dc_val = (((m_tmpCoeff[0] * 64 + add_1st) >> shift_1st) * 64 + add_2nd) >> shift_2nd;
             primitives.blockfill_s[log2BlockSize](residual, stride, dc_val);
 
             return;
         }
-#endif
 
         // TODO: this may need larger data types for X265_DEPTH > 8
         primitives.idct[IDCT_4x4 + log2BlockSize - ((trSize == 4) && (mode != REG_DCT))](m_tmpCoeff, residual, stride);


More information about the x265-devel mailing list