Merge pull request #2309 from shihuade/MultiThread_V4.4_ThreadSliceNum_V3_Pull

remove iCountThreadsNum and unitfy with iMultipleThreadIdc
This commit is contained in:
sijchen 2015-12-14 09:44:13 -08:00
commit 406f89ec54
4 changed files with 16 additions and 21 deletions

View File

@ -111,8 +111,6 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
bool bDeblockingParallelFlag; // deblocking filter parallelization control flag
int32_t iBitsVaryPercentage;
short
iCountThreadsNum; // # derived from disable_multiple_slice_idc (=0 or >1) means;
int8_t iDecompStages; // GOP size dependency
int32_t iMaxNumRefFrame;
@ -202,8 +200,6 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
bDeblockingParallelFlag = false;// deblocking filter parallelization control flag
iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means;
iDecompStages = 0; // GOP size dependency, unknown here and be revised later
iBitsVaryPercentage = 0;
}

View File

@ -760,7 +760,7 @@ void PerformDeblockingFilter (sWelsEncCtx* pEnc) {
++ iSliceIdx;
} while (iSliceIdx < iSliceCount);
} else { // for dynamic slicing mode
const int32_t kiNumPicPartition = pEnc->iActiveThreadsNum; //pSvcParam->iCountThreadsNum;
const int32_t kiNumPicPartition = pEnc->iActiveThreadsNum;
int32_t iPartitionIdx = 0;
while (iPartitionIdx < kiNumPicPartition) {

View File

@ -1186,7 +1186,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p
// for dynamic slicing mode
if (SM_SIZELIMITED_SLICE == pDlayer->sSliceArgument.uiSliceMode) {
const int32_t iSize = pParam->iCountThreadsNum * sizeof (int32_t);
const int32_t iSize = pParam->iMultipleThreadIdc * sizeof (int32_t);
pDqLayer->pNumSliceCodedOfPartition = (int32_t*)pMa->WelsMallocz (iSize, "pNumSliceCodedOfPartition");
pDqLayer->pLastCodedMbIdxOfPartition = (int32_t*)pMa->WelsMallocz (iSize, "pLastCodedMbIdxOfPartition");
@ -2291,8 +2291,7 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar
++ iSpatialIdx;
} while (iSpatialIdx < iSpatialNum);
pCodingParam->iCountThreadsNum = WELS_MIN (kiCpuCores, iMaxSliceCount);
pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum;
pCodingParam->iMultipleThreadIdc = WELS_MIN (kiCpuCores, iMaxSliceCount);
if (pCodingParam->iLoopFilterDisableIdc == 0
&& pCodingParam->iMultipleThreadIdc != 1) // Loop filter requested to be enabled, with threading enabled
pCodingParam->iLoopFilterDisableIdc =
@ -2454,7 +2453,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar
}
InitFunctionPointers (pCtx, pCtx->pSvcParam, uiCpuFeatureFlags);
pCtx->iActiveThreadsNum = pCodingParam->iCountThreadsNum;
pCtx->iActiveThreadsNum = pCodingParam->iMultipleThreadIdc;
pCtx->iMaxSliceCount = iSliceNum;
iRet = RequestMemorySvc (&pCtx, pExistingParasetList);
if (iRet != 0) {
@ -2593,15 +2592,15 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) {
return;
WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_INFO,
"WelsUninitEncoderExt(), pCtx= %p, iThreadCount= %d, iMultipleThreadIdc= %d.",
(void*) (*ppCtx), (*ppCtx)->pSvcParam->iCountThreadsNum, (*ppCtx)->pSvcParam->iMultipleThreadIdc);
"WelsUninitEncoderExt(), pCtx= %p, iMultipleThreadIdc= %d.",
(void*) (*ppCtx), (*ppCtx)->pSvcParam->iMultipleThreadIdc);
#if defined(STAT_OUTPUT)
StatOverallEncodingExt (*ppCtx);
#endif
if ((*ppCtx)->pSvcParam->iMultipleThreadIdc > 1 && (*ppCtx)->pSliceThreading != NULL) {
const int32_t iThreadCount = (*ppCtx)->pSvcParam->iCountThreadsNum;
const int32_t iThreadCount = (*ppCtx)->pSvcParam->iMultipleThreadIdc;
int32_t iThreadIdx = 0;
while (iThreadIdx < iThreadCount) {
@ -2656,7 +2655,7 @@ void DynslcUpdateMbNeighbourInfoListForAllSlices (SDqLayer* pCurDq, SMB* pMbList
int32_t PicPartitionNumDecision (sWelsEncCtx* pCtx) {
int32_t iPartitionNum = 1;
if (pCtx->pSvcParam->iMultipleThreadIdc > 1) {
iPartitionNum = pCtx->pSvcParam->iCountThreadsNum;
iPartitionNum = pCtx->pSvcParam->iMultipleThreadIdc;
}
return iPartitionNum;
}
@ -3964,7 +3963,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
}
// THREAD_FULLY_FIRE_MODE && SM_SIZELIMITED_SLICE
else if ((SM_SIZELIMITED_SLICE == pParam->sSliceArgument.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) {
const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum; //pSvcParam->iCountThreadsNum;
const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum;
#if 0 //TODO: temporarily use this to keep old codes for a while, will remove old codes later
int32_t iRet = 0;
@ -3975,8 +3974,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
pFbi, kiPartitionCnt, &pCtx->pCurDqLayer->sSliceEncCtx, true);
if (iRet) {
WelsLog (pLogCtx, WELS_LOG_ERROR,
"[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!",
iRet, pSvcParam->iCountThreadsNum, iSliceCount, pParam->sSliceArgument.uiSliceMode, pSvcParam->iMultipleThreadIdc);
"[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!",
iRet, iSliceCount, pParam->sSliceArgument.uiSliceMode, pSvcParam->iMultipleThreadIdc);
return ENC_RETURN_UNEXPECTED;
}

View File

@ -299,7 +299,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
pMa = (*ppCtx)->pMemAlign;
pPara = pCodingParam;
iNumSpatialLayers = pPara->iSpatialLayerNum;
iThreadNum = pPara->iCountThreadsNum;
iThreadNum = pPara->iMultipleThreadIdc;
iMaxSliceNum = (*ppCtx)->iMaxSliceCount;
pSmt = (SSliceThreading*)pMa->WelsMalloc (sizeof (SSliceThreading), "SSliceThreading");
@ -406,8 +406,8 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
iReturn = WelsMutexInit (& (*ppCtx)->mutexEncoderError);
WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))
MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "RequestMtResource(), iThreadNum=%d, iCountSliceNum= %d",
pPara->iCountThreadsNum,
MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "RequestMtResource(), iThreadNum=%d, iMultipleThreadIdc= %d",
pPara->iMultipleThreadIdc,
iMaxSliceNum);
return 0;
@ -426,7 +426,7 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) {
pMa = (*ppCtx)->pMemAlign;
uiSliceNum = (*ppCtx)->iMaxSliceCount;
iThreadNum = (*ppCtx)->pSvcParam->iCountThreadsNum;
iThreadNum = (*ppCtx)->pSvcParam->iMultipleThreadIdc;
pSmt = (*ppCtx)->pSliceThreading;
if (NULL == pSmt)
@ -880,7 +880,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
}
int32_t CreateSliceThreads (sWelsEncCtx* pCtx) {
const int32_t kiThreadCount = pCtx->pSvcParam->iCountThreadsNum;
const int32_t kiThreadCount = pCtx->pSvcParam->iMultipleThreadIdc;
int32_t iIdx = 0;
while (iIdx < kiThreadCount) {