diff --git a/inc/H264_V4l2DeviceSource.h b/inc/H264_V4l2DeviceSource.h index bf70856..6ed6573 100644 --- a/inc/H264_V4l2DeviceSource.h +++ b/inc/H264_V4l2DeviceSource.h @@ -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: diff --git a/src/H264_V4l2DeviceSource.cpp b/src/H264_V4l2DeviceSource.cpp index b8dc2de..864be4c 100644 --- a/src/H264_V4l2DeviceSource.cpp +++ b/src/H264_V4l2DeviceSource.cpp @@ -95,20 +95,30 @@ 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; } } - size -= outsize; + size -= outsize; } return outFrame; }