History

change API for slicing part for easier usage (the UseLoadBalancing flag is still under working)

sijchen committed 11 years ago

Commit 33c378f1 parent 24916a626 files · +7334 −7329Browse files

Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 26 files). Show all

Unified · Split

codec/encoder/core/src/slice_multi_threading.cpp+17−18
@@ -360,11 +360,12 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 359 unmodified lines
360360
361361 iIdx = 0;
362362 while (iIdx < iNumSpatialLayers) {
363− SSliceConfig* pMso = &pPara->sSpatialLayers[iIdx].sSliceCfg;
364− const int32_t kiSliceNum = pMso->sSliceArgument.uiSliceNum;
365− if (((pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE) || (pMso->uiSliceMode == SM_AUTO_SLICE))
366− && pPara->iMultipleThreadIdc > 1
367− && pPara->iMultipleThreadIdc >= kiSliceNum) {
363+ SSliceArgument* pSliceArgument = &pPara->sSpatialLayers[iIdx].sSliceArgument;
364+ const int32_t kiSliceNum = pSliceArgument->uiSliceNum;
365+ if ((pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE)
366+ && (pPara->bUseLoadBalancing)
367+ && (pPara->iMultipleThreadIdc > 1)
368+ && (pPara->iMultipleThreadIdc >= kiSliceNum)) {
368369 pSmt->pSliceConsumeTime[iIdx] = (uint32_t*)pMa->WelsMallocz (kiSliceNum * sizeof (uint32_t), "pSliceConsumeTime[]");
369370 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceConsumeTime[iIdx]), FreeMemorySvc (ppCtx))
370371 pSmt->pSliceComplexRatio[iIdx] = (int32_t*)pMa->WelsMalloc (kiSliceNum * sizeof (int32_t), "pSliceComplexRatio[]");
@@ -374,8 +375,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 3 unmodified lines
374375 pSmt->pSliceComplexRatio[iIdx] = NULL;
375376 }
376377
377− if ( pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE || pMso->uiSliceMode == SM_RASTER_SLICE
378− || pMso->uiSliceMode == SM_ROWMB_SLICE || pMso->uiSliceMode == SM_AUTO_SLICE) {
378+ if ( pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE || pSliceArgument->uiSliceMode == SM_RASTER_SLICE) {
379379 bWillUseTaskManage = true;
380380 }
381381 ++ iIdx;
@@ -576,7 +576,7 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 194 unmodified lines
576576 SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam;
577577 SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId];
578578 SWelsSliceBs* pSliceBs = NULL;
579− const bool kbIsDynamicSlicingMode = (pDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE);
579+ const bool kbIsDynamicSlicingMode = (pDlp->sSliceArgument.uiSliceMode == SM_SIZELIMITED_SLICE);
580580
581581 int32_t iLayerSize = 0;
582582 int32_t iNalIdxBase = pLbi->iNalCount;
@@ -613,7 +613,7 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 30 unmodified lines
613613 ++ iSliceIdx;
614614 ++ pSliceBs;
615615 }
616− } else { // for SM_DYN_SLICE
616+ } else { // for SM_SIZELIMITED_SLICE
617617 const int32_t kiPartitionCnt = iSliceCount;
618618 int32_t iPartitionIdx = 0;
619619
@@ -744,17 +744,16 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 124 unmodified lines
744744 eNalRefIdc = pEncPEncCtx->eNalPriority;
745745 bNeedPrefix = pEncPEncCtx->bNeedPrefixNalFlag;
746746
747− if (pParamD->sSliceCfg.uiSliceMode != SM_DYN_SLICE) {
747+ if (pParamD->sSliceArgument.uiSliceMode != SM_SIZELIMITED_SLICE) {
748748 int64_t iSliceStart = 0;
749749 bool bDsaFlag = false;
750750 iSliceIdx = pPrivateData->iSliceIndex;
751751 pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
752752 pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx];
753753
754− bDsaFlag = (((pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)
755− || (pParamD->sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) &&
754+ bDsaFlag = ((pParamD->sSliceArgument.uiSliceMode == SM_FIXEDSLCNUM_SLICE) &&
756755 pCodingParam->iMultipleThreadIdc > 1 &&
757− pCodingParam->iMultipleThreadIdc >= pParamD->sSliceCfg.sSliceArgument.uiSliceNum);
756+ pCodingParam->iMultipleThreadIdc >= pParamD->sSliceArgument.uiSliceNum);
758757 if (bDsaFlag)
759758 iSliceStart = WelsTime();
760759
@@ -838,7 +837,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 77 unmodified lines
838837 &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
839838 WelsEventSignal (
840839 &pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent);
841− } else { // for SM_DYN_SLICE parallelization
840+ } else { // for SM_SIZELIMITED_SLICE parallelization
842841 SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;
843842 const int32_t kiPartitionId = iThreadIdx;
844843 const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum;
@@ -1090,9 +1089,9 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 245 unmodified lines
10901089 // if using spatial base layer for complexity estimation
10911090
10921091 const bool kbModelingFromSpatial = (pCtx->pCurDqLayer->pRefLayer != NULL && iCurDid > 0)
1093− && (pCtx->pSvcParam->sSpatialLayers[iCurDid - 1].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
1092+ && (pCtx->pSvcParam->sSpatialLayers[iCurDid - 1].sSliceArgument.uiSliceMode == SM_FIXEDSLCNUM_SLICE
10941093 && pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sSpatialLayers[iCurDid -
1095− 1].sSliceCfg.sSliceArgument.uiSliceNum);
1094+ 1].sSliceArgument.uiSliceNum);
10961095
10971096 if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation
10981097 // do not need adjust due to not different at both slices of consumed time
@@ -1156,13 +1155,13 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t · 57 unmodified lines
11561155 while (iSpatialIdx < iSpatialNum) {
11571156 const int32_t kiDid = pDidList[iSpatialIdx];
11581157 SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid];
1159− SSliceConfig* pMso = &pDlp->sSliceCfg;
1158+ SSliceConfig* pSliceArgument = &pDlp->sSliceArgument;
11601159 SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid];
11611160 SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;
11621161 const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame;
11631162 if (pCtx->pSliceThreading) {
11641163 if (pCtx->pSliceThreading->pFSliceDiff
1165− && ((pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE) || (pMso->uiSliceMode == SM_AUTO_SLICE))
1164+ && ((pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE) || (pSliceArgument->uiSliceMode == SM_AUTO_SLICE))
11661165 && pPara->iMultipleThreadIdc > 1
11671166 && pPara->iMultipleThreadIdc >= kuiCountSliceNum) {
11681167 uint32_t i = 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t