| 1556 | } |
| 1557 | |
| 1558 | int32_t FrameBsRealloc (sWelsEncCtx* pCtx, |
| 1559 | SFrameBSInfo* pFrameBsInfo, |
| 1560 | SLayerBSInfo* pLayerBsInfo, |
| 1561 | const int32_t kiMaxSliceNumOld) { |
| 1562 | CMemoryAlign* pMA = pCtx->pMemAlign; |
| 1563 | int32_t iCountNals = pCtx->pOut->iCountNals; |
| 1564 | iCountNals += kiMaxSliceNumOld * (pCtx->pSvcParam->iSpatialLayerNum + pCtx->bNeedPrefixNalFlag); |
| 1565 | |
| 1566 | SWelsNalRaw* pNalList = (SWelsNalRaw*)pMA->WelsMallocz (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList"); |
| 1567 | if (NULL == pNalList) { |
| 1568 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::FrameBsRealloc: pNalList is NULL"); |
| 1569 | return ENC_RETURN_MEMALLOCERR; |
| 1570 | } |
| 1571 | memcpy (pNalList, pCtx->pOut->sNalList, sizeof (SWelsNalRaw) * pCtx->pOut->iCountNals); |
| 1572 | pMA->WelsFree (pCtx->pOut->sNalList, "pOut->sNalList"); |
| 1573 | pCtx->pOut->sNalList = pNalList; |
| 1574 | |
| 1575 | int32_t* pNalLen = (int32_t*)pMA->WelsMallocz (iCountNals * sizeof (int32_t), "pOut->pNalLen"); |
| 1576 | if (NULL == pNalLen) { |
| 1577 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::FrameBsRealloc: pNalLen is NULL"); |
| 1578 | return ENC_RETURN_MEMALLOCERR; |
| 1579 | } |
| 1580 | memcpy (pNalLen, pCtx->pOut->pNalLen, sizeof (int32_t) * pCtx->pOut->iCountNals); |
| 1581 | pMA->WelsFree (pCtx->pOut->pNalLen, "pOut->pNalLen"); |
| 1582 | pCtx->pOut->pNalLen = pNalLen; |
| 1583 | |
| 1584 | pCtx->pOut->iCountNals = iCountNals; |
| 1585 | SLayerBSInfo* pLBI1, *pLBI2; |
| 1586 | pLBI1 = &pFrameBsInfo->sLayerInfo[0]; |
| 1587 | pLBI1->pNalLengthInByte = pCtx->pOut->pNalLen; |
| 1588 | while (pLBI1 != pLayerBsInfo) { |
| 1589 | pLBI2 = pLBI1; |
| 1590 | ++ pLBI1; |
| 1591 | pLBI1->pNalLengthInByte = pLBI2->pNalLengthInByte + pLBI2->iNalCount; |
| 1592 | } |
| 1593 | |
| 1594 | return ENC_RETURN_SUCCESS; |
| 1595 | } |
| 1596 | |
| 1597 | int32_t SliceLayerInfoUpdate (sWelsEncCtx* pCtx, |
| 1598 | SFrameBSInfo* pFrameBsInfo, |
no test coverage detected