History

correct the termination of error handling under multi-thread

Sijia Chen committed 11 years ago

Commit 2a15a791 parent 9be80c02 files · +35 −10Browse 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+33−9
@@ -69,6 +69,12 @@ · 68 unmodified lines
6969 #define MT_TRACE_LOG(x, ...)
7070 #endif
7171
72+#define WELS_THREAD_SIGNAL_AND_BREAK(CodedEventList, CodedMasterEvent, iEventIdx) { \
73+ WelsEventSignal(&CodedEventList[iEventIdx]); \
74+ WelsEventSignal (&CodedMasterEvent); \
75+ break; \
76+}
77+
7278 namespace WelsEnc {
7379 void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx,
7480 SMB* pMbList,
@@ -766,7 +772,9 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 691 unmodified lines
766772 iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType);
767773 if (ENC_RETURN_SUCCESS != iReturn) {
768774 uiThrdRet = iReturn;
769− break;
775+ WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
776+ pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
777+ iEventIdx);
770778 }
771779
772780 WelsUnloadNalForSlice (pSliceBs);
@@ -776,14 +784,18 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 3 unmodified lines
776784 iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx, iSliceSize);
777785 if (ENC_RETURN_SUCCESS != iReturn) {
778786 uiThrdRet = iReturn;
779− break;
787+ WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
788+ pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
789+ iEventIdx);
780790 }
781791 pEncPEncCtx->iPosBsBuffer += iSliceSize;
782792 } else {
783793 iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize);
784794 if (ENC_RETURN_SUCCESS != iReturn) {
785795 uiThrdRet = iReturn;
786− break;
796+ WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
797+ pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
798+ iEventIdx);
787799 }
788800 }
789801
@@ -846,7 +858,9 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 56 unmodified lines
846858 // TODO: need exception handler for not large enough of MAX_SLICES_NUM related memory usage
847859 // No idea about its solution due MAX_SLICES_NUM is fixed lenght in relevent pData structure
848860 uiThrdRet = 1;
849− break;
861+ WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
862+ pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
863+ iEventIdx);
850864 }
851865
852866 pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
@@ -873,7 +887,9 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 20 unmodified lines
873887 iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType);
874888 if (ENC_RETURN_SUCCESS != iReturn) {
875889 uiThrdRet = iReturn;
876− break;
890+ WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
891+ pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
892+ iEventIdx);
877893 }
878894
879895 WelsUnloadNalForSlice (pSliceBs);
@@ -885,14 +901,18 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 5 unmodified lines
885901 iSliceSize);
886902 if (ENC_RETURN_SUCCESS != iReturn) {
887903 uiThrdRet = iReturn;
888− break;
904+ WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
905+ pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
906+ iEventIdx);
889907 }
890908 pEncPEncCtx->iPosBsBuffer += iSliceSize;
891909 } else {
892− iSliceSize = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize);
910+ iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize);
893911 if (ENC_RETURN_SUCCESS != iReturn) {
894912 uiThrdRet = iReturn;
895− break;
913+ WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
914+ pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
915+ iEventIdx);
896916 }
897917 }
898918
@@ -926,7 +946,11 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 27 unmodified lines
926946 }
927947
928948 if (uiThrdRet) // any exception??
929− break;
949+ {
950+ WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
951+ pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
952+ iEventIdx);
953+ }
930954
931955 WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
932956 WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent);

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