| 19 | } |
| 20 | |
| 21 | int32_t RandAvailableThread (sWelsEncCtx* pCtx, const int32_t kiMinBufferNum) { |
| 22 | int32_t aiThrdList[MAX_THREADS_NUM] = { -1 }; |
| 23 | int32_t iCodedSlcNum = 0; |
| 24 | int32_t iMaxSlcNumInThrd = 0; |
| 25 | int32_t iAvailableThrdNum = 0; |
| 26 | int32_t iRandThrdIdx = -1; |
| 27 | |
| 28 | if (NULL == pCtx || NULL == pCtx->pCurDqLayer || pCtx->iActiveThreadsNum <= 0) { |
| 29 | return -1; |
| 30 | } |
| 31 | |
| 32 | for (int32_t iThrdIdx = 0; iThrdIdx < pCtx->iActiveThreadsNum; iThrdIdx++) { |
| 33 | iCodedSlcNum = pCtx->pCurDqLayer->sSliceBufferInfo[iThrdIdx].iCodedSliceNum; |
| 34 | iMaxSlcNumInThrd = pCtx->pCurDqLayer->sSliceBufferInfo[iThrdIdx].iMaxSliceNum; |
| 35 | |
| 36 | if ((iCodedSlcNum + kiMinBufferNum) <= iMaxSlcNumInThrd) { |
| 37 | aiThrdList[iAvailableThrdNum] = iThrdIdx; |
| 38 | iAvailableThrdNum++; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | if (0 == iAvailableThrdNum) { |
| 43 | return -1; |
| 44 | } |
| 45 | iRandThrdIdx = rand() % iAvailableThrdNum; |
| 46 | |
| 47 | return aiThrdList[iRandThrdIdx]; |
| 48 | } |
| 49 | |
| 50 | int32_t AllocateLayerBuffer (sWelsEncCtx* pCtx, const int32_t iLayerIdx) { |
| 51 | SSpatialLayerConfig* pLayerCfg = &pCtx->pSvcParam->sSpatialLayers[iLayerIdx]; |
no outgoing calls
no test coverage detected