typefind: probe for DVD ISO files, to avoid matching H.264

https://bugzilla.gnome.org/show_bug.cgi?id=674069
This commit is contained in:
Vincent Penquerc'h 2012-06-11 11:09:24 +01:00
parent 512f96906e
commit 0bd8070ebd

View file

@ -4568,6 +4568,32 @@ degas_type_find (GstTypeFind * tf, gpointer private)
} }
} }
/*** DVD ISO images (looks like H.264, see #674069) ***/
static void
dvdiso_type_find (GstTypeFind * tf, gpointer private)
{
/* 0x8000 bytes of zeros, then "\001CD001" */
gint64 len;
const guint8 *data;
len = gst_type_find_get_length (tf);
if (len < 0x8006)
return;
data = gst_type_find_peek (tf, 0, 0x8006);
if (G_UNLIKELY (data == NULL))
return;
for (len = 0; len < 0x8000; len++)
if (data[len])
return;
/* Can the '1' be anything else ? My three samples all have '1'. */
if (memcmp (data + 0x8000, "\001CD001", 6))
return;
/* May need more inspection, we may be able to demux some of them */
gst_type_find_suggest_simple (tf, GST_TYPE_FIND_LIKELY,
"application/octet-stream", NULL);
}
/*** generic typefind for streams that have some data at a specific position***/ /*** generic typefind for streams that have some data at a specific position***/
typedef struct typedef struct
{ {
@ -4939,6 +4965,8 @@ plugin_init (GstPlugin * plugin)
TYPE_FIND_REGISTER (plugin, "image/x-degas", GST_RANK_MARGINAL, TYPE_FIND_REGISTER (plugin, "image/x-degas", GST_RANK_MARGINAL,
degas_type_find, NULL, NULL, NULL, NULL); degas_type_find, NULL, NULL, NULL, NULL);
TYPE_FIND_REGISTER (plugin, "application/octet-stream", GST_RANK_MARGINAL,
dvdiso_type_find, NULL, NULL, NULL, NULL);
return TRUE; return TRUE;
} }