shithub: openh264

Download patch

ref: adb27ff0b1d407ad467ed53811a481bf1199db91
parent: ced9e41b5d5923e94877cab1e2e1658b91ccb77a
parent: 1eaa38b1306118b82eb3d0aaeaf2c3aceaa35a6f
author: volvet <qizh@cisco.com>
date: Wed Mar 5 07:31:15 EST 2014

Merge pull request #405 from mstorsjo/simplify-threads

Adjust WELS_EVENT definitions to allow sharing more code between unix and win32 codepaths

--- a/codec/common/WelsThreadLib.cpp
+++ b/codec/common/WelsThreadLib.cpp
@@ -255,14 +255,14 @@
 // unnamed semaphores aren't supported on OS X
 
 WELS_THREAD_ERROR_CODE    WelsEventInit (WELS_EVENT* event) {
-  return sem_init (event, 0, 0);
+  return sem_init (*event, 0, 0);
 }
 
 WELS_THREAD_ERROR_CODE   WelsEventDestroy (WELS_EVENT* event) {
-  return sem_destroy (event);	// match with sem_init
+  return sem_destroy (*event);	// match with sem_init
 }
 
-WELS_THREAD_ERROR_CODE    WelsEventOpen (WELS_EVENT** p_event, const char* event_name) {
+WELS_THREAD_ERROR_CODE    WelsEventOpen (WELS_EVENT* p_event, const char* event_name) {
   if (p_event == NULL || event_name == NULL)
     return WELS_THREAD_ERROR_GENERAL;
   *p_event = sem_open (event_name, O_CREAT, (S_IRUSR | S_IWUSR)/*0600*/, 0);
@@ -275,7 +275,7 @@
   }
 }
 WELS_THREAD_ERROR_CODE    WelsEventClose (WELS_EVENT* event, const char* event_name) {
-  WELS_THREAD_ERROR_CODE err = sem_close (event);	// match with sem_open
+  WELS_THREAD_ERROR_CODE err = sem_close (*event);	// match with sem_open
   if (event_name)
     sem_unlink (event_name);
   return err;
@@ -286,7 +286,7 @@
 //	int32_t val = 0;
 //	sem_getvalue(event, &val);
 //	fprintf( stderr, "before signal it, val= %d..\n",val );
-  err = sem_post (event);
+  err = sem_post (*event);
 //	sem_getvalue(event, &val);
 //	fprintf( stderr, "after signal it, val= %d..\n",val );
   return err;
@@ -293,18 +293,18 @@
 }
 
 WELS_THREAD_ERROR_CODE   WelsEventWait (WELS_EVENT* event) {
-  return sem_wait (event);	// blocking until signaled
+  return sem_wait (*event);	// blocking until signaled
 }
 
 WELS_THREAD_ERROR_CODE    WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds) {
   if (dwMilliseconds != (uint32_t) - 1) {
-    return sem_wait (event);
+    return sem_wait (*event);
   } else {
 #if defined(__APPLE__)
     int32_t err = 0;
     int32_t wait_count = 0;
     do {
-      err = sem_trywait (event);
+      err = sem_trywait (*event);
       if (WELS_THREAD_ERROR_OK == err)
         break;// WELS_THREAD_ERROR_OK;
       else if (wait_count > 0)
@@ -323,13 +323,13 @@
     ts.tv_sec = tv.tv_sec + ts.tv_nsec / 1000000000;
     ts.tv_nsec %= 1000000000;
 
-    return sem_timedwait (event, &ts);
+    return sem_timedwait (*event, &ts);
 #endif//__APPLE__
   }
 }
 
 WELS_THREAD_ERROR_CODE    WelsMultipleEventsWaitSingleBlocking (uint32_t nCount,
-    WELS_EVENT** event_list,
+    WELS_EVENT* event_list,
     uint32_t dwMilliseconds) {
   // bWaitAll = FALSE && blocking
   uint32_t nIdx = 0;
@@ -401,7 +401,7 @@
   return WELS_THREAD_ERROR_WAIT_FAILED;
 }
 
-WELS_THREAD_ERROR_CODE    WelsMultipleEventsWaitAllBlocking (uint32_t nCount, WELS_EVENT** event_list) {
+WELS_THREAD_ERROR_CODE    WelsMultipleEventsWaitAllBlocking (uint32_t nCount, WELS_EVENT* event_list) {
   // bWaitAll = TRUE && blocking
   uint32_t nIdx = 0;
 //	const uint32_t kuiAccessTime = (uint32_t)-1;// 1 ms once
--- a/codec/common/WelsThreadLib.h
+++ b/codec/common/WelsThreadLib.h
@@ -79,7 +79,7 @@
 typedef  void* (*LPWELS_THREAD_ROUTINE) (void*);
 
 typedef   pthread_mutex_t           WELS_MUTEX;
-typedef   sem_t                     WELS_EVENT;
+typedef   sem_t*                    WELS_EVENT;
 
 #define   WELS_THREAD_ROUTINE_TYPE         void *
 #define   WELS_THREAD_ROUTINE_RETURN(rc)   return (void*)(intptr_t)rc;
@@ -106,7 +106,7 @@
 WELS_THREAD_ERROR_CODE    WelsMutexDestroy (WELS_MUTEX* mutex);
 
 #ifndef _WIN32
-WELS_THREAD_ERROR_CODE    WelsEventOpen (WELS_EVENT** p_event, const char* event_name);
+WELS_THREAD_ERROR_CODE    WelsEventOpen (WELS_EVENT* p_event, const char* event_name);
 WELS_THREAD_ERROR_CODE    WelsEventClose (WELS_EVENT* event, const char* event_name);
 #endif//!_WIN32
 WELS_THREAD_ERROR_CODE    WelsEventInit (WELS_EVENT* event);
@@ -114,15 +114,9 @@
 WELS_THREAD_ERROR_CODE    WelsEventSignal (WELS_EVENT* event);
 WELS_THREAD_ERROR_CODE    WelsEventWait (WELS_EVENT* event);
 WELS_THREAD_ERROR_CODE    WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds);
-#ifdef _WIN32
 WELS_THREAD_ERROR_CODE    WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, WELS_EVENT* event_list,
     uint32_t dwMilliseconds);
 WELS_THREAD_ERROR_CODE    WelsMultipleEventsWaitAllBlocking (uint32_t nCount, WELS_EVENT* event_list);
-#else
-WELS_THREAD_ERROR_CODE    WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, WELS_EVENT** event_list,
-    uint32_t dwMilliseconds);
-WELS_THREAD_ERROR_CODE    WelsMultipleEventsWaitAllBlocking (uint32_t nCount, WELS_EVENT** event_list);
-#endif//_WIN32
 
 WELS_THREAD_ERROR_CODE    WelsThreadCreate (WELS_THREAD_HANDLE* thread,  LPWELS_THREAD_ROUTINE  routine,
     void* arg, WELS_THREAD_ATTR attr);
