shithub: openh264

Download patch

ref: 9cf34e76156205551b702c671c33609c536fb08b
parent: 73cc5862bad6518709f9a74f194d008fd2150734
author: Martin Storsjö <martin@martin.st>
date: Fri Feb 28 20:43:11 EST 2014

Unify the interface for the different variants of WelsCPUFeatureDetect

The caller of the function should not need to know exactly which
implementation of it is being used.

For the variants that don't support detecting the number of cores,
the pNumberOfLogicProcessors parameter can be left untouched
and the caller will use a higher level API for finding it out.

This simplifies all the calling code, and simplifies adding
more implementations of cpu feature detection.

--- a/codec/common/cpu.cpp
+++ b/codec/common/cpu.cpp
@@ -212,9 +212,7 @@
 void WelsXmmRegEmptyOp(void * pSrc) {
 }
 
-#endif
-
-#if defined(HAVE_NEON)//For supporting both android platform and iOS platform
+#elif defined(HAVE_NEON) //For supporting both android platform and iOS platform
 #if defined(ANDROID_NDK)
 uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors)
 {
@@ -242,10 +240,8 @@
   return uiCPU;
 }
 
-#endif
-
-#if defined(APPLE_IOS)
-uint32_t WelsCPUFeatureDetectIOS() //Need to be updated for the new device of APPLE
+#elif defined(APPLE_IOS)
+uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors)
 {
     uint32_t       uiCPU = 0;
     struct utsname sSystemInfo;
@@ -262,7 +258,17 @@
     }
     return uiCPU;
 }
+#else /* HAVE_NEON enabled but no runtime detection */
+uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
+  return 0;
+}
 #endif
+#else /* Neither X86_ASM nor HAVE_NEON */
+
+uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
+  return 0;
+}
+
 #endif
 
 
--- a/codec/common/cpu.h
+++ b/codec/common/cpu.h
@@ -62,8 +62,6 @@
 
 void WelsEmms();
 
-uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors);
-
 /*
  *	clear FPU registers states for potential float based calculation if support
  */
@@ -80,17 +78,7 @@
 
 void     WelsXmmRegEmptyOp(void * pSrc);
 
-#if defined(HAVE_NEON)
-#if defined(ANDROID_NDK)
-
 uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors);
-
-#endif
-
-#if defined(APPLE_IOS)
-	uint32_t WelsCPUFeatureDetectIOS();
-#endif
-#endif
 
 #if defined(__cplusplus)
 }
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -144,16 +144,7 @@
   pCtx->bAuReadyFlag				= 0; // au data is not ready
 
 
-#if defined(X86_ASM)
   pCtx->uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores);
-#elif defined(HAVE_NEON)
-#if defined(ANDROID_NDK)
-  pCtx->uiCpuFlag	= WelsCPUFeatureDetect(&iCpuCores);
-#endif
-#if defined(APPLE_IOS)
-  pCtx->uiCpuFlag	= WelsCPUFeatureDetectIOS();
-#endif
-#endif
 
   pCtx->iImgWidthInPixel		= 0;
   pCtx->iImgHeightInPixel		= 0;		// alloc picture data when picture size is available
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -1933,8 +1933,8 @@
   }
 
   // for cpu features detection, Only detect once??
-#ifdef X86_ASM
   uiCpuFeatureFlags	= WelsCPUFeatureDetect (&uiCpuCores);	// detect cpu capacity features
+#ifdef X86_ASM
   if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_128)
     iCacheLineSize = 128;
   else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_64)
--- a/codec/processing/src/common/WelsFrameWork.cpp
+++ b/codec/processing/src/common/WelsFrameWork.cpp
@@ -87,11 +87,7 @@
 
 CVpFrameWork::CVpFrameWork (uint32_t uiThreadsNum, EResult& eReturn) {
   int32_t iCoreNum = 1;
-#ifndef X86_ASM
-  uint32_t uiCPUFlag = 0;
-#else
   uint32_t uiCPUFlag = WelsCPUFeatureDetect (&iCoreNum);
-#endif
 
   for (int32_t i = 0; i < MAX_STRATEGY_NUM; i++) {
     IStrategy* pStrategy = m_pStgChain[i];