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 | if (pSliceArgument->uiSliceNum == 0) { | 181 | if (pSliceArgument->uiSliceNum == 0) { |
| 182 | WelsCPUFeatureDetect (&iCpuCores); | 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 | pSliceArgument->uiSliceNum = iCpuCores; | 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, | 2253 | int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingParam, |
| 2249 | int16_t* pMaxSliceCount) { | 2254 | const int32_t kiCpuCores, int16_t* pMaxSliceCount) { |
| 2250 | int32_t iSpatialIdx = 0, iSpatialNum = pCodingParam->iSpatialLayerNum; | 2255 | int32_t iSpatialIdx = 0, iSpatialNum = pCodingParam->iSpatialLayerNum; |
| 2251 | uint16_t iMaxSliceCount = 0; | 2256 | uint16_t iMaxSliceCount = 0; |
| 2252 | 2257 | ||
| @@ -2254,11 +2259,6 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar · 1 unmodified line | |||
| 2254 | SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[iSpatialIdx]; | 2259 | SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[iSpatialIdx]; |
| 2255 | SSliceArgument* pSliceArgument = &pDlp->sSliceArgument; | 2260 | SSliceArgument* pSliceArgument = &pDlp->sSliceArgument; |
| 2256 | int32_t iReturn = 0; | 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 | switch (pSliceArgument->uiSliceMode) { | 2263 | switch (pSliceArgument->uiSliceMode) { |
| 2264 | case SM_SIZELIMITED_SLICE: | 2264 | case SM_SIZELIMITED_SLICE: |
| @@ -2273,16 +2273,15 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar · 8 unmodified lines | |||
| 2273 | if (pSliceArgument->uiSliceNum > iMaxSliceCount) { | 2273 | if (pSliceArgument->uiSliceNum > iMaxSliceCount) { |
| 2274 | iMaxSliceCount = pSliceArgument->uiSliceNum; | 2274 | iMaxSliceCount = pSliceArgument->uiSliceNum; |
| 2275 | } | 2275 | } |
| 2276 | |||
| 2277 | } | 2276 | } |
| 2278 | break; | 2277 | break; |
| 2279 | case SM_SINGLE_SLICE: | 2278 | case SM_SINGLE_SLICE: |
| 2280 | if (iSliceNum > iMaxSliceCount) | 2279 | if (pSliceArgument->uiSliceNum > iMaxSliceCount) |
| 2281 | iMaxSliceCount = iSliceNum; | 2280 | iMaxSliceCount = pSliceArgument->uiSliceNum; |
| 2282 | break; | 2281 | break; |
| 2283 | case SM_RASTER_SLICE: | 2282 | case SM_RASTER_SLICE: |
| 2284 | if (iSliceNum > iMaxSliceCount) | 2283 | if (pSliceArgument->uiSliceNum > iMaxSliceCount) |
| 2285 | iMaxSliceCount = iSliceNum; | 2284 | iMaxSliceCount = pSliceArgument->uiSliceNum; |
| 2286 | break; | 2285 | break; |
| 2287 | default: | 2286 | default: |
| 2288 | break; | 2287 | break; |
| @@ -2371,16 +2370,19 @@ int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCoding · 82 unmodified lines | |||
| 2371 | iCacheLineSize = 16; // 16 bytes aligned in default | 2370 | iCacheLineSize = 16; // 16 bytes aligned in default |
| 2372 | #endif//X86_ASM | 2371 | #endif//X86_ASM |
| 2373 | 2372 | ||
| 2374 | if (pCodingParam->iMultipleThreadIdc > 0) | 2373 | if (0 == pCodingParam->iMultipleThreadIdc && uiCpuCores == 0) { |
| 2375 | uiCpuCores = pCodingParam->iMultipleThreadIdc; | 2374 | // cpuid not supported or doesn't expose the number of cores, |
| 2376 | else { | 2375 | // use high level system API as followed to detect number of pysical/logic processor |
| 2377 | if (uiCpuCores == | 2376 | uiCpuCores = DynamicDetectCpuCores(); |
| 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 | ||
| 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 | if (InitSliceSettings (pLogCtx, pCodingParam, uiCpuCores, &iSliceNum)) { | 2387 | if (InitSliceSettings (pLogCtx, pCodingParam, uiCpuCores, &iSliceNum)) { |
| 2386 | WelsLog (pLogCtx, WELS_LOG_ERROR, "GetMultipleThreadIdc(), InitSliceSettings failed."); | 2388 | WelsLog (pLogCtx, WELS_LOG_ERROR, "GetMultipleThreadIdc(), InitSliceSettings failed."); |