Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 4 files). Show all
Unified · Split
| @@ -628,31 +628,30 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 627 unmodified lines | |||
| 628 | return iLayerSize; | 628 | return iLayerSize; |
| 629 | } | 629 | } |
| 630 | 630 | ||
| 631 | int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pDst, | 631 | int32_t WriteSliceBs (sWelsEncCtx* pCtx,SWelsSliceBs* pSliceBs,const int32_t iSliceIdx,int32_t& iSliceSize) { |
| 632 | int32_t* pNalLen, | ||
| 633 | int32_t iTotalLeftLength, | ||
| 634 | const int32_t iSliceIdx, | ||
| 635 | int32_t& iSliceSize) { | ||
| 636 | SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; | ||
| 637 | SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; | ||
| 638 | |||
| 639 | const int32_t kiNalCnt = pSliceBs->iNalIndex; | 632 | const int32_t kiNalCnt = pSliceBs->iNalIndex; |
| 640 | int32_t iNalIdx = 0; | 633 | int32_t iNalIdx = 0; |
| 641 | int32_t iNalSize = 0; | 634 | int32_t iNalSize = 0; |
| 642 | int32_t iReturn = ENC_RETURN_SUCCESS; | 635 | int32_t iReturn = ENC_RETURN_SUCCESS; |
| 643 | iSliceSize = 0; | 636 | int32_t iTotalLeftLength = (iSliceIdx > 0) ? (pSliceBs->uiSize - pSliceBs->uiBsPos) |
| 637 | : (pCtx->iFrameBsSize - pCtx->iPosBsBuffer); | ||
| 638 | SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; | ||
| 639 | uint8_t* pDst = pSliceBs->pBs; | ||
| 640 | |||
| 644 | assert (kiNalCnt <= 2); | 641 | assert (kiNalCnt <= 2); |
| 645 | if (kiNalCnt > 2) | 642 | if (kiNalCnt > 2) |
| 646 | return 0; | 643 | return 0; |
| 647 | 644 | ||
| 645 | iSliceSize = 0; | ||
| 648 | while (iNalIdx < kiNalCnt) { | 646 | while (iNalIdx < kiNalCnt) { |
| 649 | iNalSize = 0; | 647 | iNalSize = 0; |
| 650 | iReturn = WelsEncodeNal (&pSliceBs->sNalList[iNalIdx], pNalHdrExt, iTotalLeftLength - iSliceSize, | 648 | iReturn = WelsEncodeNal (&pSliceBs->sNalList[iNalIdx], pNalHdrExt, iTotalLeftLength - iSliceSize, |
| 651 | pDst, &iNalSize); | 649 | pDst, &iNalSize); |
| 652 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | 650 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 653 | pNalLen[iNalIdx] = iNalSize; | 651 | |
| 654 | iSliceSize += iNalSize; | 652 | pSliceBs->iNalLen[iNalIdx] = iNalSize; |
| 655 | pDst += iNalSize; | 653 | iSliceSize += iNalSize; |
| 654 | pDst += iNalSize; | ||
| 656 | ++ iNalIdx; | 655 | ++ iNalIdx; |
| 657 | } | 656 | } |
| 658 | pSliceBs->uiBsPos = iSliceSize; | 657 | pSliceBs->uiBsPos = iSliceSize; |
| @@ -761,13 +760,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 102 unmodified lines | |||
| 761 | 760 | ||
| 762 | WelsUnloadNalForSlice (pSliceBs); | 761 | WelsUnloadNalForSlice (pSliceBs); |
| 763 | 762 | ||
| 764 | int32_t iLeftBufferSize = (iSliceIdx > 0) ? | 763 | iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs, iSliceIdx, iSliceSize); |
| 765 | (pSliceBs->uiSize - pSliceBs->uiBsPos) | ||
| 766 | : (pEncPEncCtx->iFrameBsSize - pEncPEncCtx->iPosBsBuffer); | ||
| 767 | iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, | ||
| 768 | &pSliceBs->iNalLen[0], | ||
| 769 | iLeftBufferSize, | ||
| 770 | iSliceIdx, iSliceSize); | ||
| 771 | if (ENC_RETURN_SUCCESS != iReturn) { | 764 | if (ENC_RETURN_SUCCESS != iReturn) { |
| 772 | uiThrdRet = iReturn; | 765 | uiThrdRet = iReturn; |
| 773 | WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent, | 766 | WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent, |
| @@ -869,10 +862,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 95 unmodified lines | |||
| 869 | 862 | ||
| 870 | WelsUnloadNalForSlice (pSliceBs); | 863 | WelsUnloadNalForSlice (pSliceBs); |
| 871 | 864 | ||
| 872 | int32_t iLeftBufferSize = (iSliceIdx > 0) ? (pSliceBs->uiSize - pSliceBs->uiBsPos) : (pEncPEncCtx->iFrameBsSize - pEncPEncCtx->iPosBsBuffer); | 865 | iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs, iSliceIdx, iSliceSize); |
| 873 | iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, &pSliceBs->iNalLen[0], | ||
| 874 | iLeftBufferSize, | ||
| 875 | iSliceIdx, iSliceSize); | ||
| 876 | if (ENC_RETURN_SUCCESS != iReturn) { | 866 | if (ENC_RETURN_SUCCESS != iReturn) { |
| 877 | uiThrdRet = iReturn; | 867 | uiThrdRet = iReturn; |
| 878 | WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent, | 868 | WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent, |