Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 16 files). Show all
Unified · Split
| @@ -347,6 +347,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 346 unmodified lines | |||
| 347 | int32_t iIdx = 0; | 347 | int32_t iIdx = 0; |
| 348 | int32_t iSliceBsBufferSize = 0; | 348 | int32_t iSliceBsBufferSize = 0; |
| 349 | int16_t iMaxSliceNum = 1; | 349 | int16_t iMaxSliceNum = 1; |
| 350 | int32_t iReturn = ENC_RETURN_SUCCESS; | ||
| 350 | 351 | ||
| 351 | if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0) | 352 | if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0) |
| 352 | return 1; | 353 | return 1; |
| @@ -492,8 +493,6 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 139 unmodified lines | |||
| 492 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pCountBsSizeInPartition), FreeMemorySvc (ppCtx)) | 493 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pCountBsSizeInPartition), FreeMemorySvc (ppCtx)) |
| 493 | #endif//PACKING_ONE_SLICE_PER_LAYER | 494 | #endif//PACKING_ONE_SLICE_PER_LAYER |
| 494 | 495 | ||
| 495 | WelsMutexInit (&pSmt->mutexSliceNumUpdate); | ||
| 496 | |||
| 497 | (*ppCtx)->pSliceBs = (SWelsSliceBs*)pMa->WelsMalloc (sizeof (SWelsSliceBs) * iMaxSliceNum, "pSliceBs"); | 496 | (*ppCtx)->pSliceBs = (SWelsSliceBs*)pMa->WelsMalloc (sizeof (SWelsSliceBs) * iMaxSliceNum, "pSliceBs"); |
| 498 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSliceBs), FreeMemorySvc (ppCtx)) | 497 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSliceBs), FreeMemorySvc (ppCtx)) |
| 499 | 498 | ||
| @@ -502,7 +501,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 2 unmodified lines | |||
| 502 | iSliceBsBufferSize = iTargetSpatialBsSize; | 501 | iSliceBsBufferSize = iTargetSpatialBsSize; |
| 503 | iIdx = 0; | 502 | iIdx = 0; |
| 504 | while (iIdx < iMaxSliceNum) { | 503 | while (iIdx < iMaxSliceNum) { |
| 505 | pSliceB->pBsBuffer = (uint8_t*)pMa->WelsMalloc (iSliceBsBufferSize, "pSliceB->pBsBuffer"); | 504 | pSliceB->pBsBuffer = (uint8_t*)pMa->WelsMalloc (iSliceBsBufferSize, "pSliceB->pBsBuffer"); |
| 506 | 505 | ||
| 507 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSliceB->pBsBuffer), FreeMemorySvc (ppCtx)) | 506 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSliceB->pBsBuffer), FreeMemorySvc (ppCtx)) |
| 508 | pSliceB->uiSize = iSliceBsBufferSize; | 507 | pSliceB->uiSize = iSliceBsBufferSize; |
| @@ -519,6 +518,12 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 10 unmodified lines | |||
| 519 | ++ iIdx; | 518 | ++ iIdx; |
| 520 | } | 519 | } |
| 521 | 520 | ||
| 521 | iReturn = WelsMutexInit (&pSmt->mutexSliceNumUpdate); | ||
| 522 | WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx)) | ||
| 523 | |||
| 524 | iReturn = WelsMutexInit (&(*ppCtx)->mutexEncoderError); | ||
| 525 | WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx)) | ||
| 526 | |||
| 522 | #if defined(ENABLE_TRACE_MT) | 527 | #if defined(ENABLE_TRACE_MT) |
| 523 | WelsLog ((*ppCtx), WELS_LOG_INFO, "RequestMtResource(), iThreadNum=%d, iCountSliceNum= %d\n", pPara->iCountThreadsNum, | 528 | WelsLog ((*ppCtx), WELS_LOG_INFO, "RequestMtResource(), iThreadNum=%d, iCountSliceNum= %d\n", pPara->iCountThreadsNum, |
| 524 | iMaxSliceNum); | 529 | iMaxSliceNum); |
| @@ -610,7 +615,9 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 85 unmodified lines | |||
| 610 | pSmt->pCountBsSizeInPartition = NULL; | 615 | pSmt->pCountBsSizeInPartition = NULL; |
| 611 | } | 616 | } |
| 612 | #endif//PACKING_ONE_SLICE_PER_LAYER | 617 | #endif//PACKING_ONE_SLICE_PER_LAYER |
| 618 | |||
| 613 | WelsMutexDestroy (&pSmt->mutexSliceNumUpdate); | 619 | WelsMutexDestroy (&pSmt->mutexSliceNumUpdate); |
| 620 | WelsMutexDestroy (&((*ppCtx)->mutexEncoderError)); | ||
| 614 | 621 | ||
| 615 | if (pSmt->pThreadPEncCtx != NULL) { | 622 | if (pSmt->pThreadPEncCtx != NULL) { |
| 616 | pMa->WelsFree (pSmt->pThreadPEncCtx, "pThreadPEncCtx"); | 623 | pMa->WelsFree (pSmt->pThreadPEncCtx, "pThreadPEncCtx"); |
| @@ -766,25 +773,32 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 149 unmodified lines | |||
| 766 | return iLayerSize; | 773 | return iLayerSize; |
| 767 | } | 774 | } |
| 768 | 775 | ||
| 769 | int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFrameBsBuffer, const int32_t iSliceIdx) { | 776 | int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFrameBsBuffer, const int32_t iSliceIdx, int32_t& iSliceSize) { |
| 770 | SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; | 777 | SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; |
| 771 | SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; | 778 | SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; |
| 772 | uint8_t* pDst = pFrameBsBuffer; | 779 | uint8_t* pDst = pFrameBsBuffer; |
| 773 | int32_t pNalLen[2]; | 780 | int32_t pNalLen[2]; |
| 774 | int32_t iSliceSize = 0; | ||
| 775 | const int32_t kiNalCnt = pSliceBs->iNalIndex; | 781 | const int32_t kiNalCnt = pSliceBs->iNalIndex; |
| 776 | int32_t iNalIdx = 0; | 782 | int32_t iNalIdx = 0; |
| 783 | int32_t iNalSize = 0; | ||
| 777 | #if !defined(PACKING_ONE_SLICE_PER_LAYER) | 784 | #if !defined(PACKING_ONE_SLICE_PER_LAYER) |
| 778 | const int32_t iFirstSlice = (iSliceIdx == 0); | 785 | const int32_t iFirstSlice = (iSliceIdx == 0); |
| 779 | int32_t iNalBase = iFirstSlice ? 0 : pLbi->iNalCount; | 786 | int32_t iNalBase = iFirstSlice ? 0 : pLbi->iNalCount; |
| 780 | #else | 787 | #else |
| 781 | int32_t iNalBase = 0; | 788 | int32_t iNalBase = 0; |
| 782 | #endif//!PACKING_ONE_SLICE_PER_LAYER | 789 | #endif//!PACKING_ONE_SLICE_PER_LAYER |
| 790 | int32_t iReturn = ENC_RETURN_SUCCESS; | ||
| 791 | const int32_t kiWrittenLength = pCtx->iPosBsBuffer; | ||
| 792 | iSliceSize = 0; | ||
| 783 | 793 | ||
| 784 | while (iNalIdx < kiNalCnt) { | 794 | while (iNalIdx < kiNalCnt) { |
| 785 | iSliceSize += WelsEncodeNalExt (&pSliceBs->sNalList[iNalIdx], pNalHdrExt, pDst, &pNalLen[iNalIdx]); | 795 | iNalSize = 0; |
| 786 | pDst += pNalLen[iNalIdx]; | 796 | iReturn = WelsEncodeNal (&pSliceBs->sNalList[iNalIdx], pNalHdrExt, pCtx->iFrameBsSize-kiWrittenLength-iSliceSize, pDst, &iNalSize); |
| 787 | pLbi->iNalLengthInByte[iNalBase + iNalIdx] = pNalLen[iNalIdx]; | 797 | WELS_VERIFY_RETURN_IFNEQ(iReturn, ENC_RETURN_SUCCESS) |
| 798 | pNalLen[iNalIdx] = iNalSize; | ||
| 799 | iSliceSize += iNalSize; | ||
| 800 | pDst += iNalSize; | ||
| 801 | pLbi->iNalLengthInByte[iNalBase + iNalIdx] = iNalSize; | ||
| 788 | 802 | ||
| 789 | ++ iNalIdx; | 803 | ++ iNalIdx; |
| 790 | } | 804 | } |
| @@ -811,31 +825,37 @@ int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFr · 20 unmodified lines | |||
| 811 | pLbi->iNalCount = kiNalCnt; | 825 | pLbi->iNalCount = kiNalCnt; |
| 812 | #endif//PACKING_ONE_SLICE_PER_LAYER | 826 | #endif//PACKING_ONE_SLICE_PER_LAYER |
| 813 | 827 | ||
| 814 | return iSliceSize; | 828 | return ENC_RETURN_SUCCESS; |
| 815 | } | 829 | } |
| 816 | 830 | ||
| 817 | int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSliceIdx) { | 831 | int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSliceIdx, int32_t& iSliceSize) { |
| 818 | SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; | 832 | SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; |
| 819 | SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; | 833 | SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; |
| 820 | uint8_t* pDst = pSliceBsBuf; | 834 | uint8_t* pDst = pSliceBsBuf; |
| 821 | int32_t* pNalLen = &pSliceBs->iNalLen[0]; | 835 | int32_t* pNalLen = &pSliceBs->iNalLen[0]; |
| 822 | int32_t iSliceSize = 0; | ||
| 823 | const int32_t kiNalCnt = pSliceBs->iNalIndex; | 836 | const int32_t kiNalCnt = pSliceBs->iNalIndex; |
| 824 | int32_t iNalIdx = 0; | 837 | int32_t iNalIdx = 0; |
| 838 | int32_t iNalSize = 0; | ||
| 839 | int32_t iReturn = ENC_RETURN_SUCCESS; | ||
| 840 | const int32_t kiWrittenLength = pSliceBs->sBsWrite.pBufPtr - pSliceBs->sBsWrite.pBuf; | ||
| 825 | 841 | ||
| 842 | iSliceSize = 0; | ||
| 826 | assert (kiNalCnt <= 2); | 843 | assert (kiNalCnt <= 2); |
| 827 | if (kiNalCnt > 2) | 844 | if (kiNalCnt > 2) |
| 828 | return 0; | 845 | return 0; |
| 829 | 846 | ||
| 830 | while (iNalIdx < kiNalCnt) { | 847 | while (iNalIdx < kiNalCnt) { |
| 831 | iSliceSize += WelsEncodeNalExt (&pSliceBs->sNalList[iNalIdx], pNalHdrExt, pDst, &pNalLen[iNalIdx]); | 848 | iNalSize = 0; |
| 832 | pDst += pNalLen[iNalIdx]; | 849 | iReturn = WelsEncodeNal (&pSliceBs->sNalList[iNalIdx], pNalHdrExt, pSliceBs->uiSize-kiWrittenLength-iSliceSize, pDst, &iNalSize); |
| 833 | 850 | WELS_VERIFY_RETURN_IFNEQ(iReturn, ENC_RETURN_SUCCESS) | |
| 851 | pNalLen[iNalIdx] = iNalSize; | ||
| 852 | iSliceSize += iNalSize; | ||
| 853 | pDst += iNalSize; | ||
| 834 | ++ iNalIdx; | 854 | ++ iNalIdx; |
| 835 | } | 855 | } |
| 836 | pSliceBs->uiBsPos = iSliceSize; | 856 | pSliceBs->uiBsPos = iSliceSize; |
| 837 | 857 | ||
| 838 | return iSliceSize; | 858 | return iReturn; |
| 839 | } | 859 | } |
| 840 | 860 | ||
| 841 | #if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) | 861 | #if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) |
| @@ -901,6 +921,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 59 unmodified lines | |||
| 901 | bool bNeedPrefix = false; | 921 | bool bNeedPrefix = false; |
| 902 | EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; | 922 | EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; |
| 903 | EWelsNalRefIdc eNalRefIdc = NRI_PRI_LOWEST; | 923 | EWelsNalRefIdc eNalRefIdc = NRI_PRI_LOWEST; |
| 924 | int32_t iReturn = ENC_RETURN_SUCCESS; | ||
| 904 | 925 | ||
| 905 | if (NULL == pPrivateData) | 926 | if (NULL == pPrivateData) |
| 906 | WELS_THREAD_ROUTINE_RETURN (1); | 927 | WELS_THREAD_ROUTINE_RETURN (1); |
| @@ -985,25 +1006,47 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 78 unmodified lines | |||
| 985 | 1006 | ||
| 986 | WelsLoadNalForSlice (pSliceBs, eNalType, eNalRefIdc); | 1007 | WelsLoadNalForSlice (pSliceBs, eNalType, eNalRefIdc); |
| 987 | 1008 | ||
| 988 | WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType); | 1009 | iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType); |
| 1010 | if (ENC_RETURN_SUCCESS!=iReturn) { | ||
| 1011 | uiThrdRet = iReturn; | ||
| 1012 | break; | ||
| 1013 | } | ||
| 989 | 1014 | ||
| 990 | WelsUnloadNalForSlice (pSliceBs); | 1015 | WelsUnloadNalForSlice (pSliceBs); |
| 991 | 1016 | ||
| 992 | #if !defined(PACKING_ONE_SLICE_PER_LAYER) | 1017 | #if !defined(PACKING_ONE_SLICE_PER_LAYER) |
| 993 | if (0 == iSliceIdx) { | 1018 | if (0 == iSliceIdx) { |
| 994 | pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer; | 1019 | pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer; |
| 995 | iSliceSize = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx); | 1020 | iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx, iSliceSize); |
| 1021 | if (ENC_RETURN_SUCCESS!=iReturn) { | ||
| 1022 | uiThrdRet = iReturn; | ||
| 1023 | break; | ||
| 1024 | } | ||
| 996 | pEncPEncCtx->iPosBsBuffer += iSliceSize; | 1025 | pEncPEncCtx->iPosBsBuffer += iSliceSize; |
| 997 | } else | 1026 | } else |
| 998 | iSliceSize = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx); | 1027 | { |
| 1028 | iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize); | ||
| 1029 | if (ENC_RETURN_SUCCESS!=iReturn) { | ||
| 1030 | uiThrdRet = iReturn; | ||
| 1031 | break; | ||
| 1032 | } | ||
| 1033 | } | ||
| 999 | #else// PACKING_ONE_SLICE_PER_LAYER | 1034 | #else// PACKING_ONE_SLICE_PER_LAYER |
| 1000 | if (0 == iSliceIdx) { | 1035 | if (0 == iSliceIdx) { |
| 1001 | pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer; | 1036 | pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer; |
| 1002 | iSliceSize = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx); | 1037 | iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx, &iSliceSize); |
| 1038 | if (ENC_RETURN_SUCCESS!=iReturn) { | ||
| 1039 | uiThrdRet = iReturn; | ||
| 1040 | break; | ||
| 1041 | } | ||
| 1003 | pEncPEncCtx->iPosBsBuffer += iSliceSize; | 1042 | pEncPEncCtx->iPosBsBuffer += iSliceSize; |
| 1004 | } else { | 1043 | } else { |
| 1005 | pLbi->pBsBuf = pSliceBs->bs + pSliceBs->uiBsPos; | 1044 | pLbi->pBsBuf = pSliceBs->bs + pSliceBs->uiBsPos; |
| 1006 | iSliceSize = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx); | 1045 | iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx, &iSliceSize); |
| 1046 | if (ENC_RETURN_SUCCESS!=iReturn) { | ||
| 1047 | uiThrdRet = iReturn; | ||
| 1048 | break; | ||
| 1049 | } | ||
| 1007 | pSliceBs->uiBsPos += iSliceSize; | 1050 | pSliceBs->uiBsPos += iSliceSize; |
| 1008 | } | 1051 | } |
| 1009 | #endif//!PACKING_ONE_SLICE_PER_LAYER | 1052 | #endif//!PACKING_ONE_SLICE_PER_LAYER |
| @@ -1101,7 +1144,11 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 91 unmodified lines | |||
| 1101 | 1144 | ||
| 1102 | WelsLoadNalForSlice (pSliceBs, eNalType, eNalRefIdc); | 1145 | WelsLoadNalForSlice (pSliceBs, eNalType, eNalRefIdc); |
| 1103 | 1146 | ||
| 1104 | WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType); | 1147 | iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType); |
| 1148 | if (ENC_RETURN_SUCCESS!=iReturn) { | ||
| 1149 | uiThrdRet = iReturn; | ||
| 1150 | break; | ||
| 1151 | } | ||
| 1105 | 1152 | ||
| 1106 | WelsUnloadNalForSlice (pSliceBs); | 1153 | WelsUnloadNalForSlice (pSliceBs); |
| 1107 | 1154 | ||
| @@ -1109,20 +1156,38 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 1 unmodified line | |||
| 1109 | if (0 == kiPartitionId) { | 1156 | if (0 == kiPartitionId) { |
| 1110 | if (0 == iSliceIdx) | 1157 | if (0 == iSliceIdx) |
| 1111 | pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer; | 1158 | pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer; |
| 1112 | iSliceSize = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer, iSliceIdx); | 1159 | iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer, iSliceIdx, iSliceSize); |
| 1160 | if (ENC_RETURN_SUCCESS!=iReturn) { | ||
| 1161 | uiThrdRet = iReturn; | ||
| 1162 | break; | ||
| 1163 | } | ||
| 1113 | pEncPEncCtx->iPosBsBuffer += iSliceSize; | 1164 | pEncPEncCtx->iPosBsBuffer += iSliceSize; |
| 1114 | } else | 1165 | } else |
| 1115 | iSliceSize = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx); | 1166 | { |
| 1167 | iSliceSize = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize); | ||
| 1168 | if (ENC_RETURN_SUCCESS!=iReturn) { | ||
| 1169 | uiThrdRet = iReturn; | ||
| 1170 | break; | ||
| 1171 | } | ||
| 1172 | } | ||
| 1116 | #else// PACKING_ONE_SLICE_PER_LAYER | 1173 | #else// PACKING_ONE_SLICE_PER_LAYER |
| 1117 | pLbiPacking = pLbi + (iSliceIdx - kiPartitionId); | 1174 | pLbiPacking = pLbi + (iSliceIdx - kiPartitionId); |
| 1118 | 1175 | ||
| 1119 | if (0 == kiPartitionId) { | 1176 | if (0 == kiPartitionId) { |
| 1120 | pLbiPacking->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer; | 1177 | pLbiPacking->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer; |
| 1121 | iSliceSize = WriteSliceToFrameBs (pEncPEncCtx, pLbiPacking, pLbiPacking->pBsBuf, iSliceIdx); | 1178 | iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbiPacking, pLbiPacking->pBsBuf, iSliceIdx, iSliceSize); |
| 1179 | if (ENC_RETURN_SUCCESS!=iReturn) { | ||
| 1180 | uiThrdRet = iReturn; | ||
| 1181 | break; | ||
| 1182 | } | ||
| 1122 | pEncPEncCtx->iPosBsBuffer += iSliceSize; | 1183 | pEncPEncCtx->iPosBsBuffer += iSliceSize; |
| 1123 | } else { | 1184 | } else { |
| 1124 | pLbiPacking->pBsBuf = pSliceBs->bs + pSliceBs->uiBsPos; | 1185 | pLbiPacking->pBsBuf = pSliceBs->bs + pSliceBs->uiBsPos; |
| 1125 | iSliceSize = WriteSliceToFrameBs (pEncPEncCtx, pLbiPacking, pLbiPacking->pBsBuf, iSliceIdx); | 1186 | iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbiPacking, pLbiPacking->pBsBuf, iSliceIdx, iSliceSize); |
| 1187 | if (ENC_RETURN_SUCCESS!=iReturn) { | ||
| 1188 | uiThrdRet = iReturn; | ||
| 1189 | break; | ||
| 1190 | } | ||
| 1126 | pSliceBs->uiBsPos += iSliceSize; | 1191 | pSliceBs->uiBsPos += iSliceSize; |
| 1127 | } | 1192 | } |
| 1128 | pEncPEncCtx->pSliceThreading->pCountBsSizeInPartition[kiPartitionId] += iSliceSize; | 1193 | pEncPEncCtx->pSliceThreading->pCountBsSizeInPartition[kiPartitionId] += iSliceSize; |
| @@ -1197,6 +1262,11 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 68 unmodified lines | |||
| 1197 | WelsEventSignal (&pEncPEncCtx->pSliceThreading->pFinSliceCodingEvent[iEventIdx]); // notify to mother encoding threading | 1262 | WelsEventSignal (&pEncPEncCtx->pSliceThreading->pFinSliceCodingEvent[iEventIdx]); // notify to mother encoding threading |
| 1198 | #endif//WIN32 | 1263 | #endif//WIN32 |
| 1199 | 1264 | ||
| 1265 | //sync multi-threading error | ||
| 1266 | WelsMutexLock (&pEncPEncCtx->mutexEncoderError); | ||
| 1267 | if (uiThrdRet) pEncPEncCtx->iEncoderError |= uiThrdRet; | ||
| 1268 | WelsMutexUnlock (&pEncPEncCtx->mutexEncoderError); | ||
| 1269 | |||
| 1200 | WELS_THREAD_ROUTINE_RETURN (uiThrdRet); | 1270 | WELS_THREAD_ROUTINE_RETURN (uiThrdRet); |
| 1201 | } | 1271 | } |
| 1202 | 1272 | ||
| @@ -1235,6 +1305,7 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { · 32 unmodified lines | |||
| 1235 | &pCtx->pSliceThreading->pThreadPEncCtx[iIdx], 0); | 1305 | &pCtx->pSliceThreading->pThreadPEncCtx[iIdx], 0); |
| 1236 | #endif//__GNUC__ | 1306 | #endif//__GNUC__ |
| 1237 | #endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) | 1307 | #endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) |
| 1308 | |||
| 1238 | ++ iIdx; | 1309 | ++ iIdx; |
| 1239 | } | 1310 | } |
| 1240 | #if defined(ENABLE_TRACE_MT) | 1311 | #if defined(ENABLE_TRACE_MT) |