MCPcopy Create free account
hub / github.com/cisco/openh264 / RandAvailableThread

Function RandAvailableThread

test/encoder/EncUT_SliceBufferReallocate.cpp:21–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21int32_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
50int32_t AllocateLayerBuffer (sWelsEncCtx* pCtx, const int32_t iLayerIdx) {
51 SSpatialLayerConfig* pLayerCfg = &pCtx->pSvcParam->sSpatialLayers[iLayerIdx];

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected