History

Use WelsMultipleEventsWaitSingleBlocking within the worker thread on unix as well

This avoids using a separate thread for handling pUpdateMbListEvent events, and later allowing using the encode exit event on unix instead of pthread cancellation.

Martin Storsjö committed 12 years ago

Commit 636df2b1 parent 801da264 files · +23 −77Browse files

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

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+5−9
@@ -2157,6 +2157,7 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 2156 unmodified lines
21572157 do {
21582158 if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] != NULL) // iThreadIdx is already created successfully
21592159 WelsEventSignal (& (*ppCtx)->pSliceThreading->pExitEncodeEvent[iThreadIdx]);
2160+ WelsEventSignal (& (*ppCtx)->pSliceThreading->pThreadMasterEvent[iThreadIdx]);
21602161 ++ iThreadIdx;
21612162 } while (iThreadIdx < iThreadCount);
21622163
@@ -2175,15 +2176,6 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 12 unmodified lines
21752176 res);
21762177 (*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] = 0;
21772178 }
2178− if ((*ppCtx)->pSliceThreading->pUpdateMbListThrdHandles[iThreadIdx]) {
2179− res = WelsThreadCancel ((*ppCtx)->pSliceThreading->pUpdateMbListThrdHandles[iThreadIdx]);
2180− WelsLog (*ppCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), WelsThreadCancel(pUpdateMbListThrdHandles%d) return %d..\n",
2181− iThreadIdx, res);
2182− res = WelsThreadJoin ((*ppCtx)->pSliceThreading->pUpdateMbListThrdHandles[iThreadIdx]); // waiting thread exit
2183− WelsLog (*ppCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), pthread_join(pUpdateMbListThrdHandles%d) return %d..\n",
2184− iThreadIdx, res);
2185− (*ppCtx)->pSliceThreading->pUpdateMbListThrdHandles[iThreadIdx] = 0;
2186− }
21872179 ++ iThreadIdx;
21882180 }
21892181 #endif//WIN32
@@ -3217,6 +3209,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 1027 unmodified lines
32173209 pCtx->iActiveThreadsNum = iSliceCount;
32183210 // to fire slice coding threads
32193211 err = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
3212+ &pCtx->pSliceThreading->pThreadMasterEvent[0],
32203213 pLayerBsInfo, iSliceCount, pCtx->pCurDqLayer->pSliceEncCtx, false);
32213214 if (err) {
32223215 WelsLog (pCtx, WELS_LOG_ERROR,
@@ -3254,6 +3247,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 31 unmodified lines
32543247 iNumThreadsRunning = iNumThreadsScheduled;
32553248 // to fire slice coding threads
32563249 err = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
3250+ &pCtx->pSliceThreading->pThreadMasterEvent[0],
32573251 pLayerBsInfo, iNumThreadsRunning, pCtx->pCurDqLayer->pSliceEncCtx, false);
32583252 if (err) {
32593253 WelsLog (pCtx, WELS_LOG_ERROR,
@@ -3279,6 +3273,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 19 unmodified lines
32793273 // thread_id equal to iEventId per implementation here
32803274 pCtx->pSliceThreading->pThreadPEncCtx[iEventId].iSliceIndex = iIndexOfSliceToBeCoded;
32813275 WelsEventSignal (&pCtx->pSliceThreading->pReadySliceCodingEvent[iEventId]);
3276+ WelsEventSignal (&pCtx->pSliceThreading->pThreadMasterEvent[iEventId]);
32823277
32833278 ++ iIndexOfSliceToBeCoded;
32843279 } else { // no other slices left for coding
@@ -3298,6 +3293,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 13 unmodified lines
32983293
32993294 // to fire slice coding threads
33003295 err = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
3296+ &pCtx->pSliceThreading->pThreadMasterEvent[0],
33013297 pLayerBsInfo, kiPartitionCnt, pCtx->pCurDqLayer->pSliceEncCtx, true);
33023298 if (err) {
33033299 WelsLog (pCtx, WELS_LOG_ERROR,

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