History

adjust encoder tasks, add ut and enable new thread pool under some slice modes

Sijia Chen committed 11 years ago

Commit 054a2971 parent 1a7a3e215 files · +330 −44Browse files

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

Unified · Split

codec/encoder/core/src/slice_multi_threading.cpp+19−0
@@ -333,6 +333,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 332 unmodified lines
333333 int32_t iIdx = 0;
334334 int16_t iMaxSliceNum = 1;
335335 int32_t iReturn = ENC_RETURN_SUCCESS;
336+ bool bWillUseTaskManage = false;
336337
337338 if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0)
338339 return 1;
@@ -372,6 +373,10 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 33 unmodified lines
372373 pSmt->pSliceConsumeTime[iIdx] = NULL;
373374 pSmt->pSliceComplexRatio[iIdx] = NULL;
374375 }
376+
377+ if ( pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE || pMso->uiSliceMode == SM_RASTER_SLICE || pMso->uiSliceMode == SM_ROWMB_SLICE) {
378+ bWillUseTaskManage = true;
379+ }
375380 ++ iIdx;
376381 }
377382 // NULL for pSliceConsumeTime[iIdx]: iIdx from iNumSpatialLayers to MAX_DEPENDENCY_LAYERS
@@ -430,9 +435,11 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 52 unmodified lines
430435 pSmt->pThreadBsBuffer[iIdx] = NULL;
431436 }
432437
438+ //previous conflict
433439 WelsSnprintf (name, SEM_NAME_MAX, "scm%s", pSmt->eventNamespace);
434440 err = WelsEventOpen (&pSmt->pSliceCodedMasterEvent, name);
435441 MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pSliceCodedMasterEvent named(%s) ret%d err%d", name, err, errno);
442+ //previous conflict ends
436443
437444
438445 iReturn = SetMultiSliceBuffer (ppCtx, pMa, pSmt, iMaxSliceNum,
@@ -444,6 +451,11 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 5 unmodified lines
444451 iReturn = WelsMutexInit (&pSmt->mutexSliceNumUpdate);
445452 WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))
446453
454+ if (bWillUseTaskManage) {
455+ (*ppCtx)->pTaskManage = IWelsTaskManage::CreateTaskManage(*ppCtx, bDynamicSlice);
456+ WELS_VERIFY_RETURN_PROC_IF (iReturn, (NULL == (*ppCtx)->pTaskManage), FreeMemorySvc (ppCtx))
457+ }
458+
447459 memset(&pSmt->bThreadBsBufferUsage, 0, MAX_THREADS_NUM * sizeof(bool));
448460 iReturn = WelsMutexInit (&pSmt->mutexThreadBsBufferUsage);
449461 WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))
@@ -530,6 +542,12 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 80 unmodified lines
530542 pMa->WelsFree ((*ppCtx)->pSliceBs, "pSliceBs");
531543 (*ppCtx)->pSliceBs = NULL;
532544 }
545+
546+ if ((*ppCtx)->pTaskManage != NULL) {
547+ delete (*ppCtx)->pTaskManage;
548+ (*ppCtx)->pTaskManage = NULL;
549+ }
550+
533551 iIdx = 0;
534552 while (iIdx < pCodingParam->iSpatialLayerNum) {
535553 if (pSmt->pSliceConsumeTime[iIdx]) {
@@ -1171,6 +1189,7 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t · 635 unmodified lines
11711189 void SetOneSliceBsBufferUnderMultithread (sWelsEncCtx* pCtx, const int32_t kiThreadIdx, const int32_t iSliceIdx) {
11721190 pCtx->pSliceBs[iSliceIdx].pBsBuffer = pCtx->pSliceThreading->pThreadBsBuffer[kiThreadIdx];
11731191 pCtx->pSliceBs[iSliceIdx].uiBsPos = 0;
1192+ //printf("SetOneSliceBsBufferUnderMultithread, thread %d, slice %d, buffer=%x\n", kiThreadIdx, iSliceIdx, pCtx->pSliceBs[iSliceIdx].pBsBuffer);
11741193 }
11751194 }
11761195

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