From 4d729c94186457f205fc73e375a781af9468229a Mon Sep 17 00:00:00 2001 From: volvet Date: Tue, 4 Mar 2014 15:50:41 +0800 Subject: [PATCH] get cpu cores for android --- codec/common/cpu.cpp | 7 ++++++- codec/common/cpu.h | 4 +++- codec/decoder/core/src/decoder.cpp | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/codec/common/cpu.cpp b/codec/common/cpu.cpp index 65ee1a04..14194ff7 100644 --- a/codec/common/cpu.cpp +++ b/codec/common/cpu.cpp @@ -216,7 +216,7 @@ void WelsXmmRegEmptyOp(void * pSrc) { #if defined(HAVE_NEON)//For supporting both android platform and iOS platform #if defined(ANDROID_NDK) -uint32_t WelsCPUFeatureDetectAndroid() +uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) { uint32_t uiCPU = 0; AndroidCpuFamily cpuFamily = ANDROID_CPU_FAMILY_UNKNOWN; @@ -234,6 +234,11 @@ uint32_t WelsCPUFeatureDetectAndroid() uiCPU |= WELS_CPU_NEON; } } + + if( pNumberOfLogicProcessors != NULL ){ + *pNumberOfLogicProcessors = android_getCpuCount(); + } + return uiCPU; } diff --git a/codec/common/cpu.h b/codec/common/cpu.h index b22b4ce3..5623cad0 100644 --- a/codec/common/cpu.h +++ b/codec/common/cpu.h @@ -82,7 +82,9 @@ void WelsXmmRegEmptyOp(void * pSrc); #if defined(HAVE_NEON) #if defined(ANDROID_NDK) - uint32_t WelsCPUFeatureDetectAndroid(); + +uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors); + #endif #if defined(APPLE_IOS) diff --git a/codec/decoder/core/src/decoder.cpp b/codec/decoder/core/src/decoder.cpp index 1cd7a95b..6200c942 100644 --- a/codec/decoder/core/src/decoder.cpp +++ b/codec/decoder/core/src/decoder.cpp @@ -148,7 +148,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx) { pCtx->uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); #elif defined(HAVE_NEON) #if defined(ANDROID_NDK) - pCtx->uiCpuFlag = WelsCPUFeatureDetectAndroid(); + pCtx->uiCpuFlag = WelsCPUFeatureDetect(&iCpuCores); #endif #if defined(APPLE_IOS) pCtx->uiCpuFlag = WelsCPUFeatureDetectIOS();