History

Merge pull request #2271 from sijchen/rf1

[Encoder] refactor multi-thread logic and add error-dealing

HaiboZhu committed 10 years ago

Commit f47be082 parents d85b1f6 12470062 files · +28 −37Browse files

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

Unified · Split

codec/encoder/core/src/slice_multi_threading.cpp+22−37
@@ -604,23 +604,19 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 603 unmodified lines
604604 pSliceBs = &pCtx->pSliceBs[iSliceIdx];
605605 if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) {
606606 if (iSliceIdx > 0) {
607− int32_t iNalIdx = 0;
608− const int32_t iCountNal = pSliceBs->iNalIndex;
609−
610607 memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage
611608 pCtx->iPosBsBuffer += pSliceBs->uiBsPos;
609+ }
612610
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;
623617 }
618+ pLbi->iNalCount += iCountNal;
619+ iNalIdxBase += iCountNal;
624620 }
625621
626622 iSliceIdx += kiPartitionCnt;
@@ -707,9 +703,9 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 80 unmodified lines
707703 &pEventsList[0],
708704 &pEncPEncCtx->pSliceThreading->pThreadMasterEvent[iEventIdx]); // blocking until at least one event is signalled
709705 if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited
710− int iLayerIndex = pEncPEncCtx->pOut->iLayerBsIndex;
711− SFrameBSInfo* pFrameBsInfo = pPrivateData->pFrameBsInfo;
712− SLayerBSInfo* pLbi = &pFrameBsInfo->sLayerInfo [iLayerIndex];
706+ //int iLayerIndex = pEncPEncCtx->pOut->iLayerBsIndex;
707+ //SFrameBSInfo* pFrameBsInfo = pPrivateData->pFrameBsInfo;
708+ //SLayerBSInfo* pLbi = &pFrameBsInfo->sLayerInfo [iLayerIndex];
713709
714710 const int32_t kiCurDid = pEncPEncCtx->uiDependencyId;
715711 SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam;
@@ -874,29 +870,18 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 158 unmodified lines
874870
875871 WelsUnloadNalForSlice (pSliceBs);
876872
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,
881876 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) {
889884 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− }
900885 }
901886
902887 pEncPEncCtx->pFuncList->pfDeblocking.pfDeblockingFilterSlice (pCurDq, pEncPEncCtx->pFuncList, iSliceIdx);

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