History

astyle for codec/encoder/core/src/slice_multi_threading.cpp

huade committed 11 years ago

Commit 953f74a1 parent 8d288321 file · +38 −35Browse files

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

Unified · Split

codec/encoder/core/src/slice_multi_threading.cpp+38−35
@@ -205,7 +205,8 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 204 unmodified lines
205205 SSliceCtx* pSliceCtx = pCurDqLayer->pSliceEncCtx;
206206 const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame;
207207 const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame;
208− int32_t iMinimalMbNum = pSliceCtx->iMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required
208+ int32_t iMinimalMbNum =
209+ pSliceCtx->iMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required
209210 int32_t iMaximalMbNum = 0; // dynamically assign later
210211 int32_t* pSliceComplexRatio = (int32_t*)pComplexRatio;
211212 int32_t iMbNumLeft = kiCountNumMb;
@@ -348,7 +349,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 136 unmodified lines
348349 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt), FreeMemorySvc (ppCtx))
349350 (*ppCtx)->pSliceThreading = pSmt;
350351 pSmt->pThreadPEncCtx = (SSliceThreadPrivateData*)pMa->WelsMalloc (sizeof (SSliceThreadPrivateData) * iThreadNum,
351− "pThreadPEncCtx");
352+ "pThreadPEncCtx");
352353 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pThreadPEncCtx), FreeMemorySvc (ppCtx))
353354
354355 #ifdef _WIN32
@@ -375,7 +376,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 20 unmodified lines
375376 pSmt->pSliceComplexRatio[iIdx] = NULL;
376377 }
377378
378− if ( pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE || pSliceArgument->uiSliceMode == SM_RASTER_SLICE) {
379+ if (pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE || pSliceArgument->uiSliceMode == SM_RASTER_SLICE) {
379380 bWillUseTaskManage = true;
380381 }
381382 ++ iIdx;
@@ -452,11 +453,11 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 70 unmodified lines
452453 WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))
453454
454455 if (bWillUseTaskManage) {
455− (*ppCtx)->pTaskManage = IWelsTaskManage::CreateTaskManage(*ppCtx, iNumSpatialLayers, bDynamicSlice);
456+ (*ppCtx)->pTaskManage = IWelsTaskManage::CreateTaskManage (*ppCtx, iNumSpatialLayers, bDynamicSlice);
456457 WELS_VERIFY_RETURN_PROC_IF (iReturn, (NULL == (*ppCtx)->pTaskManage), FreeMemorySvc (ppCtx))
457458 }
458459
459− memset(&pSmt->bThreadBsBufferUsage, 0, MAX_THREADS_NUM * sizeof(bool));
460+ memset (&pSmt->bThreadBsBufferUsage, 0, MAX_THREADS_NUM * sizeof (bool));
460461 iReturn = WelsMutexInit (&pSmt->mutexThreadBsBufferUsage);
461462 WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))
462463
@@ -527,7 +528,7 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 64 unmodified lines
527528 pSmt->pThreadBsBuffer[i] = NULL;
528529 }
529530 }
530− memset(&pSmt->bThreadBsBufferUsage, 0, MAX_THREADS_NUM * sizeof(bool));
531+ memset (&pSmt->bThreadBsBufferUsage, 0, MAX_THREADS_NUM * sizeof (bool));
531532
532533 pSliceB = (*ppCtx)->pSliceBs;
533534 iIdx = 0;
@@ -752,8 +753,8 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 218 unmodified lines
752753 pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx];
753754
754755 bDsaFlag = ((pParamD->sSliceArgument.uiSliceMode == SM_FIXEDSLCNUM_SLICE) &&
755− pCodingParam->iMultipleThreadIdc > 1 &&
756− pCodingParam->iMultipleThreadIdc >= pParamD->sSliceArgument.uiSliceNum);
756+ pCodingParam->iMultipleThreadIdc > 1 &&
757+ pCodingParam->iMultipleThreadIdc >= pParamD->sSliceArgument.uiSliceNum);
757758 if (bDsaFlag)
758759 iSliceStart = WelsTime();
759760
@@ -812,7 +813,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 52 unmodified lines
812813 if (bDsaFlag) {
813814 pEncPEncCtx->pSliceThreading->pSliceConsumeTime[pEncPEncCtx->uiDependencyId][iSliceIdx] = (uint32_t) (
814815 WelsTime() - iSliceStart);
815− MT_TRACE_LOG (&(pEncPEncCtx->sLogCtx), WELS_LOG_INFO,
816+ MT_TRACE_LOG (& (pEncPEncCtx->sLogCtx), WELS_LOG_INFO,
816817 "[MT] CodingSliceThreadProc(), coding_idx %d, uiSliceIdx %d, pSliceConsumeTime %d, iSliceSize %d, pFirstMbInSlice %d, count_num_mb_in_slice %d",
817818 pEncPEncCtx->iCodingIndex, iSliceIdx,
818819 pEncPEncCtx->pSliceThreading->pSliceConsumeTime[pEncPEncCtx->uiDependencyId][iSliceIdx], iSliceSize,
@@ -848,7 +849,8 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 29 unmodified lines
848849 iSliceIdx = pPrivateData->iSliceIndex;
849850
850851 pSliceCtx->pFirstMbInSlice[iSliceIdx] = kiFirstMbInPartition;
851− pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one pSlice per partition intialized, dynamic slicing inside
852+ pCurDq->pNumSliceCodedOfPartition[kiPartitionId] =
853+ 1; // one pSlice per partition intialized, dynamic slicing inside
852854 pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1;
853855
854856 pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId] = 0;
@@ -858,9 +860,9 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 3 unmodified lines
858860 // TODO: need exception handler for not large enough of MAX_SLICES_NUM related memory usage
859861 // No idea about its solution due MAX_SLICES_NUM is fixed lenght in relevent pData structure
860862 uiThrdRet = 1;
861− WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
862− pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
863− iEventIdx);
863+ WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
864+ pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
865+ iEventIdx);
864866 }
865867
866868 SetOneSliceBsBufferUnderMultithread (pEncPEncCtx, kiPartitionId, iSliceIdx);
@@ -889,24 +891,24 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 22 unmodified lines
889891 iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType);
890892 if (ENC_RETURN_SUCCESS != iReturn) {
891893 uiThrdRet = iReturn;
892− WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
893− pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
894− iEventIdx);
894+ WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
895+ pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
896+ iEventIdx);
895897 }
896898
897899 WelsUnloadNalForSlice (pSliceBs);
898900
899901 if (0 == iSliceIdx) {
900902 iReturn = WriteSliceBs (pEncPEncCtx, pLbi->pBsBuf,
901− &pLbi->pNalLengthInByte[pLbi->iNalCount],
902− pEncPEncCtx->iFrameBsSize - pEncPEncCtx->iPosBsBuffer,
903− iSliceIdx, iSliceSize);
903+ &pLbi->pNalLengthInByte[pLbi->iNalCount],
904+ pEncPEncCtx->iFrameBsSize - pEncPEncCtx->iPosBsBuffer,
905+ iSliceIdx, iSliceSize);
904906 pLbi->iNalCount += pSliceBs->iNalIndex;
905907 if (ENC_RETURN_SUCCESS != iReturn) {
906908 uiThrdRet = iReturn;
907− WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
908− pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
909− iEventIdx);
909+ WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
910+ pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
911+ iEventIdx);
910912 }
911913 pEncPEncCtx->iPosBsBuffer += iSliceSize;
912914 } else {
@@ -915,9 +917,9 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 2 unmodified lines
915917 iSliceIdx, iSliceSize);
916918 if (ENC_RETURN_SUCCESS != iReturn) {
917919 uiThrdRet = iReturn;
918− WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
919− pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
920− iEventIdx);
920+ WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
921+ pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
922+ iEventIdx);
921923 }
922924 }
923925
@@ -942,11 +944,10 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 18 unmodified lines
942944 iSliceIdx += kiSliceIdxStep;
943945 }
944946
945− if (uiThrdRet) // any exception??
946− {
947− WELS_THREAD_SIGNAL_AND_BREAK(pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
948− pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
949− iEventIdx);
947+ if (uiThrdRet) { // any exception??
948+ WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
949+ pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
950+ iEventIdx);
950951 }
951952
952953 WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
@@ -1060,7 +1061,8 @@ int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) { · 107 unmodified lines
10601061 #endif//MT_DEBUG
10611062
10621063 pCtx->pCurDqLayer = pCurDq;
1063− memcpy((pCtx->pSliceThreading->pSliceConsumeTime[0]), (pCurDq->pSliceEncCtx->pSliceConsumeTime), pCurDq->pSliceEncCtx->iSliceNumInFrame*sizeof(uint32_t));
1064+ memcpy ((pCtx->pSliceThreading->pSliceConsumeTime[0]), (pCurDq->pSliceEncCtx->pSliceConsumeTime),
1065+ pCurDq->pSliceEncCtx->iSliceNumInFrame * sizeof (uint32_t));
10641066 // do not need adjust due to not different at both slices of consumed time
10651067 iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[0], pCurDq->pSliceEncCtx->iSliceNumInFrame);
10661068 if (iNeedAdj)
@@ -1089,10 +1091,11 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 22 unmodified lines
10891091 // if using spatial base layer for complexity estimation
10901092
10911093 const bool kbModelingFromSpatial = (pCtx->pCurDqLayer->pRefLayer != NULL && iCurDid > 0)
1092− && (pCtx->pSvcParam->sSpatialLayers[iCurDid - 1].sSliceArgument.uiSliceMode == SM_FIXEDSLCNUM_SLICE
1093− && pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sSpatialLayers[iCurDid -
1094− 1].sSliceArgument.uiSliceNum);
1095− memcpy((pCtx->pSliceThreading->pSliceConsumeTime[iCurDid]), (pCtx->pCurDqLayer->pSliceEncCtx->pSliceConsumeTime), pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame*sizeof(uint32_t));
1094+ && (pCtx->pSvcParam->sSpatialLayers[iCurDid - 1].sSliceArgument.uiSliceMode == SM_FIXEDSLCNUM_SLICE
1095+ && pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sSpatialLayers[iCurDid -
1096+ 1].sSliceArgument.uiSliceNum);
1097+ memcpy ((pCtx->pSliceThreading->pSliceConsumeTime[iCurDid]), (pCtx->pCurDqLayer->pSliceEncCtx->pSliceConsumeTime),
1098+ pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame * sizeof (uint32_t));
10961099
10971100 if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation
10981101 // do not need adjust due to not different at both slices of consumed time

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