gst/typefind/gsttypefindfunctions.c: Small mpeg2 system stream typefinding improvement: make typefinder probe a bit i...

Original commit message from CVS:
* gst/typefind/gsttypefindfunctions.c: (mpeg2_sys_type_find):
Small mpeg2 system stream typefinding improvement: make typefinder
probe a bit into the stream instead of just looking for a marker
at the beginning. Fixes #397810.
This commit is contained in:
Tim-Philipp Müller 2007-01-19 11:31:50 +00:00
parent 4936d6ba02
commit c47074371a
2 changed files with 34 additions and 13 deletions

View file

@ -1,3 +1,10 @@
2007-01-19 Tim-Philipp Müller <tim at centricular dot net>
* gst/typefind/gsttypefindfunctions.c: (mpeg2_sys_type_find):
Small mpeg2 system stream typefinding improvement: make typefinder
probe a bit into the stream instead of just looking for a marker
at the beginning. Fixes #397810.
2007-01-18 Tim-Philipp Müller <tim at centricular dot net>
* gst/audioconvert/gstchannelmix.c:

View file

@ -1029,27 +1029,41 @@ static GstStaticCaps mpeg_sys_caps = GST_STATIC_CAPS ("video/mpeg, "
(((guint8 *)(data))[3] == 0xC0) || \
(((guint8 *)(data))[3] == 0xBD)))
#define MPEG2_MAX_PROBE_LENGTH 4096 /* 4kB (random value) */
static void
mpeg2_sys_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data = gst_type_find_peek (tf, 0, 5);
gint mpegversion;
guint8 *data;
gint mpegversion, len;
if (data && IS_MPEG_PACK_HEADER (data)) {
if ((data[4] & 0xC0) == 0x40) {
/* type 2 */
len = MPEG2_MAX_PROBE_LENGTH * 2;
do {
len = len / 2;
data = gst_type_find_peek (tf, 0, 5 + len);
} while (data == NULL && len >= 32);
if (!data)
return;
while (len > 0) {
if (IS_MPEG_PACK_HEADER (data)) {
if ((data[4] & 0xC0) == 0x40) {
/* type 2 */
mpegversion = 2;
goto suggest;
} else if ((data[4] & 0xF0) == 0x20) {
mpegversion = 1;
goto suggest;
}
} else if (IS_MPEG_PES_HEADER (data)) {
/* PES stream */
mpegversion = 2;
goto suggest;
} else if ((data[4] & 0xF0) == 0x20) {
mpegversion = 1;
goto suggest;
}
} else if (data && IS_MPEG_PES_HEADER (data)) {
/* PES stream */
mpegversion = 2;
goto suggest;
++data;
--len;
}
return;
suggest:
{