History

Merge pull request #2207 from sijchen/thp53

[Encoder] remove unneeded codes and add some logs (basing on PR2206)

sijchen committed 11 years ago

Commit 597adfd2 parents b0c6ea9 3d388467 files · +29 −112Browse 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+12−102
@@ -4007,6 +4007,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 4006 unmodified lines
40074007 int32_t iRet = 0;
40084008 // THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_DYN_SLICE
40094009 if ((SM_DYN_SLICE != pParam->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) {
4010+
40104011 iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx);
40114012 if (iLayerNum + 1 >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info for further writing as followed
40124013 WelsLog (pLogCtx, WELS_LOG_ERROR,
@@ -4020,108 +4021,17 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 7 unmodified lines
40204021 iSliceCount);
40214022 return ENC_RETURN_UNEXPECTED;
40224023 }
4023− if (SM_AUTO_SLICE == pParam->sSliceCfg.uiSliceMode) {
4024− if (pSvcParam->iCountThreadsNum >= iSliceCount) { //THREAD_FULLY_FIRE_MODE
4025−#if defined(MT_DEBUG)
4026− int64_t t_bs_append = 0;
4027−#endif
4028−
4029− pCtx->iActiveThreadsNum = iSliceCount;
4030− // to fire slice coding threads
4031− iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0],
4032− &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
4033− &pCtx->pSliceThreading->pThreadMasterEvent[0],
4034− pFbi, iSliceCount, pCtx->pCurDqLayer->pSliceEncCtx, false);
4035− if (iRet) {
4036− WelsLog (pLogCtx, WELS_LOG_ERROR,
4037− "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!",
4038− iRet, pSvcParam->iCountThreadsNum, iSliceCount, pParam->sSliceCfg.uiSliceMode, pSvcParam->iMultipleThreadIdc);
4039− return ENC_RETURN_UNEXPECTED;
4040− }
4041−
4042− WelsMultipleEventsWaitAllBlocking (iSliceCount, &pCtx->pSliceThreading->pSliceCodedEvent[0],
4043− &pCtx->pSliceThreading->pSliceCodedMasterEvent);
4044−
4045−
4046− // all slices are finished coding here
4047− WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
4048−
4049− // append exclusive slice 0 bs to pFrameBs
4050−#if defined(MT_DEBUG)
4051− t_bs_append = WelsTime();
4052−#endif//MT_DEBUG
4053− iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, iSliceCount);
4054−#if defined(MT_DEBUG)
4055− t_bs_append = WelsTime() - t_bs_append;
4056− if (pCtx->pSliceThreading->pFSliceDiff) {
4057− fprintf (pCtx->pSliceThreading->pFSliceDiff,
4058− "%6" PRId64 " us consumed at AppendSliceToFrameBs() for coding_idx: %d iDid: %d qid: %d\n",
4059− t_bs_append, pCtx->iCodingIndex, iCurDid, 0);
4060− }
4061−#endif//MT_DEBUG
4062− } else { //THREAD_PICK_UP_MODE
4063− int32_t iNumThreadsRunning = 0;
4064− int32_t iNumThreadsScheduled = 0;
4065− int32_t iIndexOfSliceToBeCoded = 0;
4066−
4067− pCtx->iActiveThreadsNum = pSvcParam->iCountThreadsNum;
4068− iNumThreadsScheduled = pCtx->iActiveThreadsNum;
4069− iNumThreadsRunning = iNumThreadsScheduled;
4070− // to fire slice coding threads
4071− iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0],
4072− &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
4073− &pCtx->pSliceThreading->pThreadMasterEvent[0],
4074− pFbi, iNumThreadsRunning, pCtx->pCurDqLayer->pSliceEncCtx, false);
4075− if (iRet) {
4076− WelsLog (pLogCtx, WELS_LOG_ERROR,
4077− "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!",
4078− iRet, pSvcParam->iCountThreadsNum, iSliceCount, pParam->sSliceCfg.uiSliceMode, pSvcParam->iMultipleThreadIdc);
4079− return ENC_RETURN_UNEXPECTED;
4080− }
4081−
4082− iIndexOfSliceToBeCoded = iNumThreadsRunning;
4083− while (1) {
4084− if (iIndexOfSliceToBeCoded >= iSliceCount && iNumThreadsRunning <= 0)
4085− break;
4086− WELS_THREAD_ERROR_CODE lwait = 0;
4087− int32_t iEventId = -1;
4088−
4089− lwait = WelsMultipleEventsWaitSingleBlocking (iNumThreadsScheduled,
4090− &pCtx->pSliceThreading->pSliceCodedEvent[0],
4091− &pCtx->pSliceThreading->pSliceCodedMasterEvent);
4092− iEventId = (int32_t) (lwait - WELS_THREAD_ERROR_WAIT_OBJECT_0);
4093− if (iEventId >= 0 && iEventId < iNumThreadsScheduled) {
4094− if (iIndexOfSliceToBeCoded < iSliceCount) {
4095− // pick up succeeding slice for threading
4096− // thread_id equal to iEventId per implementation here
4097− pCtx->pSliceThreading->pThreadPEncCtx[iEventId].iSliceIndex = iIndexOfSliceToBeCoded;
4098− SetOneSliceBsBufferUnderMultithread (pCtx, iEventId, iIndexOfSliceToBeCoded);
4099− WelsEventSignal (&pCtx->pSliceThreading->pReadySliceCodingEvent[iEventId]);
4100− WelsEventSignal (&pCtx->pSliceThreading->pThreadMasterEvent[iEventId]);
4101− ++ iIndexOfSliceToBeCoded;
4102− } else { // no other slices left for coding
4103− -- iNumThreadsRunning;
4104− }
4105− }
4106− }//while(1)
4107−
4108− // all slices are finished coding here
4109− // append exclusive slice 0 bs to pFrameBs
4110− iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, iSliceCount);
4111− }
4112−
4113− } else {
4114− pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer;
4115− pLayerBsInfo->uiLayerType = VIDEO_CODING_LAYER;
4116− pLayerBsInfo->uiSpatialId = pCtx->uiDependencyId;
4117− pLayerBsInfo->uiTemporalId = pCtx->uiTemporalId;
4118− pLayerBsInfo->uiQualityId = 0;
4119− pLayerBsInfo->iNalCount = 0;
4120− pCtx->pSliceBs[0].pBs = pLayerBsInfo->pBsBuf;
4121−
4122− pCtx->pTaskManage->ExecuteTasks();
4123− iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, iSliceCount);
4124− }
4024+ //note: the old codes are removed at commit: 3e0ee69
4025+ pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer;
4026+ pLayerBsInfo->uiLayerType = VIDEO_CODING_LAYER;
4027+ pLayerBsInfo->uiSpatialId = pCtx->uiDependencyId;
4028+ pLayerBsInfo->uiTemporalId = pCtx->uiTemporalId;
4029+ pLayerBsInfo->uiQualityId = 0;
4030+ pLayerBsInfo->iNalCount = 0;
4031+ pCtx->pSliceBs[0].pBs = pLayerBsInfo->pBsBuf;
4032+
4033+ pCtx->pTaskManage->ExecuteTasks();
4034+ iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, iSliceCount);
41254035 }
41264036 // THREAD_FULLY_FIRE_MODE && SM_DYN_SLICE
41274037 else if ((SM_DYN_SLICE == pParam->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) {

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