typefinding: flac typefinder fixes

Use scan context for initial peek as well. Peek 6 bytes in the initial
peek rather than 5 bytes, to match the length of the memcmp we're doing
on that data later. Return immediately when we found caps from looking
at the beginning of the data - no point in continuing to scan the next
64kB for something matching a frame header.
This commit is contained in:
Tim-Philipp Müller 2009-03-11 13:33:33 +00:00
parent 18f612ffa9
commit 4cbe4d2c72

View file

@ -552,19 +552,21 @@ static GstStaticCaps flac_caps = GST_STATIC_CAPS ("audio/x-flac");
static void
flac_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data;
DataScanCtx c = { 0, NULL, 0 };
data = gst_type_find_peek (tf, 0, 5);
if (G_LIKELY (data)) {
/* standard flac */
if (memcmp (data, "fLaC", 4) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, FLAC_CAPS);
}
/* flac-in-ogg, see http://flac.sourceforge.net/ogg_mapping.html */
else if (memcmp (data, "\177FLAC\001", 6) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, FLAC_CAPS);
}
if (G_UNLIKELY (!data_scan_ctx_ensure_data (tf, &c, 6)))
return;
/* standard flac */
if (memcmp (c.data, "fLaC", 4) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, FLAC_CAPS);
return;
}
/* flac-in-ogg, see http://flac.sourceforge.net/ogg_mapping.html */
if (memcmp (c.data, "\177FLAC\001", 6) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, FLAC_CAPS);
return;
}
/* flac without headers (subset format) */