History

remove unneeded codes and add some logs

Sijia Chen committed 11 years ago

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