Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 4 files). Show all
Unified · Split
| @@ -2421,9 +2421,6 @@ void WelsDqLayerDecodeStart (PWelsDecoderContext pCtx, PNalUnit pCurNal, PSps pS · 2420 unmodified lines | ||
| 2421 | 2421 | |
| 2422 | 2422 | int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t iPoc) { |
| 2423 | 2423 | int32_t iRet = ERR_NONE; |
| 2424 | − if (GetThreadCount (pCtx) > 1 && pCtx->bNewSeqBegin) { | |
| 2425 | − WelsResetRefPic (pCtx); | |
| 2426 | − } | |
| 2427 | 2424 | if (pCtx->eSliceType == B_SLICE) { |
| 2428 | 2425 | iRet = WelsInitBSliceRefList (pCtx, iPoc); |
| 2429 | 2426 | CreateImplicitWeightTable (pCtx); |
| @@ -2525,37 +2522,20 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 95 unmodified lines | ||
| 2525 | 2522 | SLayerInfo pLayerInfo; |
| 2526 | 2523 | PSliceHeaderExt pShExt = NULL; |
| 2527 | 2524 | PSliceHeader pSh = NULL; |
| 2528 | − | |
| 2529 | − if (pLastThreadCtx != NULL) { | |
| 2530 | − pSh = &pNalCur->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader; | |
| 2531 | − if (pSh->iFirstMbInSlice == 0) { | |
| 2532 | − if (pLastThreadCtx->pCtx->pDec != NULL && pLastThreadCtx->pCtx->pDec->bIsUngroupedMultiSlice) { | |
| 2533 | − WAIT_EVENT (&pLastThreadCtx->sSliceDecodeFinish, WELS_DEC_THREAD_WAIT_INFINITE); | |
| 2534 | − } | |
| 2535 | − pCtx->pDec = NULL; | |
| 2536 | − pCtx->iTotalNumMbRec = 0; | |
| 2537 | − } else if (pLastThreadCtx->pCtx->pDec != NULL) { | |
| 2538 | − if (pSh->iFrameNum == pLastThreadCtx->pCtx->pDec->iFrameNum | |
| 2539 | − && pSh->iPicOrderCntLsb == pLastThreadCtx->pCtx->pDec->iFramePoc) { | |
| 2540 | − WAIT_EVENT (&pLastThreadCtx->sSliceDecodeFinish, WELS_DEC_THREAD_WAIT_INFINITE); | |
| 2541 | − pCtx->pDec = pLastThreadCtx->pCtx->pDec; | |
| 2542 | − pCtx->pDec->bIsUngroupedMultiSlice = true; | |
| 2543 | − pCtx->sRefPic = pLastThreadCtx->pCtx->sRefPic; | |
| 2544 | − pCtx->iTotalNumMbRec = pLastThreadCtx->pCtx->iTotalNumMbRec; | |
| 2545 | − } | |
| 2546 | − } | |
| 2547 | − } | |
| 2548 | 2525 | bool isNewFrame = true; |
| 2549 | 2526 | if (iThreadCount > 1) { |
| 2550 | 2527 | isNewFrame = pCtx->pDec == NULL; |
| 2551 | 2528 | } |
| 2552 | 2529 | if (pCtx->pDec == NULL) { |
| 2553 | − if (pLastThreadCtx != NULL && iIdx == 0) { | |
| 2530 | + //make call PrefetchPic first before updating reference lists in threaded mode | |
| 2531 | + //this prevents from possible thread-decoding hanging | |
| 2532 | + pCtx->pDec = PrefetchPic (pCtx->pPicBuff); | |
| 2533 | + if (pLastThreadCtx != NULL) { | |
| 2554 | 2534 | pLastThreadCtx->pDec->bUsedAsRef = pLastThreadCtx->pCtx->uiNalRefIdc > 0; |
| 2555 | 2535 | if (pLastThreadCtx->pDec->bUsedAsRef) { |
| 2556 | 2536 | for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { |
| 2557 | 2537 | uint32_t i = 0; |
| 2558 | − while (i < MAX_DPB_COUNT && pLastThreadCtx->pCtx->sRefPic.pRefList[listIdx][i]) { | |
| 2538 | + while (i < MAX_REF_PIC_COUNT && pLastThreadCtx->pCtx->sRefPic.pRefList[listIdx][i]) { | |
| 2559 | 2539 | pLastThreadCtx->pDec->pRefPic[listIdx][i] = pLastThreadCtx->pCtx->sRefPic.pRefList[listIdx][i]; |
| 2560 | 2540 | ++i; |
| 2561 | 2541 | } |
| @@ -2567,7 +2547,11 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 5 unmodified lines | ||
| 2567 | 2547 | pCtx->sRefPic = pLastThreadCtx->pCtx->sRefPic; |
| 2568 | 2548 | } |
| 2569 | 2549 | } |
| 2570 | − pCtx->pDec = PrefetchPic (pCtx->pPicBuff); | |
| 2550 | + //WelsResetRefPic needs to be called when a new sequence is encountered | |
| 2551 | + //Otherwise artifacts is observed in decoded yuv in couple of unit tests with multiple-slice frame | |
| 2552 | + if (GetThreadCount (pCtx) > 1 && pCtx->bNewSeqBegin) { | |
| 2553 | + WelsResetRefPic (pCtx); | |
| 2554 | + } | |
| 2571 | 2555 | if (pCtx->iTotalNumMbRec != 0) |
| 2572 | 2556 | pCtx->iTotalNumMbRec = 0; |
| 2573 | 2557 | |
| @@ -2580,7 +2564,6 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 6 unmodified lines | ||
| 2580 | 2564 | return ERR_INFO_REF_COUNT_OVERFLOW; |
| 2581 | 2565 | } |
| 2582 | 2566 | if (pThreadCtx != NULL) { |
| 2583 | − pCtx->pDec->bIsUngroupedMultiSlice = false; | |
| 2584 | 2567 | pThreadCtx->pDec = pCtx->pDec; |
| 2585 | 2568 | if (iThreadCount > 1) ++pCtx->pDec->iRefCount; |
| 2586 | 2569 | uint32_t uiMbHeight = (pCtx->pDec->iHeightInPixel + 15) >> 4; |
| @@ -2683,25 +2666,8 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 96 unmodified lines | ||
| 2683 | 2666 | // Subclause 8.2.5.2 Decoding process for gaps in frame_num |
| 2684 | 2667 | int32_t iPrevFrameNum = pCtx->pLastDecPicInfo->iPrevFrameNum; |
| 2685 | 2668 | if (pLastThreadCtx != NULL) { |
| 2686 | − if (pCtx->bNewSeqBegin) { | |
| 2687 | − iPrevFrameNum = 0; | |
| 2688 | − } else if (pLastThreadCtx->pDec != NULL) { | |
| 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 | − } | |
| 2702 | − } else { | |
| 2703 | − iPrevFrameNum = pCtx->bNewSeqBegin ? 0 : pLastThreadCtx->pCtx->iFrameNum; | |
| 2704 | − } | |
| 2669 | + //call GetPrevFrameNum() to get correct iPrevFrameNum to prevent frame gap warning | |
| 2670 | + iPrevFrameNum = pCtx->bNewSeqBegin ? 0 : GetPrevFrameNum (pCtx); | |
| 2705 | 2671 | } |
| 2706 | 2672 | if (!kbIdrFlag && |
| 2707 | 2673 | pSh->iFrameNum != iPrevFrameNum && |
| @@ -2727,6 +2693,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 19 unmodified lines | ||
| 2727 | 2693 | |
| 2728 | 2694 | if (iCurrIdD == kuiDependencyIdMax && iCurrIdQ == BASE_QUALITY_ID && isNewFrame) { |
| 2729 | 2695 | iRet = InitRefPicList (pCtx, pCtx->uiNalRefIdc, pSh->iPicOrderCntLsb); |
| 2696 | + if (iThreadCount > 1) isNewFrame = false; | |
| 2730 | 2697 | if (iRet) { |
| 2731 | 2698 | pCtx->bRPLRError = true; |
| 2732 | 2699 | bAllRefComplete = false; // RPLR error, set ref pictures complete flag false |