History

Add tasks and thread pool call for SM_SIZELIMITED_SLICE mode

sijchen committed 10 years ago

Commit 76ca5641 parent 76b428a7 files · +165 −21Browse files

Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 7 files). Show all

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+39−2
@@ -3975,7 +3975,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 3974 unmodified lines
39753975 WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
39763976 } else {
39773977 //other multi-slice uiSliceMode
3978− int32_t iRet = 0;
39793978 // THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_SIZELIMITED_SLICE
39803979 if ((SM_SIZELIMITED_SLICE != pParam->sSliceArgument.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) {
39813980 iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer);
@@ -4000,18 +3999,21 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 18 unmodified lines
40003999 pLayerBsInfo->iNalCount = 0;
40014000
40024001 pCtx->pTaskManage->ExecuteTasks();
4003− iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, iSliceCount);
40044002 if (pCtx->iEncoderError) {
40054003 WelsLog (pLogCtx, WELS_LOG_ERROR,
40064004 "WelsEncoderEncodeExt(), multi-slice (mode %d) encoding error!",
40074005 pParam->sSliceArgument.uiSliceMode);
40084006 return pCtx->iEncoderError;
40094007 }
4008+
4009+ iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, iSliceCount);
40104010 }
40114011 // THREAD_FULLY_FIRE_MODE && SM_SIZELIMITED_SLICE
40124012 else if ((SM_SIZELIMITED_SLICE == pParam->sSliceArgument.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) {
40134013 const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum; //pSvcParam->iCountThreadsNum;
40144014
4015+#if 0 //TODO: temporarily use this to keep old codes for a while, will remove old codes later
4016+ int32_t iRet = 0;
40154017 // to fire slice coding threads
40164018 iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0],
40174019 &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
@@ -4027,6 +4029,41 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 9 unmodified lines
40274029 WelsMultipleEventsWaitAllBlocking (kiPartitionCnt, &pCtx->pSliceThreading->pSliceCodedEvent[0],
40284030 &pCtx->pSliceThreading->pSliceCodedMasterEvent);
40294031 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
40304067
40314068 iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt);
40324069 } else { // for non-dynamic-slicing mode single threading branch..

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