[x265] initLambda: avoid use of pow() to reduce platform dependency [CHANGES OUTPUTS]

Satoshi Nakagawa nakagawa424 at oki.com
Thu Apr 24 02:43:06 CEST 2014


# HG changeset patch
# User Satoshi Nakagawa <nakagawa424 at oki.com>
# Date 1398260609 -32400
#      Wed Apr 23 22:43:29 2014 +0900
# Node ID d6226ce3db3da5d6b01819d364a91329aa3e2a64
# Parent  ea597d46f30e97600641051c9a8f96435545e09a
initLambda: avoid use of pow() to reduce platform dependency [CHANGES OUTPUTS]

diff -r ea597d46f30e -r d6226ce3db3d source/Lib/TLibCommon/TComRom.cpp
--- a/source/Lib/TLibCommon/TComRom.cpp	Wed Apr 23 01:56:45 2014 -0500
+++ b/source/Lib/TLibCommon/TComRom.cpp	Wed Apr 23 22:43:29 2014 +0900
@@ -131,12 +131,25 @@
 
 static void initLambda(double scale)
 {
+    // pow(2, (double)q / 6 - 2);
+    static const double lambda_base[6] =
+    {
+        0.25,
+        0.28061551207734324536,
+        0.31498026247371829119,
+        0.35355339059327376220,
+        0.39685026299204986869,
+        0.44544935907016965237,
+    };
+
     for (int q = 0; q <= MAX_MAX_QP; q++)
     {
-        double lambda = pow(2, (double)q / 6 - 2);
+        int p = q / 6;
+        int r = q % 6;
+        double lambda = lambda_base[r] * (double)(1 << p);
 
         x265_lambda_tab[q]  = lambda;
-        x265_lambda2_tab[q] = pow(lambda, 2) * scale;
+        x265_lambda2_tab[q] = lambda * lambda * scale;
     }
 }
 


More information about the x265-devel mailing list