From 96a7f9c8b1195129f0c2157cbbcbaa6cab45056e Mon Sep 17 00:00:00 2001 From: Thijs Vermeir Date: Thu, 14 Oct 2010 11:45:55 +0200 Subject: [PATCH] mpegvideoparse: accelerate search for start code As the startcode always starts with 0x000001 some iterations can be skipped if values > 1 are detected. ~ 70% faster on HD video stream. https://bugzilla.gnome.org/show_bug.cgi?id=632130 --- gst/mpegvideoparse/mpegpacketiser.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gst/mpegvideoparse/mpegpacketiser.c b/gst/mpegvideoparse/mpegpacketiser.c index fb8c9f5..694c476 100644 --- a/gst/mpegvideoparse/mpegpacketiser.c +++ b/gst/mpegvideoparse/mpegpacketiser.c @@ -108,6 +108,16 @@ mpeg_util_find_start_code (guint32 * sync_word, guint8 * cur, guint8 * end) return cur; } + /* accelerate search for start code */ + if (*cur > 1) { + while (cur < (end - 4) && *cur > 1) + if (cur[3] > 1) + cur += 4; + else + cur++; + code = 0xffffff00; + } + /* Add the next available byte to the collected sync word */ code |= *cur++; } -- 2.7.4