History

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.

Martin Storsjö committed 12 years ago

Commit 1eaa38b1 parent ae63f062 files · +8 −72Browse files

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

Unified · Split

codec/encoder/core/src/slice_multi_threading.cpp+0−64
@@ -316,32 +316,6 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 315 unmodified lines
316316 pSmt->pThreadPEncCtx = (SSliceThreadPrivateData*)pMa->WelsMalloc (sizeof (SSliceThreadPrivateData) * iThreadNum,
317317 "pThreadPEncCtx");
318318 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pThreadPEncCtx), FreeMemorySvc (ppCtx))
319− pSmt->pThreadHandles = (WELS_THREAD_HANDLE*)pMa->WelsMalloc (sizeof (WELS_THREAD_HANDLE) * iThreadNum,
320− "pThreadHandles");
321− WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pThreadHandles), FreeMemorySvc (ppCtx))
322−
323− pSmt->pSliceCodedEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pSliceCodedEvent");
324− WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceCodedEvent), FreeMemorySvc (ppCtx))
325− pSmt->pReadySliceCodingEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum,
326− "pReadySliceCodingEvent");
327− WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pReadySliceCodingEvent), FreeMemorySvc (ppCtx))
328−
329− pSmt->pUpdateMbListEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pUpdateMbListEvent");
330− WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pUpdateMbListEvent), FreeMemorySvc (ppCtx))
331− pSmt->pFinUpdateMbListEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pFinUpdateMbListEvent");
332− WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pFinUpdateMbListEvent), FreeMemorySvc (ppCtx))
333−
334−#ifdef _WIN32
335− pSmt->pFinSliceCodingEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pFinSliceCodingEvent");
336− WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pFinSliceCodingEvent), FreeMemorySvc (ppCtx))
337−
338− pSmt->pExitEncodeEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pExitEncodeEvent");
339− WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pExitEncodeEvent), FreeMemorySvc (ppCtx))
340−#else
341− pSmt->pUpdateMbListThrdHandles = (WELS_THREAD_HANDLE*)pMa->WelsMalloc (sizeof (WELS_THREAD_HANDLE) * iThreadNum,
342− "pUpdateMbListThrdHandles");
343− WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pUpdateMbListThrdHandles), FreeMemorySvc (ppCtx))
344−#endif//!_WIN32
345319
346320 iIdx = 0;
347321 while (iIdx < iNumSpatialLayers) {
@@ -515,25 +489,6 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 167 unmodified lines
515489 ++ iIdx;
516490 }
517491
518− if (pSmt->pSliceCodedEvent != NULL) {
519− pMa->WelsFree (pSmt->pSliceCodedEvent, "pSliceCodedEvent");
520− pSmt->pSliceCodedEvent = NULL;
521− }
522− if (pSmt->pReadySliceCodingEvent != NULL) {
523− pMa->WelsFree (pSmt->pReadySliceCodingEvent, "pReadySliceCodingEvent");
524− pSmt->pReadySliceCodingEvent = NULL;
525− }
526−#ifdef _WIN32
527− if (pSmt->pExitEncodeEvent != NULL) {
528− pMa->WelsFree (pSmt->pExitEncodeEvent, "pExitEncodeEvent");
529− pSmt->pExitEncodeEvent = NULL;
530− }
531− if (pSmt->pFinSliceCodingEvent != NULL) {
532− pMa->WelsFree (pSmt->pFinSliceCodingEvent, "pFinSliceCodingEvent");
533− pSmt->pFinSliceCodingEvent = NULL;
534− }
535−#endif//_WIN32
536−
537492 WelsMutexDestroy (&pSmt->mutexSliceNumUpdate);
538493 WelsMutexDestroy (&((*ppCtx)->mutexEncoderError));
539494
@@ -541,10 +496,6 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 1 unmodified line
541496 pMa->WelsFree (pSmt->pThreadPEncCtx, "pThreadPEncCtx");
542497 pSmt->pThreadPEncCtx = NULL;
543498 }
544− if (pSmt->pThreadHandles != NULL) {
545− pMa->WelsFree (pSmt->pThreadHandles, "pThreadHandles");
546− pSmt->pThreadHandles = NULL;
547− }
548499
549500 pSliceB = (*ppCtx)->pSliceBs;
550501 iIdx = 0;
@@ -574,21 +525,6 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 23 unmodified lines
574525 ++ iIdx;
575526 }
576527
577− if (pSmt->pUpdateMbListEvent != NULL) {
578− pMa->WelsFree (pSmt->pUpdateMbListEvent, "pUpdateMbListEvent");
579− pSmt->pUpdateMbListEvent = NULL;
580− }
581− if (pSmt->pFinUpdateMbListEvent != NULL) {
582− pMa->WelsFree (pSmt->pFinUpdateMbListEvent, "pFinUpdateMbListEvent");
583− pSmt->pFinUpdateMbListEvent = NULL;
584− }
585−#ifndef _WIN32
586− if (pSmt->pUpdateMbListThrdHandles) {
587− pMa->WelsFree (pSmt->pUpdateMbListThrdHandles, "pUpdateMbListThrdHandles");
588− pSmt->pUpdateMbListThrdHandles = NULL;
589− }
590−#endif//!_WIN32
591−
592528 #ifdef MT_DEBUG
593529 // file handle for debug
594530 if (pSmt->pFSliceDiff) {

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