WelsErrorType CWelsTaskManageBase::CreateTasks (sWelsEncCtx* pEncCtx, const int32_t kiCurDid) { CWelsBaseTask* pTask = NULL; int32_t kiTaskCount; uint32_t uiSliceMode = pEncCtx->pSvcParam->sSpatialLayers[kiCurDid].sSliceArgument.uiSliceMode; if (uiSliceMode != SM_SIZELIMITED_SLICE) { kiTaskCount = m_iTaskNum[kiCurDid] = pEncCtx->pSvcParam->sSpatialLayers[kiCurDid].sSliceArgument.uiSliceNum; } else { kiTaskCount = m_iTaskNum[kiCurDid] = pEncCtx->iActiveThreadsNum; } for (int idx = 0; idx < kiTaskCount; idx++) { pTask = WELS_NEW_OP (CWelsUpdateMbMapTask (this, pEncCtx, idx), CWelsUpdateMbMapTask); WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == pTask) m_cPreEncodingTaskList[kiCurDid]->push_back (pTask); } for (int idx = 0; idx < kiTaskCount; idx++) { if (uiSliceMode==SM_SIZELIMITED_SLICE) { pTask = WELS_NEW_OP (CWelsConstrainedSizeSlicingEncodingTask (this, pEncCtx, idx), CWelsConstrainedSizeSlicingEncodingTask); } else { if (pEncCtx->pSvcParam->bUseLoadBalancing) { pTask = WELS_NEW_OP (CWelsLoadBalancingSlicingEncodingTask (this, pEncCtx, idx), CWelsLoadBalancingSlicingEncodingTask); } else { pTask = WELS_NEW_OP (CWelsSliceEncodingTask (this, pEncCtx, idx), CWelsSliceEncodingTask); } } WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == pTask) m_cEncodingTaskList[kiCurDid]->push_back (pTask); } //printf ("CWelsTaskManageBase CreateTasks m_iThreadNum %d kiTaskCount=%d\n", m_iThreadNum, kiTaskCount); return ENC_RETURN_SUCCESS; }
WelsErrorType CWelsTaskManageBase::CreateTasks (sWelsEncCtx* pEncCtx, const int32_t kiTaskCount) { CWelsBaseTask* pTask = NULL; for (int idx = 0; idx < kiTaskCount; idx++) { pTask = WELS_NEW_OP (CWelsUpdateMbMapTask (pEncCtx, idx), CWelsUpdateMbMapTask); WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == pTask) m_cPreEncodingTaskList->push_back (pTask); } for (int idx = 0; idx < kiTaskCount; idx++) { if (pEncCtx->pSvcParam->bUseLoadBalancing) { pTask = WELS_NEW_OP (CWelsLoadBalancingSlicingEncodingTask (pEncCtx, idx), CWelsLoadBalancingSlicingEncodingTask); } else { pTask = WELS_NEW_OP (CWelsSliceEncodingTask (pEncCtx, idx), CWelsSliceEncodingTask); } WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == pTask) m_cEncodingTaskList->push_back (pTask); } m_iTotalTaskNum = kiTaskCount; //printf ("CWelsTaskManageBase CreateTasks m_iThreadNum %d kiTaskCount=%d\n", m_iThreadNum, kiTaskCount); return ENC_RETURN_SUCCESS; }