fix build issue when some macro turn on
Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 1 file). Show all
Unified · Split
| @@ -207,7 +207,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 206 unmodified lines | ||
| 207 | 207 | |
| 208 | 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 | 212 | iSliceIdx = 0; |
| 213 | 213 | while (iSliceIdx + 1 < kiCountSliceNum) { |
| @@ -232,7 +232,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 18 unmodified lines | ||
| 232 | 232 | return; |
| 233 | 233 | } |
| 234 | 234 | iRunLen[iSliceIdx] = iNumMbAssigning; |
| 235 | − MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG, | |
| 235 | + MT_TRACE_LOG (&(pCtx->sLogCtx), WELS_LOG_DEBUG, | |
| 236 | 236 | "[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d", |
| 237 | 237 | iSliceIdx, pSliceInLayer[iSliceIdx].iSliceComplexRatio * 1.0f / INT_MULTIPLY, |
| 238 | 238 | pSliceInLayer[iSliceIdx].iCountMbNumInSlice, |
| @@ -241,9 +241,9 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 2 unmodified lines | ||
| 241 | 241 | iMaximalMbNum = iMbNumLeft - (kiCountSliceNum - iSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts |
| 242 | 242 | } |
| 243 | 243 | iRunLen[iSliceIdx] = iMbNumLeft; |
| 244 | − MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG, | |
| 244 | + MT_TRACE_LOG (&(pCtx->sLogCtx), WELS_LOG_DEBUG, | |
| 245 | 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 | 248 | pCurDqLayer->bNeedAdjustingSlicing = !DynamicAdjustSlicePEncCtxAll (pCurDqLayer, iRunLen); |
| 249 | 249 | } |
| @@ -257,10 +257,11 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 7 unmodified lines | ||
| 257 | 257 | int32_t iThreadNum = 0; |
| 258 | 258 | int32_t iIdx = 0; |
| 259 | 259 | int32_t iReturn = ENC_RETURN_SUCCESS; |
| 260 | − | |
| 261 | 260 | if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0) |
| 262 | 261 | return 1; |
| 263 | − | |
| 262 | +#if defined(ENABLE_TRACE_MT) | |
| 263 | + SLogContext* pLogCtx = & ((*ppCtx)->sLogCtx); | |
| 264 | +#endif | |
| 264 | 265 | pMa = (*ppCtx)->pMemAlign; |
| 265 | 266 | pPara = pCodingParam; |
| 266 | 267 | iNumSpatialLayers = pPara->iSpatialLayerNum; |
| @@ -291,7 +292,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 24 unmodified lines | ||
| 291 | 292 | pSmt->pFSliceDiff = fopen ("slice_time.txt", "wt+"); |
| 292 | 293 | #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 | 297 | char name[SEM_NAME_MAX] = {0}; |
| 297 | 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 | 307 | WelsSnprintf (name, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace); |
| 307 | 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 | 310 | WelsSnprintf (name, SEM_NAME_MAX, "tm%d%s", iIdx, pSmt->eventNamespace); |
| 310 | 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 | 313 | // length of semaphore name should be system constrained at least on mac 10.7 |
| 313 | 314 | WelsSnprintf (name, SEM_NAME_MAX, "ud%d%s", iIdx, pSmt->eventNamespace); |
| 314 | 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 | 317 | WelsSnprintf (name, SEM_NAME_MAX, "fu%d%s", iIdx, pSmt->eventNamespace); |
| 317 | 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 | 320 | errno); |
| 320 | 321 | WelsSnprintf (name, SEM_NAME_MAX, "sc%d%s", iIdx, pSmt->eventNamespace); |
| 321 | 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 | 324 | WelsSnprintf (name, SEM_NAME_MAX, "rc%d%s", iIdx, pSmt->eventNamespace); |
| 324 | 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 | 327 | (void*)pSmt->pReadySliceCodingEvent[iIdx], name, err, errno); |
| 327 | 328 | |
| 328 | 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 | 338 | WelsSnprintf (name, SEM_NAME_MAX, "scm%s", pSmt->eventNamespace); |
| 338 | 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 | 342 | iReturn = WelsMutexInit (&pSmt->mutexSliceNumUpdate); |
| 342 | 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 | 352 | iReturn = WelsMutexInit (& (*ppCtx)->mutexEncoderError); |
| 352 | 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 | 356 | pPara->iMultipleThreadIdc, |
| 356 | 357 | (*ppCtx)->iMaxSliceCount); |
| 357 | 358 | return 0; |
| @@ -567,7 +568,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 209 unmodified lines | ||
| 567 | 568 | WelsThreadSetName ("OpenH264Enc_CodingSliceThreadProc"); |
| 568 | 569 | |
| 569 | 570 | do { |
| 570 | − MT_TRACE_LOG (pEncPEncCtx, WELS_LOG_INFO, | |
| 571 | + MT_TRACE_LOG (&(pEncPEncCtx->sLogCtx), WELS_LOG_INFO, | |
| 571 | 572 | "[MT] CodingSliceThreadProc(), try to call WelsMultipleEventsWaitSingleBlocking(pEventsList= %p %p %p), pEncPEncCtx= %p!", |
| 572 | 573 | pEventsList[0], pEventsList[1], pEventsList[1], (void*)pEncPEncCtx); |
| 573 | 574 | iWaitRet = WelsMultipleEventsWaitSingleBlocking (iEventCount, |
| @@ -760,7 +761,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 186 unmodified lines | ||
| 760 | 761 | ); |
| 761 | 762 | #endif//SLICE_INFO_OUTPUT |
| 762 | 763 | |
| 763 | − MT_TRACE_LOG (pEncPEncCtx, WELS_LOG_INFO, | |
| 764 | + MT_TRACE_LOG (&(pEncPEncCtx->sLogCtx), WELS_LOG_INFO, | |
| 764 | 765 | "[MT] CodingSliceThreadProc(), coding_idx %d, iPartitionId %d, uiSliceIdx %d, iSliceSize %d, count_mb_slice %d, iEndMbInPartition %d, pCurDq->pLastCodedMbIdxOfPartition[%d] %d\n", |
| 765 | 766 | pEncPEncCtx->iCodingIndex, kiPartitionId, iSliceIdx, iSliceSize, |
| 766 | 767 | pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].iCountMbNumInSlice, |
| @@ -819,7 +820,7 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { · 52 unmodified lines | ||
| 819 | 820 | |
| 820 | 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 | 824 | return 0; |
| 824 | 825 | } |
| 825 | 826 | |
| @@ -899,7 +900,7 @@ int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) { · 73 unmodified lines | ||
| 899 | 900 | iT0 = WelsTime() - iT0; |
| 900 | 901 | if (pCtx->pSliceThreading->pFSliceDiff) { |
| 901 | 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 | 904 | iT0, iNeedAdj); |
| 904 | 905 | } |
| 905 | 906 | #endif//MT_DEBUG |
| @@ -944,7 +945,7 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 38 unmodified lines | ||
| 944 | 945 | iT1 = WelsTime() - iT1; |
| 945 | 946 | if (pCtx->pSliceThreading->pFSliceDiff) { |
| 946 | 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 | 949 | iT1, iCurDid, iNeedAdj); |
| 949 | 950 | } |
| 950 | 951 | #endif//MT_DEBUG |
| @@ -980,22 +981,21 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t · 29 unmodified lines | ||
| 980 | 981 | pPara = pCtx->pSvcParam; |
| 981 | 982 | while (iSpatialIdx < iSpatialNum) { |
| 982 | 983 | const int32_t kiDid = pDidList[iSpatialIdx]; |
| 983 | − SSliceConfig* pSliceArgument = &pPara->sDependencyLayers[kiDid].sSliceArgument; | |
| 984 | + SSliceArgument* pSliceArgument = &pPara->sSpatialLayers[kiDid].sSliceArgument; | |
| 984 | 985 | SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid]; |
| 985 | 986 | SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer; |
| 986 | 987 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; |
| 987 | 988 | const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame; |
| 988 | 989 | if (pCtx->pSliceThreading) { |
| 989 | 990 | 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 | 992 | && pPara->iMultipleThreadIdc > 1 |
| 992 | 993 | && pPara->iMultipleThreadIdc >= kuiCountSliceNum) { |
| 993 | 994 | uint32_t i = 0; |
| 994 | 995 | uint32_t uiMaxT = 0; |
| 995 | 996 | int32_t iMaxI = 0; |
| 996 | 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 | 999 | pSliceInLayer[i].uiSliceConsumeTime, pCtx->iCodingIndex, kiDid, i /*/ 1000*/); |
| 1000 | 1000 | if (pSliceInLayer[i].uiSliceConsumeTime > uiMaxT) { |
| 1001 | 1001 | uiMaxT = pSliceInLayer[i].uiSliceConsumeTime; |