Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 3 files). Show all
Unified · Split
| @@ -259,8 +259,8 @@ int32_t SetMultiSliceBuffer (sWelsEncCtx** ppCtx, CMemoryAlign* pMa, SSliceThrea · 258 unmodified lines | ||
| 259 | 259 | return ENC_RETURN_UNEXPECTED; |
| 260 | 260 | } |
| 261 | 261 | //slice 0 |
| 262 | − (*ppCtx)->pSliceBs[0].uiSize = iSlice0Len; | |
| 263 | − (*ppCtx)->pSliceBs[0].pBs = (*ppCtx)->pFrameBs; | |
| 262 | + (*ppCtx)->pSliceBs[0].uiSize = iSlice1Len; | |
| 263 | + (*ppCtx)->pSliceBs[0].pBs = (*ppCtx)->pFrameBs + iSlice0Len; | |
| 264 | 264 | (*ppCtx)->pSliceBs[0].uiBsPos = 0; |
| 265 | 265 | (*ppCtx)->pSliceBs[0].pBsBuffer = pSmt->pThreadBsBuffer[0]; |
| 266 | 266 | if ((iMaxSliceNum == 1) && (!bDynamicSlice)) { |
| @@ -524,13 +524,11 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 257 unmodified lines | ||
| 524 | 524 | assert (pSliceBs->bSliceCodedFlag); |
| 525 | 525 | #endif//MT_DEBUG_BS_WR |
| 526 | 526 | |
| 527 | − if (iSliceIdx > 0) { | |
| 528 | − // pSlice 0 bs has been written to pFrameBs yet by now, so uiSliceIdx base should be 1 | |
| 529 | − memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage | |
| 530 | − pCtx->iPosBsBuffer += pSliceBs->uiBsPos; | |
| 527 | + memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage | |
| 528 | + pCtx->iPosBsBuffer += pSliceBs->uiBsPos; | |
| 529 | + | |
| 530 | + iLayerSize += pSliceBs->uiBsPos; | |
| 531 | 531 | |
| 532 | − iLayerSize += pSliceBs->uiBsPos; | |
| 533 | − } | |
| 534 | 532 | while (iNalIdx < iCountNal) { |
| 535 | 533 | pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; |
| 536 | 534 | ++ iNalIdx; |
| @@ -555,10 +553,8 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 18 unmodified lines | ||
| 555 | 553 | while (iIdx < kiCountSlicesCoded) { |
| 556 | 554 | pSliceBs = &pCtx->pSliceBs[iSliceIdx]; |
| 557 | 555 | if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) { |
| 558 | − if (iSliceIdx > 0) { | |
| 559 | − memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage | |
| 560 | − pCtx->iPosBsBuffer += pSliceBs->uiBsPos; | |
| 561 | − } | |
| 556 | + memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage | |
| 557 | + pCtx->iPosBsBuffer += pSliceBs->uiBsPos; | |
| 562 | 558 | |
| 563 | 559 | const int32_t iCountNal = pSliceBs->iNalIndex; |
| 564 | 560 | iLayerSize += pSliceBs->uiBsPos; |
| @@ -586,8 +582,7 @@ int32_t WriteSliceBs (sWelsEncCtx* pCtx,SWelsSliceBs* pSliceBs,const int32_t iSl · 21 unmodified lines | ||
| 586 | 582 | int32_t iNalIdx = 0; |
| 587 | 583 | int32_t iNalSize = 0; |
| 588 | 584 | int32_t iReturn = ENC_RETURN_SUCCESS; |
| 589 | − int32_t iTotalLeftLength = (iSliceIdx > 0) ? (pSliceBs->uiSize - pSliceBs->uiBsPos) | |
| 590 | − : (pCtx->iFrameBsSize - pCtx->iPosBsBuffer); | |
| 585 | + int32_t iTotalLeftLength = pSliceBs->uiSize - pSliceBs->uiBsPos; | |
| 591 | 586 | SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; |
| 592 | 587 | uint8_t* pDst = pSliceBs->pBs; |
| 593 | 588 | |
| @@ -720,9 +715,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 126 unmodified lines | ||
| 720 | 715 | pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent, |
| 721 | 716 | iEventIdx); |
| 722 | 717 | } |
| 723 | − if (0 == iSliceIdx) { | |
| 724 | − pEncPEncCtx->iPosBsBuffer += iSliceSize; | |
| 725 | − } | |
| 726 | 718 | |
| 727 | 719 | pEncPEncCtx->pFuncList->pfDeblocking.pfDeblockingFilterSlice (pCurDq, pEncPEncCtx->pFuncList, iSliceIdx); |
| 728 | 720 | |
| @@ -822,9 +814,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 93 unmodified lines | ||
| 822 | 814 | pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent, |
| 823 | 815 | iEventIdx); |
| 824 | 816 | } |
| 825 | − if (0 == iSliceIdx) { | |
| 826 | − pEncPEncCtx->iPosBsBuffer += iSliceSize; | |
| 827 | − } | |
| 828 | 817 | |
| 829 | 818 | pEncPEncCtx->pFuncList->pfDeblocking.pfDeblockingFilterSlice (pCurDq, pEncPEncCtx->pFuncList, iSliceIdx); |
| 830 | 819 | |
| @@ -936,7 +925,6 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, · 105 unmodified lines | ||
| 936 | 925 | pLbi->uiTemporalId = pCtx->uiTemporalId; |
| 937 | 926 | pLbi->uiQualityId = 0; |
| 938 | 927 | pLbi->iNalCount = 0; |
| 939 | − pCtx->pSliceBs[0].pBs = pLbi->pBsBuf; | |
| 940 | 928 | |
| 941 | 929 | iIdx = 0; |
| 942 | 930 | while (iIdx < kiEventCnt) { |