1. Distinguish non-threaded decoding with m_iThreadCount = 0 from one-thread decoding with m_iThreadCount=1. 2. Removed the use of bAvailable of PPicture and replaced by the use of iRefCount to more preciously represent the picture's being-use counts in both threaded and non-threaded mode.
Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 14 files). Show all
Unified · Split
| @@ -151,8 +151,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 150 unmodified lines | |||
| 151 | for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { | 151 | for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { |
| 152 | pPicNewBuf->ppPic[i]->bUsedAsRef = false; | 152 | pPicNewBuf->ppPic[i]->bUsedAsRef = false; |
| 153 | pPicNewBuf->ppPic[i]->bIsLongRef = false; | 153 | pPicNewBuf->ppPic[i]->bIsLongRef = false; |
| 154 | pPicNewBuf->ppPic[i]->uiRefCount = 0; | 154 | pPicNewBuf->ppPic[i]->iRefCount = 0; |
| 155 | pPicNewBuf->ppPic[i]->bAvailableFlag = true; | ||
| 156 | pPicNewBuf->ppPic[i]->bIsComplete = false; | 155 | pPicNewBuf->ppPic[i]->bIsComplete = false; |
| 157 | } | 156 | } |
| 158 | // remove old PicBuf | 157 | // remove old PicBuf |
| @@ -240,8 +239,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 81 unmodified lines | |||
| 240 | for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { | 239 | for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { |
| 241 | pPicNewBuf->ppPic[i]->bUsedAsRef = false; | 240 | pPicNewBuf->ppPic[i]->bUsedAsRef = false; |
| 242 | pPicNewBuf->ppPic[i]->bIsLongRef = false; | 241 | pPicNewBuf->ppPic[i]->bIsLongRef = false; |
| 243 | pPicNewBuf->ppPic[i]->uiRefCount = 0; | 242 | pPicNewBuf->ppPic[i]->iRefCount = 0; |
| 244 | pPicNewBuf->ppPic[i]->bAvailableFlag = true; | ||
| 245 | pPicNewBuf->ppPic[i]->bIsComplete = false; | 243 | pPicNewBuf->ppPic[i]->bIsComplete = false; |
| 246 | } | 244 | } |
| 247 | // remove old PicBuf | 245 | // remove old PicBuf |
| @@ -440,7 +438,7 @@ static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { · 192 unmodified lines | |||
| 440 | iNumRefFrames = MAX_REF_PIC_COUNT + 2; | 438 | iNumRefFrames = MAX_REF_PIC_COUNT + 2; |
| 441 | } else { | 439 | } else { |
| 442 | iNumRefFrames = pCtx->pSps->iNumRefFrames + 2; | 440 | iNumRefFrames = pCtx->pSps->iNumRefFrames + 2; |
| 443 | if (pCtx->pThreadCtx != NULL) { | 441 | if (GetThreadCount (pCtx) > 1) { |
| 444 | iNumRefFrames = MAX_REF_PIC_COUNT + 1; | 442 | iNumRefFrames = MAX_REF_PIC_COUNT + 1; |
| 445 | } | 443 | } |
| 446 | } | 444 | } |
| @@ -484,7 +482,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 37 unmodified lines | |||
| 484 | && kiPicHeight == pCtx->iImgHeightInPixel) && (!bNeedChangePicQueue)) // have same scaled buffer | 482 | && kiPicHeight == pCtx->iImgHeightInPixel) && (!bNeedChangePicQueue)) // have same scaled buffer |
| 485 | 483 | ||
| 486 | // sync update pRefList | 484 | // sync update pRefList |
| 487 | if (pCtx->pThreadCtx == NULL) { | 485 | if (GetThreadCount (pCtx) <= 1) { |
| 488 | WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free | 486 | WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free |
| 489 | } | 487 | } |
| 490 | 488 | ||
| @@ -562,7 +560,7 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 71 unmodified lines | |||
| 562 | if (NULL != pPicBuff && NULL != *pPicBuff) { | 560 | if (NULL != pPicBuff && NULL != *pPicBuff) { |
| 563 | DestroyPicBuff (pCtx, pPicBuff, pMa); | 561 | DestroyPicBuff (pCtx, pPicBuff, pMa); |
| 564 | } | 562 | } |
| 565 | if (pCtx->pThreadCtx != NULL) { | 563 | if (GetThreadCount (pCtx) > 1) { |
| 566 | //prevent from double destruction of PPicBuff | 564 | //prevent from double destruction of PPicBuff |
| 567 | PWelsDecoderThreadCTX pThreadCtx = (PWelsDecoderThreadCTX) (pCtx->pThreadCtx); | 565 | PWelsDecoderThreadCTX pThreadCtx = (PWelsDecoderThreadCTX) (pCtx->pThreadCtx); |
| 568 | int32_t threadCount = pThreadCtx->sThreadInfo.uiThrMaxNum; | 566 | int32_t threadCount = pThreadCtx->sThreadInfo.uiThrMaxNum; |