Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 6 files). Show all
Unified · Split
| @@ -1983,6 +1983,9 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 1982 unmodified lines | ||
| 1983 | 1983 | return 1; |
| 1984 | 1984 | } |
| 1985 | 1985 | |
| 1986 | + (*ppCtx)->pReferenceStrategy = IWelsReferenceStrategy::CreateReferenceStrategy((*ppCtx), pParam->iUsageType, pParam->bEnableLongTermReference); | |
| 1987 | + WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pReferenceStrategy), FreeMemorySvc (ppCtx)) | |
| 1988 | + | |
| 1986 | 1989 | (*ppCtx)->pIntra4x4PredModeBlocks = static_cast<int8_t*> |
| 1987 | 1990 | (pMa->WelsMallocz (iCountMaxMbNum * INTRA_4x4_MODE_NUM, "pIntra4x4PredModeBlocks")); |
| 1988 | 1991 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pIntra4x4PredModeBlocks), FreeMemorySvc (ppCtx)) |
| @@ -2171,6 +2174,10 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 182 unmodified lines | ||
| 2171 | 2174 | if (pParam != NULL && pParam->iMultipleThreadIdc > 1) |
| 2172 | 2175 | ReleaseMtResource (ppCtx); |
| 2173 | 2176 | |
| 2177 | + if (NULL != pCtx->pReferenceStrategy) { | |
| 2178 | + WELS_DELETE_OP(pCtx->pReferenceStrategy); | |
| 2179 | + } | |
| 2180 | + | |
| 2174 | 2181 | // frame bitstream pBuffer |
| 2175 | 2182 | if (NULL != pCtx->pFrameBs) { |
| 2176 | 2183 | pMa->WelsFree (pCtx->pFrameBs, "pFrameBs"); |
| @@ -4013,8 +4020,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 1836 unmodified lines | ||
| 4013 | 4020 | |
| 4014 | 4021 | WelsInitCurrentLayer (pCtx, iCurWidth, iCurHeight); |
| 4015 | 4022 | |
| 4016 | − pCtx->pFuncList->pMarkPic (pCtx); | |
| 4017 | − if (!pCtx->pFuncList->pBuildRefList (pCtx, pParamInternal->iPOC, 0)) { | |
| 4023 | + pCtx->pReferenceStrategy->MarkPic (); | |
| 4024 | + if (!pCtx->pReferenceStrategy->BuildRefList (pParamInternal->iPOC, 0)) { | |
| 4018 | 4025 | WelsLog (pLogCtx, WELS_LOG_WARNING, |
| 4019 | 4026 | "WelsEncoderEncodeExt(), WelsBuildRefList failed for P frames, pCtx->iNumRef0= %d. ForceCodingIDR!", |
| 4020 | 4027 | pCtx->iNumRef0); |
| @@ -4023,7 +4030,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 2 unmodified lines | ||
| 4023 | 4030 | break; |
| 4024 | 4031 | } |
| 4025 | 4032 | if (pCtx->eSliceType != I_SLICE) { |
| 4026 | − pCtx->pFuncList->pAfterBuildRefList (pCtx); | |
| 4033 | + pCtx->pReferenceStrategy->AfterBuildRefList (); | |
| 4027 | 4034 | } |
| 4028 | 4035 | #ifdef LONG_TERM_REF_DUMP |
| 4029 | 4036 | DumpRef (pCtx); |
| @@ -4277,7 +4284,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 247 unmodified lines | ||
| 4277 | 4284 | |
| 4278 | 4285 | // reference picture list update |
| 4279 | 4286 | if (eNalRefIdc != NRI_PRI_LOWEST) { |
| 4280 | − if (!pCtx->pFuncList->pUpdateRefList (pCtx)) { | |
| 4287 | + if (!pCtx->pReferenceStrategy->UpdateRefList ()) { | |
| 4281 | 4288 | WelsLog (pLogCtx, WELS_LOG_WARNING, "WelsEncoderEncodeExt(), WelsUpdateRefList failed. ForceCodingIDR!"); |
| 4282 | 4289 | //the above is to set the next frame to be IDR |
| 4283 | 4290 | pCtx->iEncoderError = ENC_RETURN_CORRECTED; |