shithub: openh264

Download patch

ref: daee3dcf22cdeb96ec6ec463a86530813e4ea024
parent: 9ecc671fc334b1562f42c3cf706105b21c5ce7e2
author: Sijia Chen <sijchen@cisco.com>
date: Mon Jun 15 14:09:39 EDT 2015

remove one always-on macro to save code complexity, and use core-1 for multi-threading in real-time

--- a/codec/encoder/core/inc/mt_defs.h
+++ b/codec/encoder/core/inc/mt_defs.h
@@ -51,9 +51,6 @@
 //#define MT_DEBUG
 //#define ENABLE_TRACE_MT
 
-
-#define DYNAMIC_DETECT_CPU_CORES
-
 #define THRESHOLD_RMSE_CORE8    0.0320f // v1.1: 0.0320f; v1.0: 0.02f
 #define THRESHOLD_RMSE_CORE4    0.0215f // v1.1: 0.0215f; v1.0: 0.03f
 #define THRESHOLD_RMSE_CORE2    0.0200f // v1.1: 0.0200f; v1.0: 0.04f
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -2395,22 +2395,18 @@
   iCacheLineSize = 16; // 16 bytes aligned in default
 #endif//X86_ASM
 
-#if defined(DYNAMIC_DETECT_CPU_CORES)
   if (pCodingParam->iMultipleThreadIdc > 0)
     uiCpuCores = pCodingParam->iMultipleThreadIdc;
   else {
     if (uiCpuCores ==
-        0) // cpuid not supported or doesn't expose the number of cores, use high level system API as followed to detect number of pysical/logic processor
+        0) { // cpuid not supported or doesn't expose the number of cores, use high level system API as followed to detect number of pysical/logic processor
       uiCpuCores = DynamicDetectCpuCores();
-    // So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms,
+    }// So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms,
     // for client application here it is constrained by maximal to MAX_THREADS_NUM
-    if (uiCpuCores > MAX_THREADS_NUM) // MAX_THREADS_NUM
-      uiCpuCores = MAX_THREADS_NUM; // MAX_THREADS_NUM
-    else if (uiCpuCores < 1) // just for safe
-      uiCpuCores = 1;
+    if ((pCodingParam->iUsageType == CAMERA_VIDEO_REAL_TIME) || (pCodingParam->iUsageType == SCREEN_CONTENT_REAL_TIME)) {
+      uiCpuCores -= 1; // minus 1 for REAL_TIME video, for the processing needed by other threads
+    }
   }
-#endif//DYNAMIC_DETECT_CPU_CORES
-
   uiCpuCores = WELS_CLIP3 (uiCpuCores, 1, MAX_THREADS_NUM);
 
   if (InitSliceSettings (pLogCtx, pCodingParam, uiCpuCores, &iSliceNum)) {