[x265] [PATCH 1 of 2] wavefront: execute from id low to high

Min Chen chenm003 at 163.com
Mon Aug 19 17:46:46 CEST 2013


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1376927119 -28800
# Node ID 6a4a9173030c962ae56d02e90485eb7e27071714
# Parent  6bd04d6588851fe2a6f40d03d5ac385c5e34e743
wavefront: execute from id low to high

diff -r 6bd04d658885 -r 6a4a9173030c source/common/wavefront.cpp
--- a/source/common/wavefront.cpp	Mon Aug 19 06:48:29 2013 -0500
+++ b/source/common/wavefront.cpp	Mon Aug 19 23:45:19 2013 +0800
@@ -63,6 +63,23 @@
     else
         return *id = 0;
 }
+
+inline int _BitScanForward64(DWORD *id, uint64_t x64) // fake 64bit CLZ
+{
+    uint32_t high32 = (uint32_t)(x64 >> 32);
+    uint32_t low32 = (uint32_t)x64;
+
+    if (high32)
+    {
+        _BitScanForward(id, high32);
+        *id += 32;
+        return 1;
+    }
+    else if (low32)
+        return _BitScanForward(id, low32);
+    else
+        return *id = 0;
+}
 #endif // if !_WIN64
 
 #if _WIN32_WINNT <= _WIN32_WINNT_WINXP
@@ -89,7 +106,7 @@
 #define ATOMIC_OR(ptr, mask)            InterlockedOr64((volatile LONG64*)ptr, mask)
 #endif // if _WIN32_WINNT <= _WIN32_WINNT_WINXP
 
-#define CLZ64(id, x)                    _BitScanReverse64(&id, x)
+#define CLZ64(id, x)                    _BitScanForward64(&id, x)
 #define ATOMIC_CAS(ptr, oldval, newval) (uint64_t)_InterlockedCompareExchange64((volatile LONG64*)ptr, newval, oldval)
 
 #endif // ifdef __GNUC__



More information about the x265-devel mailing list