Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 1 file). Show all
Unified · Split
| @@ -1001,6 +1001,22 @@ void FreeDqLayer (SDqLayer*& pDq, CMemoryAlign* pMa) { · 1000 unmodified lines | ||
| 1001 | 1001 | pDq = NULL; |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | +void FreeRefList (SRefList*& pRefList, CMemoryAlign* pMa, const int iMaxNumRefFrame) { | |
| 1005 | + if (NULL == pRefList) { | |
| 1006 | + return; | |
| 1007 | + } | |
| 1008 | + | |
| 1009 | + int32_t iRef = 0; | |
| 1010 | + do { | |
| 1011 | + if (pRefList->pRef[iRef] != NULL) { | |
| 1012 | + FreePicture (pMa, &pRefList->pRef[iRef]); | |
| 1013 | + } | |
| 1014 | + ++ iRef; | |
| 1015 | + } while (iRef < 1 + iMaxNumRefFrame); | |
| 1016 | + | |
| 1017 | + pMa->WelsFree (pRefList, "pRefList"); | |
| 1018 | + pRefList = NULL; | |
| 1019 | +} | |
| 1004 | 1020 | |
| 1005 | 1021 | static int32_t WelsGenerateNewSps (sWelsEncCtx* pCtx, const bool kbUseSubsetSps, const int32_t iDlayerIndex, |
| 1006 | 1022 | const int32_t iDlayerCount, const int32_t kiSpsId, |
| @@ -1243,7 +1259,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 236 unmodified lines | ||
| 1243 | 1259 | do { |
| 1244 | 1260 | pRefList->pRef[i] = AllocPicture (pMa, kiWidth, kiHeight, true, |
| 1245 | 1261 | (iDlayerIndex == iDlayerCount - 1) ? kiNeedFeatureStorage : 0); // to use actual size of current layer |
| 1246 | − WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList->pRef[i]), FreeMemorySvc (ppCtx)) | |
| 1262 | + WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList->pRef[i]), FreeRefList (pRefList, pMa, iNumRef)) | |
| 1247 | 1263 | ++ i; |
| 1248 | 1264 | } while (i < 1 + iNumRef); |
| 1249 | 1265 | |
| @@ -2206,19 +2222,8 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 956 unmodified lines | ||
| 2206 | 2222 | if (NULL != pCtx->ppRefPicListExt && pParam != NULL) { |
| 2207 | 2223 | ilayer = 0; |
| 2208 | 2224 | while (ilayer < pParam->iSpatialLayerNum) { |
| 2209 | − SRefList* pRefList = pCtx->ppRefPicListExt[ilayer]; | |
| 2210 | − if (NULL != pRefList) { | |
| 2211 | − int32_t iRef = 0; | |
| 2212 | − do { | |
| 2213 | − if (pRefList->pRef[iRef] != NULL) { | |
| 2214 | − FreePicture (pMa, &pRefList->pRef[iRef]); | |
| 2215 | − } | |
| 2216 | − ++ iRef; | |
| 2217 | − } while (iRef < 1 + pParam->iMaxNumRefFrame); | |
| 2218 | − | |
| 2219 | − pMa->WelsFree (pCtx->ppRefPicListExt[ilayer], "ppRefPicListExt[]"); | |
| 2220 | − pCtx->ppRefPicListExt[ilayer] = NULL; | |
| 2221 | − } | |
| 2225 | + FreeRefList (pCtx->ppRefPicListExt[ilayer], pMa, pParam->iMaxNumRefFrame); | |
| 2226 | + pCtx->ppRefPicListExt[ilayer] = NULL; | |
| 2222 | 2227 | ++ ilayer; |
| 2223 | 2228 | } |
| 2224 | 2229 | |