MCPcopy Create free account
hub / github.com/cisco/openh264 / GetMultipleThreadIdc

Function GetMultipleThreadIdc

codec/encoder/core/src/encoder_ext.cpp:2192–2232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2190
2191
2192int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingParam, int16_t& iSliceNum,
2193 int32_t& iCacheLineSize, uint32_t& uiCpuFeatureFlags) {
2194 // for cpu features detection, Only detect once??
2195 int32_t uiCpuCores =
2196 0; // number of logic processors on physical processor package, zero logic processors means HTT not supported
2197 uiCpuFeatureFlags = WelsCPUFeatureDetect (&uiCpuCores); // detect cpu capacity features
2198
2199#ifdef X86_ASM
2200 if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_128)
2201 iCacheLineSize = 128;
2202 else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_64)
2203 iCacheLineSize = 64;
2204 else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_32)
2205 iCacheLineSize = 32;
2206 else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_16)
2207 iCacheLineSize = 16;
2208 OutputCpuFeaturesLog (pLogCtx, uiCpuFeatureFlags, uiCpuCores, iCacheLineSize);
2209#else
2210 iCacheLineSize = 16; // 16 bytes aligned in default
2211#endif//X86_ASM
2212
2213 if (0 == pCodingParam->iMultipleThreadIdc && uiCpuCores == 0) {
2214 // cpuid not supported or doesn't expose the number of cores,
2215 // use high level system API as followed to detect number of pysical/logic processor
2216 uiCpuCores = DynamicDetectCpuCores();
2217 }
2218
2219 if (0 == pCodingParam->iMultipleThreadIdc)
2220 pCodingParam->iMultipleThreadIdc = (uiCpuCores > 0) ? uiCpuCores : 1;
2221
2222 // So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms,
2223 // for client application here it is constrained by maximal to MAX_THREADS_NUM
2224 pCodingParam->iMultipleThreadIdc = WELS_CLIP3 (pCodingParam->iMultipleThreadIdc, 1, MAX_THREADS_NUM);
2225 uiCpuCores = pCodingParam->iMultipleThreadIdc;
2226
2227 if (InitSliceSettings (pLogCtx, pCodingParam, uiCpuCores, &iSliceNum)) {
2228 WelsLog (pLogCtx, WELS_LOG_ERROR, "GetMultipleThreadIdc(), InitSliceSettings failed.");
2229 return 1;
2230 }
2231 return 0;
2232}
2233
2234/*!
2235 * \brief uninitialize Wels encoder core library

Callers 2

WelsInitEncoderExtFunction · 0.85
WelsEncoderParamAdjustFunction · 0.85

Calls 5

WelsCPUFeatureDetectFunction · 0.85
OutputCpuFeaturesLogFunction · 0.85
DynamicDetectCpuCoresFunction · 0.85
InitSliceSettingsFunction · 0.85
WelsLogFunction · 0.85

Tested by

no test coverage detected