Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 7 files). Show all
Unified · Split
| @@ -3975,7 +3975,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 3974 unmodified lines | |||
| 3975 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | 3975 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3976 | } else { | 3976 | } else { |
| 3977 | //other multi-slice uiSliceMode | 3977 | //other multi-slice uiSliceMode |
| 3978 | int32_t iRet = 0; | ||
| 3979 | // THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_SIZELIMITED_SLICE | 3978 | // THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_SIZELIMITED_SLICE |
| 3980 | if ((SM_SIZELIMITED_SLICE != pParam->sSliceArgument.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { | 3979 | if ((SM_SIZELIMITED_SLICE != pParam->sSliceArgument.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { |
| 3981 | iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer); | 3980 | iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer); |
| @@ -4000,18 +3999,21 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 18 unmodified lines | |||
| 4000 | pLayerBsInfo->iNalCount = 0; | 3999 | pLayerBsInfo->iNalCount = 0; |
| 4001 | 4000 | ||
| 4002 | pCtx->pTaskManage->ExecuteTasks(); | 4001 | pCtx->pTaskManage->ExecuteTasks(); |
| 4003 | iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, iSliceCount); | ||
| 4004 | if (pCtx->iEncoderError) { | 4002 | if (pCtx->iEncoderError) { |
| 4005 | WelsLog (pLogCtx, WELS_LOG_ERROR, | 4003 | WelsLog (pLogCtx, WELS_LOG_ERROR, |
| 4006 | "WelsEncoderEncodeExt(), multi-slice (mode %d) encoding error!", | 4004 | "WelsEncoderEncodeExt(), multi-slice (mode %d) encoding error!", |
| 4007 | pParam->sSliceArgument.uiSliceMode); | 4005 | pParam->sSliceArgument.uiSliceMode); |
| 4008 | return pCtx->iEncoderError; | 4006 | return pCtx->iEncoderError; |
| 4009 | } | 4007 | } |
| 4008 | |||
| 4009 | iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, iSliceCount); | ||
| 4010 | } | 4010 | } |
| 4011 | // THREAD_FULLY_FIRE_MODE && SM_SIZELIMITED_SLICE | 4011 | // THREAD_FULLY_FIRE_MODE && SM_SIZELIMITED_SLICE |
| 4012 | else if ((SM_SIZELIMITED_SLICE == pParam->sSliceArgument.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { | 4012 | else if ((SM_SIZELIMITED_SLICE == pParam->sSliceArgument.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { |
| 4013 | const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum; //pSvcParam->iCountThreadsNum; | 4013 | const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum; //pSvcParam->iCountThreadsNum; |
| 4014 | 4014 | ||
| 4015 | #if 0 //TODO: temporarily use this to keep old codes for a while, will remove old codes later | ||
| 4016 | int32_t iRet = 0; | ||
| 4015 | // to fire slice coding threads | 4017 | // to fire slice coding threads |
| 4016 | iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], | 4018 | iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], |
| 4017 | &pCtx->pSliceThreading->pReadySliceCodingEvent[0], | 4019 | &pCtx->pSliceThreading->pReadySliceCodingEvent[0], |
| @@ -4027,6 +4029,41 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 9 unmodified lines | |||
| 4027 | WelsMultipleEventsWaitAllBlocking (kiPartitionCnt, &pCtx->pSliceThreading->pSliceCodedEvent[0], | 4029 | WelsMultipleEventsWaitAllBlocking (kiPartitionCnt, &pCtx->pSliceThreading->pSliceCodedEvent[0], |
| 4028 | &pCtx->pSliceThreading->pSliceCodedMasterEvent); | 4030 | &pCtx->pSliceThreading->pSliceCodedMasterEvent); |
| 4029 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | 4031 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 4032 | #else | ||
| 4033 | int32_t iEndMbIdx = pCtx->pCurDqLayer->sSliceEncCtx.iMbNumInFrame; | ||
| 4034 | for (int32_t iIdx = kiPartitionCnt - 1; iIdx >= 0; --iIdx) { | ||
| 4035 | const int32_t iFirstMbIdx = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iIdx].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; | ||
| 4036 | pCtx->pSliceThreading->pThreadPEncCtx[iIdx].iStartMbIndex = iFirstMbIdx; | ||
| 4037 | pCtx->pSliceThreading->pThreadPEncCtx[iIdx].iEndMbIndex = iEndMbIdx; | ||
| 4038 | iEndMbIdx = iFirstMbIdx; | ||
| 4039 | } | ||
| 4040 | |||
| 4041 | //TODO: use a function to remove duplicate code here and ln3994 | ||
| 4042 | int32_t iLayerBsIdx = pCtx->pOut->iLayerBsIndex; | ||
| 4043 | SLayerBSInfo* pLbi = &pFbi->sLayerInfo[iLayerBsIdx]; | ||
| 4044 | pLbi->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | ||
| 4045 | pLbi->uiLayerType = VIDEO_CODING_LAYER; | ||
| 4046 | pLbi->uiSpatialId = pCtx->uiDependencyId; | ||
| 4047 | pLbi->uiTemporalId = pCtx->uiTemporalId; | ||
| 4048 | pLbi->uiQualityId = 0; | ||
| 4049 | pLbi->iNalCount = 0; | ||
| 4050 | |||
| 4051 | int32_t iIdx = 0; | ||
| 4052 | while (iIdx < kiPartitionCnt) { | ||
| 4053 | pCtx->pSliceThreading->pThreadPEncCtx[iIdx].pFrameBsInfo = pFbi; | ||
| 4054 | pCtx->pSliceThreading->pThreadPEncCtx[iIdx].iSliceIndex = iIdx; | ||
| 4055 | SetOneSliceBsBufferUnderMultithread (pCtx, iIdx, iIdx); | ||
| 4056 | ++ iIdx; | ||
| 4057 | } | ||
| 4058 | pCtx->pTaskManage->ExecuteTasks(); | ||
| 4059 | |||
| 4060 | if (pCtx->iEncoderError) { | ||
| 4061 | WelsLog (pLogCtx, WELS_LOG_ERROR, | ||
| 4062 | "WelsEncoderEncodeExt(), multi-slice (mode %d) encoding error = %d!", | ||
| 4063 | pParam->sSliceArgument.uiSliceMode, pCtx->iEncoderError); | ||
| 4064 | return pCtx->iEncoderError; | ||
| 4065 | } | ||
| 4066 | #endif | ||
| 4030 | 4067 | ||
| 4031 | iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt); | 4068 | iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt); |
| 4032 | } else { // for non-dynamic-slicing mode single threading branch.. | 4069 | } else { // for non-dynamic-slicing mode single threading branch.. |