Simplify code by allocating the arrays of events and thread handles statically
This avoids having to malloc a whole lot of separate arrays, all which are all bounded by MAX_THREADS_NUM.
This commit is contained in:
parent
ae63f064a0
commit
1eaa38b130
@ -91,17 +91,17 @@ int32_t iEndMbIndex; // exclusive
|
||||
|
||||
typedef struct TagSliceThreading {
|
||||
SSliceThreadPrivateData* pThreadPEncCtx;// thread context, [iThreadIdx]
|
||||
WELS_THREAD_HANDLE* pThreadHandles;// thread handles, [iThreadIdx]
|
||||
WELS_EVENT* pSliceCodedEvent;// events for slice coded state, [iThreadIdx]
|
||||
WELS_EVENT* pReadySliceCodingEvent; // events for slice coding ready, [iThreadIdx]
|
||||
WELS_EVENT* pUpdateMbListEvent; // signal to update mb list neighbor for various slices
|
||||
WELS_EVENT* pFinUpdateMbListEvent; // signal to indicate finish updating mb list
|
||||
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* 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_THREAD_HANDLE* pUpdateMbListThrdHandles; // thread handles for update mb list thread, [iThreadIdx]
|
||||
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
|
||||
|
@ -316,32 +316,6 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
|
||||
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))
|
||||
|
||||
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->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))
|
||||
|
||||
#ifdef _WIN32
|
||||
pSmt->pFinSliceCodingEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pFinSliceCodingEvent");
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pFinSliceCodingEvent), FreeMemorySvc (ppCtx))
|
||||
|
||||
pSmt->pExitEncodeEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pExitEncodeEvent");
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pExitEncodeEvent), 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
|
||||
|
||||
iIdx = 0;
|
||||
while (iIdx < iNumSpatialLayers) {
|
||||
@ -515,25 +489,6 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) {
|
||||
++ iIdx;
|
||||
}
|
||||
|
||||
if (pSmt->pSliceCodedEvent != NULL) {
|
||||
pMa->WelsFree (pSmt->pSliceCodedEvent, "pSliceCodedEvent");
|
||||
pSmt->pSliceCodedEvent = NULL;
|
||||
}
|
||||
if (pSmt->pReadySliceCodingEvent != NULL) {
|
||||
pMa->WelsFree (pSmt->pReadySliceCodingEvent, "pReadySliceCodingEvent");
|
||||
pSmt->pReadySliceCodingEvent = NULL;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (pSmt->pExitEncodeEvent != NULL) {
|
||||
pMa->WelsFree (pSmt->pExitEncodeEvent, "pExitEncodeEvent");
|
||||
pSmt->pExitEncodeEvent = NULL;
|
||||
}
|
||||
if (pSmt->pFinSliceCodingEvent != NULL) {
|
||||
pMa->WelsFree (pSmt->pFinSliceCodingEvent, "pFinSliceCodingEvent");
|
||||
pSmt->pFinSliceCodingEvent = NULL;
|
||||
}
|
||||
#endif//_WIN32
|
||||
|
||||
WelsMutexDestroy (&pSmt->mutexSliceNumUpdate);
|
||||
WelsMutexDestroy (&((*ppCtx)->mutexEncoderError));
|
||||
|
||||
@ -541,10 +496,6 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) {
|
||||
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;
|
||||
@ -574,21 +525,6 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) {
|
||||
++ iIdx;
|
||||
}
|
||||
|
||||
if (pSmt->pUpdateMbListEvent != NULL) {
|
||||
pMa->WelsFree (pSmt->pUpdateMbListEvent, "pUpdateMbListEvent");
|
||||
pSmt->pUpdateMbListEvent = NULL;
|
||||
}
|
||||
if (pSmt->pFinUpdateMbListEvent != NULL) {
|
||||
pMa->WelsFree (pSmt->pFinUpdateMbListEvent, "pFinUpdateMbListEvent");
|
||||
pSmt->pFinUpdateMbListEvent = NULL;
|
||||
}
|
||||
#ifndef _WIN32
|
||||
if (pSmt->pUpdateMbListThrdHandles) {
|
||||
pMa->WelsFree (pSmt->pUpdateMbListThrdHandles, "pUpdateMbListThrdHandles");
|
||||
pSmt->pUpdateMbListThrdHandles = NULL;
|
||||
}
|
||||
#endif//!_WIN32
|
||||
|
||||
#ifdef MT_DEBUG
|
||||
// file handle for debug
|
||||
if (pSmt->pFSliceDiff) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user