Merge pull request #402 from mstorsjo/unify-cpu-feature-detect
Unify the interface for the different variants of WelsCPUFeatureDetect
This commit is contained in:
commit
fc8fcc2e62
@ -38,6 +38,7 @@
|
|||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
#ifdef ANDROID_NDK
|
#ifdef ANDROID_NDK
|
||||||
#include <cpu-features.h>
|
#include <cpu-features.h>
|
||||||
#endif
|
#endif
|
||||||
@ -212,9 +213,7 @@ void WelsCPURestore (const uint32_t kuiCPU) {
|
|||||||
void WelsXmmRegEmptyOp(void * pSrc) {
|
void WelsXmmRegEmptyOp(void * pSrc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#elif defined(HAVE_NEON) //For supporting both android platform and iOS platform
|
||||||
|
|
||||||
#if defined(HAVE_NEON)//For supporting both android platform and iOS platform
|
|
||||||
#if defined(ANDROID_NDK)
|
#if defined(ANDROID_NDK)
|
||||||
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors)
|
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors)
|
||||||
{
|
{
|
||||||
@ -242,10 +241,8 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors)
|
|||||||
return uiCPU;
|
return uiCPU;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#elif defined(APPLE_IOS)
|
||||||
|
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors)
|
||||||
#if defined(APPLE_IOS)
|
|
||||||
uint32_t WelsCPUFeatureDetectIOS() //Need to be updated for the new device of APPLE
|
|
||||||
{
|
{
|
||||||
uint32_t uiCPU = 0;
|
uint32_t uiCPU = 0;
|
||||||
struct utsname sSystemInfo;
|
struct utsname sSystemInfo;
|
||||||
@ -262,7 +259,47 @@ uint32_t WelsCPUFeatureDetectIOS() //Need to be updated for the new device of AP
|
|||||||
}
|
}
|
||||||
return uiCPU;
|
return uiCPU;
|
||||||
}
|
}
|
||||||
|
#elif defined(__linux__)
|
||||||
|
|
||||||
|
/* Generic arm/linux cpu feature detection */
|
||||||
|
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
|
||||||
|
FILE *f = fopen("/proc/cpuinfo", "r");
|
||||||
|
|
||||||
|
if (!f)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
char buf[200];
|
||||||
|
int flags = 0;
|
||||||
|
while (fgets(buf, sizeof(buf), f)) {
|
||||||
|
if (!strncmp(buf, "Features", strlen("Features"))) {
|
||||||
|
if (strstr(buf, " neon "))
|
||||||
|
flags |= WELS_CPU_NEON;
|
||||||
|
if (strstr(buf, " vfpv3 "))
|
||||||
|
flags |= WELS_CPU_VFPv3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* HAVE_NEON enabled but no runtime detection */
|
||||||
|
|
||||||
|
/* No runtime feature detection available, but built with HAVE_NEON - assume
|
||||||
|
* that NEON and all associated features are available. */
|
||||||
|
|
||||||
|
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
|
||||||
|
return WELS_CPU_ARMv7 |
|
||||||
|
WELS_CPU_VFPv3 |
|
||||||
|
WELS_CPU_NEON;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#else /* Neither X86_ASM nor HAVE_NEON */
|
||||||
|
|
||||||
|
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,8 +62,6 @@ int32_t WelsCPUSupportFMA (uint32_t eax, uint32_t ecx);
|
|||||||
|
|
||||||
void WelsEmms();
|
void WelsEmms();
|
||||||
|
|
||||||
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* clear FPU registers states for potential float based calculation if support
|
* clear FPU registers states for potential float based calculation if support
|
||||||
*/
|
*/
|
||||||
@ -80,18 +78,8 @@ void WelsXmmRegLoad(void * src);
|
|||||||
|
|
||||||
void WelsXmmRegEmptyOp(void * pSrc);
|
void WelsXmmRegEmptyOp(void * pSrc);
|
||||||
|
|
||||||
#if defined(HAVE_NEON)
|
|
||||||
#if defined(ANDROID_NDK)
|
|
||||||
|
|
||||||
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors);
|
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(APPLE_IOS)
|
|
||||||
uint32_t WelsCPUFeatureDetectIOS();
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif//__cplusplus
|
#endif//__cplusplus
|
||||||
|
@ -144,16 +144,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx) {
|
|||||||
pCtx->bAuReadyFlag = 0; // au data is not ready
|
pCtx->bAuReadyFlag = 0; // au data is not ready
|
||||||
|
|
||||||
|
|
||||||
#if defined(X86_ASM)
|
|
||||||
pCtx->uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores);
|
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->iImgWidthInPixel = 0;
|
||||||
pCtx->iImgHeightInPixel = 0; // alloc picture data when picture size is available
|
pCtx->iImgHeightInPixel = 0; // alloc picture data when picture size is available
|
||||||
|
@ -1933,8 +1933,8 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for cpu features detection, Only detect once??
|
// for cpu features detection, Only detect once??
|
||||||
#ifdef X86_ASM
|
|
||||||
uiCpuFeatureFlags = WelsCPUFeatureDetect (&uiCpuCores); // detect cpu capacity features
|
uiCpuFeatureFlags = WelsCPUFeatureDetect (&uiCpuCores); // detect cpu capacity features
|
||||||
|
#ifdef X86_ASM
|
||||||
if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_128)
|
if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_128)
|
||||||
iCacheLineSize = 128;
|
iCacheLineSize = 128;
|
||||||
else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_64)
|
else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_64)
|
||||||
|
@ -87,11 +87,7 @@ EResult DestroySpecificVpInterface (IWelsVP* pCtx) {
|
|||||||
|
|
||||||
CVpFrameWork::CVpFrameWork (uint32_t uiThreadsNum, EResult& eReturn) {
|
CVpFrameWork::CVpFrameWork (uint32_t uiThreadsNum, EResult& eReturn) {
|
||||||
int32_t iCoreNum = 1;
|
int32_t iCoreNum = 1;
|
||||||
#ifndef X86_ASM
|
|
||||||
uint32_t uiCPUFlag = 0;
|
|
||||||
#else
|
|
||||||
uint32_t uiCPUFlag = WelsCPUFeatureDetect (&iCoreNum);
|
uint32_t uiCPUFlag = WelsCPUFeatureDetect (&iCoreNum);
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < MAX_STRATEGY_NUM; i++) {
|
for (int32_t i = 0; i < MAX_STRATEGY_NUM; i++) {
|
||||||
IStrategy* pStrategy = m_pStgChain[i];
|
IStrategy* pStrategy = m_pStgChain[i];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user