History

refactor for future simplification

Sijia Chen committed 11 years ago

Commit dfcc78e1 parent 82a0d3e2 files · +24 −31Browse files

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

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+22−27
@@ -1067,6 +1067,25 @@ int32_t FindExistingPps (SWelsSPS* pSps, SSubsetSps* pSubsetSps, const bool kbUs · 1066 unmodified lines
10671067 return INVALID_ID;
10681068 }
10691069
1070+static inline int32_t InitpSliceInLayer (sWelsEncCtx** ppCtx, SDqLayer* pDqLayer, CMemoryAlign* pMa,
1071+ const int32_t iMaxSliceNum, bool bMultithread) {
1072+ int32_t iSliceIdx = 0;
1073+ while (iSliceIdx < iMaxSliceNum) {
1074+ SSlice* pSlice = &pDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx];
1075+ pSlice->uiSliceIdx = iSliceIdx;
1076+ if (bMultithread)
1077+ pSlice->pSliceBsa = & (*ppCtx)->pSliceBs[iSliceIdx].sBsWrite;
1078+ else
1079+ pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite;
1080+ if (AllocMbCacheAligned (&pSlice->sMbCacheInfo, pMa)) {
1081+ FreeMemorySvc (ppCtx);
1082+ return ENC_RETURN_MEMALLOCERR;
1083+ }
1084+ ++ iSliceIdx;
1085+ }
1086+ return ENC_RETURN_SUCCESS;
1087+}
1088+
10701089 /*!
10711090 * \brief initialize ppDqLayerList and slicepEncCtx_list due to count number of layers available
10721091 * \pParam pCtx sWelsEncCtx*
@@ -1161,35 +1180,11 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 88 unmodified lines
11611180 pDqLayer->iMbWidth = kiMbW;
11621181 pDqLayer->iMbHeight = kiMbH;
11631182 {
1164− int32_t iSliceIdx = 0;
11651183 pDqLayer->sLayerInfo.pSliceInLayer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInLayer");
1166−
11671184 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pDqLayer->sLayerInfo.pSliceInLayer), FreeMemorySvc (ppCtx))
1168− if (iMaxSliceNum > 1) {
1169− while (iSliceIdx < iMaxSliceNum) {
1170− SSlice* pSlice = &pDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx];
1171− pSlice->uiSliceIdx = iSliceIdx;
1172− if (pParam->iMultipleThreadIdc > 1)
1173− pSlice->pSliceBsa = & (*ppCtx)->pSliceBs[iSliceIdx].sBsWrite;
1174− else
1175− pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite;
1176− if (AllocMbCacheAligned (&pSlice->sMbCacheInfo, pMa)) {
1177− FreeMemorySvc (ppCtx);
1178− return 1;
1179− }
1180− ++ iSliceIdx;
1181− }
1182− }
1183− // fix issue in case single pSlice coding might be inclusive exist in variant spatial layer setting, also introducing multi-pSlice modes
1184− else { // only one pSlice
1185− SSlice* pSlice = &pDqLayer->sLayerInfo.pSliceInLayer[0];
1186− pSlice->uiSliceIdx = 0;
1187− pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite;
1188− if (AllocMbCacheAligned (&pSlice->sMbCacheInfo, pMa)) {
1189− FreeMemorySvc (ppCtx);
1190− return 1;
1191− }
1192− }
1185+
1186+ int32_t iReturn = InitpSliceInLayer (ppCtx, pDqLayer, pMa, iMaxSliceNum, pParam->iMultipleThreadIdc > 1);
1187+ WELS_VERIFY_RETURN_PROC_IF (1, (ENC_RETURN_SUCCESS != iReturn), FreeMemorySvc (ppCtx))
11931188 }
11941189
11951190 //deblocking parameters initialization

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