Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 73 files). Show all
Unified · Split
| @@ -309,11 +309,11 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 308 unmodified lines | ||
| 309 | 309 | const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum; |
| 310 | 310 | int32_t iThreadIdx = 0; |
| 311 | 311 | do { |
| 312 | −#ifdef WIN32 | |
| 312 | +#ifdef _WIN32 | |
| 313 | 313 | WelsEventSignal (&pCtx->pSliceThreading->pUpdateMbListEvent[iThreadIdx]); |
| 314 | 314 | #else |
| 315 | 315 | WelsEventSignal (pCtx->pSliceThreading->pUpdateMbListEvent[iThreadIdx]); |
| 316 | −#endif//WIN32 | |
| 316 | +#endif//_WIN32 | |
| 317 | 317 | ++ iThreadIdx; |
| 318 | 318 | } while (iThreadIdx < kiThreadNum); |
| 319 | 319 | |
| @@ -367,7 +367,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 47 unmodified lines | ||
| 367 | 367 | "pThreadHandles"); |
| 368 | 368 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pThreadHandles), FreeMemorySvc (ppCtx)) |
| 369 | 369 | |
| 370 | −#ifdef WIN32 | |
| 370 | +#ifdef _WIN32 | |
| 371 | 371 | pSmt->pSliceCodedEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pSliceCodedEvent"); |
| 372 | 372 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceCodedEvent), FreeMemorySvc (ppCtx)) |
| 373 | 373 | pSmt->pReadySliceCodingEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, |
| @@ -375,7 +375,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 1 unmodified line | ||
| 375 | 375 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pReadySliceCodingEvent), FreeMemorySvc (ppCtx)) |
| 376 | 376 | pSmt->pFinSliceCodingEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pFinSliceCodingEvent"); |
| 377 | 377 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pFinSliceCodingEvent), FreeMemorySvc (ppCtx)) |
| 378 | −#endif//WIN32 | |
| 378 | +#endif//_WIN32 | |
| 379 | 379 | |
| 380 | 380 | #if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) |
| 381 | 381 | #if defined(__GNUC__) |
| @@ -383,18 +383,18 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 1 unmodified line | ||
| 383 | 383 | "pUpdateMbListThrdHandles"); |
| 384 | 384 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pUpdateMbListThrdHandles), FreeMemorySvc (ppCtx)) |
| 385 | 385 | #endif//__GNUC__ |
| 386 | −#ifdef WIN32 | |
| 386 | +#ifdef _WIN32 | |
| 387 | 387 | pSmt->pUpdateMbListEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pUpdateMbListEvent"); |
| 388 | 388 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pUpdateMbListEvent), FreeMemorySvc (ppCtx)) |
| 389 | 389 | pSmt->pFinUpdateMbListEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pFinUpdateMbListEvent"); |
| 390 | 390 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pFinUpdateMbListEvent), FreeMemorySvc (ppCtx)) |
| 391 | −#endif//WIN32 | |
| 391 | +#endif//_WIN32 | |
| 392 | 392 | #endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) |
| 393 | 393 | |
| 394 | −#ifdef WIN32 | |
| 394 | +#ifdef _WIN32 | |
| 395 | 395 | pSmt->pExitEncodeEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pExitEncodeEvent"); |
| 396 | 396 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pExitEncodeEvent), FreeMemorySvc (ppCtx)) |
| 397 | −#endif//WIN32 | |
| 397 | +#endif//_WIN32 | |
| 398 | 398 | |
| 399 | 399 | #if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG) |
| 400 | 400 | iIdx = 0; |
| @@ -428,11 +428,11 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 27 unmodified lines | ||
| 428 | 428 | fclose (pSmt->pFSliceDiff); |
| 429 | 429 | pSmt->pFSliceDiff = NULL; |
| 430 | 430 | } |
| 431 | −#ifdef WIN32 | |
| 431 | +#ifdef _WIN32 | |
| 432 | 432 | pSmt->pFSliceDiff = fopen (".\\slice_time.txt", "wt+"); |
| 433 | 433 | #else |
| 434 | 434 | pSmt->pFSliceDiff = fopen ("/tmp/slice_time.txt", "wt+"); |
| 435 | −#endif//WIN32 | |
| 435 | +#endif//_WIN32 | |
| 436 | 436 | #endif//MT_DEBUG |
| 437 | 437 | |
| 438 | 438 | #if defined(ENABLE_TRACE_MT) |
| @@ -452,7 +452,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 13 unmodified lines | ||
| 452 | 452 | pSmt->pThreadHandles[iIdx] = 0; |
| 453 | 453 | |
| 454 | 454 | #if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) |
| 455 | −#ifdef WIN32 | |
| 455 | +#ifdef _WIN32 | |
| 456 | 456 | WelsEventInit (&pSmt->pUpdateMbListEvent[iIdx]); |
| 457 | 457 | WelsEventInit (&pSmt->pFinUpdateMbListEvent[iIdx]); |
| 458 | 458 | #else |
| @@ -468,10 +468,10 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 9 unmodified lines | ||
| 468 | 468 | #if defined(ENABLE_TRACE_MT) |
| 469 | 469 | WelsLog ((*ppCtx), WELS_LOG_INFO, "[MT] Open pFinUpdateMbListEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno); |
| 470 | 470 | #endif |
| 471 | −#endif//WIN32 | |
| 471 | +#endif//_WIN32 | |
| 472 | 472 | #endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) |
| 473 | 473 | |
| 474 | −#ifdef WIN32 | |
| 474 | +#ifdef _WIN32 | |
| 475 | 475 | WelsEventInit (&pSmt->pSliceCodedEvent[iIdx]); |
| 476 | 476 | WelsEventInit (&pSmt->pReadySliceCodingEvent[iIdx]); |
| 477 | 477 | WelsEventInit (&pSmt->pFinSliceCodingEvent[iIdx]); |
| @@ -490,7 +490,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 12 unmodified lines | ||
| 490 | 490 | WelsLog ((*ppCtx), WELS_LOG_INFO, "[MT] Open pReadySliceCodingEvent%d = 0x%p named(%s) ret%d err%d\n", iIdx, |
| 491 | 491 | (void*)pSmt->pReadySliceCodingEvent[iIdx]), (void*) (*ppCtx), err, errno); |
| 492 | 492 | #endif |
| 493 | −#endif//WIN32 | |
| 493 | +#endif//_WIN32 | |
| 494 | 494 | |
| 495 | 495 | ++ iIdx; |
| 496 | 496 | } |
| @@ -557,7 +557,7 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 60 unmodified lines | ||
| 557 | 557 | return; |
| 558 | 558 | |
| 559 | 559 | while (iIdx < iThreadNum) { |
| 560 | −#ifdef WIN32 | |
| 560 | +#ifdef _WIN32 | |
| 561 | 561 | if (pSmt->pThreadHandles != NULL && pSmt->pThreadHandles[iIdx] != NULL) |
| 562 | 562 | WelsThreadDestroy (&pSmt->pThreadHandles[iIdx]); |
| 563 | 563 | |
| @@ -592,12 +592,12 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 28 unmodified lines | ||
| 592 | 592 | ename[used_len] = '\0'; |
| 593 | 593 | WelsEventClose (pSmt->pFinUpdateMbListEvent[iIdx], ename); |
| 594 | 594 | #endif//DYNAMIC_SLICE_ASSIGN && TRY_SLICING_BALANCE |
| 595 | −#endif//WIN32 | |
| 595 | +#endif//_WIN32 | |
| 596 | 596 | |
| 597 | 597 | ++ iIdx; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | −#ifdef WIN32 | |
| 600 | +#ifdef _WIN32 | |
| 601 | 601 | if (pSmt->pExitEncodeEvent != NULL) { |
| 602 | 602 | pMa->WelsFree (pSmt->pExitEncodeEvent, "pExitEncodeEvent"); |
| 603 | 603 | pSmt->pExitEncodeEvent = NULL; |
| @@ -614,7 +614,7 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 10 unmodified lines | ||
| 614 | 614 | pMa->WelsFree (pSmt->pFinSliceCodingEvent, "pFinSliceCodingEvent"); |
| 615 | 615 | pSmt->pFinSliceCodingEvent = NULL; |
| 616 | 616 | } |
| 617 | −#endif//WIN32 | |
| 617 | +#endif//_WIN32 | |
| 618 | 618 | |
| 619 | 619 | #ifdef PACKING_ONE_SLICE_PER_LAYER |
| 620 | 620 | if (NULL != pSmt->pCountBsSizeInPartition) { |
| @@ -669,7 +669,7 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 48 unmodified lines | ||
| 669 | 669 | |
| 670 | 670 | #if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) |
| 671 | 671 | |
| 672 | −#ifdef WIN32 | |
| 672 | +#ifdef _WIN32 | |
| 673 | 673 | if (pSmt->pUpdateMbListEvent != NULL) { |
| 674 | 674 | pMa->WelsFree (pSmt->pUpdateMbListEvent, "pUpdateMbListEvent"); |
| 675 | 675 | pSmt->pUpdateMbListEvent = NULL; |
| @@ -683,7 +683,7 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 7 unmodified lines | ||
| 683 | 683 | pMa->WelsFree (pSmt->pUpdateMbListThrdHandles, "pUpdateMbListThrdHandles"); |
| 684 | 684 | pSmt->pUpdateMbListThrdHandles = NULL; |
| 685 | 685 | } |
| 686 | −#endif//WIN32 | |
| 686 | +#endif//_WIN32 | |
| 687 | 687 | |
| 688 | 688 | #endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) |
| 689 | 689 | |
| @@ -901,7 +901,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 211 unmodified lines | ||
| 901 | 901 | SDqLayer* pCurDq = NULL; |
| 902 | 902 | SSlice* pSlice = NULL; |
| 903 | 903 | SWelsSliceBs* pSliceBs = NULL; |
| 904 | −#ifdef WIN32 | |
| 904 | +#ifdef _WIN32 | |
| 905 | 905 | WELS_EVENT pEventsList[3]; |
| 906 | 906 | int32_t iEventCount = 0; |
| 907 | 907 | #endif |
| @@ -925,16 +925,16 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 17 unmodified lines | ||
| 925 | 925 | iThreadIdx = pPrivateData->iThreadIndex; |
| 926 | 926 | iEventIdx = iThreadIdx; |
| 927 | 927 | |
| 928 | −#ifdef WIN32 | |
| 928 | +#ifdef _WIN32 | |
| 929 | 929 | pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx]; |
| 930 | 930 | pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pExitEncodeEvent[iEventIdx]; |
| 931 | 931 | #if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) |
| 932 | 932 | pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx]; |
| 933 | 933 | #endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) |
| 934 | −#endif//WIN32 | |
| 934 | +#endif//_WIN32 | |
| 935 | 935 | |
| 936 | 936 | do { |
| 937 | −#ifdef WIN32 | |
| 937 | +#ifdef _WIN32 | |
| 938 | 938 | iWaitRet = WelsMultipleEventsWaitSingleBlocking (iEventCount, |
| 939 | 939 | &pEventsList[0], |
| 940 | 940 | (uint32_t) - 1); // blocking until at least one event is |
| @@ -1058,7 +1058,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 117 unmodified lines | ||
| 1058 | 1058 | pSliceBs->bSliceCodedFlag = TRUE; |
| 1059 | 1059 | #endif//MT_DEBUG_BS_WR |
| 1060 | 1060 | |
| 1061 | −#ifdef WIN32 | |
| 1061 | +#ifdef _WIN32 | |
| 1062 | 1062 | WelsEventSignal ( |
| 1063 | 1063 | &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice |
| 1064 | 1064 | #else |
| @@ -1174,14 +1174,14 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 109 unmodified lines | ||
| 1174 | 1174 | if (uiThrdRet) // any exception?? |
| 1175 | 1175 | break; |
| 1176 | 1176 | |
| 1177 | −#ifdef WIN32 | |
| 1177 | +#ifdef _WIN32 | |
| 1178 | 1178 | WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice |
| 1179 | 1179 | #else |
| 1180 | 1180 | WelsEventSignal (pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice |
| 1181 | 1181 | #endif//WIN32 |
| 1182 | 1182 | } |
| 1183 | 1183 | } |
| 1184 | −#ifdef WIN32 | |
| 1184 | +#ifdef _WIN32 | |
| 1185 | 1185 | else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 1 == iWaitRet) { // exit thread signal |
| 1186 | 1186 | uiThrdRet = 0; |
| 1187 | 1187 | break; |
| @@ -1206,7 +1206,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 18 unmodified lines | ||
| 1206 | 1206 | } |
| 1207 | 1207 | } while (1); |
| 1208 | 1208 | |
| 1209 | −#ifdef WIN32 | |
| 1209 | +#ifdef _WIN32 | |
| 1210 | 1210 | WelsEventSignal (&pEncPEncCtx->pSliceThreading->pFinSliceCodingEvent[iEventIdx]); // notify to mother encoding threading |
| 1211 | 1211 | #endif//WIN32 |
| 1212 | 1212 | |
| @@ -1216,7 +1216,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 3 unmodified lines | ||
| 1216 | 1216 | int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { |
| 1217 | 1217 | const int32_t kiThreadCount = pCtx->pSvcParam->iCountThreadsNum; |
| 1218 | 1218 | int32_t iIdx = 0; |
| 1219 | −#if defined(WIN32) && defined(BIND_CPU_CORES_TO_THREADS) | |
| 1219 | +#if defined(_WIN32) && defined(BIND_CPU_CORES_TO_THREADS) | |
| 1220 | 1220 | DWORD dwProcessAffinity; |
| 1221 | 1221 | DWORD dwSystemAffinity; |
| 1222 | 1222 | GetProcessAffinityMask (GetCurrentProcess(), &dwProcessAffinity, &dwSystemAffinity); |
| @@ -1225,7 +1225,7 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { · 2 unmodified lines | ||
| 1225 | 1225 | while (iIdx < kiThreadCount) { |
| 1226 | 1226 | WelsThreadCreate (&pCtx->pSliceThreading->pThreadHandles[iIdx], CodingSliceThreadProc, |
| 1227 | 1227 | &pCtx->pSliceThreading->pThreadPEncCtx[iIdx], 0); |
| 1228 | −#if defined(WIN32) && defined(BIND_CPU_CORES_TO_THREADS) | |
| 1228 | +#if defined(_WIN32) && defined(BIND_CPU_CORES_TO_THREADS) | |
| 1229 | 1229 | if (dwProcessAffinity > 1 |
| 1230 | 1230 | && pCtx->pSliceThreading->pThreadHandles[iIdx] != NULL) { // multiple cores and thread created successfully |
| 1231 | 1231 | DWORD dw = 0; |
| @@ -1264,7 +1264,7 @@ void ResetCountBsSizeInPartitions (uint32_t* pCountBsSizeList, const int32_t iPa · 32 unmodified lines | ||
| 1264 | 1264 | } |
| 1265 | 1265 | #endif//PACKING_ONE_SLICE_PER_LAYER |
| 1266 | 1266 | |
| 1267 | −#ifdef WIN32 | |
| 1267 | +#ifdef _WIN32 | |
| 1268 | 1268 | int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, SLayerBSInfo* pLbi, |
| 1269 | 1269 | const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const BOOL_T bIsDynamicSlicingMode) |
| 1270 | 1270 | #else |
| @@ -1299,7 +1299,7 @@ int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT** pEven · 28 unmodified lines | ||
| 1299 | 1299 | while (iIdx < kiEventCnt) { |
| 1300 | 1300 | pPriData[iIdx].pLayerBs = pLbi; |
| 1301 | 1301 | pPriData[iIdx].iSliceIndex = iIdx; |
| 1302 | −#ifdef WIN32 | |
| 1302 | +#ifdef _WIN32 | |
| 1303 | 1303 | if (pEventsList[iIdx]) |
| 1304 | 1304 | WelsEventSignal (&pEventsList[iIdx]); |
| 1305 | 1305 | #else |
| @@ -1325,7 +1325,7 @@ int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT** pEven · 19 unmodified lines | ||
| 1325 | 1325 | while (iIdx < kiEventCnt) { |
| 1326 | 1326 | pPriData[iIdx].pLayerBs = pLbi; |
| 1327 | 1327 | pPriData[iIdx].iSliceIndex = iIdx; |
| 1328 | −#ifdef WIN32 | |
| 1328 | +#ifdef _WIN32 | |
| 1329 | 1329 | if (pEventsList[iIdx]) |
| 1330 | 1330 | WelsEventSignal (&pEventsList[iIdx]); |
| 1331 | 1331 | #else |
| @@ -1371,7 +1371,7 @@ int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) { · 39 unmodified lines | ||
| 1371 | 1371 | iT0 = WelsTime() - iT0; |
| 1372 | 1372 | if (pCtx->pSliceThreading->pFSliceDiff) { |
| 1373 | 1373 | fprintf (pCtx->pSliceThreading->pFSliceDiff, |
| 1374 | −#ifdef WIN32 | |
| 1374 | +#ifdef _WIN32 | |
| 1375 | 1375 | "%6I64d us adjust time at base spatial layer, iNeedAdj %d, DynamicAdjustSlicing()\n", |
| 1376 | 1376 | #else |
| 1377 | 1377 | "%6lld us adjust time at base spatial layer, iNeedAdj %d, DynamicAdjustSlicing()\n", |
| @@ -1429,7 +1429,7 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 51 unmodified lines | ||
| 1429 | 1429 | iT1 = WelsTime() - iT1; |
| 1430 | 1430 | if (pCtx->pSliceThreading->pFSliceDiff) { |
| 1431 | 1431 | fprintf (pCtx->pSliceThreading->pFSliceDiff, |
| 1432 | −#ifdef WIN32 | |
| 1432 | +#ifdef _WIN32 | |
| 1433 | 1433 | "%6I64d us adjust time at spatial layer %d, iNeedAdj %d, DynamicAdjustSlicing()\n", |
| 1434 | 1434 | #else |
| 1435 | 1435 | "%6lld us adjust time at spatial layer %d, iNeedAdj %d, DynamicAdjustSlicing()\n", |