It also fix SetUnRef crashing which should only loop for LIST_1 if ref pic is B_SLICE.
Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 8 files). Show all
Unified · Split
| @@ -62,6 +62,7 @@ extern void FreePicture (PPicture pPic, CMemoryAlign* pMa); · 61 unmodified lines | |||
| 62 | 62 | ||
| 63 | static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiSize, | 63 | static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiSize, |
| 64 | const int32_t kiPicWidth, const int32_t kiPicHeight) { | 64 | const int32_t kiPicWidth, const int32_t kiPicHeight) { |
| 65 | |||
| 65 | PPicBuff pPicBuf = NULL; | 66 | PPicBuff pPicBuf = NULL; |
| 66 | int32_t iPicIdx = 0; | 67 | int32_t iPicIdx = 0; |
| 67 | if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) { | 68 | if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) { |
| @@ -80,7 +81,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 12 unmodified lines | |||
| 80 | 81 | ||
| 81 | if (NULL == pPicBuf->ppPic) { | 82 | if (NULL == pPicBuf->ppPic) { |
| 82 | pPicBuf->iCapacity = 0; | 83 | pPicBuf->iCapacity = 0; |
| 83 | DestroyPicBuff (&pPicBuf, pMa); | 84 | DestroyPicBuff (pCtx, &pPicBuf, pMa); |
| 84 | return ERR_INFO_OUT_OF_MEMORY; | 85 | return ERR_INFO_OUT_OF_MEMORY; |
| 85 | } | 86 | } |
| 86 | 87 | ||
| @@ -89,7 +90,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 2 unmodified lines | |||
| 89 | if (NULL == pPic) { | 90 | if (NULL == pPic) { |
| 90 | // init capacity first for free memory | 91 | // init capacity first for free memory |
| 91 | pPicBuf->iCapacity = iPicIdx; | 92 | pPicBuf->iCapacity = iPicIdx; |
| 92 | DestroyPicBuff (&pPicBuf, pMa); | 93 | DestroyPicBuff (pCtx, &pPicBuf, pMa); |
| 93 | return ERR_INFO_OUT_OF_MEMORY; | 94 | return ERR_INFO_OUT_OF_MEMORY; |
| 94 | } | 95 | } |
| 95 | pPicBuf->ppPic[iPicIdx] = pPic; | 96 | pPicBuf->ppPic[iPicIdx] = pPic; |
| @@ -123,7 +124,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 27 unmodified lines | |||
| 123 | 124 | ||
| 124 | if (NULL == pPicNewBuf->ppPic) { | 125 | if (NULL == pPicNewBuf->ppPic) { |
| 125 | pPicNewBuf->iCapacity = 0; | 126 | pPicNewBuf->iCapacity = 0; |
| 126 | DestroyPicBuff (&pPicNewBuf, pMa); | 127 | DestroyPicBuff (pCtx, &pPicNewBuf, pMa); |
| 127 | return ERR_INFO_OUT_OF_MEMORY; | 128 | return ERR_INFO_OUT_OF_MEMORY; |
| 128 | } | 129 | } |
| 129 | 130 | ||
| @@ -133,7 +134,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 3 unmodified lines | |||
| 133 | if (NULL == pPic) { | 134 | if (NULL == pPic) { |
| 134 | // Set maximum capacity as the new malloc memory at the tail | 135 | // Set maximum capacity as the new malloc memory at the tail |
| 135 | pPicNewBuf->iCapacity = iPicIdx; | 136 | pPicNewBuf->iCapacity = iPicIdx; |
| 136 | DestroyPicBuff (&pPicNewBuf, pMa); | 137 | DestroyPicBuff (pCtx, &pPicNewBuf, pMa); |
| 137 | return ERR_INFO_OUT_OF_MEMORY; | 138 | return ERR_INFO_OUT_OF_MEMORY; |
| 138 | } | 139 | } |
| 139 | pPicNewBuf->ppPic[iPicIdx] = pPic; | 140 | pPicNewBuf->ppPic[iPicIdx] = pPic; |
| @@ -187,7 +188,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 47 unmodified lines | |||
| 187 | 188 | ||
| 188 | if (NULL == pPicNewBuf->ppPic) { | 189 | if (NULL == pPicNewBuf->ppPic) { |
| 189 | pPicNewBuf->iCapacity = 0; | 190 | pPicNewBuf->iCapacity = 0; |
| 190 | DestroyPicBuff (&pPicNewBuf, pMa); | 191 | DestroyPicBuff (pCtx, &pPicNewBuf, pMa); |
| 191 | return ERR_INFO_OUT_OF_MEMORY; | 192 | return ERR_INFO_OUT_OF_MEMORY; |
| 192 | } | 193 | } |
| 193 | 194 | ||
| @@ -254,9 +255,11 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 60 unmodified lines | |||
| 254 | return ERR_NONE; | 255 | return ERR_NONE; |
| 255 | } | 256 | } |
| 256 | 257 | ||
| 257 | void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) { | 258 | void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* pMa) { |
| 258 | PPicBuff pPicBuf = NULL; | 259 | PPicBuff pPicBuf = NULL; |
| 259 | 260 | ||
| 261 | ResetReorderingPictureBuffers (pCtx->pPictReoderingStatus, pCtx->pPictInfoList, false); | ||
| 262 | |||
| 260 | if (NULL == ppPicBuf || NULL == *ppPicBuf) | 263 | if (NULL == ppPicBuf || NULL == *ppPicBuf) |
| 261 | return; | 264 | return; |
| 262 | 265 | ||
| @@ -285,6 +288,24 @@ void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) { · 22 unmodified lines | |||
| 285 | *ppPicBuf = NULL; | 288 | *ppPicBuf = NULL; |
| 286 | } | 289 | } |
| 287 | 290 | ||
| 291 | //reset picture reodering buffer list | ||
| 292 | void ResetReorderingPictureBuffers (PPictReoderingStatus pPictReoderingStatus, PPictInfo pPictInfo, | ||
| 293 | const bool& fullReset) { | ||
| 294 | if (pPictReoderingStatus != NULL && pPictInfo != NULL) { | ||
| 295 | int32_t pictInfoListCount = fullReset ? 16 : (pPictReoderingStatus->iLargestBufferedPicIndex + 1); | ||
| 296 | pPictReoderingStatus->iPictInfoIndex = 0; | ||
| 297 | pPictReoderingStatus->iMinPOC = IMinInt32; | ||
| 298 | pPictReoderingStatus->iNumOfPicts = 0; | ||
| 299 | pPictReoderingStatus->iLastGOPRemainPicts = 0; | ||
| 300 | pPictReoderingStatus->iLastWrittenPOC = IMinInt32; | ||
| 301 | pPictReoderingStatus->iLargestBufferedPicIndex = 0; | ||
| 302 | for (int32_t i = 0; i < pictInfoListCount; ++i) { | ||
| 303 | pPictInfo[i].bLastGOP = false; | ||
| 304 | pPictInfo[i].iPOC = IMinInt32; | ||
| 305 | } | ||
| 306 | } | ||
| 307 | } | ||
| 308 | |||
| 288 | /* | 309 | /* |
| 289 | * fill data fields in default for decoder context | 310 | * fill data fields in default for decoder context |
| 290 | */ | 311 | */ |
| @@ -485,7 +506,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 194 unmodified lines | |||
| 485 | // for Recycled_Pic_Queue | 506 | // for Recycled_Pic_Queue |
| 486 | PPicBuff* ppPic = &pCtx->pPicBuff; | 507 | PPicBuff* ppPic = &pCtx->pPicBuff; |
| 487 | if (NULL != ppPic && NULL != *ppPic) { | 508 | if (NULL != ppPic && NULL != *ppPic) { |
| 488 | DestroyPicBuff (ppPic, pMa); | 509 | DestroyPicBuff (pCtx, ppPic, pMa); |
| 489 | } | 510 | } |
| 490 | 511 | ||
| 491 | 512 | ||
| @@ -531,7 +552,7 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 39 unmodified lines | |||
| 531 | 552 | ||
| 532 | PPicBuff* pPicBuff = &pCtx->pPicBuff; | 553 | PPicBuff* pPicBuff = &pCtx->pPicBuff; |
| 533 | if (NULL != pPicBuff && NULL != *pPicBuff) { | 554 | if (NULL != pPicBuff && NULL != *pPicBuff) { |
| 534 | DestroyPicBuff (pPicBuff, pMa); | 555 | DestroyPicBuff (pCtx, pPicBuff, pMa); |
| 535 | } | 556 | } |
| 536 | 557 | ||
| 537 | if (pCtx->pTempDec) { | 558 | if (pCtx->pTempDec) { |