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
69#define MT_TRACE_LOG(x, ...)69#define MT_TRACE_LOG(x, ...)
70#endif70#endif
71 71
72#define WELS_THREAD_SIGNAL_AND_BREAK(CodedEventList, CodedMasterEvent, iEventIdx) { \
73 WelsEventSignal(&CodedEventList[iEventIdx]); \
74 WelsEventSignal (&CodedMasterEvent); \
75 break; \
76}
77
72namespace WelsEnc {78namespace WelsEnc {
73void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx,79void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx,
74 SMB* pMbList,80 SMB* pMbList,
@@ -766,7 +772,9 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 691 unmodified lines
766 iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType);772 iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType);
767 if (ENC_RETURN_SUCCESS != iReturn) {773 if (ENC_RETURN_SUCCESS != iReturn) {
768 uiThrdRet = iReturn;774 uiThrdRet = iReturn;
769 break;775 WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
776 pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
777 iEventIdx);
770 }778 }
771 779
772 WelsUnloadNalForSlice (pSliceBs);780 WelsUnloadNalForSlice (pSliceBs);
@@ -776,14 +784,18 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 3 unmodified lines
776 iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx, iSliceSize);784 iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx, iSliceSize);
777 if (ENC_RETURN_SUCCESS != iReturn) {785 if (ENC_RETURN_SUCCESS != iReturn) {
778 uiThrdRet = iReturn;786 uiThrdRet = iReturn;
779 break;787 WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
788 pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
789 iEventIdx);
780 }790 }
781 pEncPEncCtx->iPosBsBuffer += iSliceSize;791 pEncPEncCtx->iPosBsBuffer += iSliceSize;
782 } else {792 } else {
783 iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize);793 iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize);
784 if (ENC_RETURN_SUCCESS != iReturn) {794 if (ENC_RETURN_SUCCESS != iReturn) {
785 uiThrdRet = iReturn;795 uiThrdRet = iReturn;
786 break;796 WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
797 pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
798 iEventIdx);
787 }799 }
788 }800 }
789 801
@@ -846,7 +858,9 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 56 unmodified lines
846 // TODO: need exception handler for not large enough of MAX_SLICES_NUM related memory usage858 // TODO: need exception handler for not large enough of MAX_SLICES_NUM related memory usage
847 // No idea about its solution due MAX_SLICES_NUM is fixed lenght in relevent pData structure859 // No idea about its solution due MAX_SLICES_NUM is fixed lenght in relevent pData structure
848 uiThrdRet = 1;860 uiThrdRet = 1;
849 break;861 WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
862 pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
863 iEventIdx);
850 }864 }
851 865
852 pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];866 pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
@@ -873,7 +887,9 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 20 unmodified lines
873 iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType);887 iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType);
874 if (ENC_RETURN_SUCCESS != iReturn) {888 if (ENC_RETURN_SUCCESS != iReturn) {
875 uiThrdRet = iReturn;889 uiThrdRet = iReturn;
876 break;890 WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
891 pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
892 iEventIdx);
877 }893 }
878 894
879 WelsUnloadNalForSlice (pSliceBs);895 WelsUnloadNalForSlice (pSliceBs);
@@ -885,14 +901,18 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 5 unmodified lines
885 iSliceSize);901 iSliceSize);
886 if (ENC_RETURN_SUCCESS != iReturn) {902 if (ENC_RETURN_SUCCESS != iReturn) {
887 uiThrdRet = iReturn;903 uiThrdRet = iReturn;
888 break;904 WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
905 pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
906 iEventIdx);
889 }907 }
890 pEncPEncCtx->iPosBsBuffer += iSliceSize;908 pEncPEncCtx->iPosBsBuffer += iSliceSize;
891 } else {909 } else {
892 iSliceSize = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize);910 iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize);
893 if (ENC_RETURN_SUCCESS != iReturn) {911 if (ENC_RETURN_SUCCESS != iReturn) {
894 uiThrdRet = iReturn;912 uiThrdRet = iReturn;
895 break;913 WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
914 pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
915 iEventIdx);
896 }916 }
897 }917 }
898 918
@@ -926,7 +946,11 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 27 unmodified lines
926 }946 }
927 947
928 if (uiThrdRet) // any exception??948 if (uiThrdRet) // any exception??
929 break;949 {
950 WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
951 pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
952 iEventIdx);
953 }
930 954
931 WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice955 WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
932 WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent);956 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