--- a/codec/encoder/core/inc/mt_defs.h
+++ b/codec/encoder/core/inc/mt_defs.h
@@ -91,26 +91,17 @@
 
 typedef struct TagSliceThreading {
 SSliceThreadPrivateData*	pThreadPEncCtx;// thread context, [iThreadIdx]
-WELS_THREAD_HANDLE*			pThreadHandles;// thread handles, [iThreadIdx]
+WELS_THREAD_HANDLE			pThreadHandles[MAX_THREADS_NUM];// thread handles, [iThreadIdx]
+WELS_EVENT					pSliceCodedEvent[MAX_THREADS_NUM];// events for slice coded state, [iThreadIdx]
+WELS_EVENT					pReadySliceCodingEvent[MAX_THREADS_NUM];	// events for slice coding ready, [iThreadIdx]
+WELS_EVENT					pUpdateMbListEvent[MAX_THREADS_NUM];		// signal to update mb list neighbor for various slices
+WELS_EVENT					pFinUpdateMbListEvent[MAX_THREADS_NUM];	// signal to indicate finish updating mb list
 #ifdef _WIN32
-WELS_EVENT*					pSliceCodedEvent;// events for slice coded state, [iThreadIdx]
-WELS_EVENT*					pReadySliceCodingEvent;	// events for slice coding ready, [iThreadIdx]
-WELS_EVENT*					pFinSliceCodingEvent;	// notify slice coding thread is done
-WELS_EVENT*					pExitEncodeEvent;			// event for exit encoding event
+WELS_EVENT					pFinSliceCodingEvent[MAX_THREADS_NUM];	// notify slice coding thread is done
+WELS_EVENT					pExitEncodeEvent[MAX_THREADS_NUM];			// event for exit encoding event
 #else
-WELS_EVENT*					pSliceCodedEvent[MAX_THREADS_NUM];// events for slice coded state, [iThreadIdx]
-WELS_EVENT*					pReadySliceCodingEvent[MAX_THREADS_NUM];	// events for slice coding ready, [iThreadIdx]
-#endif//_WIN32
 
-#if !defined(_WIN32)
-WELS_THREAD_HANDLE*			pUpdateMbListThrdHandles;	// thread handles for update mb list thread, [iThreadIdx]
-#endif//!_WIN32
-#ifdef _WIN32
-WELS_EVENT*					pUpdateMbListEvent;		// signal to update mb list neighbor for various slices
-WELS_EVENT*					pFinUpdateMbListEvent;	// signal to indicate finish updating mb list
-#else
-WELS_EVENT*					pUpdateMbListEvent[MAX_THREADS_NUM];		// signal to update mb list neighbor for various slices
-WELS_EVENT*					pFinUpdateMbListEvent[MAX_THREADS_NUM];	// signal to indicate finish updating mb list
+WELS_THREAD_HANDLE			pUpdateMbListThrdHandles[MAX_THREADS_NUM];	// thread handles for update mb list thread, [iThreadIdx]
 #endif//_WIN32
 
 WELS_MUTEX					mutexSliceNumUpdate;	// for dynamic slicing mode MT
--- a/codec/encoder/core/inc/slice_multi_threading.h
+++ b/codec/encoder/core/inc/slice_multi_threading.h
@@ -83,13 +83,8 @@
 
 int32_t CreateSliceThreads (sWelsEncCtx* pCtx);
 
-#ifdef _WIN32
 int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, SLayerBSInfo* pLayerBsInfo,
                            const uint32_t kuiNumThreads/*, int32_t *iLayerNum*/, SSliceCtx* pSliceCtx, const bool kbIsDynamicSlicingMode);
-#else
-int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT** ppEventsList, SLayerBSInfo* pLayerBsInfo,
-                           const uint32_t kuiNumThreads/*, int32_t *iLayerNum*/, SSliceCtx* pSliceCtx, const bool kbIsDynamicSlicingMode);
-#endif//_WIN32
 
 int32_t DynamicDetectCpuCores();
 
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3306,7 +3306,7 @@
                 if (iIndexOfSliceToBeCoded >= iSliceCount)
                   break;
                 pCtx->pSliceThreading->pThreadPEncCtx[iThreadIdx].iSliceIndex = iIndexOfSliceToBeCoded;
-                WelsEventSignal (pCtx->pSliceThreading->pReadySliceCodingEvent[iThreadIdx]);
+                WelsEventSignal (&pCtx->pSliceThreading->pReadySliceCodingEvent[iThreadIdx]);
 
                 ++ iIndexOfSliceToBeCoded;
                 ++ iThreadIdx;
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -278,11 +278,7 @@
     const int32_t kiThreadNum	= pCtx->pSvcParam->iCountThreadsNum;
     int32_t iThreadIdx			= 0;
     do {
-#ifdef _WIN32
       WelsEventSignal (&pCtx->pSliceThreading->pUpdateMbListEvent[iThreadIdx]);
-#else
-      WelsEventSignal (pCtx->pSliceThreading->pUpdateMbListEvent[iThreadIdx]);
-#endif//_WIN32
       ++ iThreadIdx;
     } while (iThreadIdx < kiThreadNum);
 
@@ -320,35 +316,7 @@
   pSmt->pThreadPEncCtx	= (SSliceThreadPrivateData*)pMa->WelsMalloc (sizeof (SSliceThreadPrivateData) * iThreadNum,
                           "pThreadPEncCtx");
   WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pThreadPEncCtx), FreeMemorySvc (ppCtx))
-  pSmt->pThreadHandles	= (WELS_THREAD_HANDLE*)pMa->WelsMalloc (sizeof (WELS_THREAD_HANDLE) * iThreadNum,
-                          "pThreadHandles");
-  WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pThreadHandles), FreeMemorySvc (ppCtx))
 
-#ifdef _WIN32
-  pSmt->pSliceCodedEvent	= (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pSliceCodedEvent");
-  WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceCodedEvent), FreeMemorySvc (ppCtx))
-  pSmt->pReadySliceCodingEvent	= (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum,
-                                  "pReadySliceCodingEvent");
-  WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pReadySliceCodingEvent), FreeMemorySvc (ppCtx))
-  pSmt->pFinSliceCodingEvent	= (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pFinSliceCodingEvent");
-  WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pFinSliceCodingEvent), FreeMemorySvc (ppCtx))
-#else
-  pSmt->pUpdateMbListThrdHandles	= (WELS_THREAD_HANDLE*)pMa->WelsMalloc (sizeof (WELS_THREAD_HANDLE) * iThreadNum,
-                                    "pUpdateMbListThrdHandles");
-  WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pUpdateMbListThrdHandles), FreeMemorySvc (ppCtx))
-#endif//!_WIN32
-#ifdef _WIN32
-  pSmt->pUpdateMbListEvent	= (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pUpdateMbListEvent");
-  WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pUpdateMbListEvent), FreeMemorySvc (ppCtx))
-  pSmt->pFinUpdateMbListEvent	= (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pFinUpdateMbListEvent");
-  WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pFinUpdateMbListEvent), FreeMemorySvc (ppCtx))
-#endif//_WIN32
-
-#ifdef _WIN32
-  pSmt->pExitEncodeEvent	= (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pExitEncodeEvent");
-  WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pExitEncodeEvent), FreeMemorySvc (ppCtx))
-#endif//_WIN32
-
   iIdx = 0;
   while (iIdx < iNumSpatialLayers) {
     SSliceConfig* pMso	= &pPara->sDependencyLayers[iIdx].sSliceCfg;
@@ -396,6 +364,10 @@
 #ifdef _WIN32
     WelsEventInit (&pSmt->pUpdateMbListEvent[iIdx]);
     WelsEventInit (&pSmt->pFinUpdateMbListEvent[iIdx]);
+    WelsEventInit (&pSmt->pSliceCodedEvent[iIdx]);
+    WelsEventInit (&pSmt->pReadySliceCodingEvent[iIdx]);
+    WelsEventInit (&pSmt->pFinSliceCodingEvent[iIdx]);
+    WelsEventInit (&pSmt->pExitEncodeEvent[iIdx]);
 #else
     // length of semaphore name should be system constrained at least on mac 10.7
     WelsSnprintf (name, SEM_NAME_MAX, "ud%d%p", iIdx, (void*) (*ppCtx));
@@ -408,14 +380,6 @@
 #if defined(ENABLE_TRACE_MT)
     WelsLog ((*ppCtx), WELS_LOG_INFO, "[MT] Open pFinUpdateMbListEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno);
 #endif
-#endif//_WIN32
-
-#ifdef _WIN32
-    WelsEventInit (&pSmt->pSliceCodedEvent[iIdx]);
-    WelsEventInit (&pSmt->pReadySliceCodingEvent[iIdx]);
-    WelsEventInit (&pSmt->pFinSliceCodingEvent[iIdx]);
-    WelsEventInit (&pSmt->pExitEncodeEvent[iIdx]);
-#else
     WelsSnprintf (name, SEM_NAME_MAX, "sc%d%p", iIdx, (void*) (*ppCtx));
     err = WelsEventOpen (&pSmt->pSliceCodedEvent[iIdx], name);
 #if defined(ENABLE_TRACE_MT)
@@ -513,37 +477,18 @@
     char ename[SEM_NAME_MAX] = {0};
     // length of semaphore name should be system constrained at least on mac 10.7
     WelsSnprintf (ename, SEM_NAME_MAX, "sc%d%p", iIdx, (void*) (*ppCtx));
-    WelsEventClose (pSmt->pSliceCodedEvent[iIdx], ename);
+    WelsEventClose (&pSmt->pSliceCodedEvent[iIdx], ename);
     WelsSnprintf (ename, SEM_NAME_MAX, "rc%d%p", iIdx, (void*) (*ppCtx));
-    WelsEventClose (pSmt->pReadySliceCodingEvent[iIdx], ename);
+    WelsEventClose (&pSmt->pReadySliceCodingEvent[iIdx], ename);
     WelsSnprintf (ename, SEM_NAME_MAX, "ud%d%p", iIdx, (void*) (*ppCtx));
-    WelsEventClose (pSmt->pUpdateMbListEvent[iIdx], ename);
+    WelsEventClose (&pSmt->pUpdateMbListEvent[iIdx], ename);
     WelsSnprintf (ename, SEM_NAME_MAX, "fu%d%p", iIdx, (void*) (*ppCtx));
-    WelsEventClose (pSmt->pFinUpdateMbListEvent[iIdx], ename);
+    WelsEventClose (&pSmt->pFinUpdateMbListEvent[iIdx], ename);
 #endif//_WIN32
 
     ++ iIdx;
   }
 
-#ifdef _WIN32
-  if (pSmt->pExitEncodeEvent != NULL) {
-    pMa->WelsFree (pSmt->pExitEncodeEvent, "pExitEncodeEvent");
-    pSmt->pExitEncodeEvent = NULL;
-  }
-  if (pSmt->pSliceCodedEvent != NULL) {
-    pMa->WelsFree (pSmt->pSliceCodedEvent, "pSliceCodedEvent");
-    pSmt->pSliceCodedEvent = NULL;
-  }
-  if (pSmt->pReadySliceCodingEvent != NULL) {
-    pMa->WelsFree (pSmt->pReadySliceCodingEvent, "pReadySliceCodingEvent");
-    pSmt->pReadySliceCodingEvent = NULL;
-  }
-  if (pSmt->pFinSliceCodingEvent != NULL) {
-    pMa->WelsFree (pSmt->pFinSliceCodingEvent, "pFinSliceCodingEvent");
-    pSmt->pFinSliceCodingEvent = NULL;
-  }
-#endif//_WIN32
-
   WelsMutexDestroy (&pSmt->mutexSliceNumUpdate);
   WelsMutexDestroy (&((*ppCtx)->mutexEncoderError));
 
@@ -551,10 +496,6 @@
     pMa->WelsFree (pSmt->pThreadPEncCtx, "pThreadPEncCtx");
     pSmt->pThreadPEncCtx = NULL;
   }
-  if (pSmt->pThreadHandles != NULL) {
-    pMa->WelsFree (pSmt->pThreadHandles, "pThreadHandles");
-    pSmt->pThreadHandles = NULL;
-  }
 
   pSliceB = (*ppCtx)->pSliceBs;
   iIdx = 0;
@@ -584,22 +525,6 @@
     ++ iIdx;
   }
 
-#ifdef _WIN32
-  if (pSmt->pUpdateMbListEvent != NULL) {
-    pMa->WelsFree (pSmt->pUpdateMbListEvent, "pUpdateMbListEvent");
-    pSmt->pUpdateMbListEvent = NULL;
-  }
-  if (pSmt->pFinUpdateMbListEvent != NULL) {
-    pMa->WelsFree (pSmt->pFinUpdateMbListEvent, "pFinUpdateMbListEvent");
-    pSmt->pFinUpdateMbListEvent = NULL;
-  }
-#else
-  if (pSmt->pUpdateMbListThrdHandles) {
-    pMa->WelsFree (pSmt->pUpdateMbListThrdHandles, "pUpdateMbListThrdHandles");
-    pSmt->pUpdateMbListThrdHandles = NULL;
-  }
-#endif//_WIN32
-
 #ifdef MT_DEBUG
   // file handle for debug
   if (pSmt->pFSliceDiff) {
@@ -787,12 +712,12 @@
     WelsLog (pEncPEncCtx, WELS_LOG_INFO, "[MT] UpdateMbListThreadProc(), try to wait (pUpdateMbListEvent[%d])!\n",
              iEventIdx);
 #endif
-    iWaitRet = WelsEventWait (pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx]);
+    iWaitRet = WelsEventWait (&pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx]);
     if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) {
       pCurDq			= pEncPEncCtx->pCurDqLayer;
       UpdateMbListNeighborParallel (pCurDq->pSliceEncCtx, pCurDq->sMbDataP, iSliceIdx);
       WelsEventSignal (
-        pEncPEncCtx->pSliceThreading->pFinUpdateMbListEvent[iEventIdx]);	// mean finished update pMb list for this pSlice
+        &pEncPEncCtx->pSliceThreading->pFinUpdateMbListEvent[iEventIdx]);	// mean finished update pMb list for this pSlice
     } else {
       WelsLog (pEncPEncCtx, WELS_LOG_WARNING,
                "[MT] UpdateMbListThreadProc(), waiting pUpdateMbListEvent[%d] failed(%d) and thread%d terminated!\n", iEventIdx,
@@ -855,7 +780,7 @@
              "[MT] CodingSliceThreadProc(), try to call WelsEventWait(pReadySliceCodingEvent[%d]= 0x%p), pEncPEncCtx= 0x%p!\n",
              iEventIdx, (void*) (pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx]), (void*)pEncPEncCtx);
 #endif
-    iWaitRet = WelsEventWait (pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx]);
+    iWaitRet = WelsEventWait (&pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx]);
 #endif//WIN32
     if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) {	// start pSlice coding signal waited
       SLayerBSInfo* pLbi = pPrivateData->pLayerBs;
@@ -965,12 +890,8 @@
         pSliceBs->bSliceCodedFlag	= true;
 #endif//MT_DEBUG_BS_WR
 
-#ifdef _WIN32
         WelsEventSignal (
           &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]);	// mean finished coding current pSlice
-#else
-        WelsEventSignal (pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]);	// mean finished coding current pSlice
-#endif//WIN32
       } else {	// for SM_DYN_SLICE parallelization
         SSliceCtx* pSliceCtx			= pCurDq->pSliceEncCtx;
         const int32_t kiPartitionId			= iThreadIdx;
@@ -1075,11 +996,7 @@
         if (uiThrdRet)	// any exception??
           break;
 
-#ifdef _WIN32
         WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]);	// mean finished coding current pSlice
-#else
-        WelsEventSignal (pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]);	// mean finished coding current pSlice
-#endif//WIN32
       }
     }
 #ifdef _WIN32
@@ -1159,13 +1076,8 @@
   return 0;
 }
 
-#ifdef _WIN32
 int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, SLayerBSInfo* pLbi,
                            const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode)
-#else
-int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT** pEventsList, SLayerBSInfo* pLbi,
-                           const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode)
-#endif//WIN32
 {
   int32_t iEndMbIdx	= 0;
   int32_t iIdx		= 0;
@@ -1193,12 +1105,8 @@
   while (iIdx < kiEventCnt) {
     pPriData[iIdx].pLayerBs = pLbi;
     pPriData[iIdx].iSliceIndex	= iIdx;
-#ifdef _WIN32
     if (pEventsList[iIdx])
       WelsEventSignal (&pEventsList[iIdx]);
-#else
-    WelsEventSignal (pEventsList[iIdx]);
-#endif//WIN32
     ++ iIdx;
   }