Merge pull request #2281 from sijchen/th11
[Encoder] remove duplicated operation after thread pool
This commit is contained in:
commit
f679da900f
@ -108,6 +108,7 @@ SPicture* pRefOri[MAX_REF_PIC_COUNT];
|
|||||||
int32_t* pNumSliceCodedOfPartition; // for dynamic slicing mode
|
int32_t* pNumSliceCodedOfPartition; // for dynamic slicing mode
|
||||||
int32_t* pLastCodedMbIdxOfPartition; // for dynamic slicing mode
|
int32_t* pLastCodedMbIdxOfPartition; // for dynamic slicing mode
|
||||||
int32_t* pLastMbIdxOfPartition; // for dynamic slicing mode
|
int32_t* pLastMbIdxOfPartition; // for dynamic slicing mode
|
||||||
|
bool bNeedAdjustingSlicing;
|
||||||
|
|
||||||
SFeatureSearchPreparation* pFeatureSearchPreparation;
|
SFeatureSearchPreparation* pFeatureSearchPreparation;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class CWelsBaseTask : public WelsCommon::IWelsTask {
|
|||||||
WELS_ENC_TASK_ENCODE_FIXED_SLICE = WELS_ENC_TASK_ENCODING,
|
WELS_ENC_TASK_ENCODE_FIXED_SLICE = WELS_ENC_TASK_ENCODING,
|
||||||
WELS_ENC_TASK_ENCODE_SLICE_LOADBALANCING = WELS_ENC_TASK_ENCODING,
|
WELS_ENC_TASK_ENCODE_SLICE_LOADBALANCING = WELS_ENC_TASK_ENCODING,
|
||||||
WELS_ENC_TASK_ENCODE_SLICE_SIZECONSTRAINED = WELS_ENC_TASK_ENCODING,
|
WELS_ENC_TASK_ENCODE_SLICE_SIZECONSTRAINED = WELS_ENC_TASK_ENCODING,
|
||||||
WELS_ENC_TASK_PREENCODING = 1,
|
WELS_ENC_TASK_UPDATEMBMAP = 1,
|
||||||
WELS_ENC_TASK_PREPROCESS = 2,
|
WELS_ENC_TASK_PREPROCESS = 2,
|
||||||
WELS_ENC_TASK_ALL = 3,
|
WELS_ENC_TASK_ALL = 3,
|
||||||
};
|
};
|
||||||
|
@ -132,7 +132,7 @@ class CWelsUpdateMbMapTask : public CWelsBaseTask {
|
|||||||
virtual WelsErrorType Execute();
|
virtual WelsErrorType Execute();
|
||||||
|
|
||||||
virtual uint32_t GetTaskType() const {
|
virtual uint32_t GetTaskType() const {
|
||||||
return WELS_ENC_TASK_PREENCODING;
|
return WELS_ENC_TASK_UPDATEMBMAP;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
sWelsEncCtx* m_pCtx;
|
sWelsEncCtx* m_pCtx;
|
||||||
|
@ -1178,6 +1178,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p
|
|||||||
NULL == pDqLayer->pLastMbIdxOfPartition),
|
NULL == pDqLayer->pLastMbIdxOfPartition),
|
||||||
FreeMemorySvc (ppCtx))
|
FreeMemorySvc (ppCtx))
|
||||||
}
|
}
|
||||||
|
pDqLayer->bNeedAdjustingSlicing = false;
|
||||||
|
|
||||||
pDqLayer->iMbWidth = kiMbW;
|
pDqLayer->iMbWidth = kiMbW;
|
||||||
pDqLayer->iMbHeight = kiMbH;
|
pDqLayer->iMbHeight = kiMbH;
|
||||||
|
@ -242,21 +242,10 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx,
|
|||||||
}
|
}
|
||||||
iRunLen[iSliceIdx] = iMbNumLeft;
|
iRunLen[iSliceIdx] = iMbNumLeft;
|
||||||
MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG,
|
MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG,
|
||||||
"[MT] DynamicAdjustSlicing(), iSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
|
"[MT] DynamicAdjustSlicing(), iSliceIdx= %d, pSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
|
||||||
iSliceIdx, pSliceInLayer[iSliceIdx].iSliceComplexRatio * 1.0f / INT_MULTIPLY,
|
iSliceIdx, pSliceComplexRatio[iSliceIdx] * 1.0f / INT_MULTIPLY, pSliceCtx->pCountMbNumInSlice[iSliceIdx], iMbNumLeft);
|
||||||
pSliceInLayer[iSliceIdx].iCountMbNumInSlice, iMbNumLeft);
|
|
||||||
|
|
||||||
if (DynamicAdjustSlicePEncCtxAll (pCurDqLayer, iRunLen) == 0) {
|
pCurDqLayer->bNeedAdjustingSlicing = !DynamicAdjustSlicePEncCtxAll (pCurDqLayer, iRunLen);
|
||||||
const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum;
|
|
||||||
int32_t iThreadIdx = 0;
|
|
||||||
do {
|
|
||||||
WelsEventSignal (&pCtx->pSliceThreading->pUpdateMbListEvent[iThreadIdx]);
|
|
||||||
WelsEventSignal (&pCtx->pSliceThreading->pThreadMasterEvent[iThreadIdx]);
|
|
||||||
++ iThreadIdx;
|
|
||||||
} while (iThreadIdx < kiThreadNum);
|
|
||||||
|
|
||||||
WelsMultipleEventsWaitAllBlocking (kiThreadNum, &pCtx->pSliceThreading->pFinUpdateMbListEvent[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t SetMultiSliceBuffer (sWelsEncCtx** ppCtx, CMemoryAlign* pMa, SSliceThreading* pSmt,
|
int32_t SetMultiSliceBuffer (sWelsEncCtx** ppCtx, CMemoryAlign* pMa, SSliceThreading* pSmt,
|
||||||
|
@ -99,7 +99,7 @@ WelsErrorType CWelsTaskManageBase::Init (sWelsEncCtx* pEncCtx) {
|
|||||||
WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == m_pThreadPool)
|
WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == m_pThreadPool)
|
||||||
|
|
||||||
m_pcAllTaskList[CWelsBaseTask::WELS_ENC_TASK_ENCODING] = m_cEncodingTaskList;
|
m_pcAllTaskList[CWelsBaseTask::WELS_ENC_TASK_ENCODING] = m_cEncodingTaskList;
|
||||||
m_pcAllTaskList[CWelsBaseTask::WELS_ENC_TASK_PREENCODING] = m_cPreEncodingTaskList;
|
m_pcAllTaskList[CWelsBaseTask::WELS_ENC_TASK_UPDATEMBMAP] = m_cPreEncodingTaskList;
|
||||||
|
|
||||||
m_iCurrentTaskNum = pEncCtx->pSvcParam->sSpatialLayers[0].sSliceArgument.uiSliceNum;
|
m_iCurrentTaskNum = pEncCtx->pSvcParam->sSpatialLayers[0].sSliceArgument.uiSliceNum;
|
||||||
//printf ("CWelsTaskManageBase Init m_iThreadNum %d m_iCurrentTaskNum %d pEncCtx->iMaxSliceCount %d\n", m_iThreadNum, m_iCurrentTaskNum, pEncCtx->iMaxSliceCount);
|
//printf ("CWelsTaskManageBase Init m_iThreadNum %d m_iCurrentTaskNum %d pEncCtx->iMaxSliceCount %d\n", m_iThreadNum, m_iCurrentTaskNum, pEncCtx->iMaxSliceCount);
|
||||||
@ -202,7 +202,9 @@ WelsErrorType CWelsTaskManageBase::ExecuteTaskList (TASKLIST_TYPE* pTargetTaskL
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CWelsTaskManageBase::InitFrame (const int32_t kiCurDid) {
|
void CWelsTaskManageBase::InitFrame (const int32_t kiCurDid) {
|
||||||
ExecuteTaskList (m_pcAllTaskList[CWelsBaseTask::WELS_ENC_TASK_PREENCODING]);
|
if (m_pEncCtx->pCurDqLayer->bNeedAdjustingSlicing) {
|
||||||
|
ExecuteTaskList (m_pcAllTaskList[CWelsBaseTask::WELS_ENC_TASK_UPDATEMBMAP]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WelsErrorType CWelsTaskManageBase::ExecuteTasks (const CWelsBaseTask::ETaskType iTaskType) {
|
WelsErrorType CWelsTaskManageBase::ExecuteTasks (const CWelsBaseTask::ETaskType iTaskType) {
|
||||||
@ -229,7 +231,9 @@ void CWelsTaskManageMultiD::InitFrame (const int32_t kiCurDid) {
|
|||||||
//printf("CWelsTaskManageMultiD: InitFrame: m_iCurDid=%d, m_iCurrentTaskNum=%d\n", m_iCurDid, m_iCurrentTaskNum);
|
//printf("CWelsTaskManageMultiD: InitFrame: m_iCurDid=%d, m_iCurrentTaskNum=%d\n", m_iCurDid, m_iCurrentTaskNum);
|
||||||
m_iCurDid = kiCurDid;
|
m_iCurDid = kiCurDid;
|
||||||
m_iCurrentTaskNum = m_iTaskNumD[kiCurDid];
|
m_iCurrentTaskNum = m_iTaskNumD[kiCurDid];
|
||||||
ExecuteTaskList (m_pcAllTaskList[CWelsBaseTask::WELS_ENC_TASK_PREENCODING]);
|
if (m_pEncCtx->pCurDqLayer->bNeedAdjustingSlicing) {
|
||||||
|
ExecuteTaskList (m_pcAllTaskList[CWelsBaseTask::WELS_ENC_TASK_UPDATEMBMAP]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WelsErrorType CWelsTaskManageMultiD::ExecuteTasks (const CWelsBaseTask::ETaskType iTaskType) {
|
WelsErrorType CWelsTaskManageMultiD::ExecuteTasks (const CWelsBaseTask::ETaskType iTaskType) {
|
||||||
|
@ -3788,6 +3788,7 @@ TEST_F (EncodeDecodeTestAPI, ThreadNumAndSliceNum) {
|
|||||||
|
|
||||||
|
|
||||||
TEST_F (EncodeDecodeTestAPI, TriggerLoadBalancing) {
|
TEST_F (EncodeDecodeTestAPI, TriggerLoadBalancing) {
|
||||||
|
//#define DEBUG_FILE_SAVE_TRIGGER
|
||||||
int iSpatialLayerNum = 1;
|
int iSpatialLayerNum = 1;
|
||||||
int iWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, (64 << 2), MAX_WIDTH);
|
int iWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, (64 << 2), MAX_WIDTH);
|
||||||
int iHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, (64 << 2),
|
int iHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, (64 << 2),
|
||||||
@ -3799,7 +3800,7 @@ TEST_F (EncodeDecodeTestAPI, TriggerLoadBalancing) {
|
|||||||
SEncParamExt sParam;
|
SEncParamExt sParam;
|
||||||
encoder_->GetDefaultParams (&sParam);
|
encoder_->GetDefaultParams (&sParam);
|
||||||
prepareParamDefault (iSpatialLayerNum, 1, iWidth, iHeight, fFrameRate, &sParam);
|
prepareParamDefault (iSpatialLayerNum, 1, iWidth, iHeight, fFrameRate, &sParam);
|
||||||
sParam.iMultipleThreadIdc = (rand() % 8) + 1;
|
sParam.iMultipleThreadIdc = 4;
|
||||||
sParam.bSimulcastAVC = 1;
|
sParam.bSimulcastAVC = 1;
|
||||||
sParam.sSpatialLayers[0].iVideoWidth = iWidth;
|
sParam.sSpatialLayers[0].iVideoWidth = iWidth;
|
||||||
sParam.sSpatialLayers[0].iVideoHeight = iHeight;
|
sParam.sSpatialLayers[0].iVideoHeight = iHeight;
|
||||||
@ -3815,6 +3816,11 @@ TEST_F (EncodeDecodeTestAPI, TriggerLoadBalancing) {
|
|||||||
int iIdx = 0;
|
int iIdx = 0;
|
||||||
int aLen[MAX_SPATIAL_LAYER_NUM] = {};
|
int aLen[MAX_SPATIAL_LAYER_NUM] = {};
|
||||||
|
|
||||||
|
#ifdef DEBUG_FILE_SAVE_TRIGGER
|
||||||
|
FILE* fEnc = fopen ("trigger00.264", "wb");
|
||||||
|
printf("Current Threads is %d\n", sParam.iMultipleThreadIdc);
|
||||||
|
#endif
|
||||||
|
|
||||||
//create decoder
|
//create decoder
|
||||||
for (iIdx = 0; iIdx < iSpatialLayerNum; iIdx++) {
|
for (iIdx = 0; iIdx < iSpatialLayerNum; iIdx++) {
|
||||||
pBsBuf[iIdx] = static_cast<unsigned char*> (malloc (iWidth * iHeight * 3 * sizeof (unsigned char) / 2));
|
pBsBuf[iIdx] = static_cast<unsigned char*> (malloc (iWidth * iHeight * 3 * sizeof (unsigned char) / 2));
|
||||||
@ -3881,8 +3887,8 @@ TEST_F (EncodeDecodeTestAPI, TriggerLoadBalancing) {
|
|||||||
pData[0] = pData[1] = pData[2] = 0;
|
pData[0] = pData[1] = pData[2] = 0;
|
||||||
memset (&dstBufInfo_, 0, sizeof (SBufferInfo));
|
memset (&dstBufInfo_, 0, sizeof (SBufferInfo));
|
||||||
|
|
||||||
#ifdef DEBUG_FILE_SAVE4
|
#ifdef DEBUG_FILE_SAVE_TRIGGER
|
||||||
fwrite (pBsBuf[iIdx], aLen[iIdx], 1, fEnc[iIdx]);
|
fwrite (pBsBuf[iIdx], aLen[iIdx], 1, fEnc);
|
||||||
#endif
|
#endif
|
||||||
iResult = decoder[iIdx]->DecodeFrame2 (pBsBuf[iIdx], aLen[iIdx], pData, &dstBufInfo_);
|
iResult = decoder[iIdx]->DecodeFrame2 (pBsBuf[iIdx], aLen[iIdx], pData, &dstBufInfo_);
|
||||||
EXPECT_TRUE (iResult == cmResultSuccess) << "iResult=" << iResult << ", LayerIdx=" << iIdx;
|
EXPECT_TRUE (iResult == cmResultSuccess) << "iResult=" << iResult << ", LayerIdx=" << iIdx;
|
||||||
@ -3900,7 +3906,9 @@ TEST_F (EncodeDecodeTestAPI, TriggerLoadBalancing) {
|
|||||||
decoder[iIdx]->Uninitialize();
|
decoder[iIdx]->Uninitialize();
|
||||||
WelsDestroyDecoder (decoder[iIdx]);
|
WelsDestroyDecoder (decoder[iIdx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_FILE_SAVE_TRIGGER
|
||||||
|
fclose(fEnc);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user