History

Change the unix version of WELS_EVENT to sem_t*

Typedeffing WELS_EVENT as sem_t* makes the typedef behave similarly to the windows version (typedeffed as HANDLE), unifying the code that allocates and uses these event objects (getting rid of most of the need for separate codepaths and ifdefs).

Martin Storsjö committed 12 years ago

Commit 71bc52d1 parent e9c34036 files · +25 −57Browse files

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

Unified · Split

codec/encoder/core/src/slice_multi_threading.cpp+7−28
@@ -278,11 +278,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 277 unmodified lines
278278 const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum;
279279 int32_t iThreadIdx = 0;
280280 do {
281−#ifdef _WIN32
282281 WelsEventSignal (&pCtx->pSliceThreading->pUpdateMbListEvent[iThreadIdx]);
283−#else
284− WelsEventSignal (pCtx->pSliceThreading->pUpdateMbListEvent[iThreadIdx]);
285−#endif//_WIN32
286282 ++ iThreadIdx;
287283 } while (iThreadIdx < kiThreadNum);
288284
@@ -506,13 +502,13 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 217 unmodified lines
506502 char ename[SEM_NAME_MAX] = {0};
507503 // length of semaphore name should be system constrained at least on mac 10.7
508504 WelsSnprintf (ename, SEM_NAME_MAX, "sc%d%p", iIdx, (void*) (*ppCtx));
509− WelsEventClose (pSmt->pSliceCodedEvent[iIdx], ename);
505+ WelsEventClose (&pSmt->pSliceCodedEvent[iIdx], ename);
510506 WelsSnprintf (ename, SEM_NAME_MAX, "rc%d%p", iIdx, (void*) (*ppCtx));
511− WelsEventClose (pSmt->pReadySliceCodingEvent[iIdx], ename);
507+ WelsEventClose (&pSmt->pReadySliceCodingEvent[iIdx], ename);
512508 WelsSnprintf (ename, SEM_NAME_MAX, "ud%d%p", iIdx, (void*) (*ppCtx));
513− WelsEventClose (pSmt->pUpdateMbListEvent[iIdx], ename);
509+ WelsEventClose (&pSmt->pUpdateMbListEvent[iIdx], ename);
514510 WelsSnprintf (ename, SEM_NAME_MAX, "fu%d%p", iIdx, (void*) (*ppCtx));
515− WelsEventClose (pSmt->pFinUpdateMbListEvent[iIdx], ename);
511+ WelsEventClose (&pSmt->pFinUpdateMbListEvent[iIdx], ename);
516512 #endif//_WIN32
517513
518514 ++ iIdx;
@@ -780,12 +776,12 @@ WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg) { · 261 unmodified lines
780776 WelsLog (pEncPEncCtx, WELS_LOG_INFO, "[MT] UpdateMbListThreadProc(), try to wait (pUpdateMbListEvent[%d])!\n",
781777 iEventIdx);
782778 #endif
783− iWaitRet = WelsEventWait (pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx]);
779+ iWaitRet = WelsEventWait (&pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx]);
784780 if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) {
785781 pCurDq = pEncPEncCtx->pCurDqLayer;
786782 UpdateMbListNeighborParallel (pCurDq->pSliceEncCtx, pCurDq->sMbDataP, iSliceIdx);
787783 WelsEventSignal (
788− pEncPEncCtx->pSliceThreading->pFinUpdateMbListEvent[iEventIdx]); // mean finished update pMb list for this pSlice
784+ &pEncPEncCtx->pSliceThreading->pFinUpdateMbListEvent[iEventIdx]); // mean finished update pMb list for this pSlice
789785 } else {
790786 WelsLog (pEncPEncCtx, WELS_LOG_WARNING,
791787 "[MT] UpdateMbListThreadProc(), waiting pUpdateMbListEvent[%d] failed(%d) and thread%d terminated!\n", iEventIdx,
@@ -848,7 +844,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 56 unmodified lines
848844 "[MT] CodingSliceThreadProc(), try to call WelsEventWait(pReadySliceCodingEvent[%d]= 0x%p), pEncPEncCtx= 0x%p!\n",
849845 iEventIdx, (void*) (pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx]), (void*)pEncPEncCtx);
850846 #endif
851− iWaitRet = WelsEventWait (pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx]);
847+ iWaitRet = WelsEventWait (&pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx]);
852848 #endif//WIN32
853849 if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited
854850 SLayerBSInfo* pLbi = pPrivateData->pLayerBs;
@@ -958,12 +954,8 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 103 unmodified lines
958954 pSliceBs->bSliceCodedFlag = true;
959955 #endif//MT_DEBUG_BS_WR
960956
961−#ifdef _WIN32
962957 WelsEventSignal (
963958 &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
964−#else
965− WelsEventSignal (pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
966−#endif//WIN32
967959 } else { // for SM_DYN_SLICE parallelization
968960 SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;
969961 const int32_t kiPartitionId = iThreadIdx;
@@ -1068,11 +1060,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 98 unmodified lines
10681060 if (uiThrdRet) // any exception??
10691061 break;
10701062
1071−#ifdef _WIN32
10721063 WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
1073−#else
1074− WelsEventSignal (pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
1075−#endif//WIN32
10761064 }
10771065 }
10781066 #ifdef _WIN32
@@ -1152,13 +1140,8 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { · 73 unmodified lines
11521140 return 0;
11531141 }
11541142
1155−#ifdef _WIN32
11561143 int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, SLayerBSInfo* pLbi,
11571144 const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode)
1158−#else
1159−int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT** pEventsList, SLayerBSInfo* pLbi,
1160− const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode)
1161−#endif//WIN32
11621145 {
11631146 int32_t iEndMbIdx = 0;
11641147 int32_t iIdx = 0;
@@ -1186,12 +1169,8 @@ int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT** pEven · 21 unmodified lines
11861169 while (iIdx < kiEventCnt) {
11871170 pPriData[iIdx].pLayerBs = pLbi;
11881171 pPriData[iIdx].iSliceIndex = iIdx;
1189−#ifdef _WIN32
11901172 if (pEventsList[iIdx])
11911173 WelsEventSignal (&pEventsList[iIdx]);
1192−#else
1193− WelsEventSignal (pEventsList[iIdx]);
1194−#endif//WIN32
11951174 ++ iIdx;
11961175 }
11971176

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