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
2157 do {2157 do {
2158 if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] != NULL) // iThreadIdx is already created successfully2158 if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] != NULL) // iThreadIdx is already created successfully
2159 WelsEventSignal (& (*ppCtx)->pSliceThreading->pExitEncodeEvent[iThreadIdx]);2159 WelsEventSignal (& (*ppCtx)->pSliceThreading->pExitEncodeEvent[iThreadIdx]);
2160 WelsEventSignal (& (*ppCtx)->pSliceThreading->pThreadMasterEvent[iThreadIdx]);
2160 ++ iThreadIdx;2161 ++ iThreadIdx;
2161 } while (iThreadIdx < iThreadCount);2162 } while (iThreadIdx < iThreadCount);
2162 2163
@@ -2175,15 +2176,6 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 12 unmodified lines
2175 res);2176 res);
2176 (*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] = 0;2177 (*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] = 0;
2177 }2178 }
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 }
2187 ++ iThreadIdx;2179 ++ iThreadIdx;
2188 }2180 }
2189#endif//WIN322181#endif//WIN32
@@ -3217,6 +3209,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 1027 unmodified lines
3217 pCtx->iActiveThreadsNum = iSliceCount;3209 pCtx->iActiveThreadsNum = iSliceCount;
3218 // to fire slice coding threads3210 // to fire slice coding threads
3219 err = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],3211 err = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
3212 &pCtx->pSliceThreading->pThreadMasterEvent[0],
3220 pLayerBsInfo, iSliceCount, pCtx->pCurDqLayer->pSliceEncCtx, false);3213 pLayerBsInfo, iSliceCount, pCtx->pCurDqLayer->pSliceEncCtx, false);
3221 if (err) {3214 if (err) {
3222 WelsLog (pCtx, WELS_LOG_ERROR,3215 WelsLog (pCtx, WELS_LOG_ERROR,
@@ -3254,6 +3247,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 31 unmodified lines
3254 iNumThreadsRunning = iNumThreadsScheduled;3247 iNumThreadsRunning = iNumThreadsScheduled;
3255 // to fire slice coding threads3248 // to fire slice coding threads
3256 err = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],3249 err = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
3250 &pCtx->pSliceThreading->pThreadMasterEvent[0],
3257 pLayerBsInfo, iNumThreadsRunning, pCtx->pCurDqLayer->pSliceEncCtx, false);3251 pLayerBsInfo, iNumThreadsRunning, pCtx->pCurDqLayer->pSliceEncCtx, false);
3258 if (err) {3252 if (err) {
3259 WelsLog (pCtx, WELS_LOG_ERROR,3253 WelsLog (pCtx, WELS_LOG_ERROR,
@@ -3279,6 +3273,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 19 unmodified lines
3279 // thread_id equal to iEventId per implementation here3273 // thread_id equal to iEventId per implementation here
3280 pCtx->pSliceThreading->pThreadPEncCtx[iEventId].iSliceIndex = iIndexOfSliceToBeCoded;3274 pCtx->pSliceThreading->pThreadPEncCtx[iEventId].iSliceIndex = iIndexOfSliceToBeCoded;
3281 WelsEventSignal (&pCtx->pSliceThreading->pReadySliceCodingEvent[iEventId]);3275 WelsEventSignal (&pCtx->pSliceThreading->pReadySliceCodingEvent[iEventId]);
3276 WelsEventSignal (&pCtx->pSliceThreading->pThreadMasterEvent[iEventId]);
3282 3277
3283 ++ iIndexOfSliceToBeCoded;3278 ++ iIndexOfSliceToBeCoded;
3284 } else { // no other slices left for coding3279 } else { // no other slices left for coding
@@ -3298,6 +3293,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 13 unmodified lines
3298 3293
3299 // to fire slice coding threads3294 // to fire slice coding threads
3300 err = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],3295 err = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
3296 &pCtx->pSliceThreading->pThreadMasterEvent[0],
3301 pLayerBsInfo, kiPartitionCnt, pCtx->pCurDqLayer->pSliceEncCtx, true);3297 pLayerBsInfo, kiPartitionCnt, pCtx->pCurDqLayer->pSliceEncCtx, true);
3302 if (err) {3298 if (err) {
3303 WelsLog (pCtx, WELS_LOG_ERROR,3299 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