From ea7349e4c75e8f0454130ae45a8acc3da0d32257 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 8 Dec 2010 12:55:24 +0100 Subject: [PATCH] typefinding: improve iso media typefinding ... by also considering compatible brands rather than only aiming at major brand (of which there are a seemingly ever expanding great many). --- gst/typefind/gsttypefindfunctions.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index 3b556824a9..a50ead34bb 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -2545,7 +2545,26 @@ qt_type_find (GstTypeFind * tf, gpointer unused) tip = 0; break; } + size = GST_READ_UINT32_BE (data); + /* check compatible brands rather than ever expaning major brands above */ + if ((STRNCMP (&data[4], "ftyp", 4) == 0) && (size >= 16)) { + new_offset = offset + 12; + while (new_offset + 4 <= offset + size) { + data = gst_type_find_peek (tf, new_offset, 4); + if (data == NULL) + goto done; + if (STRNCMP (&data[4], "isom", 4) == 0 || + STRNCMP (&data[4], "avc1", 4) == 0 || + STRNCMP (&data[4], "mp41", 4) == 0 || + STRNCMP (&data[4], "mp42", 4) == 0) { + tip = GST_TYPE_FIND_MAXIMUM; + variant = "iso"; + goto done; + } + new_offset += 4; + } + } if (size == 1) { guint8 *sizedata; @@ -2564,6 +2583,7 @@ qt_type_find (GstTypeFind * tf, gpointer unused) offset = new_offset; } +done: if (tip > 0) { if (variant) { GstCaps *caps = gst_caps_copy (QT_CAPS);