mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-05 02:02:26 +00:00
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.
This commit is contained in:
parent
a65390d31a
commit
cf69768bfb
2 changed files with 36 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
2008-11-05 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||
|
||||
patch by: Josep Torra
|
||||
|
||||
* gst/mpegdemux/gstmpegtsdemux.c:
|
||||
Heuristic approach when resyncing.
|
||||
|
||||
2008-11-05 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||
|
||||
patch by: Sebastian Pölsterl
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue