Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 64 files). Show all
Unified · Split
| @@ -73,17 +73,17 @@ namespace WelsEnc { · 72 unmodified lines | |||
| 73 | void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx, | 73 | void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx, |
| 74 | SMB* pMbList, | 74 | SMB* pMbList, |
| 75 | const int32_t uiSliceIdc) { | 75 | const int32_t uiSliceIdc) { |
| 76 | const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap; | 76 | const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap; |
| 77 | const int32_t kiMbWidth = pSliceCtx->iMbWidth; | 77 | const int32_t kiMbWidth = pSliceCtx->iMbWidth; |
| 78 | int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc]; | 78 | int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc]; |
| 79 | const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1; | 79 | const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1; |
| 80 | 80 | ||
| 81 | do { | 81 | do { |
| 82 | SMB* pMb = &pMbList[iIdx]; | 82 | SMB* pMb = &pMbList[iIdx]; |
| 83 | uint32_t uiNeighborAvailFlag = 0; | 83 | uint32_t uiNeighborAvailFlag = 0; |
| 84 | const int32_t kiMbXY = pMb->iMbXY; | 84 | const int32_t kiMbXY = pMb->iMbXY; |
| 85 | const int32_t kiMbX = pMb->iMbX; | 85 | const int32_t kiMbX = pMb->iMbX; |
| 86 | const int32_t kiMbY = pMb->iMbY; | 86 | const int32_t kiMbY = pMb->iMbY; |
| 87 | bool bLeft; | 87 | bool bLeft; |
| 88 | bool bTop; | 88 | bool bTop; |
| 89 | bool bLeftTop; | 89 | bool bLeftTop; |
| @@ -112,21 +112,21 @@ void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx, · 22 unmodified lines | |||
| 112 | if (bRightTop) { | 112 | if (bRightTop) { |
| 113 | uiNeighborAvailFlag |= TOPRIGHT_MB_POS; | 113 | uiNeighborAvailFlag |= TOPRIGHT_MB_POS; |
| 114 | } | 114 | } |
| 115 | pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag; | 115 | pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag; |
| 116 | pMb->uiSliceIdc = uiSliceIdc; | 116 | pMb->uiSliceIdc = uiSliceIdc; |
| 117 | 117 | ||
| 118 | ++ iIdx; | 118 | ++ iIdx; |
| 119 | } while (iIdx <= kiEndMbInSlice); | 119 | } while (iIdx <= kiEndMbInSlice); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSliceConsume) { | 122 | void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSliceConsume) { |
| 123 | int32_t* pRatioList = (int32_t*)pRatio; | 123 | int32_t* pRatioList = (int32_t*)pRatio; |
| 124 | int32_t iAvI[MAX_SLICES_NUM]; | 124 | int32_t iAvI[MAX_SLICES_NUM]; |
| 125 | int32_t iSumAv = 0; | 125 | int32_t iSumAv = 0; |
| 126 | uint32_t* pSliceTime = (uint32_t*)pSliceConsume; | 126 | uint32_t* pSliceTime = (uint32_t*)pSliceConsume; |
| 127 | int32_t* pCountMbInSlice = (int32_t*)pSliceCtx->pCountMbNumInSlice; | 127 | int32_t* pCountMbInSlice = (int32_t*)pSliceCtx->pCountMbNumInSlice; |
| 128 | const int32_t kiSliceCount = pSliceCtx->iSliceNumInFrame; | 128 | const int32_t kiSliceCount = pSliceCtx->iSliceNumInFrame; |
| 129 | int32_t iSliceIdx = 0; | 129 | int32_t iSliceIdx = 0; |
| 130 | 130 | ||
| 131 | WelsEmms(); | 131 | WelsEmms(); |
| 132 | 132 | ||
| @@ -145,10 +145,10 @@ void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSlice · 12 unmodified lines | |||
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) { | 147 | int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) { |
| 148 | uint32_t* pSliceConsume = (uint32_t*)pConsumeTime; | 148 | uint32_t* pSliceConsume = (uint32_t*)pConsumeTime; |
| 149 | uint32_t uiTotalConsume = 0; | 149 | uint32_t uiTotalConsume = 0; |
| 150 | int32_t iSliceIdx = 0; | 150 | int32_t iSliceIdx = 0; |
| 151 | int32_t iNeedAdj = false; | 151 | int32_t iNeedAdj = false; |
| 152 | 152 | ||
| 153 | WelsEmms(); | 153 | WelsEmms(); |
| 154 | 154 | ||
| @@ -164,9 +164,9 @@ int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) { · 9 unmodified lines | |||
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | iSliceIdx = 0; | 166 | iSliceIdx = 0; |
| 167 | float fThr = EPSN; // threshold for various cores cases | 167 | float fThr = EPSN; // threshold for various cores cases |
| 168 | float fRmse = .0f; // root mean square error of pSlice consume ratios | 168 | float fRmse = .0f; // root mean square error of pSlice consume ratios |
| 169 | const float kfMeanRatio = 1.0f / iSliceNum; | 169 | const float kfMeanRatio = 1.0f / iSliceNum; |
| 170 | do { | 170 | do { |
| 171 | const float fRatio = 1.0f * pSliceConsume[iSliceIdx] / uiTotalConsume; | 171 | const float fRatio = 1.0f * pSliceConsume[iSliceIdx] / uiTotalConsume; |
| 172 | const float fDiffRatio = fRatio - kfMeanRatio; | 172 | const float fDiffRatio = fRatio - kfMeanRatio; |
| @@ -195,15 +195,15 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 22 unmodified lines | |||
| 195 | SDqLayer* pCurDqLayer, | 195 | SDqLayer* pCurDqLayer, |
| 196 | void* pComplexRatio, | 196 | void* pComplexRatio, |
| 197 | int32_t iCurDid) { | 197 | int32_t iCurDid) { |
| 198 | SSliceCtx* pSliceCtx = pCurDqLayer->pSliceEncCtx; | 198 | SSliceCtx* pSliceCtx = pCurDqLayer->pSliceEncCtx; |
| 199 | const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame; | 199 | const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame; |
| 200 | const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame; | 200 | const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame; |
| 201 | int32_t iMinimalMbNum = pSliceCtx->iMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required | 201 | int32_t iMinimalMbNum = pSliceCtx->iMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required |
| 202 | int32_t iMaximalMbNum = 0; // dynamically assign later | 202 | int32_t iMaximalMbNum = 0; // dynamically assign later |
| 203 | int32_t* pSliceComplexRatio = (int32_t*)pComplexRatio; | 203 | int32_t* pSliceComplexRatio = (int32_t*)pComplexRatio; |
| 204 | int32_t iMbNumLeft = kiCountNumMb; | 204 | int32_t iMbNumLeft = kiCountNumMb; |
| 205 | int32_t iRunLen[MAX_THREADS_NUM] = {0}; | 205 | int32_t iRunLen[MAX_THREADS_NUM] = {0}; |
| 206 | int32_t iSliceIdx = 0; | 206 | int32_t iSliceIdx = 0; |
| 207 | 207 | ||
| 208 | int32_t iNumMbInEachGom = 0; | 208 | int32_t iNumMbInEachGom = 0; |
| 209 | SWelsSvcRc* pWelsSvcRc = &pCtx->pWelsSvcRc[iCurDid]; | 209 | SWelsSvcRc* pWelsSvcRc = &pCtx->pWelsSvcRc[iCurDid]; |
| @@ -271,8 +271,8 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 61 unmodified lines | |||
| 271 | 271 | ||
| 272 | 272 | ||
| 273 | if (DynamicAdjustSlicePEncCtxAll (pSliceCtx, iRunLen) == 0) { | 273 | if (DynamicAdjustSlicePEncCtxAll (pSliceCtx, iRunLen) == 0) { |
| 274 | const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum; | 274 | const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum; |
| 275 | int32_t iThreadIdx = 0; | 275 | int32_t iThreadIdx = 0; |
| 276 | do { | 276 | do { |
| 277 | WelsEventSignal (&pCtx->pSliceThreading->pUpdateMbListEvent[iThreadIdx]); | 277 | WelsEventSignal (&pCtx->pSliceThreading->pUpdateMbListEvent[iThreadIdx]); |
| 278 | WelsEventSignal (&pCtx->pSliceThreading->pThreadMasterEvent[iThreadIdx]); | 278 | WelsEventSignal (&pCtx->pSliceThreading->pThreadMasterEvent[iThreadIdx]); |
| @@ -286,16 +286,16 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 7 unmodified lines | |||
| 286 | 286 | ||
| 287 | int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam, const int32_t iCountBsLen, | 287 | int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam, const int32_t iCountBsLen, |
| 288 | const int32_t iTargetSpatialBsSize) { | 288 | const int32_t iTargetSpatialBsSize) { |
| 289 | CMemoryAlign* pMa = NULL; | 289 | CMemoryAlign* pMa = NULL; |
| 290 | SWelsSvcCodingParam* pPara = NULL; | 290 | SWelsSvcCodingParam* pPara = NULL; |
| 291 | SSliceThreading* pSmt = NULL; | 291 | SSliceThreading* pSmt = NULL; |
| 292 | SWelsSliceBs* pSliceB = NULL; | 292 | SWelsSliceBs* pSliceB = NULL; |
| 293 | uint8_t* pBsBase = NULL; | 293 | uint8_t* pBsBase = NULL; |
| 294 | int32_t iNumSpatialLayers = 0; | 294 | int32_t iNumSpatialLayers = 0; |
| 295 | int32_t iThreadNum = 0; | 295 | int32_t iThreadNum = 0; |
| 296 | int32_t iIdx = 0; | 296 | int32_t iIdx = 0; |
| 297 | int32_t iSliceBsBufferSize = 0; | 297 | int32_t iSliceBsBufferSize = 0; |
| 298 | int16_t iMaxSliceNum = 1; | 298 | int16_t iMaxSliceNum = 1; |
| 299 | int32_t iReturn = ENC_RETURN_SUCCESS; | 299 | int32_t iReturn = ENC_RETURN_SUCCESS; |
| 300 | 300 | ||
| 301 | if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0) | 301 | if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0) |
| @@ -333,8 +333,8 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 31 unmodified lines | |||
| 333 | pSmt->pSliceComplexRatio[iIdx] = (int32_t*)pMa->WelsMalloc (kiSliceNum * sizeof (int32_t), "pSliceComplexRatio[]"); | 333 | pSmt->pSliceComplexRatio[iIdx] = (int32_t*)pMa->WelsMalloc (kiSliceNum * sizeof (int32_t), "pSliceComplexRatio[]"); |
| 334 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceComplexRatio[iIdx]), FreeMemorySvc (ppCtx)) | 334 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceComplexRatio[iIdx]), FreeMemorySvc (ppCtx)) |
| 335 | } else { | 335 | } else { |
| 336 | pSmt->pSliceConsumeTime[iIdx] = NULL; | 336 | pSmt->pSliceConsumeTime[iIdx] = NULL; |
| 337 | pSmt->pSliceComplexRatio[iIdx] = NULL; | 337 | pSmt->pSliceComplexRatio[iIdx] = NULL; |
| 338 | } | 338 | } |
| 339 | ++ iIdx; | 339 | ++ iIdx; |
| 340 | } | 340 | } |
| @@ -358,10 +358,10 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 17 unmodified lines | |||
| 358 | 358 | ||
| 359 | iIdx = 0; | 359 | iIdx = 0; |
| 360 | while (iIdx < iThreadNum) { | 360 | while (iIdx < iThreadNum) { |
| 361 | pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) *ppCtx; | 361 | pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) *ppCtx; |
| 362 | pSmt->pThreadPEncCtx[iIdx].iSliceIndex = iIdx; | 362 | pSmt->pThreadPEncCtx[iIdx].iSliceIndex = iIdx; |
| 363 | pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx; | 363 | pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx; |
| 364 | pSmt->pThreadHandles[iIdx] = 0; | 364 | pSmt->pThreadHandles[iIdx] = 0; |
| 365 | 365 | ||
| 366 | WelsSnprintf (name, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace); | 366 | WelsSnprintf (name, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace); |
| 367 | err = WelsEventOpen (&pSmt->pExitEncodeEvent[iIdx], name); | 367 | err = WelsEventOpen (&pSmt->pExitEncodeEvent[iIdx], name); |
| @@ -395,9 +395,9 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 27 unmodified lines | |||
| 395 | (*ppCtx)->pSliceBs = (SWelsSliceBs*)pMa->WelsMalloc (sizeof (SWelsSliceBs) * iMaxSliceNum, "pSliceBs"); | 395 | (*ppCtx)->pSliceBs = (SWelsSliceBs*)pMa->WelsMalloc (sizeof (SWelsSliceBs) * iMaxSliceNum, "pSliceBs"); |
| 396 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSliceBs), FreeMemorySvc (ppCtx)) | 396 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSliceBs), FreeMemorySvc (ppCtx)) |
| 397 | 397 | ||
| 398 | pBsBase = (*ppCtx)->pFrameBs + iCountBsLen; | 398 | pBsBase = (*ppCtx)->pFrameBs + iCountBsLen; |
| 399 | pSliceB = (*ppCtx)->pSliceBs; | 399 | pSliceB = (*ppCtx)->pSliceBs; |
| 400 | iSliceBsBufferSize = iTargetSpatialBsSize; | 400 | iSliceBsBufferSize = iTargetSpatialBsSize; |
| 401 | iIdx = 0; | 401 | iIdx = 0; |
| 402 | while (iIdx < iMaxSliceNum) { | 402 | while (iIdx < iMaxSliceNum) { |
| 403 | pSliceB->pBsBuffer = (uint8_t*)pMa->WelsMalloc (iSliceBsBufferSize, "pSliceB->pBsBuffer"); | 403 | pSliceB->pBsBuffer = (uint8_t*)pMa->WelsMalloc (iSliceBsBufferSize, "pSliceB->pBsBuffer"); |
| @@ -406,12 +406,12 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 2 unmodified lines | |||
| 406 | pSliceB->uiSize = iSliceBsBufferSize; | 406 | pSliceB->uiSize = iSliceBsBufferSize; |
| 407 | 407 | ||
| 408 | if (iIdx > 0) { | 408 | if (iIdx > 0) { |
| 409 | pSliceB->pBs = pBsBase; | 409 | pSliceB->pBs = pBsBase; |
| 410 | pSliceB->uiBsPos = 0; | 410 | pSliceB->uiBsPos = 0; |
| 411 | pBsBase += iSliceBsBufferSize; | 411 | pBsBase += iSliceBsBufferSize; |
| 412 | } else { | 412 | } else { |
| 413 | pSliceB->pBs = NULL; | 413 | pSliceB->pBs = NULL; |
| 414 | pSliceB->uiBsPos = 0; | 414 | pSliceB->uiBsPos = 0; |
| 415 | } | 415 | } |
| 416 | ++ pSliceB; | 416 | ++ pSliceB; |
| 417 | ++ iIdx; | 417 | ++ iIdx; |
| @@ -431,22 +431,22 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 13 unmodified lines | |||
| 431 | } | 431 | } |
| 432 | 432 | ||
| 433 | void ReleaseMtResource (sWelsEncCtx** ppCtx) { | 433 | void ReleaseMtResource (sWelsEncCtx** ppCtx) { |
| 434 | SWelsSliceBs* pSliceB = NULL; | 434 | SWelsSliceBs* pSliceB = NULL; |
| 435 | SWelsSvcCodingParam* pCodingParam = NULL; | 435 | SWelsSvcCodingParam* pCodingParam = NULL; |
| 436 | SSliceThreading* pSmt = NULL; | 436 | SSliceThreading* pSmt = NULL; |
| 437 | CMemoryAlign* pMa = NULL; | 437 | CMemoryAlign* pMa = NULL; |
| 438 | int32_t iIdx = 0; | 438 | int32_t iIdx = 0; |
| 439 | int32_t iThreadNum = 0; | 439 | int32_t iThreadNum = 0; |
| 440 | int16_t uiSliceNum = 0; | 440 | int16_t uiSliceNum = 0; |
| 441 | 441 | ||
| 442 | if (NULL == ppCtx || NULL == *ppCtx) | 442 | if (NULL == ppCtx || NULL == *ppCtx) |
| 443 | return; | 443 | return; |
| 444 | 444 | ||
| 445 | pMa = (*ppCtx)->pMemAlign; | 445 | pMa = (*ppCtx)->pMemAlign; |
| 446 | pCodingParam = (*ppCtx)->pSvcParam; | 446 | pCodingParam = (*ppCtx)->pSvcParam; |
| 447 | uiSliceNum = (*ppCtx)->iMaxSliceCount; | 447 | uiSliceNum = (*ppCtx)->iMaxSliceCount; |
| 448 | iThreadNum = (*ppCtx)->pSvcParam->iCountThreadsNum; | 448 | iThreadNum = (*ppCtx)->pSvcParam->iCountThreadsNum; |
| 449 | pSmt = (*ppCtx)->pSliceThreading; | 449 | pSmt = (*ppCtx)->pSliceThreading; |
| 450 | 450 | ||
| 451 | if (NULL == pSmt) | 451 | if (NULL == pSmt) |
| 452 | return; | 452 | return; |
| @@ -520,19 +520,19 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 67 unmodified lines | |||
| 520 | } | 520 | } |
| 521 | 521 | ||
| 522 | int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32_t iSliceCount) { | 522 | int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32_t iSliceCount) { |
| 523 | SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam; | 523 | SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam; |
| 524 | SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId]; | 524 | SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId]; |
| 525 | SWelsSliceBs* pSliceBs = NULL; | 525 | SWelsSliceBs* pSliceBs = NULL; |
| 526 | const bool kbIsDynamicSlicingMode = (pDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE); | 526 | const bool kbIsDynamicSlicingMode = (pDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE); |
| 527 | 527 | ||
| 528 | int32_t iLayerSize = 0; | 528 | int32_t iLayerSize = 0; |
| 529 | int32_t iNalIdxBase = pLbi->iNalCount; | 529 | int32_t iNalIdxBase = pLbi->iNalCount; |
| 530 | int32_t iSliceIdx = 0; | 530 | int32_t iSliceIdx = 0; |
| 531 | 531 | ||
| 532 | if (!kbIsDynamicSlicingMode) { | 532 | if (!kbIsDynamicSlicingMode) { |
| 533 | pSliceBs = &pCtx->pSliceBs[0]; | 533 | pSliceBs = &pCtx->pSliceBs[0]; |
| 534 | iLayerSize = pSliceBs->uiBsPos; // assign with base pSlice first | 534 | iLayerSize = pSliceBs->uiBsPos; // assign with base pSlice first |
| 535 | iSliceIdx = 1; // pSlice 0 bs has been written to pFrameBs yet by now, so uiSliceIdx base should be 1 | 535 | iSliceIdx = 1; // pSlice 0 bs has been written to pFrameBs yet by now, so uiSliceIdx base should be 1 |
| 536 | while (iSliceIdx < iSliceCount) { | 536 | while (iSliceIdx < iSliceCount) { |
| 537 | ++ pSliceBs; | 537 | ++ pSliceBs; |
| 538 | if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) { | 538 | if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) { |
| @@ -552,14 +552,14 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 13 unmodified lines | |||
| 552 | pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; | 552 | pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; |
| 553 | ++ iNalIdx; | 553 | ++ iNalIdx; |
| 554 | } | 554 | } |
| 555 | pLbi->iNalCount += iCountNal; | 555 | pLbi->iNalCount += iCountNal; |
| 556 | iNalIdxBase += iCountNal; | 556 | iNalIdxBase += iCountNal; |
| 557 | } | 557 | } |
| 558 | ++ iSliceIdx; | 558 | ++ iSliceIdx; |
| 559 | } | 559 | } |
| 560 | } else { // for SM_DYN_SLICE | 560 | } else { // for SM_DYN_SLICE |
| 561 | const int32_t kiPartitionCnt = iSliceCount; | 561 | const int32_t kiPartitionCnt = iSliceCount; |
| 562 | int32_t iPartitionIdx = 0; | 562 | int32_t iPartitionIdx = 0; |
| 563 | 563 | ||
| 564 | // due partition_0 has been written to pFrameBsBuffer | 564 | // due partition_0 has been written to pFrameBsBuffer |
| 565 | // so iLayerSize need add it | 565 | // so iLayerSize need add it |
| @@ -584,8 +584,8 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 18 unmodified lines | |||
| 584 | pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; | 584 | pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; |
| 585 | ++ iNalIdx; | 585 | ++ iNalIdx; |
| 586 | } | 586 | } |
| 587 | pLbi->iNalCount += iCountNal; | 587 | pLbi->iNalCount += iCountNal; |
| 588 | iNalIdxBase += iCountNal; | 588 | iNalIdxBase += iCountNal; |
| 589 | } else { | 589 | } else { |
| 590 | iLayerSize += pSliceBs->uiBsPos; | 590 | iLayerSize += pSliceBs->uiBsPos; |
| 591 | } | 591 | } |
| @@ -603,17 +603,17 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 11 unmodified lines | |||
| 603 | 603 | ||
| 604 | int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFrameBsBuffer, const int32_t iSliceIdx, | 604 | int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFrameBsBuffer, const int32_t iSliceIdx, |
| 605 | int32_t& iSliceSize) { | 605 | int32_t& iSliceSize) { |
| 606 | SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; | 606 | SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; |
| 607 | SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; | 607 | SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; |
| 608 | uint8_t* pDst = pFrameBsBuffer; | 608 | uint8_t* pDst = pFrameBsBuffer; |
| 609 | const int32_t kiNalCnt = pSliceBs->iNalIndex; | 609 | const int32_t kiNalCnt = pSliceBs->iNalIndex; |
| 610 | int32_t iNalIdx = 0; | 610 | int32_t iNalIdx = 0; |
| 611 | int32_t iNalSize = 0; | 611 | int32_t iNalSize = 0; |
| 612 | const int32_t iFirstSlice = (iSliceIdx == 0); | 612 | const int32_t iFirstSlice = (iSliceIdx == 0); |
| 613 | int32_t iNalBase = iFirstSlice ? 0 : pLbi->iNalCount; | 613 | int32_t iNalBase = iFirstSlice ? 0 : pLbi->iNalCount; |
| 614 | int32_t iReturn = ENC_RETURN_SUCCESS; | 614 | int32_t iReturn = ENC_RETURN_SUCCESS; |
| 615 | const int32_t kiWrittenLength = pCtx->iPosBsBuffer; | 615 | const int32_t kiWrittenLength = pCtx->iPosBsBuffer; |
| 616 | iSliceSize = 0; | 616 | iSliceSize = 0; |
| 617 | 617 | ||
| 618 | while (iNalIdx < kiNalCnt) { | 618 | while (iNalIdx < kiNalCnt) { |
| 619 | iNalSize = 0; | 619 | iNalSize = 0; |
| @@ -630,26 +630,26 @@ int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFr · 10 unmodified lines | |||
| 630 | pSliceBs->uiBsPos = iSliceSize; | 630 | pSliceBs->uiBsPos = iSliceSize; |
| 631 | if (iFirstSlice) { | 631 | if (iFirstSlice) { |
| 632 | // pBsBuffer has been updated at coding_slice_0_in_encoder_mother_thread() | 632 | // pBsBuffer has been updated at coding_slice_0_in_encoder_mother_thread() |
| 633 | pLbi->uiLayerType = VIDEO_CODING_LAYER; | 633 | pLbi->uiLayerType = VIDEO_CODING_LAYER; |
| 634 | pLbi->uiSpatialId = pNalHdrExt->uiDependencyId; | 634 | pLbi->uiSpatialId = pNalHdrExt->uiDependencyId; |
| 635 | pLbi->uiTemporalId = pNalHdrExt->uiTemporalId; | 635 | pLbi->uiTemporalId = pNalHdrExt->uiTemporalId; |
| 636 | pLbi->uiQualityId = 0; | 636 | pLbi->uiQualityId = 0; |
| 637 | pLbi->iNalCount = kiNalCnt; | 637 | pLbi->iNalCount = kiNalCnt; |
| 638 | } else { | 638 | } else { |
| 639 | pLbi->iNalCount += kiNalCnt; | 639 | pLbi->iNalCount += kiNalCnt; |
| 640 | } | 640 | } |
| 641 | 641 | ||
| 642 | return ENC_RETURN_SUCCESS; | 642 | return ENC_RETURN_SUCCESS; |
| 643 | } | 643 | } |
| 644 | 644 | ||
| 645 | int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSliceIdx, int32_t& iSliceSize) { | 645 | int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSliceIdx, int32_t& iSliceSize) { |
| 646 | SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; | 646 | SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; |
| 647 | SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; | 647 | SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; |
| 648 | uint8_t* pDst = pSliceBsBuf; | 648 | uint8_t* pDst = pSliceBsBuf; |
| 649 | int32_t* pNalLen = &pSliceBs->iNalLen[0]; | 649 | int32_t* pNalLen = &pSliceBs->iNalLen[0]; |
| 650 | const int32_t kiNalCnt = pSliceBs->iNalIndex; | 650 | const int32_t kiNalCnt = pSliceBs->iNalIndex; |
| 651 | int32_t iNalIdx = 0; | 651 | int32_t iNalIdx = 0; |
| 652 | int32_t iNalSize = 0; | 652 | int32_t iNalSize = 0; |
| 653 | int32_t iReturn = ENC_RETURN_SUCCESS; | 653 | int32_t iReturn = ENC_RETURN_SUCCESS; |
| 654 | const int32_t kiWrittenLength = (int32_t) (pSliceBs->sBsWrite.pCurBuf - pSliceBs->sBsWrite.pStartBuf); | 654 | const int32_t kiWrittenLength = (int32_t) (pSliceBs->sBsWrite.pCurBuf - pSliceBs->sBsWrite.pStartBuf); |
| 655 | 655 | ||
| @@ -675,34 +675,34 @@ int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSl · 19 unmodified lines | |||
| 675 | 675 | ||
| 676 | // thread process for coding one pSlice | 676 | // thread process for coding one pSlice |
| 677 | WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { | 677 | WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { |
| 678 | SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg; | 678 | SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg; |
| 679 | sWelsEncCtx* pEncPEncCtx = NULL; | 679 | sWelsEncCtx* pEncPEncCtx = NULL; |
| 680 | SDqLayer* pCurDq = NULL; | 680 | SDqLayer* pCurDq = NULL; |
| 681 | SSlice* pSlice = NULL; | 681 | SSlice* pSlice = NULL; |
| 682 | SWelsSliceBs* pSliceBs = NULL; | 682 | SWelsSliceBs* pSliceBs = NULL; |
| 683 | WELS_EVENT pEventsList[3]; | 683 | WELS_EVENT pEventsList[3]; |
| 684 | int32_t iEventCount = 0; | 684 | int32_t iEventCount = 0; |
| 685 | WELS_THREAD_ERROR_CODE iWaitRet = WELS_THREAD_ERROR_GENERAL; | 685 | WELS_THREAD_ERROR_CODE iWaitRet = WELS_THREAD_ERROR_GENERAL; |
| 686 | uint32_t uiThrdRet = 0; | 686 | uint32_t uiThrdRet = 0; |
| 687 | int32_t iSliceSize = 0; | 687 | int32_t iSliceSize = 0; |
| 688 | int32_t iSliceIdx = -1; | 688 | int32_t iSliceIdx = -1; |
| 689 | int32_t iThreadIdx = -1; | 689 | int32_t iThreadIdx = -1; |
| 690 | int32_t iEventIdx = -1; | 690 | int32_t iEventIdx = -1; |
| 691 | bool bNeedPrefix = false; | 691 | bool bNeedPrefix = false; |
| 692 | EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; | 692 | EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; |
| 693 | EWelsNalRefIdc eNalRefIdc = NRI_PRI_LOWEST; | 693 | EWelsNalRefIdc eNalRefIdc = NRI_PRI_LOWEST; |
| 694 | int32_t iReturn = ENC_RETURN_SUCCESS; | 694 | int32_t iReturn = ENC_RETURN_SUCCESS; |
| 695 | 695 | ||
| 696 | if (NULL == pPrivateData) | 696 | if (NULL == pPrivateData) |
| 697 | WELS_THREAD_ROUTINE_RETURN (1); | 697 | WELS_THREAD_ROUTINE_RETURN (1); |
| 698 | 698 | ||
| 699 | pEncPEncCtx = (sWelsEncCtx*)pPrivateData->pWelsPEncCtx; | 699 | pEncPEncCtx = (sWelsEncCtx*)pPrivateData->pWelsPEncCtx; |
| 700 | 700 | ||
| 701 | iThreadIdx = pPrivateData->iThreadIndex; | 701 | iThreadIdx = pPrivateData->iThreadIndex; |
| 702 | iEventIdx = iThreadIdx; | 702 | iEventIdx = iThreadIdx; |
| 703 | 703 | ||
| 704 | pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx]; | 704 | pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx]; |
| 705 | pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pExitEncodeEvent[iEventIdx]; | 705 | pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pExitEncodeEvent[iEventIdx]; |
| 706 | pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx]; | 706 | pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx]; |
| 707 | 707 | ||
| 708 | WelsThreadSetName ("OpenH264Enc_CodingSliceThreadProc"); | 708 | WelsThreadSetName ("OpenH264Enc_CodingSliceThreadProc"); |
| @@ -716,32 +716,32 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 7 unmodified lines | |||
| 716 | &pEncPEncCtx->pSliceThreading->pThreadMasterEvent[iEventIdx]); // blocking until at least one event is signalled | 716 | &pEncPEncCtx->pSliceThreading->pThreadMasterEvent[iEventIdx]); // blocking until at least one event is signalled |
| 717 | if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited | 717 | if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited |
| 718 | SLayerBSInfo* pLbi = pPrivateData->pLayerBs; | 718 | SLayerBSInfo* pLbi = pPrivateData->pLayerBs; |
| 719 | const int32_t kiCurDid = pEncPEncCtx->uiDependencyId; | 719 | const int32_t kiCurDid = pEncPEncCtx->uiDependencyId; |
| 720 | const int32_t kiCurTid = pEncPEncCtx->uiTemporalId; | 720 | const int32_t kiCurTid = pEncPEncCtx->uiTemporalId; |
| 721 | SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam; | 721 | SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam; |
| 722 | SSpatialLayerConfig* pParamD = &pCodingParam->sSpatialLayers[kiCurDid]; | 722 | SSpatialLayerConfig* pParamD = &pCodingParam->sSpatialLayers[kiCurDid]; |
| 723 | 723 | ||
| 724 | pCurDq = pEncPEncCtx->pCurDqLayer; | 724 | pCurDq = pEncPEncCtx->pCurDqLayer; |
| 725 | eNalType = pEncPEncCtx->eNalType; | 725 | eNalType = pEncPEncCtx->eNalType; |
| 726 | eNalRefIdc = pEncPEncCtx->eNalPriority; | 726 | eNalRefIdc = pEncPEncCtx->eNalPriority; |
| 727 | bNeedPrefix = pEncPEncCtx->bNeedPrefixNalFlag; | 727 | bNeedPrefix = pEncPEncCtx->bNeedPrefixNalFlag; |
| 728 | 728 | ||
| 729 | if (pParamD->sSliceCfg.uiSliceMode != SM_DYN_SLICE) { | 729 | if (pParamD->sSliceCfg.uiSliceMode != SM_DYN_SLICE) { |
| 730 | int64_t iSliceStart = 0; | 730 | int64_t iSliceStart = 0; |
| 731 | bool bDsaFlag = false; | 731 | bool bDsaFlag = false; |
| 732 | iSliceIdx = pPrivateData->iSliceIndex; | 732 | iSliceIdx = pPrivateData->iSliceIndex; |
| 733 | pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx]; | 733 | pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx]; |
| 734 | pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx]; | 734 | pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx]; |
| 735 | 735 | ||
| 736 | bDsaFlag = (((pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE) | 736 | bDsaFlag = (((pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE) |
| 737 | || (pParamD->sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) && | 737 | || (pParamD->sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) && |
| 738 | pCodingParam->iMultipleThreadIdc > 1 && | 738 | pCodingParam->iMultipleThreadIdc > 1 && |
| 739 | pCodingParam->iMultipleThreadIdc >= pParamD->sSliceCfg.sSliceArgument.uiSliceNum); | 739 | pCodingParam->iMultipleThreadIdc >= pParamD->sSliceCfg.sSliceArgument.uiSliceNum); |
| 740 | if (bDsaFlag) | 740 | if (bDsaFlag) |
| 741 | iSliceStart = WelsTime(); | 741 | iSliceStart = WelsTime(); |
| 742 | 742 | ||
| 743 | pSliceBs->uiBsPos = 0; | 743 | pSliceBs->uiBsPos = 0; |
| 744 | pSliceBs->iNalIndex = 0; | 744 | pSliceBs->iNalIndex = 0; |
| 745 | assert ((void*) (&pSliceBs->sBsWrite) == (void*)pSlice->pSliceBsa); | 745 | assert ((void*) (&pSliceBs->sBsWrite) == (void*)pSlice->pSliceBsa); |
| 746 | InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize); | 746 | InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize); |
| 747 | 747 | ||
| @@ -825,21 +825,21 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 77 unmodified lines | |||
| 825 | &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice | 825 | &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice |
| 826 | WelsEventSignal ( | 826 | WelsEventSignal ( |
| 827 | &pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent); | 827 | &pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent); |
| 828 | } else { // for SM_DYN_SLICE parallelization | 828 | } else { // for SM_DYN_SLICE parallelization |
| 829 | SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; | 829 | SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; |
| 830 | const int32_t kiPartitionId = iThreadIdx; | 830 | const int32_t kiPartitionId = iThreadIdx; |
| 831 | const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum; | 831 | const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum; |
| 832 | const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive | 832 | const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive |
| 833 | const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive | 833 | const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive |
| 834 | int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition; | 834 | int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition; |
| 835 | 835 | ||
| 836 | iSliceIdx = pPrivateData->iSliceIndex; | 836 | iSliceIdx = pPrivateData->iSliceIndex; |
| 837 | 837 | ||
| 838 | pSliceCtx->pFirstMbInSlice[iSliceIdx] = kiFirstMbInPartition; | 838 | pSliceCtx->pFirstMbInSlice[iSliceIdx] = kiFirstMbInPartition; |
| 839 | pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one pSlice per partition intialized, dynamic slicing inside | 839 | pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one pSlice per partition intialized, dynamic slicing inside |
| 840 | pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1; | 840 | pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1; |
| 841 | 841 | ||
| 842 | pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId] = 0; | 842 | pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId] = 0; |
| 843 | 843 | ||
| 844 | while (iAnyMbLeftInPartition > 0) { | 844 | while (iAnyMbLeftInPartition > 0) { |
| 845 | if (iSliceIdx >= pSliceCtx->iMaxSliceNumConstraint) { | 845 | if (iSliceIdx >= pSliceCtx->iMaxSliceNumConstraint) { |
| @@ -849,11 +849,11 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 3 unmodified lines | |||
| 849 | break; | 849 | break; |
| 850 | } | 850 | } |
| 851 | 851 | ||
| 852 | pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx]; | 852 | pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx]; |
| 853 | pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx]; | 853 | pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx]; |
| 854 | 854 | ||
| 855 | pSliceBs->uiBsPos = 0; | 855 | pSliceBs->uiBsPos = 0; |
| 856 | pSliceBs->iNalIndex = 0; | 856 | pSliceBs->iNalIndex = 0; |
| 857 | InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize); | 857 | InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize); |
| 858 | 858 | ||
| 859 | if (bNeedPrefix) { | 859 | if (bNeedPrefix) { |
| @@ -978,8 +978,8 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { · 118 unmodified lines | |||
| 978 | int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, | 978 | int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, |
| 979 | WELS_EVENT* pMasterEventsList, SLayerBSInfo* pLbi, | 979 | WELS_EVENT* pMasterEventsList, SLayerBSInfo* pLbi, |
| 980 | const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode) { | 980 | const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode) { |
| 981 | int32_t iEndMbIdx = 0; | 981 | int32_t iEndMbIdx = 0; |
| 982 | int32_t iIdx = 0; | 982 | int32_t iIdx = 0; |
| 983 | const int32_t kiEventCnt = uiNumThreads; | 983 | const int32_t kiEventCnt = uiNumThreads; |
| 984 | 984 | ||
| 985 | if (pPriData == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) { | 985 | if (pPriData == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) { |
| @@ -993,10 +993,10 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, · 7 unmodified lines | |||
| 993 | if (bIsDynamicSlicingMode) { | 993 | if (bIsDynamicSlicingMode) { |
| 994 | iEndMbIdx = pSliceCtx->iMbNumInFrame; | 994 | iEndMbIdx = pSliceCtx->iMbNumInFrame; |
| 995 | for (iIdx = kiEventCnt - 1; iIdx >= 0; --iIdx) { | 995 | for (iIdx = kiEventCnt - 1; iIdx >= 0; --iIdx) { |
| 996 | const int32_t iFirstMbIdx = pSliceCtx->pFirstMbInSlice[iIdx]; | 996 | const int32_t iFirstMbIdx = pSliceCtx->pFirstMbInSlice[iIdx]; |
| 997 | pPriData[iIdx].iStartMbIndex = iFirstMbIdx; | 997 | pPriData[iIdx].iStartMbIndex = iFirstMbIdx; |
| 998 | pPriData[iIdx].iEndMbIndex = iEndMbIdx; | 998 | pPriData[iIdx].iEndMbIndex = iEndMbIdx; |
| 999 | iEndMbIdx = iFirstMbIdx; | 999 | iEndMbIdx = iFirstMbIdx; |
| 1000 | } | 1000 | } |
| 1001 | } | 1001 | } |
| 1002 | 1002 | ||
| @@ -1021,8 +1021,8 @@ int32_t DynamicDetectCpuCores() { · 18 unmodified lines | |||
| 1021 | } | 1021 | } |
| 1022 | 1022 | ||
| 1023 | int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) { | 1023 | int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) { |
| 1024 | SDqLayer* pCurDq = pCtx->ppDqLayerList[0]; | 1024 | SDqLayer* pCurDq = pCtx->ppDqLayerList[0]; |
| 1025 | int32_t iNeedAdj = 1; | 1025 | int32_t iNeedAdj = 1; |
| 1026 | #ifdef MT_DEBUG | 1026 | #ifdef MT_DEBUG |
| 1027 | int64_t iT0 = WelsTime(); | 1027 | int64_t iT0 = WelsTime(); |
| 1028 | #endif//MT_DEBUG | 1028 | #endif//MT_DEBUG |
| @@ -1121,10 +1121,10 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t · 92 unmodified lines | |||
| 1121 | 1121 | ||
| 1122 | pPara = pCtx->pSvcParam; | 1122 | pPara = pCtx->pSvcParam; |
| 1123 | while (iSpatialIdx < iSpatialNum) { | 1123 | while (iSpatialIdx < iSpatialNum) { |
| 1124 | const int32_t kiDid = pDidList[iSpatialIdx]; | 1124 | const int32_t kiDid = pDidList[iSpatialIdx]; |
| 1125 | SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid]; | 1125 | SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid]; |
| 1126 | SSliceConfig* pMso = &pDlp->sSliceCfg; | 1126 | SSliceConfig* pMso = &pDlp->sSliceCfg; |
| 1127 | SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid]; | 1127 | SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid]; |
| 1128 | SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; | 1128 | SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; |
| 1129 | const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame; | 1129 | const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame; |
| 1130 | if (pCtx->pSliceThreading) { | 1130 | if (pCtx->pSliceThreading) { |