diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2009-02-06 11:09:11 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2009-02-06 11:09:11 +0100 |
commit | f529a4c6b3a6239e3719d661dcbb3d935a0770c3 (patch) | |
tree | 4c2557c0a2ad5a3dd201b4adee21e3a8c54cf99e /gst/mxf | |
parent | 0d8099685dc263f015636062d8a2206305a2708d (diff) | |
download | gst-plugins-bad-f529a4c6b3a6239e3719d661dcbb3d935a0770c3.tar.gz gst-plugins-bad-f529a4c6b3a6239e3719d661dcbb3d935a0770c3.tar.bz2 gst-plugins-bad-f529a4c6b3a6239e3719d661dcbb3d935a0770c3.zip |
mxfdemux: Implement keyframe detection for MPEG4 video streams
Diffstat (limited to 'gst/mxf')
-rw-r--r-- | gst/mxf/mxfmpeg.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/gst/mxf/mxfmpeg.c b/gst/mxf/mxfmpeg.c index 940b2439..4719def2 100644 --- a/gst/mxf/mxfmpeg.c +++ b/gst/mxf/mxfmpeg.c @@ -307,6 +307,45 @@ mxf_mpeg_is_mpeg2_keyframe (GstBuffer * buffer) return FALSE; } +static gboolean +mxf_mpeg_is_mpeg4_keyframe (GstBuffer * buffer) +{ + GstByteReader reader = GST_BYTE_READER_INIT_FROM_BUFFER (buffer); + guint32 tmp; + + while (gst_byte_reader_get_remaining (&reader) > 3) { + if (gst_byte_reader_peek_uint24_be (&reader, &tmp) && tmp == 0x000001) { + guint8 type; + + /* Found sync code */ + gst_byte_reader_skip (&reader, 3); + + if (!gst_byte_reader_get_uint8 (&reader, &type)) + break; + + if (type == 0xb6) { + guint8 pic_type; + + if (!gst_byte_reader_get_uint8 (&reader, &pic_type)) + break; + + pic_type = (pic_type >> 6) & 0x03; + if (pic_type == 0) { + return TRUE; + } else { + return FALSE; + } + } + } else { + gst_byte_reader_skip (&reader, 1); + } + } + + g_assert_not_reached (); + + return FALSE; +} + static GstFlowReturn mxf_mpeg_video_handle_essence_element (const MXFUL * key, GstBuffer * buffer, GstCaps * caps, MXFMetadataTimelineTrack * track, @@ -330,6 +369,12 @@ mxf_mpeg_video_handle_essence_element (const MXFUL * key, GstBuffer * buffer, else GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT); break; + case MXF_MPEG_ESSENCE_TYPE_VIDEO_MPEG4: + if (mxf_mpeg_is_mpeg4_keyframe (buffer)) + GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_DELTA_UNIT); + else + GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT); + break; default: break; |