Skip to content

Commit

Permalink
Use memory pool for nal unit parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Kalatozishvili committed Nov 23, 2024
1 parent dc7a88d commit 7dd7b2d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/nalu.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@

#include "nalu.h"

#define XNAL_UNIT_INITIAL_COUNT 32

static void XNAL_UnitClearCb(xarray_data_t *pArrData)
{
XASSERT_VOID_RET(pArrData);
free(pArrData->pData);
xpool_t *pPool = (xpool_t*)pArrData->pPool;
xfreen(pPool, pArrData->pData, sizeof(xnal_unit_t));
}

void XNAL_InitUnit(xnal_unit_t *pUnit)
Expand Down Expand Up @@ -52,7 +55,8 @@ size_t XNAL_CheckStartCode(uint8_t *pBuffer, size_t nPos)

xarray_t* XNAL_ParseUnits(uint8_t *pBuffer, size_t nSize)
{
xarray_t *pUnits = XArray_New(NULL, XSTDNON, XFALSE);
size_t nPoolSize = sizeof(xnal_unit_t) * XNAL_UNIT_INITIAL_COUNT;
xarray_t *pUnits = XArray_NewPool(nPoolSize, XSTDNON, XFALSE);
XASSERT(pUnits, NULL);

pUnits->clearCb = XNAL_UnitClearCb;
Expand Down

0 comments on commit 7dd7b2d

Please sign in to comment.