Merge pull request #2013 from sijchen/mem10
[Encoder] refactoring: simplify and wrap a function
This commit is contained in:
commit
1308027377
@ -1067,6 +1067,25 @@ int32_t FindExistingPps (SWelsSPS* pSps, SSubsetSps* pSubsetSps, const bool kbUs
|
||||
return INVALID_ID;
|
||||
}
|
||||
|
||||
static inline int32_t InitpSliceInLayer (sWelsEncCtx** ppCtx, SDqLayer* pDqLayer, CMemoryAlign* pMa,
|
||||
const int32_t iMaxSliceNum, bool bMultithread) {
|
||||
int32_t iSliceIdx = 0;
|
||||
while (iSliceIdx < iMaxSliceNum) {
|
||||
SSlice* pSlice = &pDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx];
|
||||
pSlice->uiSliceIdx = iSliceIdx;
|
||||
if (bMultithread)
|
||||
pSlice->pSliceBsa = & (*ppCtx)->pSliceBs[iSliceIdx].sBsWrite;
|
||||
else
|
||||
pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite;
|
||||
if (AllocMbCacheAligned (&pSlice->sMbCacheInfo, pMa)) {
|
||||
FreeMemorySvc (ppCtx);
|
||||
return ENC_RETURN_MEMALLOCERR;
|
||||
}
|
||||
++ iSliceIdx;
|
||||
}
|
||||
return ENC_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief initialize ppDqLayerList and slicepEncCtx_list due to count number of layers available
|
||||
* \pParam pCtx sWelsEncCtx*
|
||||
@ -1161,35 +1180,11 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p
|
||||
pDqLayer->iMbWidth = kiMbW;
|
||||
pDqLayer->iMbHeight = kiMbH;
|
||||
{
|
||||
int32_t iSliceIdx = 0;
|
||||
pDqLayer->sLayerInfo.pSliceInLayer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInLayer");
|
||||
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pDqLayer->sLayerInfo.pSliceInLayer), FreeMemorySvc (ppCtx))
|
||||
if (iMaxSliceNum > 1) {
|
||||
while (iSliceIdx < iMaxSliceNum) {
|
||||
SSlice* pSlice = &pDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx];
|
||||
pSlice->uiSliceIdx = iSliceIdx;
|
||||
if (pParam->iMultipleThreadIdc > 1)
|
||||
pSlice->pSliceBsa = & (*ppCtx)->pSliceBs[iSliceIdx].sBsWrite;
|
||||
else
|
||||
pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite;
|
||||
if (AllocMbCacheAligned (&pSlice->sMbCacheInfo, pMa)) {
|
||||
FreeMemorySvc (ppCtx);
|
||||
return 1;
|
||||
}
|
||||
++ iSliceIdx;
|
||||
}
|
||||
}
|
||||
// fix issue in case single pSlice coding might be inclusive exist in variant spatial layer setting, also introducing multi-pSlice modes
|
||||
else { // only one pSlice
|
||||
SSlice* pSlice = &pDqLayer->sLayerInfo.pSliceInLayer[0];
|
||||
pSlice->uiSliceIdx = 0;
|
||||
pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite;
|
||||
if (AllocMbCacheAligned (&pSlice->sMbCacheInfo, pMa)) {
|
||||
FreeMemorySvc (ppCtx);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t iReturn = InitpSliceInLayer (ppCtx, pDqLayer, pMa, iMaxSliceNum, pParam->iMultipleThreadIdc > 1);
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (ENC_RETURN_SUCCESS != iReturn), FreeMemorySvc (ppCtx))
|
||||
}
|
||||
|
||||
//deblocking parameters initialization
|
||||
|
@ -77,9 +77,8 @@ void WelsUnloadNal (SWelsEncoderOutput* pEncoderOuput) {
|
||||
/*!
|
||||
* \brief load an initialize NAL pRawNal pData
|
||||
*/
|
||||
void WelsLoadNalForSlice (SWelsSliceBs* pSliceBsIn, const int32_t/*EWelsNalUnitType*/ kiType,
|
||||
void WelsLoadNalForSlice (SWelsSliceBs* pSliceBs, const int32_t/*EWelsNalUnitType*/ kiType,
|
||||
const int32_t/*EWelsNalRefIdc*/ kiNalRefIdc) {
|
||||
SWelsSliceBs* pSliceBs = pSliceBsIn;
|
||||
SWelsNalRaw* pRawNal = &pSliceBs->sNalList[ pSliceBs->iNalIndex ];
|
||||
SNalUnitHeader* sNalUnitHeader = &pRawNal->sNalExt.sNalUnitHeader;
|
||||
SBitStringAux* pBitStringAux = &pSliceBs->sBsWrite;
|
||||
@ -97,8 +96,7 @@ void WelsLoadNalForSlice (SWelsSliceBs* pSliceBsIn, const int32_t/*EWelsNalUnitT
|
||||
/*!
|
||||
* \brief unload pRawNal NAL
|
||||
*/
|
||||
void WelsUnloadNalForSlice (SWelsSliceBs* pSliceBsIn) {
|
||||
SWelsSliceBs* pSliceBs = pSliceBsIn;
|
||||
void WelsUnloadNalForSlice (SWelsSliceBs* pSliceBs) {
|
||||
int32_t* pIdx = &pSliceBs->iNalIndex;
|
||||
SWelsNalRaw* pRawNal = &pSliceBs->sNalList[ *pIdx ];
|
||||
SBitStringAux* pBitStringAux = &pSliceBs->sBsWrite;
|
||||
|
Loading…
Reference in New Issue
Block a user