Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 3 files). Show all
Unified · Split
| @@ -2338,7 +2338,7 @@ int32_t InitConstructAccessUnit (PWelsDecoderContext pCtx, SBufferInfo* pDstInfo · 2337 unmodified lines | ||
| 2338 | 2338 | */ |
| 2339 | 2339 | int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) { |
| 2340 | 2340 | int32_t iErr = ERR_NONE; |
| 2341 | − if (pCtx->pThreadCtx == NULL) { | |
| 2341 | + if (GetThreadCount (pCtx) <= 1) { | |
| 2342 | 2342 | iErr = InitConstructAccessUnit (pCtx, pDstInfo); |
| 2343 | 2343 | if (ERR_NONE != iErr) { |
| 2344 | 2344 | return iErr; |
| @@ -2550,7 +2550,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 205 unmodified lines | ||
| 2550 | 2550 | isNewFrame = pCtx->pDec == NULL; |
| 2551 | 2551 | } |
| 2552 | 2552 | if (pCtx->pDec == NULL) { |
| 2553 | − if (pLastThreadCtx != NULL) { | |
| 2553 | + if (pLastThreadCtx != NULL && iIdx == 0) { | |
| 2554 | 2554 | pLastThreadCtx->pDec->bUsedAsRef = pLastThreadCtx->pCtx->uiNalRefIdc > 0; |
| 2555 | 2555 | if (pLastThreadCtx->pDec->bUsedAsRef) { |
| 2556 | 2556 | for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { |
| @@ -2686,7 +2686,19 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 129 unmodified lines | ||
| 2686 | 2686 | if (pCtx->bNewSeqBegin) { |
| 2687 | 2687 | iPrevFrameNum = 0; |
| 2688 | 2688 | } else if (pLastThreadCtx->pDec != NULL) { |
| 2689 | − iPrevFrameNum = pLastThreadCtx->pDec->iFrameNum; | |
| 2689 | + if (pLastThreadCtx->pDec->uiTimeStamp == pCtx->uiTimeStamp - 1) { | |
| 2690 | + iPrevFrameNum = pLastThreadCtx->pDec->iFrameNum; | |
| 2691 | + if (iPrevFrameNum == -1) iPrevFrameNum = pLastThreadCtx->pCtx->iFrameNum; | |
| 2692 | + } else { | |
| 2693 | + int32_t id = pThreadCtx->sThreadInfo.uiThrNum; | |
| 2694 | + for (int32_t i = 0; i < iThreadCount; ++i) { | |
| 2695 | + if (pThreadCtx[i - id].pCtx->uiTimeStamp == pCtx->uiTimeStamp - 1) { | |
| 2696 | + if (pThreadCtx[i - id].pDec != NULL) iPrevFrameNum = pThreadCtx[i - id].pDec->iFrameNum; | |
| 2697 | + if (iPrevFrameNum == -1) iPrevFrameNum = pThreadCtx[i - id].pCtx->iFrameNum; | |
| 2698 | + break; | |
| 2699 | + } | |
| 2700 | + } | |
| 2701 | + } | |
| 2690 | 2702 | } else { |
| 2691 | 2703 | iPrevFrameNum = pCtx->bNewSeqBegin ? 0 : pLastThreadCtx->pCtx->iFrameNum; |
| 2692 | 2704 | } |
| @@ -2734,8 +2746,10 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 41 unmodified lines | ||
| 2734 | 2746 | ComputeColocatedTemporalScaling (pCtx); |
| 2735 | 2747 | |
| 2736 | 2748 | if (iThreadCount > 1) { |
| 2737 | − memset (&pCtx->lastReadyHeightOffset[0][0], -1, LIST_A * MAX_REF_PIC_COUNT * sizeof (int16_t)); | |
| 2738 | − SET_EVENT (&pThreadCtx->sSliceDecodeStart); | |
| 2749 | + if (iIdx == 0) { | |
| 2750 | + memset (&pCtx->lastReadyHeightOffset[0][0], -1, LIST_A * MAX_REF_PIC_COUNT * sizeof (int16_t)); | |
| 2751 | + SET_EVENT (&pThreadCtx->sSliceDecodeStart); | |
| 2752 | + } | |
| 2739 | 2753 | iRet = WelsDecodeAndConstructSlice (pCtx); |
| 2740 | 2754 | } else { |
| 2741 | 2755 | iRet = WelsDecodeSlice (pCtx, bFreshSliceAvailable, pNalCur); |