Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 1 file). Show all
Unified · Split
| @@ -180,6 +180,11 @@ int32_t SliceArgumentValidationFixedSliceMode(SLogContext* pLogCtx, · 179 unmodified lines | ||
| 180 | 180 | |
| 181 | 181 | if (pSliceArgument->uiSliceNum == 0) { |
| 182 | 182 | WelsCPUFeatureDetect (&iCpuCores); |
| 183 | + if (0 == iCpuCores ) { | |
| 184 | + // cpuid not supported or doesn't expose the number of cores, | |
| 185 | + // use high level system API as followed to detect number of pysical/logic processor | |
| 186 | + iCpuCores = DynamicDetectCpuCores(); | |
| 187 | + } | |
| 183 | 188 | pSliceArgument->uiSliceNum = iCpuCores; |
| 184 | 189 | } |
| 185 | 190 | |
| @@ -2245,8 +2250,8 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 2059 unmodified lines | ||
| 2245 | 2250 | } |
| 2246 | 2251 | } |
| 2247 | 2252 | |
| 2248 | −int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingParam, const int32_t kiCpuCores, | |
| 2249 | − int16_t* pMaxSliceCount) { | |
| 2253 | +int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingParam, | |
| 2254 | + const int32_t kiCpuCores, int16_t* pMaxSliceCount) { | |
| 2250 | 2255 | int32_t iSpatialIdx = 0, iSpatialNum = pCodingParam->iSpatialLayerNum; |
| 2251 | 2256 | uint16_t iMaxSliceCount = 0; |
| 2252 | 2257 | |
| @@ -2254,11 +2259,6 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar · 1 unmodified line | ||
| 2254 | 2259 | SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[iSpatialIdx]; |
| 2255 | 2260 | SSliceArgument* pSliceArgument = &pDlp->sSliceArgument; |
| 2256 | 2261 | int32_t iReturn = 0; |
| 2257 | − int32_t iSliceNum = (SM_FIXEDSLCNUM_SLICE == pSliceArgument->uiSliceMode && 0==pSliceArgument->uiSliceNum) ? kiCpuCores : pSliceArgument->uiSliceNum; | |
| 2258 | − // NOTE: Per design, in case MT/DYNAMIC_SLICE_ASSIGN enabled, for SM_FIXEDSLCNUM_SLICE mode, | |
| 2259 | − // uiSliceNum of current spatial layer settings equals to uiCpuCores number; SM_SIZELIMITED_SLICE mode, | |
| 2260 | − // uiSliceNum intials as uiCpuCores also, stay tuned dynamically slicing in future | |
| 2261 | − pSliceArgument->uiSliceNum = iSliceNum; // used fixed one | |
| 2262 | 2262 | |
| 2263 | 2263 | switch (pSliceArgument->uiSliceMode) { |
| 2264 | 2264 | case SM_SIZELIMITED_SLICE: |
| @@ -2273,16 +2273,15 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar · 8 unmodified lines | ||
| 2273 | 2273 | if (pSliceArgument->uiSliceNum > iMaxSliceCount) { |
| 2274 | 2274 | iMaxSliceCount = pSliceArgument->uiSliceNum; |
| 2275 | 2275 | } |
| 2276 | − | |
| 2277 | 2276 | } |
| 2278 | 2277 | break; |
| 2279 | 2278 | case SM_SINGLE_SLICE: |
| 2280 | − if (iSliceNum > iMaxSliceCount) | |
| 2281 | − iMaxSliceCount = iSliceNum; | |
| 2279 | + if (pSliceArgument->uiSliceNum > iMaxSliceCount) | |
| 2280 | + iMaxSliceCount = pSliceArgument->uiSliceNum; | |
| 2282 | 2281 | break; |
| 2283 | 2282 | case SM_RASTER_SLICE: |
| 2284 | − if (iSliceNum > iMaxSliceCount) | |
| 2285 | − iMaxSliceCount = iSliceNum; | |
| 2283 | + if (pSliceArgument->uiSliceNum > iMaxSliceCount) | |
| 2284 | + iMaxSliceCount = pSliceArgument->uiSliceNum; | |
| 2286 | 2285 | break; |
| 2287 | 2286 | default: |
| 2288 | 2287 | break; |
| @@ -2371,16 +2370,19 @@ int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCoding · 82 unmodified lines | ||
| 2371 | 2370 | iCacheLineSize = 16; // 16 bytes aligned in default |
| 2372 | 2371 | #endif//X86_ASM |
| 2373 | 2372 | |
| 2374 | − if (pCodingParam->iMultipleThreadIdc > 0) | |
| 2375 | − uiCpuCores = pCodingParam->iMultipleThreadIdc; | |
| 2376 | − else { | |
| 2377 | − if (uiCpuCores == | |
| 2378 | − 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 | |
| 2379 | − uiCpuCores = DynamicDetectCpuCores(); | |
| 2380 | − }// So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms, | |
| 2381 | − // for client application here it is constrained by maximal to MAX_THREADS_NUM | |
| 2373 | + if (0 == pCodingParam->iMultipleThreadIdc && uiCpuCores == 0) { | |
| 2374 | + // cpuid not supported or doesn't expose the number of cores, | |
| 2375 | + // use high level system API as followed to detect number of pysical/logic processor | |
| 2376 | + uiCpuCores = DynamicDetectCpuCores(); | |
| 2382 | 2377 | } |
| 2383 | − uiCpuCores = WELS_CLIP3 (uiCpuCores, 1, MAX_THREADS_NUM); | |
| 2378 | + | |
| 2379 | + if(0 == pCodingParam->iMultipleThreadIdc) | |
| 2380 | + pCodingParam->iMultipleThreadIdc = (uiCpuCores > 0) ? uiCpuCores : 1; | |
| 2381 | + | |
| 2382 | + // So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms, | |
| 2383 | + // for client application here it is constrained by maximal to MAX_THREADS_NUM | |
| 2384 | + pCodingParam->iMultipleThreadIdc = WELS_CLIP3 (pCodingParam->iMultipleThreadIdc, 1, MAX_THREADS_NUM); | |
| 2385 | + uiCpuCores = pCodingParam->iMultipleThreadIdc; | |
| 2384 | 2386 | |
| 2385 | 2387 | if (InitSliceSettings (pLogCtx, pCodingParam, uiCpuCores, &iSliceNum)) { |
| 2386 | 2388 | WelsLog (pLogCtx, WELS_LOG_ERROR, "GetMultipleThreadIdc(), InitSliceSettings failed."); |