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
996 const int32_t kiThreadIdx,996 const int32_t kiThreadIdx,
997 const int32_t kiDlayerIdx,997 const int32_t kiDlayerIdx,
998 const int32_t kiSliceIdx) {998 const int32_t kiSliceIdx) {
999 const int32_t kiCodedNumInThread = pCtx->pCurDqLayer->sSliceThreadInfo[kiThreadIdx].iCodedSliceNum;
1000 999
1001 assert(kiCodedNumInThread <= pCtx->pCurDqLayer->sSliceThreadInfo[kiThreadIdx].iMaxSliceNum -1 );1000 if (pCtx->pCurDqLayer->bThreadSlcBufferFlag) {
1002 1001 const int32_t kiCodedNumInThread = pCtx->pCurDqLayer->sSliceThreadInfo[kiThreadIdx].iCodedSliceNum;
1003 pSlice = &pCtx->pCurDqLayer->sSliceThreadInfo [kiThreadIdx].pSliceInThread[kiCodedNumInThread];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 }
1004 pSlice->iSliceIdx = kiSliceIdx;1007 pSlice->iSliceIdx = kiSliceIdx;
1005 pSlice->uiThreadIdx = kiThreadIdx;1008 pSlice->uiThreadIdx = kiThreadIdx;
1006 1009
@@ -1018,18 +1021,22 @@ int32_t InitSliceThreadInfo (sWelsEncCtx* pCtx, · 11 unmodified lines
1018 CMemoryAlign* pMa) {1021 CMemoryAlign* pMa) {
1019 int32_t iThreadNum = pCtx->pSvcParam->iMultipleThreadIdc;1022 int32_t iThreadNum = pCtx->pSvcParam->iMultipleThreadIdc;
1020 int32_t iMaxSliceNum = 0;1023 int32_t iMaxSliceNum = 0;
1024 int32_t iSlcBufferNum = 0;
1021 int32_t iIdx = 0;1025 int32_t iIdx = 0;
1022 int32_t iRet = 0;1026 int32_t iRet = 0;
1023 SliceModeEnum eSlicMode = pCtx->pSvcParam->sSpatialLayers[kiDlayerIndex].sSliceArgument.uiSliceMode;
1024 1027
1025 assert (iThreadNum > 0);1028 assert (iThreadNum > 0);
1026 if( SM_SIZELIMITED_SLICE == eSlicMode && iThreadNum > 1) {1029
1027 iMaxSliceNum = pDqLayer->iMaxSliceNum / iThreadNum + 1;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;
1028 } else {1034 } else {
1029 iMaxSliceNum = pDqLayer->iMaxSliceNum;1035 iMaxSliceNum = pDqLayer->iMaxSliceNum;
1036 iSlcBufferNum = 1;
1030 }1037 }
1031 1038
1032 while (iIdx < iThreadNum) {1039 while (iIdx < iSlcBufferNum) {
1033 pDqLayer->sSliceThreadInfo[iIdx].iMaxSliceNum = iMaxSliceNum;1040 pDqLayer->sSliceThreadInfo[iIdx].iMaxSliceNum = iMaxSliceNum;
1034 pDqLayer->sSliceThreadInfo[iIdx].iCodedSliceNum = 0;1041 pDqLayer->sSliceThreadInfo[iIdx].iCodedSliceNum = 0;
1035 pDqLayer->sSliceThreadInfo[iIdx].pSliceInThread = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInThread");1042 pDqLayer->sSliceThreadInfo[iIdx].pSliceInThread = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInThread");
@@ -1055,6 +1062,7 @@ int32_t InitSliceThreadInfo (sWelsEncCtx* pCtx, · 19 unmodified lines
1055 pDqLayer->sSliceThreadInfo[iIdx].iCodedSliceNum = 0;1062 pDqLayer->sSliceThreadInfo[iIdx].iCodedSliceNum = 0;
1056 pDqLayer->sSliceThreadInfo[iIdx].pSliceInThread = NULL;1063 pDqLayer->sSliceThreadInfo[iIdx].pSliceInThread = NULL;
1057 }1064 }
1065
1058 return ENC_RETURN_SUCCESS;1066 return ENC_RETURN_SUCCESS;
1059}1067}
1060 1068
@@ -1108,7 +1116,7 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 47 unmodified lines
1108 return ENC_RETURN_MEMALLOCERR;1116 return ENC_RETURN_MEMALLOCERR;
1109 }1117 }
1110 1118
1111 iRet = InitSliceBoundaryInfo (pDqLayer, &pCtx->pSvcParam->sSpatialLayers[kiDlayerIndex].sSliceArgument, iMaxSliceNum);1119 iRet = InitSliceBoundaryInfo (pDqLayer, pSliceArgument, iMaxSliceNum);
1112 if (ENC_RETURN_SUCCESS != iRet) {1120 if (ENC_RETURN_SUCCESS != iRet) {
1113 return iRet;1121 return iRet;
1114 }1122 }

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