History

Merge pull request #2330 from ruil2/mt_build_1

fix build issue when some macro turn on

HaiboZhu committed 10 years ago

Commit d11f12d2 parents 67f9256 67f4dcf1 file · +24 −24Browse 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+24−24
@@ -207,7 +207,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 206 unmodified lines
207 207
208 WelsEmms();208 WelsEmms();
209 209
210 MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG, "[MT] DynamicAdjustSlicing(), iDid= %d, iCountNumMb= %d", iCurDid, kiCountNumMb);210 MT_TRACE_LOG (&(pCtx->sLogCtx), WELS_LOG_DEBUG, "[MT] DynamicAdjustSlicing(), iDid= %d, iCountNumMb= %d", iCurDid, kiCountNumMb);
211 211
212 iSliceIdx = 0;212 iSliceIdx = 0;
213 while (iSliceIdx + 1 < kiCountSliceNum) {213 while (iSliceIdx + 1 < kiCountSliceNum) {
@@ -232,7 +232,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 18 unmodified lines
232 return;232 return;
233 }233 }
234 iRunLen[iSliceIdx] = iNumMbAssigning;234 iRunLen[iSliceIdx] = iNumMbAssigning;
235 MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG,235 MT_TRACE_LOG (&(pCtx->sLogCtx), WELS_LOG_DEBUG,
236 "[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",236 "[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
237 iSliceIdx, pSliceInLayer[iSliceIdx].iSliceComplexRatio * 1.0f / INT_MULTIPLY,237 iSliceIdx, pSliceInLayer[iSliceIdx].iSliceComplexRatio * 1.0f / INT_MULTIPLY,
238 pSliceInLayer[iSliceIdx].iCountMbNumInSlice,238 pSliceInLayer[iSliceIdx].iCountMbNumInSlice,
@@ -241,9 +241,9 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 2 unmodified lines
241 iMaximalMbNum = iMbNumLeft - (kiCountSliceNum - iSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts241 iMaximalMbNum = iMbNumLeft - (kiCountSliceNum - iSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts
242 }242 }
243 iRunLen[iSliceIdx] = iMbNumLeft;243 iRunLen[iSliceIdx] = iMbNumLeft;
244 MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG,244 MT_TRACE_LOG (&(pCtx->sLogCtx), WELS_LOG_DEBUG,
245 "[MT] DynamicAdjustSlicing(), iSliceIdx= %d, pSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",245 "[MT] DynamicAdjustSlicing(), iSliceIdx= %d, pSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
246 iSliceIdx, pSliceComplexRatio[iSliceIdx] * 1.0f / INT_MULTIPLY, pSliceCtx->pCountMbNumInSlice[iSliceIdx], iMbNumLeft);246 iSliceIdx, pSliceInLayer[iSliceIdx].iSliceComplexRatio * 1.0f / INT_MULTIPLY, pSliceInLayer[iSliceIdx].iCountMbNumInSlice, iMbNumLeft);
247 247
248 pCurDqLayer->bNeedAdjustingSlicing = !DynamicAdjustSlicePEncCtxAll (pCurDqLayer, iRunLen);248 pCurDqLayer->bNeedAdjustingSlicing = !DynamicAdjustSlicePEncCtxAll (pCurDqLayer, iRunLen);
249}249}
@@ -257,10 +257,11 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 7 unmodified lines
257 int32_t iThreadNum = 0;257 int32_t iThreadNum = 0;
258 int32_t iIdx = 0;258 int32_t iIdx = 0;
259 int32_t iReturn = ENC_RETURN_SUCCESS;259 int32_t iReturn = ENC_RETURN_SUCCESS;
260
261 if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0)260 if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0)
262 return 1;261 return 1;
263 262#if defined(ENABLE_TRACE_MT)
263 SLogContext* pLogCtx = & ((*ppCtx)->sLogCtx);
264#endif
264 pMa = (*ppCtx)->pMemAlign;265 pMa = (*ppCtx)->pMemAlign;
265 pPara = pCodingParam;266 pPara = pCodingParam;
266 iNumSpatialLayers = pPara->iSpatialLayerNum;267 iNumSpatialLayers = pPara->iSpatialLayerNum;
@@ -291,7 +292,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 24 unmodified lines
291 pSmt->pFSliceDiff = fopen ("slice_time.txt", "wt+");292 pSmt->pFSliceDiff = fopen ("slice_time.txt", "wt+");
292#endif//MT_DEBUG293#endif//MT_DEBUG
293 294
294 MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "encpEncCtx= 0x%p", (void*) *ppCtx);295 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "encpEncCtx= 0x%p", (void*) *ppCtx);
295 296
296 char name[SEM_NAME_MAX] = {0};297 char name[SEM_NAME_MAX] = {0};
297 WELS_GCC_UNUSED WELS_THREAD_ERROR_CODE err = 0;298 WELS_GCC_UNUSED WELS_THREAD_ERROR_CODE err = 0;
@@ -305,24 +306,24 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 7 unmodified lines
305 306
306 WelsSnprintf (name, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace);307 WelsSnprintf (name, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace);
307 err = WelsEventOpen (&pSmt->pExitEncodeEvent[iIdx], name);308 err = WelsEventOpen (&pSmt->pExitEncodeEvent[iIdx], name);
308 MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pExitEncodeEvent%d named(%s) ret%d err%d", iIdx, name, err, errno);309 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pExitEncodeEvent%d named(%s) ret%d err%d", iIdx, name, err, errno);
309 WelsSnprintf (name, SEM_NAME_MAX, "tm%d%s", iIdx, pSmt->eventNamespace);310 WelsSnprintf (name, SEM_NAME_MAX, "tm%d%s", iIdx, pSmt->eventNamespace);
310 err = WelsEventOpen (&pSmt->pThreadMasterEvent[iIdx], name);311 err = WelsEventOpen (&pSmt->pThreadMasterEvent[iIdx], name);
311 MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pThreadMasterEvent%d named(%s) ret%d err%d", iIdx, name, err, errno);312 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pThreadMasterEvent%d named(%s) ret%d err%d", iIdx, name, err, errno);
312 // length of semaphore name should be system constrained at least on mac 10.7313 // length of semaphore name should be system constrained at least on mac 10.7
313 WelsSnprintf (name, SEM_NAME_MAX, "ud%d%s", iIdx, pSmt->eventNamespace);314 WelsSnprintf (name, SEM_NAME_MAX, "ud%d%s", iIdx, pSmt->eventNamespace);
314 err = WelsEventOpen (&pSmt->pUpdateMbListEvent[iIdx], name);315 err = WelsEventOpen (&pSmt->pUpdateMbListEvent[iIdx], name);
315 MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pUpdateMbListEvent%d named(%s) ret%d err%d", iIdx, name, err, errno);316 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pUpdateMbListEvent%d named(%s) ret%d err%d", iIdx, name, err, errno);
316 WelsSnprintf (name, SEM_NAME_MAX, "fu%d%s", iIdx, pSmt->eventNamespace);317 WelsSnprintf (name, SEM_NAME_MAX, "fu%d%s", iIdx, pSmt->eventNamespace);
317 err = WelsEventOpen (&pSmt->pFinUpdateMbListEvent[iIdx], name);318 err = WelsEventOpen (&pSmt->pFinUpdateMbListEvent[iIdx], name);
318 MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pFinUpdateMbListEvent%d named(%s) ret%d err%d", iIdx, name, err,319 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pFinUpdateMbListEvent%d named(%s) ret%d err%d", iIdx, name, err,
319 errno);320 errno);
320 WelsSnprintf (name, SEM_NAME_MAX, "sc%d%s", iIdx, pSmt->eventNamespace);321 WelsSnprintf (name, SEM_NAME_MAX, "sc%d%s", iIdx, pSmt->eventNamespace);
321 err = WelsEventOpen (&pSmt->pSliceCodedEvent[iIdx], name);322 err = WelsEventOpen (&pSmt->pSliceCodedEvent[iIdx], name);
322 MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pSliceCodedEvent%d named(%s) ret%d err%d", iIdx, name, err, errno);323 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pSliceCodedEvent%d named(%s) ret%d err%d", iIdx, name, err, errno);
323 WelsSnprintf (name, SEM_NAME_MAX, "rc%d%s", iIdx, pSmt->eventNamespace);324 WelsSnprintf (name, SEM_NAME_MAX, "rc%d%s", iIdx, pSmt->eventNamespace);
324 err = WelsEventOpen (&pSmt->pReadySliceCodingEvent[iIdx], name);325 err = WelsEventOpen (&pSmt->pReadySliceCodingEvent[iIdx], name);
325 MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pReadySliceCodingEvent%d = 0x%p named(%s) ret%d err%d", iIdx,326 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pReadySliceCodingEvent%d = 0x%p named(%s) ret%d err%d", iIdx,
326 (void*)pSmt->pReadySliceCodingEvent[iIdx], name, err, errno);327 (void*)pSmt->pReadySliceCodingEvent[iIdx], name, err, errno);
327 328
328 pSmt->pThreadBsBuffer[iIdx] = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pSmt->pThreadBsBuffer");329 pSmt->pThreadBsBuffer[iIdx] = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pSmt->pThreadBsBuffer");
@@ -336,7 +337,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 7 unmodified lines
336 337
337 WelsSnprintf (name, SEM_NAME_MAX, "scm%s", pSmt->eventNamespace);338 WelsSnprintf (name, SEM_NAME_MAX, "scm%s", pSmt->eventNamespace);
338 err = WelsEventOpen (&pSmt->pSliceCodedMasterEvent, name);339 err = WelsEventOpen (&pSmt->pSliceCodedMasterEvent, name);
339 MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pSliceCodedMasterEvent named(%s) ret%d err%d", name, err, errno);340 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pSliceCodedMasterEvent named(%s) ret%d err%d", name, err, errno);
340 341
341 iReturn = WelsMutexInit (&pSmt->mutexSliceNumUpdate);342 iReturn = WelsMutexInit (&pSmt->mutexSliceNumUpdate);
342 WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))343 WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))
@@ -351,7 +352,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 8 unmodified lines
351 iReturn = WelsMutexInit (& (*ppCtx)->mutexEncoderError);352 iReturn = WelsMutexInit (& (*ppCtx)->mutexEncoderError);
352 WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))353 WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))
353 354
354 MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "RequestMtResource(), iThreadNum=%d, iMultipleThreadIdc= %d",355 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "RequestMtResource(), iThreadNum=%d, iMultipleThreadIdc= %d",
355 pPara->iMultipleThreadIdc,356 pPara->iMultipleThreadIdc,
356 (*ppCtx)->iMaxSliceCount);357 (*ppCtx)->iMaxSliceCount);
357 return 0;358 return 0;
@@ -567,7 +568,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 209 unmodified lines
567 WelsThreadSetName ("OpenH264Enc_CodingSliceThreadProc");568 WelsThreadSetName ("OpenH264Enc_CodingSliceThreadProc");
568 569
569 do {570 do {
570 MT_TRACE_LOG (pEncPEncCtx, WELS_LOG_INFO,571 MT_TRACE_LOG (&(pEncPEncCtx->sLogCtx), WELS_LOG_INFO,
571 "[MT] CodingSliceThreadProc(), try to call WelsMultipleEventsWaitSingleBlocking(pEventsList= %p %p %p), pEncPEncCtx= %p!",572 "[MT] CodingSliceThreadProc(), try to call WelsMultipleEventsWaitSingleBlocking(pEventsList= %p %p %p), pEncPEncCtx= %p!",
572 pEventsList[0], pEventsList[1], pEventsList[1], (void*)pEncPEncCtx);573 pEventsList[0], pEventsList[1], pEventsList[1], (void*)pEncPEncCtx);
573 iWaitRet = WelsMultipleEventsWaitSingleBlocking (iEventCount,574 iWaitRet = WelsMultipleEventsWaitSingleBlocking (iEventCount,
@@ -760,7 +761,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 186 unmodified lines
760 );761 );
761#endif//SLICE_INFO_OUTPUT762#endif//SLICE_INFO_OUTPUT
762 763
763 MT_TRACE_LOG (pEncPEncCtx, WELS_LOG_INFO,764 MT_TRACE_LOG (&(pEncPEncCtx->sLogCtx), WELS_LOG_INFO,
764 "[MT] CodingSliceThreadProc(), coding_idx %d, iPartitionId %d, uiSliceIdx %d, iSliceSize %d, count_mb_slice %d, iEndMbInPartition %d, pCurDq->pLastCodedMbIdxOfPartition[%d] %d\n",765 "[MT] CodingSliceThreadProc(), coding_idx %d, iPartitionId %d, uiSliceIdx %d, iSliceSize %d, count_mb_slice %d, iEndMbInPartition %d, pCurDq->pLastCodedMbIdxOfPartition[%d] %d\n",
765 pEncPEncCtx->iCodingIndex, kiPartitionId, iSliceIdx, iSliceSize,766 pEncPEncCtx->iCodingIndex, kiPartitionId, iSliceIdx, iSliceSize,
766 pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].iCountMbNumInSlice,767 pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].iCountMbNumInSlice,
@@ -819,7 +820,7 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { · 52 unmodified lines
819 820
820 ++ iIdx;821 ++ iIdx;
821 }822 }
822 MT_TRACE_LOG (pCtx, WELS_LOG_INFO, "CreateSliceThreads() exit..");823 MT_TRACE_LOG (&(pCtx->sLogCtx), WELS_LOG_INFO, "CreateSliceThreads() exit..");
823 return 0;824 return 0;
824}825}
825 826
@@ -899,7 +900,7 @@ int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) { · 73 unmodified lines
899 iT0 = WelsTime() - iT0;900 iT0 = WelsTime() - iT0;
900 if (pCtx->pSliceThreading->pFSliceDiff) {901 if (pCtx->pSliceThreading->pFSliceDiff) {
901 fprintf (pCtx->pSliceThreading->pFSliceDiff,902 fprintf (pCtx->pSliceThreading->pFSliceDiff,
902 "%6"PRId64" us adjust time at base spatial layer, iNeedAdj %d, DynamicAdjustSlicing()\n",903 "%6" PRId64" us adjust time at base spatial layer, iNeedAdj %d, DynamicAdjustSlicing()\n",
903 iT0, iNeedAdj);904 iT0, iNeedAdj);
904 }905 }
905#endif//MT_DEBUG906#endif//MT_DEBUG
@@ -944,7 +945,7 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 38 unmodified lines
944 iT1 = WelsTime() - iT1;945 iT1 = WelsTime() - iT1;
945 if (pCtx->pSliceThreading->pFSliceDiff) {946 if (pCtx->pSliceThreading->pFSliceDiff) {
946 fprintf (pCtx->pSliceThreading->pFSliceDiff,947 fprintf (pCtx->pSliceThreading->pFSliceDiff,
947 "%6"PRId64" us adjust time at spatial layer %d, iNeedAdj %d, DynamicAdjustSlicing()\n",948 "%6" PRId64" us adjust time at spatial layer %d, iNeedAdj %d, DynamicAdjustSlicing()\n",
948 iT1, iCurDid, iNeedAdj);949 iT1, iCurDid, iNeedAdj);
949 }950 }
950#endif//MT_DEBUG951#endif//MT_DEBUG
@@ -980,22 +981,21 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t · 29 unmodified lines
980 pPara = pCtx->pSvcParam;981 pPara = pCtx->pSvcParam;
981 while (iSpatialIdx < iSpatialNum) {982 while (iSpatialIdx < iSpatialNum) {
982 const int32_t kiDid = pDidList[iSpatialIdx];983 const int32_t kiDid = pDidList[iSpatialIdx];
983 SSliceConfig* pSliceArgument = &pPara->sDependencyLayers[kiDid].sSliceArgument;984 SSliceArgument* pSliceArgument = &pPara->sSpatialLayers[kiDid].sSliceArgument;
984 SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid];985 SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid];
985 SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer;986 SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer;
986 SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;987 SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
987 const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame;988 const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame;
988 if (pCtx->pSliceThreading) {989 if (pCtx->pSliceThreading) {
989 if (pCtx->pSliceThreading->pFSliceDiff990 if (pCtx->pSliceThreading->pFSliceDiff
990 && ((pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE) || (pSliceArgument->uiSliceMode == SM_AUTO_SLICE))991 && ((pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE) || (pSliceArgument->uiSliceMode == SM_SIZELIMITED_SLICE))
991 && pPara->iMultipleThreadIdc > 1992 && pPara->iMultipleThreadIdc > 1
992 && pPara->iMultipleThreadIdc >= kuiCountSliceNum) {993 && pPara->iMultipleThreadIdc >= kuiCountSliceNum) {
993 uint32_t i = 0;994 uint32_t i = 0;
994 uint32_t uiMaxT = 0;995 uint32_t uiMaxT = 0;
995 int32_t iMaxI = 0;996 int32_t iMaxI = 0;
996 while (i < kuiCountSliceNum) {997 while (i < kuiCountSliceNum) {
997 if (pSliceInLayer[i] != NULL)998 fprintf (pCtx->pSliceThreading->pFSliceDiff, "%6d us consume_time coding_idx %d iDid %d pSlice %d\n",
998 fprintf (pCtx->pSliceThreading->pFSliceDiff, "%6d us consume_time coding_idx %d iDid %d pSlice %d\n",
999 pSliceInLayer[i].uiSliceConsumeTime, pCtx->iCodingIndex, kiDid, i /*/ 1000*/);999 pSliceInLayer[i].uiSliceConsumeTime, pCtx->iCodingIndex, kiDid, i /*/ 1000*/);
1000 if (pSliceInLayer[i].uiSliceConsumeTime > uiMaxT) {1000 if (pSliceInLayer[i].uiSliceConsumeTime > uiMaxT) {
1001 uiMaxT = pSliceInLayer[i].uiSliceConsumeTime;1001 uiMaxT = pSliceInLayer[i].uiSliceConsumeTime;

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