@@ -564,63 +564,12 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara
|
||||
#endif//!MT_ENABLED
|
||||
|
||||
if (NULL != pCountLayers)
|
||||
*pCountLayers = iCountNumLayers;
|
||||
*pCountLayers = iCountNumLayers;
|
||||
if (NULL != pCountNals)
|
||||
*pCountNals = iCountNumNals;
|
||||
*pCountNals = iCountNumNals;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief alloc spatial layers pictures (I420 based source pictures)
|
||||
*/
|
||||
int32_t AllocSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pParam) {
|
||||
CMemoryAlign* pMa = pCtx->pMemAlign;
|
||||
const int32_t kiDlayerCount = pParam->iSpatialLayerNum;
|
||||
int32_t iDlayerIndex = 0;
|
||||
|
||||
// spatial pictures
|
||||
iDlayerIndex = 0;
|
||||
do {
|
||||
const int32_t kiPicWidth = pParam->sDependencyLayers[iDlayerIndex].iFrameWidth;
|
||||
const int32_t kiPicHeight = pParam->sDependencyLayers[iDlayerIndex].iFrameHeight;
|
||||
const uint8_t kuiLayerInTemporal = 2 + WELS_MAX (pParam->sDependencyLayers[iDlayerIndex].iHighestTemporalId, 1);
|
||||
const uint8_t kuiRefNumInTemporal = kuiLayerInTemporal + pParam->iLTRRefNum;
|
||||
uint8_t i = 0;
|
||||
|
||||
do {
|
||||
SPicture* pPic = AllocPicture (pMa, kiPicWidth, kiPicHeight, false);
|
||||
WELS_VERIFY_RETURN_IF(1, (NULL == pPic))
|
||||
pCtx->pSpatialPic[iDlayerIndex][i] = pPic;
|
||||
++ i;
|
||||
} while (i < kuiRefNumInTemporal);
|
||||
|
||||
pCtx->uiSpatialLayersInTemporal[iDlayerIndex] = kuiLayerInTemporal;
|
||||
pCtx->uiSpatialPicNum[iDlayerIndex] = kuiRefNumInTemporal;
|
||||
++ iDlayerIndex;
|
||||
} while (iDlayerIndex < kiDlayerCount);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FreeSpatialPictures (sWelsEncCtx* pCtx) {
|
||||
CMemoryAlign* pMa = pCtx->pMemAlign;
|
||||
int32_t j = 0;
|
||||
while (j < pCtx->pSvcParam->iSpatialLayerNum) {
|
||||
uint8_t i = 0;
|
||||
uint8_t uiRefNumInTemporal = pCtx->uiSpatialPicNum[j];
|
||||
|
||||
while (i < uiRefNumInTemporal) {
|
||||
if (NULL != pCtx->pSpatialPic[j][i]) {
|
||||
FreePicture (pMa, &pCtx->pSpatialPic[j][i]);
|
||||
}
|
||||
++ i;
|
||||
}
|
||||
pCtx->uiSpatialLayersInTemporal[j] = 0;
|
||||
++ j;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void InitMbInfo (sWelsEncCtx* pEnc, SMB* pList, SDqLayer* pLayer, const int32_t kiDlayerId,
|
||||
const int32_t kiMaxMbNum) {
|
||||
int32_t iMbWidth = pLayer->iMbWidth;
|
||||
@@ -846,12 +795,6 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
|
||||
++ iDlayerIndex;
|
||||
}
|
||||
|
||||
// for I420 based source spatial pictures
|
||||
if (AllocSpatialPictures (*ppCtx, pParam)) {
|
||||
FreeMemorySvc (ppCtx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
iDlayerIndex = 0;
|
||||
while (iDlayerIndex < iDlayerCount) {
|
||||
SDqLayer* pDqLayer = NULL;
|
||||
@@ -1703,8 +1646,6 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) {
|
||||
pMa->WelsFree (pCtx->ppDqLayerList, "ppDqLayerList");
|
||||
pCtx->ppDqLayerList = NULL;
|
||||
}
|
||||
FreeSpatialPictures (pCtx);
|
||||
|
||||
// reference picture list extension
|
||||
if (NULL != pCtx->ppRefPicListExt && pParam != NULL) {
|
||||
ilayer = 0;
|
||||
@@ -2126,10 +2067,16 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar
|
||||
|
||||
pCtx->pVpp = new CWelsPreProcess (pCtx);
|
||||
if (pCtx->pVpp == NULL) {
|
||||
iRet = 1;
|
||||
WelsLog (pCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), pOut of memory in case new CWelsPreProcess().\n");
|
||||
FreeMemorySvc (&pCtx);
|
||||
return iRet;
|
||||
}
|
||||
if( (iRet = pCtx->pVpp->AllocSpatialPictures(pCtx, pCtx->pSvcParam)) != 0 ){
|
||||
WelsLog( pCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), pVPP alloc spatial pictures failed\n");
|
||||
FreeMemorySvc(&pCtx);
|
||||
return iRet;
|
||||
}
|
||||
|
||||
#if defined(MEMORY_MONITOR)
|
||||
WelsLog (pCtx, WELS_LOG_INFO, "WelsInitEncoderExt() exit, overall memory usage: %llu bytes\n",
|
||||
@@ -2286,6 +2233,7 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) {
|
||||
#endif//MT_ENABLED
|
||||
|
||||
if ((*ppCtx)->pVpp) {
|
||||
(*ppCtx)->pVpp->FreeSpatialPictures(*ppCtx);
|
||||
delete (*ppCtx)->pVpp;
|
||||
(*ppCtx)->pVpp = NULL;
|
||||
}
|
||||
@@ -3747,23 +3695,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
pCtx->bLongTermRefFlag[d_idx][0] = true;
|
||||
}
|
||||
|
||||
if (iCurTid < pCtx->uiSpatialLayersInTemporal[d_idx] - 1 || pSvcParam->iDecompStages == 0) {
|
||||
if ((iCurTid >= MAX_TEMPORAL_LEVEL) || (pCtx->uiSpatialLayersInTemporal[d_idx] - 1 > MAX_TEMPORAL_LEVEL)) {
|
||||
ForceCodingIDR (pCtx); // some logic error
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pSvcParam->bEnableLongTermReference && pCtx->bLongTermRefFlag[d_idx][iCurTid]) {
|
||||
SPicture* tmp = pCtx->pSpatialPic[d_idx][pCtx->uiSpatialLayersInTemporal[d_idx] + pCtx->pVaa->uiMarkLongTermPicIdx];
|
||||
pCtx->pSpatialPic[d_idx][pCtx->uiSpatialLayersInTemporal[d_idx] + pCtx->pVaa->uiMarkLongTermPicIdx] =
|
||||
pCtx->pSpatialPic[d_idx][iCurTid];
|
||||
pCtx->pSpatialPic[d_idx][iCurTid] = pCtx->pSpatialPic[d_idx][pCtx->uiSpatialLayersInTemporal[d_idx] - 1];
|
||||
pCtx->pSpatialPic[d_idx][pCtx->uiSpatialLayersInTemporal[d_idx] - 1] = tmp;
|
||||
pCtx->bLongTermRefFlag[d_idx][iCurTid] = false;
|
||||
} else {
|
||||
WelsExchangeSpatialPictures (&pCtx->pSpatialPic[d_idx][pCtx->uiSpatialLayersInTemporal[d_idx] - 1],
|
||||
&pCtx->pSpatialPic[d_idx][iCurTid]);
|
||||
}
|
||||
if( pCtx->pVpp->UpdateSpatialPictures(pCtx, pSvcParam, iCurTid, d_idx) != 0 ){
|
||||
ForceCodingIDR(pCtx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pSvcParam->bEnableLongTermReference && ((pCtx->pLtr[pCtx->uiDependencyId].bLTRMarkingFlag
|
||||
|
||||
Reference in New Issue
Block a user