[Live-devel] Decoding H264 non-IDR picture

Miladin Sajic miladin.sajic at citysync.co.uk
Fri Jun 20 02:42:35 PDT 2014


Hi,

I am trying to implement decoding of H264 NAL units that are received from the camera (using live555 rtsp streaming). Everything works fine if received NAL unit is IDR (see part of the code in PS) but it does not work for SLICE NAL unit (nal_unit_type == 1). To decode image this NAL unit is not enough on its own and reference needs to be made to all the units since last IDR unit (key frame with nal_unit_type == 5). I do not know how to implement this.

How to combine last IDR unit with the following SLICE NAL units  to produce H264 frame before sending it to the decoder?

[cid:image003.png at 01CF8C74.58C38FA0]

Can you give me any advice or point me to the right direction? Any help is greatly appreciated.

Regards,
Miladin

PS.

Content of the buffer sent to the H264 decoder that gets decoded properly.

[cid:image001.png at 01CF8C73.13092D90]

unsigned char strTmp[4] = { 0, 0, 0, 1 };

// getting SPS config info
memcpy(acSPS, strTmp, 4);
memcpy(&acSPS[4], m_pcRtspStream->m_ustrSPS, m_pcRtspStream->m_iSPSLen);
nSPSLength = m_pcRtspStream->m_iSPSLen + 4;

// getting PPS config info
memcpy(acPPS, strTmp, 4);
memcpy(&acPPS[4], m_pcRtspStream->m_ustrPPS, m_pcRtspStream->m_iPPSLen);
nPPSLength = m_pcRtspStream->m_iPPSLen + 4;

//  before passing data to be decoder add SPS, PPS and 4 byte of strTmp to the IDR NAL unit (pcbCompressedData)
iStrTmpImageSize = nSPSLength + nPPSLength + 4 + nCompressedLength;
p = strTmpImage; // strTmpImage is empty allocated memory

memcpy(p, acSPS, nSPSLength);
p += nSPSLength;

memcpy(p, acPPS, nPPSLength);
p += nPPSLength;

memcpy(p, strTmp, 4);
p += 4;

memcpy(p, pcbCompressedData, nCompressedLength);
pHdr->nLength = iStrTmpImageSize;

pcbCompressedData = strTmpImage;
nCompressedLength = iStrTmpImageSize;

// Pass pcbCompressedData and nCompressedLength to the decoder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20140620/77448ee8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 2279 bytes
Desc: image001.png
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20140620/77448ee8/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 1728 bytes
Desc: image003.png
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20140620/77448ee8/attachment-0001.png>


More information about the live-devel mailing list