Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 2 files). Show all
Unified · Split
| @@ -604,23 +604,19 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 603 unmodified lines | ||
| 604 | 604 | pSliceBs = &pCtx->pSliceBs[iSliceIdx]; |
| 605 | 605 | if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) { |
| 606 | 606 | if (iSliceIdx > 0) { |
| 607 | − int32_t iNalIdx = 0; | |
| 608 | − const int32_t iCountNal = pSliceBs->iNalIndex; | |
| 609 | − | |
| 610 | 607 | memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage |
| 611 | 608 | pCtx->iPosBsBuffer += pSliceBs->uiBsPos; |
| 609 | + } | |
| 612 | 610 | |
| 613 | − iLayerSize += pSliceBs->uiBsPos; | |
| 614 | − | |
| 615 | − while (iNalIdx < iCountNal) { | |
| 616 | − pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; | |
| 617 | − ++ iNalIdx; | |
| 618 | − } | |
| 619 | − pLbi->iNalCount += iCountNal; | |
| 620 | − iNalIdxBase += iCountNal; | |
| 621 | − } else { | |
| 622 | − iLayerSize += pSliceBs->uiBsPos; | |
| 611 | + const int32_t iCountNal = pSliceBs->iNalIndex; | |
| 612 | + iLayerSize += pSliceBs->uiBsPos; | |
| 613 | + int32_t iNalIdx = 0; | |
| 614 | + while (iNalIdx < iCountNal) { | |
| 615 | + pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; | |
| 616 | + ++ iNalIdx; | |
| 623 | 617 | } |
| 618 | + pLbi->iNalCount += iCountNal; | |
| 619 | + iNalIdxBase += iCountNal; | |
| 624 | 620 | } |
| 625 | 621 | |
| 626 | 622 | iSliceIdx += kiPartitionCnt; |
| @@ -709,7 +705,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 82 unmodified lines | ||
| 709 | 705 | if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited |
| 710 | 706 | int iLayerIndex = pEncPEncCtx->pOut->iLayerBsIndex; |
| 711 | 707 | SFrameBSInfo* pFrameBsInfo = pPrivateData->pFrameBsInfo; |
| 712 | − SLayerBSInfo* pLbi = &pFrameBsInfo->sLayerInfo [iLayerIndex]; | |
| 708 | + //SLayerBSInfo* pLbi = &pFrameBsInfo->sLayerInfo [iLayerIndex]; | |
| 713 | 709 | |
| 714 | 710 | const int32_t kiCurDid = pEncPEncCtx->uiDependencyId; |
| 715 | 711 | SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam; |
| @@ -874,29 +870,18 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 158 unmodified lines | ||
| 874 | 870 | |
| 875 | 871 | WelsUnloadNalForSlice (pSliceBs); |
| 876 | 872 | |
| 877 | − if (0 == iSliceIdx) { | |
| 878 | − iReturn = WriteSliceBs (pEncPEncCtx, pLbi->pBsBuf, | |
| 879 | − &pLbi->pNalLengthInByte[pLbi->iNalCount], | |
| 880 | − pEncPEncCtx->iFrameBsSize - pEncPEncCtx->iPosBsBuffer, | |
| 873 | + int32_t iLeftBufferSize = (iSliceIdx > 0) ? (pSliceBs->uiSize - pSliceBs->uiBsPos) : (pEncPEncCtx->iFrameBsSize - pEncPEncCtx->iPosBsBuffer); | |
| 874 | + iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, &pSliceBs->iNalLen[0], | |
| 875 | + iLeftBufferSize, | |
| 881 | 876 | iSliceIdx, iSliceSize); |
| 882 | − pLbi->iNalCount += pSliceBs->iNalIndex; | |
| 883 | − if (ENC_RETURN_SUCCESS != iReturn) { | |
| 884 | − uiThrdRet = iReturn; | |
| 885 | − WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent, | |
| 886 | − pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent, | |
| 887 | − iEventIdx); | |
| 888 | − } | |
| 877 | + if (ENC_RETURN_SUCCESS != iReturn) { | |
| 878 | + uiThrdRet = iReturn; | |
| 879 | + WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent, | |
| 880 | + pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent, | |
| 881 | + iEventIdx); | |
| 882 | + } | |
| 883 | + if (0 == iSliceIdx) { | |
| 889 | 884 | pEncPEncCtx->iPosBsBuffer += iSliceSize; |
| 890 | − } else { | |
| 891 | − iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, &pSliceBs->iNalLen[0], | |
| 892 | − pSliceBs->uiSize - pSliceBs->uiBsPos, | |
| 893 | − iSliceIdx, iSliceSize); | |
| 894 | − if (ENC_RETURN_SUCCESS != iReturn) { | |
| 895 | − uiThrdRet = iReturn; | |
| 896 | − WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent, | |
| 897 | − pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent, | |
| 898 | − iEventIdx); | |
| 899 | − } | |
| 900 | 885 | } |
| 901 | 886 | |
| 902 | 887 | pEncPEncCtx->pFuncList->pfDeblocking.pfDeblockingFilterSlice (pCurDq, pEncPEncCtx->pFuncList, iSliceIdx); |