summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorEdward Hervey <edward@collabora.com>2013-08-01 11:01:03 +0200
committerEdward Hervey <edward@collabora.com>2013-08-02 10:41:25 +0200
commit3b60f8843793b27a8045a345866676eb42af6e75 (patch)
treec1a80aab1c326a093aadb1c659812dc561650642 /gst
parentc28acaa3c570fed5e2cd8bc140494ee311578518 (diff)
downloadgstreamer-plugins-bad-3b60f8843793b27a8045a345866676eb42af6e75.tar.gz
mpegtspacketizer: Look harder for next sync position
If ever we lose sync, we were just checking for the next 0x47 marker ... which might actually happen within a mpeg-ts packet. Instead check for 3 repeating 0x47 at the expected packet size interval, which the same logic we use when we initially look for the packet size.
Diffstat (limited to 'gst')
-rw-r--r--gst/mpegtsdemux/mpegtspacketizer.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/gst/mpegtsdemux/mpegtspacketizer.c b/gst/mpegtsdemux/mpegtspacketizer.c
index 449547ae6..6f21bb5a5 100644
--- a/gst/mpegtsdemux/mpegtspacketizer.c
+++ b/gst/mpegtsdemux/mpegtspacketizer.c
@@ -799,9 +799,11 @@ mpegts_packetizer_next_packet (MpegTSPacketizer2 * packetizer,
GST_LOG ("Lost sync %d", packet_size);
- /* Find the 0x47 in the buffer */
- for (; sync_offset < priv->mapped_size; sync_offset++)
- if (priv->mapped[sync_offset] == 0x47)
+ /* Find the 0x47 in the buffer (and require at least 2 checks) */
+ for (; sync_offset < priv->mapped_size + 2 * packet_size; sync_offset++)
+ if (priv->mapped[sync_offset] == 0x47 &&
+ priv->mapped[sync_offset + packet_size] == 0x47 &&
+ priv->mapped[sync_offset + 2 * packet_size] == 0x47)
break;
/* Pop out the remaining data... */