History

unitfy slice bs writing for multi-thread(sliceindex==0 is the same with others )

huade committed 10 years ago

Commit dcfe76d1 parent 6dc3f723 files · +10 −26Browse files

Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 3 files). Show all

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t