static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx) { PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx); if (pPic) { SetUnRef (pPic); } return pPic; }
static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum) { PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum); if (pPic) { SetUnRef (pPic); } return pPic; }
void WelsResetRefPic (PWelsDecoderContext pCtx) { int32_t i = 0; PRefPic pRefPic = &pCtx->sRefPic; pCtx->sRefPic.uiLongRefCount[LIST_0] = pCtx->sRefPic.uiShortRefCount[LIST_0] = 0; pRefPic->uiRefCount[LIST_0] = 0; for (i = 0; i < MAX_DPB_COUNT; i++) { if (pRefPic->pShortRefList[LIST_0][i] != NULL) { SetUnRef (pRefPic->pShortRefList[LIST_0][i]); pRefPic->pShortRefList[LIST_0][i] = NULL; } } pRefPic->uiShortRefCount[LIST_0] = 0; for (i = 0; i < MAX_DPB_COUNT; i++) { if (pRefPic->pLongRefList[LIST_0][i] != NULL) { SetUnRef (pRefPic->pLongRefList[LIST_0][i]); pRefPic->pLongRefList[LIST_0][i] = NULL; } } pRefPic->uiLongRefCount[LIST_0] = 0; }
static int32_t SlidingWindow (PWelsDecoderContext pCtx) { PRefPic pRefPic = &pCtx->sRefPic; PPicture pPic = NULL; int32_t i = 0; if (pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames) { for (i = pRefPic->uiShortRefCount[LIST_0] - 1; i >= 0; i--) { pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum); if (pPic) { SetUnRef (pPic); break; } else { return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW; } } } return ERR_NONE; }
static int32_t SlidingWindow (PWelsDecoderContext pCtx) { PRefPic pRefPic = &pCtx->sRefPic; PPicture pPic = NULL; int32_t i = 0; if (pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames) { if (pCtx->sRefPic.uiShortRefCount[LIST_0] == 0) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "No reference picture in short term list when sliding window"); return ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH; } for (i = pRefPic->uiShortRefCount[LIST_0] - 1; i >= 0; i--) { pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum); if (pPic) { SetUnRef (pPic); break; } else { return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW; } } } return ERR_NONE; }