[x264-devel] commit: Optimize exp2fix8 (Anton Mitrofanov )

git version control git at videolan.org
Mon Oct 12 10:42:28 CEST 2009


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Thu Oct  8 14:55:26 2009 -0700| [60c630c01dd4cb125a2bcc08da88873ce3a41dbc] | committer: Jason Garrett-Glaser 

Optimize exp2fix8
Slightly faster and more accurate rounding.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=60c630c01dd4cb125a2bcc08da88873ce3a41dbc
---

 common/common.h   |    6 +++---
 encoder/analyse.c |    8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/common/common.h b/common/common.h
index a0afeda..4313db8 100644
--- a/common/common.h
+++ b/common/common.h
@@ -165,9 +165,9 @@ extern const float x264_log2_lz_lut[32];
  * qp to qscale. */
 static ALWAYS_INLINE int x264_exp2fix8( float x )
 {
-    if( x >= 512.f/6.f ) return 0;
-    if( x <= -512.f/6.f ) return 0xffff;
-    int i = x*(-64.f/6.f) + 512;
+    int i = x*(-64.f/6.f) + 512.5f;
+    if( i < 0 ) return 0;
+    if( i > 1023 ) return 0xffff;
     return (x264_exp2_lut[i&63]+256) << (i>>6) >> 8;
 }
 
diff --git a/encoder/analyse.c b/encoder/analyse.c
index b941557..41be7b7 100644
--- a/encoder/analyse.c
+++ b/encoder/analyse.c
@@ -154,10 +154,10 @@ const int x264_lambda2_tab[52] = {
 };
 
 const uint8_t x264_exp2_lut[64] = {
-      1,   4,   7,  10,  13,  16,  19,  22,  25,  28,  31,  34,  37,  40,  44,  47,
-     50,  53,  57,  60,  64,  67,  71,  74,  78,  81,  85,  89,  93,  96, 100, 104,
-    108, 112, 116, 120, 124, 128, 132, 137, 141, 145, 150, 154, 159, 163, 168, 172,
-    177, 182, 186, 191, 196, 201, 206, 211, 216, 221, 226, 232, 237, 242, 248, 253,
+      0,   3,   6,   8,  11,  14,  17,  20,  23,  26,  29,  32,  36,  39,  42,  45,
+     48,  52,  55,  58,  62,  65,  69,  72,  76,  80,  83,  87,  91,  94,  98, 102,
+    106, 110, 114, 118, 122, 126, 130, 135, 139, 143, 147, 152, 156, 161, 165, 170,
+    175, 179, 184, 189, 194, 198, 203, 208, 214, 219, 224, 229, 234, 240, 245, 250
 };
 
 const float x264_log2_lut[128] = {



More information about the x264-devel mailing list