[Encoder] put the logic related to multiple D layer into a class for better structure
This commit is contained in:
parent
beacba76e3
commit
aeb5ab4b99
@ -58,7 +58,7 @@ class IWelsTaskManage {
|
|||||||
virtual void InitFrame (const int32_t kiCurDid) {}
|
virtual void InitFrame (const int32_t kiCurDid) {}
|
||||||
virtual WelsErrorType ExecuteTasks(const CWelsBaseTask::ETaskType iTaskType = CWelsBaseTask::WELS_ENC_TASK_ENCODING) = 0;
|
virtual WelsErrorType ExecuteTasks(const CWelsBaseTask::ETaskType iTaskType = CWelsBaseTask::WELS_ENC_TASK_ENCODING) = 0;
|
||||||
|
|
||||||
static IWelsTaskManage* CreateTaskManage (sWelsEncCtx* pCtx, bool bNeedLock);
|
static IWelsTaskManage* CreateTaskManage (sWelsEncCtx* pCtx, const int32_t iSpatialLayer, const bool bNeedLock);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -71,29 +71,29 @@ class CWelsTaskManageBase : public IWelsTaskManage, public WelsCommon::IWelsThr
|
|||||||
CWelsTaskManageBase();
|
CWelsTaskManageBase();
|
||||||
virtual ~ CWelsTaskManageBase();
|
virtual ~ CWelsTaskManageBase();
|
||||||
|
|
||||||
virtual WelsErrorType Init (sWelsEncCtx* pEncCtx);
|
virtual WelsErrorType Init (sWelsEncCtx* pEncCtx);
|
||||||
void Uninit();
|
virtual void InitFrame (const int32_t kiCurDid = 0);
|
||||||
|
|
||||||
virtual void InitFrame (const int32_t kiCurDid);
|
virtual WelsErrorType ExecuteTasks(const CWelsBaseTask::ETaskType iTaskType = CWelsBaseTask::WELS_ENC_TASK_ENCODING);
|
||||||
virtual WelsErrorType ExecuteTasks(const CWelsBaseTask::ETaskType iTaskType = CWelsBaseTask::WELS_ENC_TASK_ENCODING);
|
|
||||||
|
|
||||||
//IWelsThreadPoolSink
|
//IWelsThreadPoolSink
|
||||||
virtual WelsErrorType OnTaskExecuted (WelsCommon::IWelsTask* pTask);
|
virtual WelsErrorType OnTaskExecuted (WelsCommon::IWelsTask* pTask);
|
||||||
virtual WelsErrorType OnTaskCancelled (WelsCommon::IWelsTask* pTask);
|
virtual WelsErrorType OnTaskCancelled (WelsCommon::IWelsTask* pTask);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual WelsErrorType CreateTasks (sWelsEncCtx* pEncCtx, const int32_t kiTaskCount);
|
virtual WelsErrorType CreateTasks (sWelsEncCtx* pEncCtx, const int32_t kiTaskCount);
|
||||||
void DestroyTasks();
|
|
||||||
WelsErrorType ExecuteTaskList(TASKLIST_TYPE* pTargetTaskList);
|
WelsErrorType ExecuteTaskList(TASKLIST_TYPE* pTargetTaskList);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
sWelsEncCtx* m_pEncCtx;
|
sWelsEncCtx* m_pEncCtx;
|
||||||
WelsCommon::CWelsThreadPool* m_pThreadPool;
|
WelsCommon::CWelsThreadPool* m_pThreadPool;
|
||||||
|
|
||||||
TASKLIST_TYPE* m_pcAllTaskList[CWelsBaseTask::WELS_ENC_TASK_ALL];
|
TASKLIST_TYPE* m_pcAllTaskList[CWelsBaseTask::WELS_ENC_TASK_ALL];
|
||||||
TASKLIST_TYPE* m_cEncodingTaskList;
|
TASKLIST_TYPE* m_cEncodingTaskList;
|
||||||
TASKLIST_TYPE* m_cPreEncodingTaskList;
|
TASKLIST_TYPE* m_cPreEncodingTaskList;
|
||||||
int32_t m_iTaskNum;
|
int32_t m_iCurrentTaskNum;
|
||||||
|
int32_t m_iTotalTaskNum;
|
||||||
|
|
||||||
//SLICE_PAIR_LIST *m_cSliceList;
|
//SLICE_PAIR_LIST *m_cSliceList;
|
||||||
|
|
||||||
@ -107,6 +107,10 @@ class CWelsTaskManageBase : public IWelsTaskManage, public WelsCommon::IWelsThr
|
|||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN (CWelsTaskManageBase);
|
DISALLOW_COPY_AND_ASSIGN (CWelsTaskManageBase);
|
||||||
void OnTaskMinusOne();
|
void OnTaskMinusOne();
|
||||||
|
|
||||||
|
void Uninit();
|
||||||
|
void DestroyTasks();
|
||||||
|
void DestroyTaskList(TASKLIST_TYPE* pTargetTaskList);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CWelsTaskManageOne : public CWelsTaskManageBase {
|
class CWelsTaskManageOne : public CWelsTaskManageBase {
|
||||||
@ -118,6 +122,17 @@ class CWelsTaskManageOne : public CWelsTaskManageBase {
|
|||||||
virtual WelsErrorType ExecuteTasks(const CWelsBaseTask::ETaskType iTaskType = CWelsBaseTask::WELS_ENC_TASK_ENCODING);
|
virtual WelsErrorType ExecuteTasks(const CWelsBaseTask::ETaskType iTaskType = CWelsBaseTask::WELS_ENC_TASK_ENCODING);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CWelsTaskManageMultiD : public CWelsTaskManageBase {
|
||||||
|
public:
|
||||||
|
virtual WelsErrorType Init (sWelsEncCtx* pEncCtx);
|
||||||
|
virtual void InitFrame (const int32_t kiCurDid);
|
||||||
|
virtual WelsErrorType ExecuteTasks(const CWelsBaseTask::ETaskType iTaskType = CWelsBaseTask::WELS_ENC_TASK_ENCODING);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32_t m_iTaskNumD[MAX_DEPENDENCY_LAYER];
|
||||||
|
int32_t m_iCurDid;
|
||||||
|
};
|
||||||
|
|
||||||
class CWelsTaskManageParallel : public CWelsTaskManageBase {
|
class CWelsTaskManageParallel : public CWelsTaskManageBase {
|
||||||
public:
|
public:
|
||||||
virtual WelsErrorType ExecuteTasks(const CWelsBaseTask::ETaskType iTaskType = CWelsBaseTask::WELS_ENC_TASK_ENCODING);
|
virtual WelsErrorType ExecuteTasks(const CWelsBaseTask::ETaskType iTaskType = CWelsBaseTask::WELS_ENC_TASK_ENCODING);
|
||||||
|
@ -452,7 +452,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
|
|||||||
WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))
|
WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))
|
||||||
|
|
||||||
if (bWillUseTaskManage) {
|
if (bWillUseTaskManage) {
|
||||||
(*ppCtx)->pTaskManage = IWelsTaskManage::CreateTaskManage(*ppCtx, bDynamicSlice);
|
(*ppCtx)->pTaskManage = IWelsTaskManage::CreateTaskManage(*ppCtx, iNumSpatialLayers, bDynamicSlice);
|
||||||
WELS_VERIFY_RETURN_PROC_IF (iReturn, (NULL == (*ppCtx)->pTaskManage), FreeMemorySvc (ppCtx))
|
WELS_VERIFY_RETURN_PROC_IF (iReturn, (NULL == (*ppCtx)->pTaskManage), FreeMemorySvc (ppCtx))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,14 +55,15 @@ namespace WelsEnc {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
IWelsTaskManage* IWelsTaskManage::CreateTaskManage (sWelsEncCtx* pCtx, bool bNeedLock) {
|
IWelsTaskManage* IWelsTaskManage::CreateTaskManage (sWelsEncCtx* pCtx, const int32_t iSpatialLayer,
|
||||||
|
const bool bNeedLock) {
|
||||||
if (NULL == pCtx) {
|
if (NULL == pCtx) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
IWelsTaskManage* pTaskManage;
|
IWelsTaskManage* pTaskManage;
|
||||||
if (bNeedLock) {
|
if (iSpatialLayer > 1) {
|
||||||
pTaskManage = WELS_NEW_OP (CWelsTaskManageParallel(), CWelsTaskManageParallel);
|
pTaskManage = WELS_NEW_OP (CWelsTaskManageMultiD(), CWelsTaskManageMultiD);
|
||||||
} else {
|
} else {
|
||||||
pTaskManage = WELS_NEW_OP (CWelsTaskManageBase(), CWelsTaskManageBase);
|
pTaskManage = WELS_NEW_OP (CWelsTaskManageBase(), CWelsTaskManageBase);
|
||||||
}
|
}
|
||||||
@ -77,7 +78,7 @@ IWelsTaskManage* IWelsTaskManage::CreateTaskManage (sWelsEncCtx* pCtx, bool bN
|
|||||||
CWelsTaskManageBase::CWelsTaskManageBase()
|
CWelsTaskManageBase::CWelsTaskManageBase()
|
||||||
: m_pEncCtx (NULL),
|
: m_pEncCtx (NULL),
|
||||||
m_pThreadPool (NULL),
|
m_pThreadPool (NULL),
|
||||||
m_iTaskNum (0),
|
m_iTotalTaskNum (0),
|
||||||
m_iWaitTaskNum (0) {
|
m_iWaitTaskNum (0) {
|
||||||
m_cEncodingTaskList = new TASKLIST_TYPE();
|
m_cEncodingTaskList = new TASKLIST_TYPE();
|
||||||
m_cPreEncodingTaskList = new TASKLIST_TYPE();
|
m_cPreEncodingTaskList = new TASKLIST_TYPE();
|
||||||
@ -85,7 +86,7 @@ CWelsTaskManageBase::CWelsTaskManageBase()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CWelsTaskManageBase::~CWelsTaskManageBase() {
|
CWelsTaskManageBase::~CWelsTaskManageBase() {
|
||||||
//printf("~CWelsTaskManageBase\n");
|
//printf ("~CWelsTaskManageBase\n");
|
||||||
Uninit();
|
Uninit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,11 +97,12 @@ WelsErrorType CWelsTaskManageBase::Init (sWelsEncCtx* pEncCtx) {
|
|||||||
m_pThreadPool = WELS_NEW_OP (WelsCommon::CWelsThreadPool (this, m_iThreadNum),
|
m_pThreadPool = WELS_NEW_OP (WelsCommon::CWelsThreadPool (this, m_iThreadNum),
|
||||||
WelsCommon::CWelsThreadPool);
|
WelsCommon::CWelsThreadPool);
|
||||||
WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == m_pThreadPool)
|
WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == m_pThreadPool)
|
||||||
//printf("CWelsTaskManageBase Init m_iThreadNum %d pEncCtx->iMaxSliceCount=%d\n", m_iThreadNum, pEncCtx->iMaxSliceCount);
|
|
||||||
|
|
||||||
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_PREENCODING] = m_cPreEncodingTaskList;
|
||||||
|
|
||||||
|
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);
|
||||||
return CreateTasks (pEncCtx, pEncCtx->iMaxSliceCount);
|
return CreateTasks (pEncCtx, pEncCtx->iMaxSliceCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,31 +129,34 @@ WelsErrorType CWelsTaskManageBase::CreateTasks (sWelsEncCtx* pEncCtx, const int3
|
|||||||
WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == pTask)
|
WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == pTask)
|
||||||
m_cEncodingTaskList->push_back (pTask);
|
m_cEncodingTaskList->push_back (pTask);
|
||||||
}
|
}
|
||||||
m_iTaskNum = kiTaskCount;
|
m_iTotalTaskNum = kiTaskCount;
|
||||||
|
|
||||||
//printf("CWelsTaskManageBase CreateTasks m_iThreadNum %d kiTaskCount=%d\n", m_iThreadNum, kiTaskCount);
|
//printf ("CWelsTaskManageBase CreateTasks m_iThreadNum %d kiTaskCount=%d\n", m_iThreadNum, kiTaskCount);
|
||||||
return ENC_RETURN_SUCCESS;
|
return ENC_RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWelsTaskManageBase::DestroyTaskList (TASKLIST_TYPE* pTargetTaskList) {
|
||||||
|
if (pTargetTaskList->size() != m_iTotalTaskNum) {
|
||||||
|
printf ("pTargetTaskList size=%d m_iTotalTaskNum=%d\n", static_cast<int32_t> (pTargetTaskList->size()),
|
||||||
|
m_iTotalTaskNum);
|
||||||
|
}
|
||||||
|
//printf ("CWelsTaskManageBase: pTargetTaskList size=%d m_iTotalTaskNum=%d\n", static_cast<int32_t> (pTargetTaskList->size()), m_iTotalTaskNum);
|
||||||
|
while (NULL != pTargetTaskList->begin()) {
|
||||||
|
CWelsBaseTask* pTask = pTargetTaskList->begin();
|
||||||
|
WELS_DELETE_OP (pTask);
|
||||||
|
pTargetTaskList->pop_front();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CWelsTaskManageBase::DestroyTasks() {
|
void CWelsTaskManageBase::DestroyTasks() {
|
||||||
if (m_iTaskNum == 0) {
|
if (m_iTotalTaskNum == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_cEncodingTaskList->size() != m_iTaskNum) {
|
DestroyTaskList (m_cEncodingTaskList);
|
||||||
//printf("m_cEncodingTaskList %d %d\n", static_cast<int32_t>(m_cEncodingTaskList->size()), m_iTaskNum);
|
DestroyTaskList (m_cPreEncodingTaskList);
|
||||||
//WELS_ERROR_TRACE ("CWelsTaskManage::DestroyTasks: Incorrect task numbers");
|
//printf ("[MT] CWelsTaskManageBase() DestroyTasks, cleaned %d tasks\n", m_iTotalTaskNum);
|
||||||
}
|
m_iTotalTaskNum = 0;
|
||||||
|
|
||||||
while (NULL != m_cEncodingTaskList->begin()) {
|
|
||||||
CWelsBaseTask* pTask = m_cEncodingTaskList->begin();
|
|
||||||
WELS_DELETE_OP (pTask);
|
|
||||||
m_cEncodingTaskList->pop_front();
|
|
||||||
}
|
|
||||||
//WelsLog (&m_pEncCtx->sLogCtx, WELS_LOG_INFO,
|
|
||||||
// "[MT] CWelsTaskManageParallel()DestroyTasks, cleaned %d tasks", m_iTaskNum);
|
|
||||||
//printf ("[MT] CWelsTaskManageBase() DestroyTasks, cleaned %d tasks\n", m_iTaskNum);
|
|
||||||
m_iTaskNum = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWelsTaskManageBase::OnTaskMinusOne() {
|
void CWelsTaskManageBase::OnTaskMinusOne() {
|
||||||
@ -159,8 +164,9 @@ void CWelsTaskManageBase::OnTaskMinusOne() {
|
|||||||
m_iWaitTaskNum --;
|
m_iWaitTaskNum --;
|
||||||
if (m_iWaitTaskNum <= 0) {
|
if (m_iWaitTaskNum <= 0) {
|
||||||
WelsEventSignal (&m_hTaskEvent);
|
WelsEventSignal (&m_hTaskEvent);
|
||||||
|
//printf ("OnTaskMinusOne WelsEventSignal m_iWaitTaskNum=%d\n", m_iWaitTaskNum);
|
||||||
}
|
}
|
||||||
//printf("OnTaskMinusOne m_iWaitTaskNum=%d\n", m_iWaitTaskNum);
|
//printf ("OnTaskMinusOne m_iWaitTaskNum=%d\n", m_iWaitTaskNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
WelsErrorType CWelsTaskManageBase::OnTaskCancelled (WelsCommon::IWelsTask* pTask) {
|
WelsErrorType CWelsTaskManageBase::OnTaskCancelled (WelsCommon::IWelsTask* pTask) {
|
||||||
@ -173,18 +179,17 @@ WelsErrorType CWelsTaskManageBase::OnTaskExecuted (WelsCommon::IWelsTask* pTask
|
|||||||
return ENC_RETURN_SUCCESS;
|
return ENC_RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWelsTaskManageBase::InitFrame (const int32_t kiCurDid) {
|
WelsErrorType CWelsTaskManageBase::ExecuteTaskList (TASKLIST_TYPE* pTargetTaskList) {
|
||||||
m_iWaitTaskNum = m_pEncCtx->pSvcParam->sSpatialLayers[kiCurDid].sSliceArgument.uiSliceNum;
|
m_iWaitTaskNum = m_iCurrentTaskNum;
|
||||||
//printf("InitFrame m_iWaitTaskNum=%d, slice_mode=%d\n", m_iWaitTaskNum, m_pEncCtx->pSvcParam->sSpatialLayers[kiCurDid].sSliceCfg.uiSliceMode);
|
//printf ("ExecuteTaskList m_iWaitTaskNum=%d\n", m_iWaitTaskNum);
|
||||||
//TODO: update mbmap;
|
if (0 == m_iWaitTaskNum) {
|
||||||
}
|
return ENC_RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
WelsErrorType CWelsTaskManageBase::ExecuteTaskList(TASKLIST_TYPE* pTargetTaskList) {
|
|
||||||
//printf("ExecuteTasks m_iWaitTaskNum=%d\n", m_iWaitTaskNum);
|
|
||||||
int32_t iCurrentTaskCount = m_iWaitTaskNum; //if directly use m_iWaitTaskNum in the loop make cause sync problem
|
int32_t iCurrentTaskCount = m_iWaitTaskNum; //if directly use m_iWaitTaskNum in the loop make cause sync problem
|
||||||
int32_t iIdx = 0;
|
int32_t iIdx = 0;
|
||||||
while (iIdx < iCurrentTaskCount) {
|
while (iIdx < iCurrentTaskCount) {
|
||||||
m_pThreadPool->QueueTask (pTargetTaskList->GetIndexNode(iIdx));
|
m_pThreadPool->QueueTask (pTargetTaskList->GetIndexNode (iIdx));
|
||||||
iIdx ++;
|
iIdx ++;
|
||||||
}
|
}
|
||||||
WelsEventWait (&m_hTaskEvent);
|
WelsEventWait (&m_hTaskEvent);
|
||||||
@ -192,27 +197,45 @@ WelsErrorType CWelsTaskManageBase::ExecuteTaskList(TASKLIST_TYPE* pTargetTaskLi
|
|||||||
return ENC_RETURN_SUCCESS;
|
return ENC_RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
WelsErrorType CWelsTaskManageBase::ExecuteTasks(const CWelsBaseTask::ETaskType iTaskType) {
|
void CWelsTaskManageBase::InitFrame (const int32_t kiCurDid) {
|
||||||
return ExecuteTaskList(m_pcAllTaskList[iTaskType]);
|
ExecuteTaskList (m_pcAllTaskList[CWelsBaseTask::WELS_ENC_TASK_PREENCODING]);
|
||||||
}
|
}
|
||||||
|
|
||||||
WelsErrorType CWelsTaskManageOne::Init (sWelsEncCtx* pEncCtx) {
|
WelsErrorType CWelsTaskManageBase::ExecuteTasks (const CWelsBaseTask::ETaskType iTaskType) {
|
||||||
Uninit();
|
return ExecuteTaskList (m_pcAllTaskList[iTaskType]);
|
||||||
m_pEncCtx = pEncCtx;
|
|
||||||
|
|
||||||
return CreateTasks (pEncCtx, pEncCtx->iMaxSliceCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WelsErrorType CWelsTaskManageOne::ExecuteTasks(const CWelsBaseTask::ETaskType iTaskType) {
|
WelsErrorType CWelsTaskManageMultiD::Init (sWelsEncCtx* pEncCtx) {
|
||||||
while (NULL != m_cEncodingTaskList->begin()) {
|
WelsErrorType ret = CWelsTaskManageBase::Init (pEncCtx);
|
||||||
(m_cEncodingTaskList->begin())->Execute();
|
|
||||||
m_cEncodingTaskList->pop_front();
|
//TODO: the iMaxTaskNum logic here is for protection for now, may remove later
|
||||||
|
int32_t iMaxTaskNum = 0;
|
||||||
|
for (int32_t i = 0; i < m_pEncCtx->pSvcParam->iSpatialLayerNum; i++) {
|
||||||
|
m_iTaskNumD[i] = m_pEncCtx->pSvcParam->sSpatialLayers[i].sSliceArgument.uiSliceNum;
|
||||||
|
iMaxTaskNum = WELS_MAX (m_iTaskNumD[i], iMaxTaskNum);
|
||||||
}
|
}
|
||||||
return ENC_RETURN_SUCCESS;
|
//printf("CWelsTaskManageMultiD::Init, m_iTotalTaskNum=%d, iMaxTaskNum=%d\n", m_iTotalTaskNum, iMaxTaskNum);
|
||||||
|
assert(m_iTotalTaskNum==iMaxTaskNum);
|
||||||
|
//
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWelsTaskManageMultiD::InitFrame (const int32_t kiCurDid) {
|
||||||
|
//printf("CWelsTaskManageMultiD: InitFrame: m_iCurDid=%d, m_iCurrentTaskNum=%d\n", m_iCurDid, m_iCurrentTaskNum);
|
||||||
|
m_iCurDid = kiCurDid;
|
||||||
|
m_iCurrentTaskNum = m_iTaskNumD[kiCurDid];
|
||||||
|
ExecuteTaskList (m_pcAllTaskList[CWelsBaseTask::WELS_ENC_TASK_PREENCODING]);
|
||||||
|
}
|
||||||
|
|
||||||
|
WelsErrorType CWelsTaskManageMultiD::ExecuteTasks (const CWelsBaseTask::ETaskType iTaskType) {
|
||||||
|
m_iCurrentTaskNum = m_iTaskNumD[m_iCurDid];
|
||||||
|
return CWelsTaskManageBase::ExecuteTasks (iTaskType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: at present there is no diff betweenCWelsTaskManageParallel and CWelsTaskManageBase, to finish later
|
//TODO: at present there is no diff betweenCWelsTaskManageParallel and CWelsTaskManageBase, to finish later
|
||||||
WelsErrorType CWelsTaskManageParallel::ExecuteTasks(const CWelsBaseTask::ETaskType iTaskType) {
|
WelsErrorType CWelsTaskManageParallel::ExecuteTasks (const CWelsBaseTask::ETaskType iTaskType) {
|
||||||
WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == m_pThreadPool)
|
WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == m_pThreadPool)
|
||||||
|
|
||||||
// need lock here?
|
// need lock here?
|
||||||
@ -231,6 +254,22 @@ WelsErrorType CWelsTaskManageParallel::CreateTasks (sWelsEncCtx* pEncCtx, cons
|
|||||||
return ENC_RETURN_SUCCESS;
|
return ENC_RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CWelsTaskManageOne is for test
|
||||||
|
WelsErrorType CWelsTaskManageOne::Init (sWelsEncCtx* pEncCtx) {
|
||||||
|
m_pEncCtx = pEncCtx;
|
||||||
|
|
||||||
|
return CreateTasks (pEncCtx, pEncCtx->iMaxSliceCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
WelsErrorType CWelsTaskManageOne::ExecuteTasks (const CWelsBaseTask::ETaskType iTaskType) {
|
||||||
|
while (NULL != m_cEncodingTaskList->begin()) {
|
||||||
|
(m_cEncodingTaskList->begin())->Execute();
|
||||||
|
m_cEncodingTaskList->pop_front();
|
||||||
|
}
|
||||||
|
return ENC_RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
// CWelsTaskManageOne is for test
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ void CWelsH264SVCEncoder::TraceParamInfo (SEncParamExt* pParam) {
|
|||||||
pSpatialCfg->sSliceArgument.uiSliceSizeConstraint,
|
pSpatialCfg->sSliceArgument.uiSliceSizeConstraint,
|
||||||
pSpatialCfg->uiProfileIdc,
|
pSpatialCfg->uiProfileIdc,
|
||||||
pSpatialCfg->uiLevelIdc
|
pSpatialCfg->uiLevelIdc
|
||||||
);
|
);
|
||||||
++ i;
|
++ i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ TEST (EncoderTaskManagement, CWelsTaskManageBase) {
|
|||||||
sCtx.pSvcParam = &sWelsSvcCodingParam;
|
sCtx.pSvcParam = &sWelsSvcCodingParam;
|
||||||
sWelsSvcCodingParam.iMultipleThreadIdc = 4;
|
sWelsSvcCodingParam.iMultipleThreadIdc = 4;
|
||||||
sCtx.iMaxSliceCount = 35;
|
sCtx.iMaxSliceCount = 35;
|
||||||
IWelsTaskManage* pTaskManage = IWelsTaskManage::CreateTaskManage (&sCtx, false);
|
IWelsTaskManage* pTaskManage = IWelsTaskManage::CreateTaskManage (&sCtx, 1, false);
|
||||||
ASSERT_TRUE (NULL != pTaskManage);
|
ASSERT_TRUE (NULL != pTaskManage);
|
||||||
|
|
||||||
delete pTaskManage;
|
delete pTaskManage;
|
||||||
@ -27,7 +27,22 @@ TEST (EncoderTaskManagement, CWelsTaskManageParallel) {
|
|||||||
sCtx.pSvcParam = &sWelsSvcCodingParam;
|
sCtx.pSvcParam = &sWelsSvcCodingParam;
|
||||||
sWelsSvcCodingParam.iMultipleThreadIdc = 4;
|
sWelsSvcCodingParam.iMultipleThreadIdc = 4;
|
||||||
sCtx.iMaxSliceCount = 35;
|
sCtx.iMaxSliceCount = 35;
|
||||||
IWelsTaskManage* pTaskManage = IWelsTaskManage::CreateTaskManage (&sCtx, true);
|
IWelsTaskManage* pTaskManage = IWelsTaskManage::CreateTaskManage (&sCtx, 1, true);
|
||||||
|
ASSERT_TRUE (NULL != pTaskManage);
|
||||||
|
|
||||||
|
delete pTaskManage;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST (EncoderTaskManagement, CWelsTaskManageMultiD) {
|
||||||
|
sWelsEncCtx sCtx;
|
||||||
|
SWelsSvcCodingParam sWelsSvcCodingParam;
|
||||||
|
|
||||||
|
sCtx.pSvcParam = &sWelsSvcCodingParam;
|
||||||
|
sWelsSvcCodingParam.iMultipleThreadIdc = 4;
|
||||||
|
sWelsSvcCodingParam.sSpatialLayers[0].sSliceArgument.uiSliceNum = 35;
|
||||||
|
sCtx.iMaxSliceCount = 35;
|
||||||
|
|
||||||
|
IWelsTaskManage* pTaskManage = IWelsTaskManage::CreateTaskManage (&sCtx, 4, true);
|
||||||
ASSERT_TRUE (NULL != pTaskManage);
|
ASSERT_TRUE (NULL != pTaskManage);
|
||||||
|
|
||||||
delete pTaskManage;
|
delete pTaskManage;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user