[x265] [PATCH] [PPC] support option --no-asm to disable Altivec

chen chenm003 at 163.com
Mon Oct 24 23:29:32 CEST 2016


From d23527c6204921b782ef8bc2f1a69de88163202a Mon Sep 17 00:00:00 2001
From: Min Chen <min.chen at multicorewareinc.com>
Date: Mon, 24 Oct 2016 16:27:35 -0500
Subject: [PATCH] [PPC] support option --no-asm to disable Altivec


---
 source/CMakeLists.txt        |    2 +-
 source/common/cpu.cpp        |   17 ++++++++++++++++-
 source/common/primitives.cpp |   11 +++++++----
 source/common/version.cpp    |    4 +---
 source/x265.h                |    3 +++
 5 files changed, 28 insertions(+), 9 deletions(-)


diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 18cad9a..9e8e5ab 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -426,7 +426,7 @@ if(POWER)
 
     option(CPU_POWER8 "Enable CPU POWER8 profiling instrumentation" ON)
     if(CPU_POWER8)
-        add_definitions(-mcpu=power8)
+        add_definitions(-mcpu=power8 -DX265_ARCH_POWER8=1)
     endif()
 endif()
 
diff --git a/source/common/cpu.cpp b/source/common/cpu.cpp
index 0dafe48..5bd1e0f 100644
--- a/source/common/cpu.cpp
+++ b/source/common/cpu.cpp
@@ -99,6 +99,10 @@ const cpu_name_t cpu_names[] =
     { "ARMv6",           X265_CPU_ARMV6 },
     { "NEON",            X265_CPU_NEON },
     { "FastNeonMRC",     X265_CPU_FAST_NEON_MRC },
+
+#elif X265_ARCH_POWER8
+    { "Altivec",         X265_CPU_ALTIVEC },
+
 #endif // if X265_ARCH_X86
     { "", 0 },
 };
@@ -363,7 +367,18 @@ uint32_t cpu_detect(void)
     return flags;
 }
 
-#else // if X265_ARCH_X86
+#elif X265_ARCH_POWER8
+
+uint32_t cpu_detect(void)
+{
+#if HAVE_ALTIVEC
+    return X265_CPU_ALTIVEC;
+#else
+    return 0;
+#endif
+}
+
+#else // if X265_ARCH_POWER8
 
 uint32_t cpu_detect(void)
 {
diff --git a/source/common/primitives.cpp b/source/common/primitives.cpp
index 569f8ad..e000a2f 100644
--- a/source/common/primitives.cpp
+++ b/source/common/primitives.cpp
@@ -244,10 +244,13 @@ void x265_setup_primitives(x265_param *param)
         setupAssemblyPrimitives(primitives, param->cpuid);
 #endif
 #if HAVE_ALTIVEC
-        setupPixelPrimitives_altivec(primitives);      // pixel_altivec.cpp, overwrite the initialization for altivec optimizated functions
-        setupDCTPrimitives_altivec(primitives);        // dct_altivec.cpp, overwrite the initialization for altivec optimizated functions
-        setupFilterPrimitives_altivec(primitives);     // ipfilter.cpp, overwrite the initialization for altivec optimizated functions
-        setupIntraPrimitives_altivec(primitives); // intrapred_altivec.cpp, overwrite the initialization for altivec optimizated functions
+        if (param->cpuid & X265_CPU_ALTIVEC)
+        {
+            setupPixelPrimitives_altivec(primitives);       // pixel_altivec.cpp, overwrite the initialization for altivec optimizated functions
+            setupDCTPrimitives_altivec(primitives);         // dct_altivec.cpp, overwrite the initialization for altivec optimizated functions
+            setupFilterPrimitives_altivec(primitives);      // ipfilter.cpp, overwrite the initialization for altivec optimizated functions
+            setupIntraPrimitives_altivec(primitives);       // intrapred_altivec.cpp, overwrite the initialization for altivec optimizated functions
+        }
 #endif
 
         setupAliasPrimitives(primitives);
diff --git a/source/common/version.cpp b/source/common/version.cpp
index dd114a3..e4d7554 100644
--- a/source/common/version.cpp
+++ b/source/common/version.cpp
@@ -77,10 +77,8 @@
 #define BITS    "[32 bit]"
 #endif
 
-#if defined(ENABLE_ASSEMBLY)
+#if defined(ENABLE_ASSEMBLY) || HAVE_ALTIVEC
 #define ASM     ""
-#elif HAVE_ALTIVEC
-#define ASM     "[altivec]"
 #else
 #define ASM     "[noasm]"
 #endif
diff --git a/source/x265.h b/source/x265.h
index 6ef27de..e6a8b01 100644
--- a/source/x265.h
+++ b/source/x265.h
@@ -335,6 +335,9 @@ typedef enum
 #define X265_CPU_NEON            0x0000002  /* ARM NEON */
 #define X265_CPU_FAST_NEON_MRC   0x0000004  /* Transfer from NEON to ARM register is fast (Cortex-A9) */
 
+/* IBM Power8 */
+#define X265_CPU_ALTIVEC         0x0000001
+
 #define X265_MAX_SUBPEL_LEVEL   7
 
 /* Log level */
-- 
1.7.9.msysgit.0

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20161025/3d558b83/attachment.html>


More information about the x265-devel mailing list