History

put CWelsThreadPool to singleTon for future usage (including add sink for IWelsTask)

sijchen committed 10 years ago

Commit d4f09d91 parent 52d25f510 files · +273 −85Browse files

Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 10 files). Show all

Unified · Split

codec/encoder/core/src/slice_multi_threading.cpp+12−3
@@ -333,9 +333,6 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 332 unmodified lines
333333 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pReadySliceCodingEvent%d = 0x%p named(%s) ret%d err%d", iIdx,
334334 (void*)pSmt->pReadySliceCodingEvent[iIdx], name, err, errno);
335335
336− pSmt->pThreadBsBuffer[iIdx] = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pSmt->pThreadBsBuffer");
337− WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pThreadBsBuffer[iIdx]), FreeMemorySvc (ppCtx))
338−
339336 pSmt->pSliceInThread[iIdx] = (SSlice*)pMa->WelsMalloc (sizeof (SSlice)*iMaxSliceNumInThread, "pSmt->pSliceInThread");
340337 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceInThread[iIdx]), FreeMemorySvc (ppCtx))
341338
@@ -350,6 +347,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 8 unmodified lines
350347 pSmt->piSliceIndexInThread[iIdx] = NULL;
351348 }
352349
350+
353351 WelsSnprintf (name, SEM_NAME_MAX, "scm%s", pSmt->eventNamespace);
354352 err = WelsEventOpen (&pSmt->pSliceCodedMasterEvent, name);
355353 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pSliceCodedMasterEvent named(%s) ret%d err%d", name, err, errno);
@@ -360,6 +358,17 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 4 unmodified lines
360358 (*ppCtx)->pTaskManage = IWelsTaskManage::CreateTaskManage (*ppCtx, iNumSpatialLayers, bDynamicSlice);
361359 WELS_VERIFY_RETURN_PROC_IF (iReturn, (NULL == (*ppCtx)->pTaskManage), FreeMemorySvc (ppCtx))
362360
361+ int32_t iThreadBufferNum = WELS_MIN((*ppCtx)->pTaskManage->GetThreadPoolThreadNum(), MAX_THREADS_NUM);
362+ for (iIdx = 0;iIdx < iThreadBufferNum; iIdx++) {
363+ pSmt->pThreadBsBuffer[iIdx] = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pSmt->pThreadBsBuffer");
364+ WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pThreadBsBuffer[iIdx]), FreeMemorySvc (ppCtx))
365+ }
366+ if (iThreadBufferNum < MAX_THREADS_NUM) {
367+ for (iIdx = iThreadBufferNum; iIdx < MAX_THREADS_NUM; iIdx++) {
368+ pSmt->pThreadBsBuffer[iIdx] = NULL;
369+ }
370+ }
371+
363372 memset (&pSmt->bThreadBsBufferUsage, 0, MAX_THREADS_NUM * sizeof (bool));
364373 iReturn = WelsMutexInit (&pSmt->mutexThreadBsBufferUsage);
365374 WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))

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