Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

H264 Encoder and NAL Split

yann_stephan
Beginner
309 Views
When I use SLICE_CHECK_LIMIT, the stream is certainly split in NAL with a given size.
I didn't find an accessor in the sample for changing the value of m_MaxSliceSize, so I changed it in the code directly.

My question is the following one:

I use the following code (not optimized for a good understanding)

int nSrcWidth = abs((long) pOutputFormat->bmiHeader.biWidth);
int nSrcHeight = abs((long) pOutputFormat->bmiHeader.biHeight);

// Compared to I420 (YUV) plans are in YV12 (YVU)
LPBYTE pDestY = lpVideoBuffer;
LPBYTE pDestU = pDestY + (nSrcWidth * nSrcHeight);
LPBYTE pDestV = pDestU + ((nSrcWidth * nSrcHeight) / 4);

m_pSrcMediaData->SetPlanePointer(pDestY, 0); // Y
m_pSrcMediaData->SetPlanePointer(pDestU, 1); // U
m_pSrcMediaData->SetPlanePointer(pDestV, 2); // V

m_pDstMediaData->SetBufferPointer(lpCompressedData + sizeof(RTP_INFO_HEADER), lOutDataLen - sizeof(RTP_INFO_HEADER));

if (m_h264VideoEncoder->GetFrame(m_pSrcMediaData, m_pDstMediaData) == UMC::UMC_OK)
{
if (m_pDstMediaData->GetDataSize() > 0)
{
....


The problem is that m_pDstMediaData is a continous stream, how I can access the NAL split in order to send it over the network. I need to split in NAL with a maximum size of the given MTU. The mode used is the single NAL unit.

I found a h264_split but it's not very how I should use it (if I need to use it)

Thanks for your answers.
0 Kudos
2 Replies
yann_stephan
Beginner
309 Views
When I use SLICE_CHECK_LIMIT, the stream is certainly split in NAL with a given size.
I didn't find an accessor in the sample for changing the value of m_MaxSliceSize, so I changed it in the code directly.

My question is the following one:

I use the following code (not optimized for a good understanding)

int nSrcWidth = abs((long) pOutputFormat->bmiHeader.biWidth);
int nSrcHeight = abs((long) pOutputFormat->bmiHeader.biHeight);

// Compared to I420 (YUV) plans are in YV12 (YVU)
LPBYTE pDestY = lpVideoBuffer;
LPBYTE pDestU = pDestY + (nSrcWidth * nSrcHeight);
LPBYTE pDestV = pDestU + ((nSrcWidth * nSrcHeight) / 4);

m_pSrcMediaData->SetPlanePointer(pDestY, 0); // Y
m_pSrcMediaData->SetPlanePointer(pDestU, 1); // U
m_pSrcMediaData->SetPlanePointer(pDestV, 2); // V

m_pDstMediaData->SetBufferPointer(lpCompressedData + sizeof(RTP_INFO_HEADER), lOutDataLen - sizeof(RTP_INFO_HEADER));

if (m_h264VideoEncoder->GetFrame(m_pSrcMediaData, m_pDstMediaData) == UMC::UMC_OK)
{
if (m_pDstMediaData->GetDataSize() > 0)
{
....


The problem is that m_pDstMediaData is a continous stream, how I can access the NAL split in order to send it over the network. I need to split in NAL with a maximum size of the given MTU. The mode used is the single NAL unit.

I found a h264_split but it's not very how I should use it (if I need to use it)

Thanks for your answers.

I found maybe the answer, NAL units are separated by a simple (at least) 4-byte sequence containing a
big-endian 1, i.e. 00 00 00 01. So, by searching them I should be able to send them over the network.
0 Kudos
Emmanuel_W_
New Contributor I
309 Views

I found maybe the answer, NAL units are separated by a simple (at least) 4-byte sequence containing a
big-endian 1, i.e. 00 00 00 01. So, by searching them I should be able to send them over the network.

This is how I did too.
0 Kudos
Reply