History

SliceBufferReallocate:RBC#1797:New slice buffer reallocate design and update UT cases

Huade Shi (huashi) committed 9 years ago

Commit f77d1901 parent d1e25d74 files · +33 −35Browse files

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

Unified · Split

codec/encoder/core/src/svc_encode_slice.cpp+18−10
@@ -996,11 +996,14 @@ int32_t InitOneSliceInThread (sWelsEncCtx* pCtx, · 995 unmodified lines
996996 const int32_t kiThreadIdx,
997997 const int32_t kiDlayerIdx,
998998 const int32_t kiSliceIdx) {
999− const int32_t kiCodedNumInThread = pCtx->pCurDqLayer->sSliceThreadInfo[kiThreadIdx].iCodedSliceNum;
1000999
1001− assert(kiCodedNumInThread <= pCtx->pCurDqLayer->sSliceThreadInfo[kiThreadIdx].iMaxSliceNum -1 );
1002−
1003− pSlice = &pCtx->pCurDqLayer->sSliceThreadInfo [kiThreadIdx].pSliceInThread[kiCodedNumInThread];
1000+ if (pCtx->pCurDqLayer->bThreadSlcBufferFlag) {
1001+ const int32_t kiCodedNumInThread = pCtx->pCurDqLayer->sSliceThreadInfo[kiThreadIdx].iCodedSliceNum;
1002+ assert(kiCodedNumInThread <= pCtx->pCurDqLayer->sSliceThreadInfo[kiThreadIdx].iMaxSliceNum -1 );
1003+ pSlice = &pCtx->pCurDqLayer->sSliceThreadInfo [kiThreadIdx].pSliceInThread[kiCodedNumInThread];
1004+ } else {
1005+ pSlice = &pCtx->pCurDqLayer->sSliceThreadInfo [0].pSliceInThread[kiSliceIdx];
1006+ }
10041007 pSlice->iSliceIdx = kiSliceIdx;
10051008 pSlice->uiThreadIdx = kiThreadIdx;
10061009
@@ -1018,18 +1021,22 @@ int32_t InitSliceThreadInfo (sWelsEncCtx* pCtx, · 11 unmodified lines
10181021 CMemoryAlign* pMa) {
10191022 int32_t iThreadNum = pCtx->pSvcParam->iMultipleThreadIdc;
10201023 int32_t iMaxSliceNum = 0;
1024+ int32_t iSlcBufferNum = 0;
10211025 int32_t iIdx = 0;
10221026 int32_t iRet = 0;
1023− SliceModeEnum eSlicMode = pCtx->pSvcParam->sSpatialLayers[kiDlayerIndex].sSliceArgument.uiSliceMode;
10241027
10251028 assert (iThreadNum > 0);
1026− if( SM_SIZELIMITED_SLICE == eSlicMode && iThreadNum > 1) {
1027− iMaxSliceNum = pDqLayer->iMaxSliceNum / iThreadNum + 1;
1029+
1030+ //for fixed slice num case, no need to reallocate, so one slice buffer for all thread
1031+ if( pDqLayer->bThreadSlcBufferFlag) {
1032+ iMaxSliceNum = pDqLayer->iMaxSliceNum / iThreadNum + 1;
1033+ iSlcBufferNum = iThreadNum;
10281034 } else {
1029− iMaxSliceNum = pDqLayer->iMaxSliceNum;
1035+ iMaxSliceNum = pDqLayer->iMaxSliceNum;
1036+ iSlcBufferNum = 1;
10301037 }
10311038
1032− while (iIdx < iThreadNum) {
1039+ while (iIdx < iSlcBufferNum) {
10331040 pDqLayer->sSliceThreadInfo[iIdx].iMaxSliceNum = iMaxSliceNum;
10341041 pDqLayer->sSliceThreadInfo[iIdx].iCodedSliceNum = 0;
10351042 pDqLayer->sSliceThreadInfo[iIdx].pSliceInThread = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInThread");
@@ -1055,6 +1062,7 @@ int32_t InitSliceThreadInfo (sWelsEncCtx* pCtx, · 19 unmodified lines
10551062 pDqLayer->sSliceThreadInfo[iIdx].iCodedSliceNum = 0;
10561063 pDqLayer->sSliceThreadInfo[iIdx].pSliceInThread = NULL;
10571064 }
1065+
10581066 return ENC_RETURN_SUCCESS;
10591067 }
10601068
@@ -1108,7 +1116,7 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 47 unmodified lines
11081116 return ENC_RETURN_MEMALLOCERR;
11091117 }
11101118
1111− iRet = InitSliceBoundaryInfo (pDqLayer, &pCtx->pSvcParam->sSpatialLayers[kiDlayerIndex].sSliceArgument, iMaxSliceNum);
1119+ iRet = InitSliceBoundaryInfo (pDqLayer, pSliceArgument, iMaxSliceNum);
11121120 if (ENC_RETURN_SUCCESS != iRet) {
11131121 return iRet;
11141122 }

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