History

Multi-thread-fixed:RBC#1715:refactoring for slice boundary info init/update module

huade committed 9 years ago

Commit e448da81 parent 74b9a3f8 files · +87 −71Browse files

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

Unified · Split

codec/encoder/core/src/svc_encode_slice.cpp+55−53
@@ -94,8 +94,6 @@ void WelsSliceHeaderExtInit (sWelsEncCtx* pEncCtx, SDqLayer* pCurLayer, SSlice* · 93 unmodified lines
9494
9595 pCurSliceExt->bStoreRefBasePicFlag = false;
9696
97− pCurSliceHeader->iFirstMbInSlice = WelsGetFirstMbOfSlice (pCurLayer->ppSliceInLayer, pSlice->uiSliceIdx);
98−
9997 pCurSliceHeader->iFrameNum = pParamInternal->iFrameNum;
10098 pCurSliceHeader->uiIdrPicId = pParamInternal->uiIdrPicId;
10199 pCurSliceHeader->iPicOrderCntLsb = pEncCtx->pEncPic->iFramePoc; // 0
@@ -814,49 +812,64 @@ void FreeMbCache (SMbCache* pMbCache, CMemoryAlign* pMa) { · 712 unmodified lines
814812 }
815813 }
816814
817−//Initialize slice's MB info)
818−int32_t InitSliceMBInfo (SSliceArgument* pSliceArgument,
819− SSlice* pSlice,
820− const int32_t kiMBWidth,
821− const int32_t kiMBHeight) {
822− SSliceHeader* pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
815+//Initialize slice's boundary info)
816+int32_t InitSliceBoundaryInfo (SDqLayer* pCurLayer, SSliceArgument* pSliceArgument) {
817+
823818 const int32_t* kpSlicesAssignList = (int32_t*) & (pSliceArgument->uiSliceMbNum[0]);
819+ const int32_t kiMBWidth = pCurLayer->iMbWidth;
820+ const int32_t kiMBHeight = pCurLayer->iMbHeight;
824821 const int32_t kiCountNumMbInFrame = kiMBWidth * kiMBHeight;
825− const int32_t kiSliceIdx = pSlice->uiSliceIdx;
822+ int32_t iSliceIdx = 0;
826823 int32_t iFirstMBInSlice = 0;
827824 int32_t iMbNumInSlice = 0;
828825
829− if (SM_SINGLE_SLICE == pSliceArgument->uiSliceMode) {
830− iFirstMBInSlice = 0;
831− iMbNumInSlice = kiCountNumMbInFrame;
826+ for( ;iSliceIdx < pCurLayer->iMaxSliceNum; iSliceIdx++ ){
827+ if (SM_SINGLE_SLICE == pSliceArgument->uiSliceMode) {
828+ iFirstMBInSlice = 0;
829+ iMbNumInSlice = kiCountNumMbInFrame;
832830
833− } else if ((SM_RASTER_SLICE == pSliceArgument->uiSliceMode) && (0 == pSliceArgument->uiSliceMbNum[0])) {
834− iFirstMBInSlice = kiSliceIdx * kiMBWidth;
835− iMbNumInSlice = kiMBWidth;
836− } else if (SM_RASTER_SLICE == pSliceArgument->uiSliceMode ||
831+ } else if ((SM_RASTER_SLICE == pSliceArgument->uiSliceMode) && (0 == pSliceArgument->uiSliceMbNum[0])) {
832+ iFirstMBInSlice = iSliceIdx * kiMBWidth;
833+ iMbNumInSlice = kiMBWidth;
834+ } else if (SM_RASTER_SLICE == pSliceArgument->uiSliceMode ||
837835 SM_FIXEDSLCNUM_SLICE == pSliceArgument->uiSliceMode) {
838− int32_t iMbIdx = 0;
839− for (int i = 0; i < kiSliceIdx; i++) {
840− iMbIdx += kpSlicesAssignList[i];
841− }
836+ int32_t iMbIdx = 0;
837+ for (int i = 0; i < iSliceIdx; i++) {
838+ iMbIdx += kpSlicesAssignList[i];
839+ }
842840
843− if (iMbIdx >= kiCountNumMbInFrame) {
844− return ENC_RETURN_UNEXPECTED;
841+ if (iMbIdx >= kiCountNumMbInFrame) {
842+ return ENC_RETURN_UNEXPECTED;
843+ }
844+
845+ iFirstMBInSlice = iMbIdx;
846+ iMbNumInSlice = kpSlicesAssignList[iSliceIdx];
847+
848+ } else if (SM_SIZELIMITED_SLICE == pSliceArgument->uiSliceMode) {
849+ iFirstMBInSlice = 0;
850+ iMbNumInSlice = kiCountNumMbInFrame;
851+
852+ } else { // any else uiSliceMode?
853+ assert (0);
845854 }
846855
847− iFirstMBInSlice = iMbIdx;
848− iMbNumInSlice = kpSlicesAssignList[kiSliceIdx];
856+ pCurLayer->pCountMbNumInSlice[iSliceIdx] = iMbNumInSlice;
857+ pCurLayer->pFirstMbIdxOfSlice[iSliceIdx] = iFirstMBInSlice;
858+ }
859+
860+ return ENC_RETURN_SUCCESS;
861+}
849862
850− } else if (SM_SIZELIMITED_SLICE == pSliceArgument->uiSliceMode) {
851− iFirstMBInSlice = 0;
852− iMbNumInSlice = kiCountNumMbInFrame;
863+int32_t SetSliceBoundaryInfo(SDqLayer* pCurLayer, SSlice* pSlice, const int32_t kiSliceIdx) {
864+ if(NULL == pCurLayer || NULL == pSlice ||
865+ NULL == pCurLayer->pFirstMbIdxOfSlice ||
866+ NULL == pCurLayer->pCountMbNumInSlice) {
853867
854− } else { // any else uiSliceMode?
855− assert (0);
868+ return ENC_RETURN_UNEXPECTED;
856869 }
857870
858− pSlice->iCountMbNumInSlice = iMbNumInSlice;
859− pSliceHeader->iFirstMbInSlice = iFirstMBInSlice;
871+ pSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = pCurLayer->pFirstMbIdxOfSlice[kiSliceIdx];
872+ pSlice->iCountMbNumInSlice = pCurLayer->pCountMbNumInSlice[kiSliceIdx];
860873
861874 return ENC_RETURN_SUCCESS;
862875 }
@@ -941,9 +954,11 @@ int32_t InitSliceList (sWelsEncCtx* pCtx, · 78 unmodified lines
941954 }
942955
943956 pSlice->uiSliceIdx = iSliceIdx;
957+ pSlice->iCountMbNumInSlice = 0;
958+ pSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = 0;
944959
945960 iRet = InitSliceBsBuffer (pSlice,
946− & pCtx->pOut->sBsWrite,
961+ &pCtx->pOut->sBsWrite,
947962 bIndependenceBsBuffer,
948963 iMaxSliceBufferSize,
949964 pMa);
@@ -951,12 +966,6 @@ int32_t InitSliceList (sWelsEncCtx* pCtx, · 1 unmodified line
951966 return iRet;
952967 }
953968
954− iRet = InitSliceMBInfo (pSliceArgument, pSlice,
955− kiMBWidth, kiMBHeight);
956−
957− if (ENC_RETURN_SUCCESS != iRet) {
958− return iRet;
959− }
960969 iRet = AllocateSliceMBBuffer (pSlice, pMa);
961970
962971 if (ENC_RETURN_SUCCESS != iRet) {
@@ -993,11 +1002,6 @@ int32_t InitOneSliceInThread (sWelsEncCtx* pCtx, · 30 unmodified lines
9931002 pSlice->sSliceBs.iNalIndex = 0;
9941003 pSlice->sSliceBs.pBsBuffer = pCtx->pSliceThreading->pThreadBsBuffer[kiThreadIdx];
9951004
996− // init slice MB info
997− iRet = InitSliceMBInfo (pSliceArgument, pSlice, kiMBWidth, kiMBHeight);
998− if (ENC_RETURN_SUCCESS != iRet) {
999− return iRet;
1000− }
10011005 return ENC_RETURN_SUCCESS;
10021006 }
10031007 */
@@ -1073,6 +1077,11 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 69 unmodified lines
10731077 return ENC_RETURN_MEMALLOCERR;
10741078 }
10751079
1080+ iRet = InitSliceBoundaryInfo (pDqLayer, &pCtx->pSvcParam->sSpatialLayers[kiDlayerIndex].sSliceArgument);
1081+ if (ENC_RETURN_SUCCESS != iRet) {
1082+ return iRet;
1083+ }
1084+
10761085 InitSliceThreadInfo (pCtx,
10771086 pDqLayer,
10781087 kiDlayerIndex,
@@ -1142,7 +1151,6 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 63 unmodified lines
11421151 const int32_t kiMaxSliceNumOld,
11431152 const int32_t kiMaxSliceNumNew) {
11441153 CMemoryAlign* pMA = pCtx->pMemAlign;
1145− SDqLayer* pCurLayer = pCtx->pCurDqLayer;
11461154 SSlice* pBaseSlice = NULL;
11471155 SSlice* pNewSliceList = NULL;
11481156 SSlice* pSlice = NULL;
@@ -1181,6 +1189,8 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 32 unmodified lines
11811189 }
11821190
11831191 pSlice->uiSliceIdx = iSliceIdx;
1192+ pSlice->iCountMbNumInSlice = 0;
1193+ pSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = 0;
11841194
11851195 iRet = InitSliceBsBuffer (pSlice,
11861196 & pCtx->pOut->sBsWrite,
@@ -1198,15 +1208,6 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 11 unmodified lines
11981208 return iRet;
11991209 }
12001210
1201− iRet = InitSliceMBInfo (pSliceArgument,
1202− pSlice,
1203− pCurLayer->iMbWidth,
1204− pCurLayer->iMbHeight);
1205− if (ENC_RETURN_SUCCESS != iRet) {
1206− FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()");
1207− return iRet;
1208− }
1209−
12101211 InitSliceHeadWithBase (pSlice, pBaseSlice);
12111212 InitSliceRefInfoWithBase (pSlice, pBaseSlice, pCtx->iNumRef0);
12121213
@@ -1357,6 +1358,7 @@ int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) { · 144 unmodified lines
13571358 return ENC_RETURN_SUCCESS;
13581359 }
13591360
1361+
13601362 /*
13611363 int32_t ReOrderSliceInLayer (SDqLayer* pCurLayer,
13621364 const int32_t kiThreadNum,

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