Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 2 files). Show all
Unified · Split
| @@ -69,6 +69,12 @@ · 68 unmodified lines | ||
| 69 | 69 | #define MT_TRACE_LOG(x, ...) |
| 70 | 70 | #endif |
| 71 | 71 | |
| 72 | +#define WELS_THREAD_SIGNAL_AND_BREAK(CodedEventList, CodedMasterEvent, iEventIdx) { \ | |
| 73 | + WelsEventSignal(&CodedEventList[iEventIdx]); \ | |
| 74 | + WelsEventSignal (&CodedMasterEvent); \ | |
| 75 | + break; \ | |
| 76 | +} | |
| 77 | + | |
| 72 | 78 | namespace WelsEnc { |
| 73 | 79 | void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx, |
| 74 | 80 | SMB* pMbList, |
| @@ -766,7 +772,9 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 691 unmodified lines | ||
| 766 | 772 | iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType); |
| 767 | 773 | if (ENC_RETURN_SUCCESS != iReturn) { |
| 768 | 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 | 780 | WelsUnloadNalForSlice (pSliceBs); |
| @@ -776,14 +784,18 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 3 unmodified lines | ||
| 776 | 784 | iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx, iSliceSize); |
| 777 | 785 | if (ENC_RETURN_SUCCESS != iReturn) { |
| 778 | 786 | uiThrdRet = iReturn; |
| 779 | − break; | |
| 787 | + WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent, | |
| 788 | + pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent, | |
| 789 | + iEventIdx); | |
| 780 | 790 | } |
| 781 | 791 | pEncPEncCtx->iPosBsBuffer += iSliceSize; |
| 782 | 792 | } else { |
| 783 | 793 | iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize); |
| 784 | 794 | if (ENC_RETURN_SUCCESS != iReturn) { |
| 785 | 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 | 858 | // TODO: need exception handler for not large enough of MAX_SLICES_NUM related memory usage |
| 847 | 859 | // No idea about its solution due MAX_SLICES_NUM is fixed lenght in relevent pData structure |
| 848 | 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 | 866 | pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx]; |
| @@ -873,7 +887,9 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 20 unmodified lines | ||
| 873 | 887 | iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType); |
| 874 | 888 | if (ENC_RETURN_SUCCESS != iReturn) { |
| 875 | 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 | 895 | WelsUnloadNalForSlice (pSliceBs); |
| @@ -885,14 +901,18 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 5 unmodified lines | ||
| 885 | 901 | iSliceSize); |
| 886 | 902 | if (ENC_RETURN_SUCCESS != iReturn) { |
| 887 | 903 | uiThrdRet = iReturn; |
| 888 | − break; | |
| 904 | + WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent, | |
| 905 | + pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent, | |
| 906 | + iEventIdx); | |
| 889 | 907 | } |
| 890 | 908 | pEncPEncCtx->iPosBsBuffer += iSliceSize; |
| 891 | 909 | } else { |
| 892 | − iSliceSize = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize); | |
| 910 | + iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize); | |
| 893 | 911 | if (ENC_RETURN_SUCCESS != iReturn) { |
| 894 | 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 | 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 | 955 | WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice |
| 932 | 956 | WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent); |