| 1395 | } |
| 1396 | |
| 1397 | int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) { |
| 1398 | |
| 1399 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; |
| 1400 | int32_t iMaxSliceNumOld = pCurLayer->sSliceBufferInfo[0].iMaxSliceNum; |
| 1401 | int32_t iMaxSliceNumNew = 0; |
| 1402 | int32_t iRet = 0; |
| 1403 | int32_t iSliceIdx = 0; |
| 1404 | int32_t iSlcBuffIdx = 0; |
| 1405 | int32_t iStartIdx = 0; |
| 1406 | const int32_t kiCurDid = pCtx->uiDependencyId; |
| 1407 | SSlice* pLastCodedSlice = pCurLayer->sSliceBufferInfo[0].pSliceBuffer + (iMaxSliceNumOld - 1); |
| 1408 | SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiCurDid].sSliceArgument; |
| 1409 | iRet = CalculateNewSliceNum (pCtx, |
| 1410 | pLastCodedSlice, |
| 1411 | iMaxSliceNumOld, |
| 1412 | iMaxSliceNumNew); |
| 1413 | |
| 1414 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1415 | return iRet; |
| 1416 | } |
| 1417 | |
| 1418 | iRet = ReallocateSliceList (pCtx, |
| 1419 | pSliceArgument, |
| 1420 | pCurLayer->sSliceBufferInfo[0].pSliceBuffer, |
| 1421 | iMaxSliceNumOld, |
| 1422 | iMaxSliceNumNew); |
| 1423 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1424 | return iRet; |
| 1425 | } |
| 1426 | |
| 1427 | pCurLayer->sSliceBufferInfo[0].iMaxSliceNum = iMaxSliceNumNew; |
| 1428 | |
| 1429 | iMaxSliceNumNew = 0; |
| 1430 | for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { |
| 1431 | iMaxSliceNumNew += pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1432 | } |
| 1433 | |
| 1434 | iRet = ExtendLayerBuffer (pCtx, pCurLayer->iMaxSliceNum, iMaxSliceNumNew); |
| 1435 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1436 | return iRet; |
| 1437 | } |
| 1438 | |
| 1439 | for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { |
| 1440 | for (iSliceIdx = 0; iSliceIdx < pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; iSliceIdx++) { |
| 1441 | pCurLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx; |
| 1442 | } |
| 1443 | iStartIdx += pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1444 | } |
| 1445 | |
| 1446 | pCurLayer->iMaxSliceNum = iMaxSliceNumNew; |
| 1447 | |
| 1448 | return ENC_RETURN_SUCCESS; |
| 1449 | } |
| 1450 | |
| 1451 | static inline int32_t CheckAllSliceBuffer (SDqLayer* pCurLayer, const int32_t kiCodedSliceNum) { |
| 1452 | int32_t iSliceIdx = 0; |
no test coverage detected