summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorZaheer Abbas Merali <zaheerabbas@merali.org>2008-11-05 18:52:38 +0000
committerZaheer Abbas Merali <zaheerabbas@merali.org>2008-11-05 18:52:38 +0000
commitcf69768bfb6c73eb5ca4a178b38251878f6b1b92 (patch)
tree73c8eb6737310ce6449d45aa08af2630c7dab606 /gst
parenta65390d31ac978155e35890f70e7a4655d6deb8d (diff)
downloadgst-plugins-bad-cf69768bfb6c73eb5ca4a178b38251878f6b1b92.tar.gz
gst-plugins-bad-cf69768bfb6c73eb5ca4a178b38251878f6b1b92.tar.bz2
gst-plugins-bad-cf69768bfb6c73eb5ca4a178b38251878f6b1b92.zip
gst/mpegdemux/gstmpegtsdemux.c: Heuristic approach when resyncing.
Original commit message from CVS: patch by: Josep Torra * gst/mpegdemux/gstmpegtsdemux.c: Heuristic approach when resyncing.
Diffstat (limited to 'gst')
-rw-r--r--gst/mpegdemux/gstmpegtsdemux.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/gst/mpegdemux/gstmpegtsdemux.c b/gst/mpegdemux/gstmpegtsdemux.c
index 1aa2f387..c00d3b63 100644
--- a/gst/mpegdemux/gstmpegtsdemux.c
+++ b/gst/mpegdemux/gstmpegtsdemux.c
@@ -2458,6 +2458,33 @@ gst_fluts_demux_src_pad_query (GstPad * pad, GstQuery * query)
}
#endif
+
+static FORCE_INLINE gint
+is_mpegts_sync (const guint8 * in_data, const guint8 * end_data,
+ guint packetsize)
+{
+ guint ret = 0;
+ if (G_LIKELY (IS_MPEGTS_SYNC (in_data)))
+ return 100;
+
+ if (in_data + packetsize < end_data - 5) {
+ if (G_LIKELY (IS_MPEGTS_SYNC (in_data + packetsize)))
+ ret += 50;
+ }
+
+ if (in_data[0] == 0x47) {
+ ret += 25;
+
+ if ((in_data[1] & 0x80) == 0x00)
+ ret += 10;
+
+ if ((in_data[3] & 0x10) == 0x10)
+ ret += 5;
+ }
+ return ret;
+}
+
+
static FORCE_INLINE guint
gst_fluts_demux_sync_scan (GstFluTSDemux * demux, const guint8 * in_data,
guint size, guint * flush)
@@ -2468,7 +2495,8 @@ gst_fluts_demux_sync_scan (GstFluTSDemux * demux, const guint8 * in_data,
while (ptr_data <= end_scan && sync_count < LENGHT_SYNC_LUT) {
/* if sync code is found try to store it in the LUT */
- if (G_LIKELY (IS_MPEGTS_SYNC (ptr_data))) {
+ guint chance = is_mpegts_sync (ptr_data, end_scan, demux->packetsize);
+ if (G_LIKELY (chance > 50)) {
/* skip paketsize bytes and try find next */
guint8 *next_sync = ptr_data + demux->packetsize;
if (next_sync < end_scan) {