accept short start code

This commit is contained in:
Michel Promonet 2015-09-05 17:58:59 +02:00
parent adf18b550f
commit f5ae14f3e4
2 changed files with 15 additions and 4 deletions

View File

@ -20,6 +20,7 @@
// H264 V4L2 FramedSource
// ---------------------------------
const char H264marker[] = {0,0,0,1};
const char H264shortmarker[] = {0,0,1};
class H264_V4L2DeviceSource : public V4L2DeviceSource
{
public:

View File

@ -95,14 +95,24 @@ unsigned char* H264_V4L2DeviceSource::extractFrame(unsigned char* frame, size_t
{
unsigned char * outFrame = NULL;
outsize = 0;
unsigned int markerlength = 0;
if ( (size>= sizeof(H264marker)) && (memcmp(frame,H264marker,sizeof(H264marker)) == 0) )
{
size -= sizeof(H264marker);
outFrame = &frame[sizeof(H264marker)];
markerlength = sizeof(H264marker);
}
else if (memcmp(frame,H264shortmarker,sizeof(H264shortmarker)) == 0)
{
markerlength = sizeof(H264shortmarker);
}
if (markerlength != 0)
{
size -= markerlength;
outFrame = &frame[markerlength];
outsize = size;
for (int i=0; i+sizeof(H264marker) < size; ++i)
{
if (memcmp(&outFrame[i],H264marker,sizeof(H264marker)) == 0)
if ( (memcmp(&outFrame[i],H264marker,sizeof(H264marker)) == 0) || (memcmp(&outFrame[i],H264shortmarker,sizeof(H264shortmarker)) == 0) )
{
outsize = i;
break;