int32_t WelsMarkAsRef (PWelsDecoderContext pCtx) { PRefPic pRefPic = &pCtx->sRefPic; PRefPicMarking pRefPicMarking = pCtx->pCurDqLayer->pRefPicMarking; PAccessUnit pCurAU = pCtx->pAccessUnitList; bool bIsIDRAU = false; uint32_t j; int32_t iRet = ERR_NONE; pCtx->pDec->uiQualityId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId; pCtx->pDec->uiTemporalId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiTemporalId; pCtx->pDec->iSpsId = pCtx->pSps->iSpsId; pCtx->pDec->iPpsId = pCtx->pPps->iPpsId; for (j = pCurAU->uiStartPos; j <= pCurAU->uiEndPos; j++) { if (pCurAU->pNalUnitsList[j]->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR || pCurAU->pNalUnitsList[j]->sNalHeaderExt.bIdrFlag) { bIsIDRAU = true; break; } } if (bIsIDRAU) { if (pRefPicMarking->bLongTermRefFlag) { pCtx->sRefPic.iMaxLongTermFrameIdx = 0; AddLongTermToList (pRefPic, pCtx->pDec, 0); } else { pCtx->sRefPic.iMaxLongTermFrameIdx = -1; } } else { if (pRefPicMarking->bAdaptiveRefPicMarkingModeFlag) { iRet = MMCO (pCtx, pRefPicMarking); if (iRet != ERR_NONE) { if (pCtx->eErrorConMethod != ERROR_CON_DISABLE) { iRet = RemainOneBufferInDpbForEC (pCtx); WELS_VERIFY_RETURN_IF (iRet, iRet); } else { return iRet; } } if (pCtx->bLastHasMmco5) { pCtx->pDec->iFrameNum = 0; pCtx->pDec->iFramePoc = 0; } } else { iRet = SlidingWindow (pCtx); if (iRet != ERR_NONE) { if (pCtx->eErrorConMethod != ERROR_CON_DISABLE) { iRet = RemainOneBufferInDpbForEC (pCtx); WELS_VERIFY_RETURN_IF (iRet, iRet); } else { return iRet; } } } } if (!pCtx->pDec->bIsLongRef) { if (pRefPic->uiLongRefCount[LIST_0] + pRefPic->uiShortRefCount[LIST_0] >= WELS_MAX (1, pCtx->pSps->iNumRefFrames)) { if (pCtx->eErrorConMethod != ERROR_CON_DISABLE) { iRet = RemainOneBufferInDpbForEC (pCtx); WELS_VERIFY_RETURN_IF (iRet, iRet); } else { return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW; } } iRet = AddShortTermToList (pRefPic, pCtx->pDec); } return iRet; }
int32_t WelsMarkAsRef(PWelsDecoderContext pCtx, const bool_t kbRefBaseMarkingFlag) { PRefPic pRefPic = &pCtx->sRefPic; PRefPicMarking pRefPicMarking = pCtx->pCurDqLayer->pRefPicMarking; PRefBasePicMarking pRefPicBaseMarking =pCtx->pCurDqLayer->pRefPicBaseMarking; PAccessUnit pCurAU = pCtx->pAccessUnitList; bool_t bIsIDRAU = FALSE; uint32_t j; int32_t iRet = ERR_NONE; if(pCtx->pCurDqLayer->bStoreRefBasePicFlag && (pCtx->pSps->iNumRefFrames<2)){ return ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH; } pCtx->pDec->bUsedAsRef = TRUE; pCtx->pDec->uiQualityId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId; pCtx->pDec->uiTemporalId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiTemporalId; pCtx->pDec->bRefBaseFlag = kbRefBaseMarkingFlag; for( j = pCurAU->uiStartPos; j <= pCurAU->uiEndPos; j++ ) { if (pCurAU->pNalUnitsList[j]->sNalHeaderExt.sNalUnitHeader.eNalUnitType== NAL_UNIT_CODED_SLICE_IDR|| pCurAU->pNalUnitsList[j]->sNalHeaderExt.bIdrFlag) { bIsIDRAU = TRUE; break; } } if(bIsIDRAU){ if (pRefPicMarking->bLongTermRefFlag){ pCtx->sRefPic.iMaxLongTermFrameIdx = 0; AddLongTermToList(pRefPic,pCtx->pDec,0); }else{ pCtx->sRefPic.iMaxLongTermFrameIdx = -1; } }else{ if (pRefPicBaseMarking->bAdaptiveRefBasePicMarkingModeFlag){ iRet = MMCOBase(pCtx,pRefPicBaseMarking); } if (iRet != ERR_NONE){ return iRet; } if (pRefPicMarking->bAdaptiveRefPicMarkingModeFlag){ iRet = MMCO(pCtx,pRefPicMarking); if( pCtx->bLastHasMmco5 ) { pCtx->pDec->iFrameNum = 0; pCtx->pDec->iFramePoc = 0; } if (pRefPic->uiLongRefCount[LIST_0]+pRefPic->uiShortRefCount[LIST_0] > pCtx->pSps->iNumRefFrames){ return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW; } }else{ iRet = SlidingWindow(pCtx); } } if (!pCtx->pDec->bIsLongRef){ AddShortTermToList(pRefPic,pCtx->pDec); } return iRet; }