typefindfunctions: backport some const-ifications from 0.11 branch

To keep code identical as much as possible between the two branches,
for easier merging.
This commit is contained in:
Tim-Philipp Müller 2011-09-25 15:31:01 +01:00
parent bfb33e09a9
commit 09e06add66

View File

@ -45,6 +45,10 @@
GST_DEBUG_CATEGORY_STATIC (type_find_debug); GST_DEBUG_CATEGORY_STATIC (type_find_debug);
#define GST_CAT_DEFAULT type_find_debug #define GST_CAT_DEFAULT type_find_debug
/* so our code stays ready for 0.11 */
#define gst_type_find_peek(tf,off,len) \
((const guint8 *)gst_type_find_peek((tf),(off),(len)))
/* DataScanCtx: helper for typefind functions that scan through data /* DataScanCtx: helper for typefind functions that scan through data
* step-by-step, to avoid doing a peek at each and every offset */ * step-by-step, to avoid doing a peek at each and every offset */
@ -130,7 +134,7 @@ static gboolean
utf8_type_find_have_valid_utf8_at_offset (GstTypeFind * tf, guint64 offset, utf8_type_find_have_valid_utf8_at_offset (GstTypeFind * tf, guint64 offset,
GstTypeFindProbability * prob) GstTypeFindProbability * prob)
{ {
guint8 *data; const guint8 *data;
/* randomly decided values */ /* randomly decided values */
guint min_size = 16; /* minimum size */ guint min_size = 16; /* minimum size */
@ -222,7 +226,7 @@ static GstStaticCaps uri_caps = GST_STATIC_CAPS ("text/uri-list");
static void static void
uri_type_find (GstTypeFind * tf, gpointer unused) uri_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, BUFFER_SIZE); const guint8 *data = gst_type_find_peek (tf, 0, BUFFER_SIZE);
guint pos = 0; guint pos = 0;
guint offset = 0; guint offset = 0;
@ -322,7 +326,7 @@ xml_check_first_element (GstTypeFind * tf, const gchar * element, guint elen,
gboolean strict) gboolean strict)
{ {
gboolean got_xmldec; gboolean got_xmldec;
guint8 *data; const guint8 *data;
guint offset = 0; guint offset = 0;
guint pos = 0; guint pos = 0;
@ -386,7 +390,7 @@ static GstStaticCaps sdp_caps = GST_STATIC_CAPS ("application/sdp");
static gboolean static gboolean
sdp_check_header (GstTypeFind * tf) sdp_check_header (GstTypeFind * tf)
{ {
guint8 *data; const guint8 *data;
data = gst_type_find_peek (tf, 0, 5); data = gst_type_find_peek (tf, 0, 5);
if (!data) if (!data)
@ -433,9 +437,9 @@ static GstStaticCaps html_caps = GST_STATIC_CAPS ("text/html");
static void static void
html_type_find (GstTypeFind * tf, gpointer unused) html_type_find (GstTypeFind * tf, gpointer unused)
{ {
gchar *d, *data; const gchar *d, *data;
data = (gchar *) gst_type_find_peek (tf, 0, 16); data = (const gchar *) gst_type_find_peek (tf, 0, 16);
if (!data) if (!data)
return; return;
@ -444,7 +448,7 @@ html_type_find (GstTypeFind * tf, gpointer unused)
} else if (xml_check_first_element (tf, "html", 4, FALSE)) { } else if (xml_check_first_element (tf, "html", 4, FALSE)) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, HTML_CAPS); gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, HTML_CAPS);
} else if ((d = memchr (data, '<', 16))) { } else if ((d = memchr (data, '<', 16))) {
data = (gchar *) gst_type_find_peek (tf, d - data, 6); data = (const gchar *) gst_type_find_peek (tf, d - data, 6);
if (data && g_ascii_strncasecmp (data, "<html>", 6) == 0) { if (data && g_ascii_strncasecmp (data, "<html>", 6) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, HTML_CAPS); gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, HTML_CAPS);
} }
@ -459,7 +463,7 @@ static GstStaticCaps mid_caps = GST_STATIC_CAPS ("audio/midi");
static void static void
mid_type_find (GstTypeFind * tf, gpointer unused) mid_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 4); const guint8 *data = gst_type_find_peek (tf, 0, 4);
/* http://jedi.ks.uiuc.edu/~johns/links/music/midifile.html */ /* http://jedi.ks.uiuc.edu/~johns/links/music/midifile.html */
if (data && data[0] == 'M' && data[1] == 'T' && data[2] == 'h' if (data && data[0] == 'M' && data[1] == 'T' && data[2] == 'h'
@ -475,7 +479,7 @@ static GstStaticCaps mxmf_caps = GST_STATIC_CAPS ("audio/mobile-xmf");
static void static void
mxmf_type_find (GstTypeFind * tf, gpointer unused) mxmf_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = NULL; const guint8 *data = NULL;
/* Search FileId "XMF_" 4 bytes */ /* Search FileId "XMF_" 4 bytes */
data = gst_type_find_peek (tf, 0, 4); data = gst_type_find_peek (tf, 0, 4);
@ -503,7 +507,7 @@ static GstStaticCaps flx_caps = GST_STATIC_CAPS ("video/x-fli");
static void static void
flx_type_find (GstTypeFind * tf, gpointer unused) flx_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 134); const guint8 *data = gst_type_find_peek (tf, 0, 134);
if (data) { if (data) {
/* check magic and the frame type of the first frame */ /* check magic and the frame type of the first frame */
@ -534,7 +538,7 @@ static GstStaticCaps id3_caps = GST_STATIC_CAPS ("application/x-id3");
static void static void
id3v2_type_find (GstTypeFind * tf, gpointer unused) id3v2_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 10); const guint8 *data = gst_type_find_peek (tf, 0, 10);
if (data && memcmp (data, "ID3", 3) == 0 && if (data && memcmp (data, "ID3", 3) == 0 &&
data[3] != 0xFF && data[4] != 0xFF && data[3] != 0xFF && data[4] != 0xFF &&
@ -547,7 +551,7 @@ id3v2_type_find (GstTypeFind * tf, gpointer unused)
static void static void
id3v1_type_find (GstTypeFind * tf, gpointer unused) id3v1_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, -128, 3); const guint8 *data = gst_type_find_peek (tf, -128, 3);
if (data && memcmp (data, "TAG", 3) == 0) { if (data && memcmp (data, "TAG", 3) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, ID3_CAPS); gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, ID3_CAPS);
@ -562,7 +566,7 @@ static GstStaticCaps apetag_caps = GST_STATIC_CAPS ("application/x-apetag");
static void static void
apetag_type_find (GstTypeFind * tf, gpointer unused) apetag_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data; const guint8 *data;
/* APEv1/2 at start of file */ /* APEv1/2 at start of file */
data = gst_type_find_peek (tf, 0, 8); data = gst_type_find_peek (tf, 0, 8);
@ -587,7 +591,7 @@ static GstStaticCaps tta_caps = GST_STATIC_CAPS ("audio/x-ttafile");
static void static void
tta_type_find (GstTypeFind * tf, gpointer unused) tta_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 3); const guint8 *data = gst_type_find_peek (tf, 0, 3);
if (data) { if (data) {
if (memcmp (data, "TTA", 3) == 0) { if (memcmp (data, "TTA", 3) == 0) {
@ -985,8 +989,8 @@ static void
mp3_type_find_at_offset (GstTypeFind * tf, guint64 start_off, mp3_type_find_at_offset (GstTypeFind * tf, guint64 start_off,
guint * found_layer, GstTypeFindProbability * found_prob) guint * found_layer, GstTypeFindProbability * found_prob)
{ {
guint8 *data = NULL; const guint8 *data = NULL;
guint8 *data_end = NULL; const guint8 *data_end = NULL;
guint size; guint size;
guint64 skipped; guint64 skipped;
gint last_free_offset = -1; gint last_free_offset = -1;
@ -1010,7 +1014,7 @@ mp3_type_find_at_offset (GstTypeFind * tf, guint64 start_off,
data_end = data + size; data_end = data + size;
} }
if (*data == 0xFF) { if (*data == 0xFF) {
guint8 *head_data = NULL; const guint8 *head_data = NULL;
guint layer = 0, bitrate, samplerate, channels; guint layer = 0, bitrate, samplerate, channels;
guint found = 0; /* number of valid headers found */ guint found = 0; /* number of valid headers found */
guint64 offset = skipped; guint64 offset = skipped;
@ -1128,7 +1132,7 @@ static void
mp3_type_find (GstTypeFind * tf, gpointer unused) mp3_type_find (GstTypeFind * tf, gpointer unused)
{ {
GstTypeFindProbability prob, mid_prob; GstTypeFindProbability prob, mid_prob;
guint8 *data; const guint8 *data;
guint layer, mid_layer; guint layer, mid_layer;
guint64 length; guint64 length;
@ -1198,7 +1202,7 @@ GST_STATIC_CAPS ("audio/x-musepack, streamversion= (int) { 7, 8 }");
static void static void
musepack_type_find (GstTypeFind * tf, gpointer unused) musepack_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 4); const guint8 *data = gst_type_find_peek (tf, 0, 4);
GstTypeFindProbability prop = GST_TYPE_FIND_MINIMUM; GstTypeFindProbability prop = GST_TYPE_FIND_MINIMUM;
gint streamversion = -1; gint streamversion = -1;
@ -1520,7 +1524,7 @@ wavpack_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint64 offset; guint64 offset;
guint32 blocksize; guint32 blocksize;
guint8 *data; const guint8 *data;
data = gst_type_find_peek (tf, 0, 32); data = gst_type_find_peek (tf, 0, 32);
if (!data) if (!data)
@ -1583,7 +1587,7 @@ GST_STATIC_CAPS ("application/postscript");
static void static void
postscript_type_find (GstTypeFind * tf, gpointer unused) postscript_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 3); const guint8 *data = gst_type_find_peek (tf, 0, 3);
if (!data) if (!data)
return; return;
@ -1633,8 +1637,8 @@ GST_STATIC_CAPS ("multipart/x-mixed-replace");
static void static void
multipart_type_find (GstTypeFind * tf, gpointer unused) multipart_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data; const guint8 *data;
guint8 *x; const guint8 *x;
#define MULTIPART_MAX_BOUNDARY_OFFSET 16 #define MULTIPART_MAX_BOUNDARY_OFFSET 16
data = gst_type_find_peek (tf, 0, MULTIPART_MAX_BOUNDARY_OFFSET); data = gst_type_find_peek (tf, 0, MULTIPART_MAX_BOUNDARY_OFFSET);
@ -1743,7 +1747,7 @@ mpeg_sys_is_valid_pack (GstTypeFind * tf, const guint8 * data, guint len,
} }
static gboolean static gboolean
mpeg_sys_is_valid_pes (GstTypeFind * tf, guint8 * data, guint len, mpeg_sys_is_valid_pes (GstTypeFind * tf, const guint8 * data, guint len,
guint * pack_size) guint * pack_size)
{ {
guint pes_packet_len; guint pes_packet_len;
@ -1771,7 +1775,7 @@ mpeg_sys_is_valid_pes (GstTypeFind * tf, guint8 * data, guint len,
} }
static gboolean static gboolean
mpeg_sys_is_valid_sys (GstTypeFind * tf, guint8 * data, guint len, mpeg_sys_is_valid_sys (GstTypeFind * tf, const guint8 * data, guint len,
guint * pack_size) guint * pack_size)
{ {
guint sys_hdr_len; guint sys_hdr_len;
@ -1812,7 +1816,7 @@ mpeg_sys_is_valid_sys (GstTypeFind * tf, guint8 * data, guint len,
static void static void
mpeg_sys_type_find (GstTypeFind * tf, gpointer unused) mpeg_sys_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data, *data0, *first_sync, *end; const guint8 *data, *data0, *first_sync, *end;
gint mpegversion = 0; gint mpegversion = 0;
guint pack_headers = 0; guint pack_headers = 0;
guint pes_headers = 0; guint pes_headers = 0;
@ -1953,7 +1957,7 @@ mpeg_ts_probe_headers (GstTypeFind * tf, guint64 offset, gint packet_size)
{ {
/* We always enter this function having found at least one header already */ /* We always enter this function having found at least one header already */
gint found = 1; gint found = 1;
guint8 *data = NULL; const guint8 *data = NULL;
GST_LOG ("looking for mpeg-ts packets of size %u", packet_size); GST_LOG ("looking for mpeg-ts packets of size %u", packet_size);
while (found < GST_MPEGTS_TYPEFIND_MAX_HEADERS) { while (found < GST_MPEGTS_TYPEFIND_MAX_HEADERS) {
@ -1978,8 +1982,7 @@ mpeg_ts_type_find (GstTypeFind * tf, gpointer unused)
/* TS packet sizes to test: normal, DVHS packet size and /* TS packet sizes to test: normal, DVHS packet size and
* FEC with 16 or 20 byte codes packet size. */ * FEC with 16 or 20 byte codes packet size. */
const gint pack_sizes[] = { 188, 192, 204, 208 }; const gint pack_sizes[] = { 188, 192, 204, 208 };
const guint8 *data = NULL;
guint8 *data = NULL;
guint size = 0; guint size = 0;
guint64 skipped = 0; guint64 skipped = 0;
@ -2414,7 +2417,7 @@ static GstStaticCaps aiff_caps = GST_STATIC_CAPS ("audio/x-aiff");
static void static void
aiff_type_find (GstTypeFind * tf, gpointer unused) aiff_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 4); const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data && memcmp (data, "FORM", 4) == 0) { if (data && memcmp (data, "FORM", 4) == 0) {
data += 8; data += 8;
@ -2431,7 +2434,7 @@ static GstStaticCaps svx_caps = GST_STATIC_CAPS ("audio/x-svx");
static void static void
svx_type_find (GstTypeFind * tf, gpointer unused) svx_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 4); const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data && memcmp (data, "FORM", 4) == 0) { if (data && memcmp (data, "FORM", 4) == 0) {
data += 8; data += 8;
@ -2448,7 +2451,7 @@ static GstStaticCaps shn_caps = GST_STATIC_CAPS ("audio/x-shorten");
static void static void
shn_type_find (GstTypeFind * tf, gpointer unused) shn_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 4); const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data && memcmp (data, "ajkg", 4) == 0) { if (data && memcmp (data, "ajkg", 4) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SHN_CAPS); gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SHN_CAPS);
@ -2467,7 +2470,7 @@ static GstStaticCaps ape_caps = GST_STATIC_CAPS ("application/x-ape");
static void static void
ape_type_find (GstTypeFind * tf, gpointer unused) ape_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 4); const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data && memcmp (data, "MAC ", 4) == 0) { if (data && memcmp (data, "MAC ", 4) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY + 10, APE_CAPS); gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY + 10, APE_CAPS);
@ -2484,7 +2487,7 @@ static GstStaticCaps m4a_caps = GST_STATIC_CAPS ("audio/x-m4a");
static void static void
m4a_type_find (GstTypeFind * tf, gpointer unused) m4a_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 4, 8); const guint8 *data = gst_type_find_peek (tf, 4, 8);
if (data && (memcmp (data, "ftypM4A ", 8) == 0)) { if (data && (memcmp (data, "ftypM4A ", 8) == 0)) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, M4A_CAPS); gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, M4A_CAPS);
@ -2521,7 +2524,7 @@ q3gp_type_find (GstTypeFind * tf, gpointer unused)
const gchar *profile; const gchar *profile;
guint32 ftyp_size = 0; guint32 ftyp_size = 0;
gint offset = 0; gint offset = 0;
guint8 *data = NULL; const guint8 *data = NULL;
if ((data = gst_type_find_peek (tf, 0, 12)) == NULL) { if ((data = gst_type_find_peek (tf, 0, 12)) == NULL) {
return; return;
@ -2571,7 +2574,7 @@ static GstStaticCaps jp2_caps = GST_STATIC_CAPS ("image/jp2");
static void static void
jp2_type_find (GstTypeFind * tf, gpointer unused) jp2_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data; const guint8 *data;
data = gst_type_find_peek (tf, 0, 24); data = gst_type_find_peek (tf, 0, 24);
if (!data) if (!data)
@ -2602,7 +2605,7 @@ static GstStaticCaps qt_caps = GST_STATIC_CAPS ("video/quicktime");
static void static void
qt_type_find (GstTypeFind * tf, gpointer unused) qt_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data; const guint8 *data;
guint tip = 0; guint tip = 0;
guint64 offset = 0; guint64 offset = 0;
guint64 size; guint64 size;
@ -2669,7 +2672,7 @@ qt_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
if (size == 1) { if (size == 1) {
guint8 *sizedata; const guint8 *sizedata;
sizedata = gst_type_find_peek (tf, offset + 8, 8); sizedata = gst_type_find_peek (tf, offset + 8, 8);
if (sizedata == NULL) if (sizedata == NULL)
@ -2765,7 +2768,7 @@ static GstStaticCaps mod_caps = GST_STATIC_CAPS ("audio/x-mod");
static void static void
mod_type_find (GstTypeFind * tf, gpointer unused) mod_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data; const guint8 *data;
/* MOD */ /* MOD */
if ((data = gst_type_find_peek (tf, 1080, 4)) != NULL) { if ((data = gst_type_find_peek (tf, 1080, 4)) != NULL) {
@ -2821,7 +2824,7 @@ mod_type_find (GstTypeFind * tf, gpointer unused)
} }
/* DSM */ /* DSM */
if (memcmp (data, "RIFF", 4) == 0) { if (memcmp (data, "RIFF", 4) == 0) {
guint8 *data2 = gst_type_find_peek (tf, 8, 4); const guint8 *data2 = gst_type_find_peek (tf, 8, 4);
if (data2) { if (data2) {
if (memcmp (data2, "DSMF", 4) == 0) { if (memcmp (data2, "DSMF", 4) == 0) {
@ -2832,7 +2835,7 @@ mod_type_find (GstTypeFind * tf, gpointer unused)
} }
/* FAM */ /* FAM */
if (memcmp (data, "FAM\xFE", 4) == 0) { if (memcmp (data, "FAM\xFE", 4) == 0) {
guint8 *data2 = gst_type_find_peek (tf, 44, 3); const guint8 *data2 = gst_type_find_peek (tf, 44, 3);
if (data2) { if (data2) {
if (memcmp (data2, "compare", 3) == 0) { if (memcmp (data2, "compare", 3) == 0) {
@ -2846,7 +2849,7 @@ mod_type_find (GstTypeFind * tf, gpointer unused)
} }
/* GDM */ /* GDM */
if (memcmp (data, "GDM\xFE", 4) == 0) { if (memcmp (data, "GDM\xFE", 4) == 0) {
guint8 *data2 = gst_type_find_peek (tf, 71, 4); const guint8 *data2 = gst_type_find_peek (tf, 71, 4);
if (data2) { if (data2) {
if (memcmp (data2, "GMFS", 4) == 0) { if (memcmp (data2, "GMFS", 4) == 0) {
@ -2877,7 +2880,7 @@ mod_type_find (GstTypeFind * tf, gpointer unused)
if ((data = gst_type_find_peek (tf, 20, 8)) != NULL) { if ((data = gst_type_find_peek (tf, 20, 8)) != NULL) {
if (g_ascii_strncasecmp ((gchar *) data, "!Scream!", 8) == 0 || if (g_ascii_strncasecmp ((gchar *) data, "!Scream!", 8) == 0 ||
g_ascii_strncasecmp ((gchar *) data, "BMOD2STM", 8) == 0) { g_ascii_strncasecmp ((gchar *) data, "BMOD2STM", 8) == 0) {
guint8 *id, *stmtype; const guint8 *id, *stmtype;
if ((id = gst_type_find_peek (tf, 28, 1)) == NULL) if ((id = gst_type_find_peek (tf, 28, 1)) == NULL)
return; return;
@ -2905,7 +2908,7 @@ GST_STATIC_CAPS ("application/x-shockwave-flash");
static void static void
swf_type_find (GstTypeFind * tf, gpointer unused) swf_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 4); const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data && (data[0] == 'F' || data[0] == 'C') && if (data && (data[0] == 'F' || data[0] == 'C') &&
data[1] == 'W' && data[2] == 'S') { data[1] == 'W' && data[2] == 'S') {
@ -3096,7 +3099,7 @@ static GstStaticCaps tiff_le_caps = GST_STATIC_CAPS ("image/tiff, "
static void static void
tiff_type_find (GstTypeFind * tf, gpointer ununsed) tiff_type_find (GstTypeFind * tf, gpointer ununsed)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 8); const guint8 *data = gst_type_find_peek (tf, 0, 8);
guint8 le_header[4] = { 0x49, 0x49, 0x2A, 0x00 }; guint8 le_header[4] = { 0x49, 0x49, 0x2A, 0x00 };
guint8 be_header[4] = { 0x4D, 0x4D, 0x00, 0x2A }; guint8 be_header[4] = { 0x4D, 0x4D, 0x00, 0x2A };
@ -3213,7 +3216,7 @@ static GstStaticCaps sds_caps = GST_STATIC_CAPS ("audio/x-sds");
static void static void
sds_type_find (GstTypeFind * tf, gpointer ununsed) sds_type_find (GstTypeFind * tf, gpointer ununsed)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 4); const guint8 *data = gst_type_find_peek (tf, 0, 4);
guint8 mask[4] = { 0xFF, 0xFF, 0x80, 0xFF }; guint8 mask[4] = { 0xFF, 0xFF, 0x80, 0xFF };
guint8 match[4] = { 0xF0, 0x7E, 0, 0x01 }; guint8 match[4] = { 0xF0, 0x7E, 0, 0x01 };
gint x; gint x;
@ -3234,7 +3237,7 @@ static GstStaticCaps ircam_caps = GST_STATIC_CAPS ("audio/x-ircam");
static void static void
ircam_type_find (GstTypeFind * tf, gpointer ununsed) ircam_type_find (GstTypeFind * tf, gpointer ununsed)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 4); const guint8 *data = gst_type_find_peek (tf, 0, 4);
guint8 mask[4] = { 0xFF, 0xFF, 0xF8, 0xFF }; guint8 mask[4] = { 0xFF, 0xFF, 0xF8, 0xFF };
guint8 match[4] = { 0x64, 0xA3, 0x00, 0x00 }; guint8 match[4] = { 0x64, 0xA3, 0x00, 0x00 };
gint x; gint x;
@ -3266,7 +3269,7 @@ static gboolean
ebml_check_header (GstTypeFind * tf, const gchar * doctype, int doctype_len) ebml_check_header (GstTypeFind * tf, const gchar * doctype, int doctype_len)
{ {
/* 4 bytes for EBML ID, 1 byte for header length identifier */ /* 4 bytes for EBML ID, 1 byte for header length identifier */
guint8 *data = gst_type_find_peek (tf, 0, 4 + 1); const guint8 *data = gst_type_find_peek (tf, 0, 4 + 1);
gint len_mask = 0x80, size = 1, n = 1, total; gint len_mask = 0x80, size = 1, n = 1, total;
if (!data) if (!data)
@ -3394,7 +3397,7 @@ static GstStaticCaps dv_caps = GST_STATIC_CAPS ("video/x-dv, "
static void static void
dv_type_find (GstTypeFind * tf, gpointer private) dv_type_find (GstTypeFind * tf, gpointer private)
{ {
guint8 *data; const guint8 *data;
data = gst_type_find_peek (tf, 0, 5); data = gst_type_find_peek (tf, 0, 5);
@ -3426,7 +3429,7 @@ static GstStaticCaps ogg_annodex_caps =
static void static void
ogganx_type_find (GstTypeFind * tf, gpointer private) ogganx_type_find (GstTypeFind * tf, gpointer private)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 4); const guint8 *data = gst_type_find_peek (tf, 0, 4);
if ((data != NULL) && (memcmp (data, "OggS", 4) == 0)) { if ((data != NULL) && (memcmp (data, "OggS", 4) == 0)) {
@ -3448,7 +3451,7 @@ static GstStaticCaps vorbis_caps = GST_STATIC_CAPS ("audio/x-vorbis");
static void static void
vorbis_type_find (GstTypeFind * tf, gpointer private) vorbis_type_find (GstTypeFind * tf, gpointer private)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 30); const guint8 *data = gst_type_find_peek (tf, 0, 30);
if (data) { if (data) {
guint blocksize_0; guint blocksize_0;
@ -3493,7 +3496,7 @@ static GstStaticCaps theora_caps = GST_STATIC_CAPS ("video/x-theora");
static void static void
theora_type_find (GstTypeFind * tf, gpointer private) theora_type_find (GstTypeFind * tf, gpointer private)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 7); //42); const guint8 *data = gst_type_find_peek (tf, 0, 7); //42);
if (data) { if (data) {
if (data[0] != 0x80) if (data[0] != 0x80)
@ -3510,7 +3513,7 @@ theora_type_find (GstTypeFind * tf, gpointer private)
static void static void
kate_type_find (GstTypeFind * tf, gpointer private) kate_type_find (GstTypeFind * tf, gpointer private)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 64); const guint8 *data = gst_type_find_peek (tf, 0, 64);
gchar category[16] = { 0, }; gchar category[16] = { 0, };
if (G_UNLIKELY (data == NULL)) if (G_UNLIKELY (data == NULL))
@ -3543,7 +3546,7 @@ GST_STATIC_CAPS ("application/x-ogm-video");
static void static void
ogmvideo_type_find (GstTypeFind * tf, gpointer private) ogmvideo_type_find (GstTypeFind * tf, gpointer private)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 9); const guint8 *data = gst_type_find_peek (tf, 0, 9);
if (data) { if (data) {
if (memcmp (data, "\001video\000\000\000", 9) != 0) if (memcmp (data, "\001video\000\000\000", 9) != 0)
@ -3558,7 +3561,7 @@ GST_STATIC_CAPS ("application/x-ogm-audio");
static void static void
ogmaudio_type_find (GstTypeFind * tf, gpointer private) ogmaudio_type_find (GstTypeFind * tf, gpointer private)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 9); const guint8 *data = gst_type_find_peek (tf, 0, 9);
if (data) { if (data) {
if (memcmp (data, "\001audio\000\000\000", 9) != 0) if (memcmp (data, "\001audio\000\000\000", 9) != 0)
@ -3573,7 +3576,7 @@ static GstStaticCaps ogmtext_caps = GST_STATIC_CAPS ("application/x-ogm-text");
static void static void
ogmtext_type_find (GstTypeFind * tf, gpointer private) ogmtext_type_find (GstTypeFind * tf, gpointer private)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 9); const guint8 *data = gst_type_find_peek (tf, 0, 9);
if (data) { if (data) {
if (memcmp (data, "\001text\000\000\000\000", 9) != 0) if (memcmp (data, "\001text\000\000\000\000", 9) != 0)
@ -3590,7 +3593,7 @@ static GstStaticCaps speex_caps = GST_STATIC_CAPS ("audio/x-speex");
static void static void
speex_type_find (GstTypeFind * tf, gpointer private) speex_type_find (GstTypeFind * tf, gpointer private)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 80); const guint8 *data = gst_type_find_peek (tf, 0, 80);
if (data) { if (data) {
/* 8 byte string "Speex " /* 8 byte string "Speex "
@ -3626,7 +3629,7 @@ static GstStaticCaps celt_caps = GST_STATIC_CAPS ("audio/x-celt");
static void static void
celt_type_find (GstTypeFind * tf, gpointer private) celt_type_find (GstTypeFind * tf, gpointer private)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 8); const guint8 *data = gst_type_find_peek (tf, 0, 8);
if (data) { if (data) {
/* 8 byte string "CELT " */ /* 8 byte string "CELT " */
@ -3645,7 +3648,7 @@ GST_STATIC_CAPS ("application/x-ogg-skeleton, parsed=(boolean)FALSE");
static void static void
oggskel_type_find (GstTypeFind * tf, gpointer private) oggskel_type_find (GstTypeFind * tf, gpointer private)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 12); const guint8 *data = gst_type_find_peek (tf, 0, 12);
if (data) { if (data) {
/* 8 byte string "fishead\0" for the ogg skeleton stream */ /* 8 byte string "fishead\0" for the ogg skeleton stream */
@ -3671,7 +3674,7 @@ static void
cmml_type_find (GstTypeFind * tf, gpointer private) cmml_type_find (GstTypeFind * tf, gpointer private)
{ {
/* Header is 12 bytes minimum (though we don't check the minor version */ /* Header is 12 bytes minimum (though we don't check the minor version */
guint8 *data = gst_type_find_peek (tf, 0, 12); const guint8 *data = gst_type_find_peek (tf, 0, 12);
if (data) { if (data) {
@ -3698,7 +3701,7 @@ static GstStaticCaps tar_caps = GST_STATIC_CAPS ("application/x-tar");
static void static void
tar_type_find (GstTypeFind * tf, gpointer unused) tar_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 257, 8); const guint8 *data = gst_type_find_peek (tf, 257, 8);
/* of course we are not certain, but we don't want other typefind funcs /* of course we are not certain, but we don't want other typefind funcs
* to detect formats of files within the tar archive, e.g. mp3s */ * to detect formats of files within the tar archive, e.g. mp3s */
@ -3720,7 +3723,7 @@ static GstStaticCaps ar_caps = GST_STATIC_CAPS ("application/x-ar");
static void static void
ar_type_find (GstTypeFind * tf, gpointer unused) ar_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 24); const guint8 *data = gst_type_find_peek (tf, 0, 24);
if (data && memcmp (data, "!<arch>", 7) == 0) { if (data && memcmp (data, "!<arch>", 7) == 0) {
gint i; gint i;
@ -3747,7 +3750,7 @@ static GstStaticCaps au_caps = GST_STATIC_CAPS ("audio/x-au");
static void static void
au_type_find (GstTypeFind * tf, gpointer unused) au_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 4); const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data) { if (data) {
if (memcmp (data, ".snd", 4) == 0 || memcmp (data, "dns.", 4) == 0) { if (memcmp (data, ".snd", 4) == 0 || memcmp (data, "dns.", 4) == 0) {
@ -3769,7 +3772,7 @@ static GstStaticCaps nuv_caps = GST_STATIC_CAPS ("video/x-nuv");
static void static void
nuv_type_find (GstTypeFind * tf, gpointer unused) nuv_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 11); const guint8 *data = gst_type_find_peek (tf, 0, 11);
if (data) { if (data) {
if (memcmp (data, "MythTVVideo", 11) == 0 if (memcmp (data, "MythTVVideo", 11) == 0
@ -3787,7 +3790,7 @@ static GstStaticCaps paris_caps = GST_STATIC_CAPS ("audio/x-paris");
static void static void
paris_type_find (GstTypeFind * tf, gpointer unused) paris_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 4); const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data) { if (data) {
if (memcmp (data, " paf", 4) == 0 || memcmp (data, "fap ", 4) == 0) { if (memcmp (data, " paf", 4) == 0 || memcmp (data, "fap ", 4) == 0) {
@ -3804,7 +3807,7 @@ static GstStaticCaps ilbc_caps = GST_STATIC_CAPS ("audio/iLBC-sh");
static void static void
ilbc_type_find (GstTypeFind * tf, gpointer unused) ilbc_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 8); const guint8 *data = gst_type_find_peek (tf, 0, 8);
if (data) { if (data) {
if (memcmp (data, "#!iLBC30", 8) == 0 || memcmp (data, "#!iLBC20", 8) == 0) { if (memcmp (data, "#!iLBC30", 8) == 0 || memcmp (data, "#!iLBC20", 8) == 0) {
@ -3822,7 +3825,7 @@ GST_STATIC_CAPS ("application/x-ms-dos-executable");
static void static void
msdos_type_find (GstTypeFind * tf, gpointer unused) msdos_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 64); const guint8 *data = gst_type_find_peek (tf, 0, 64);
if (data && data[0] == 'M' && data[1] == 'Z' && if (data && data[0] == 'M' && data[1] == 'Z' &&
GST_READ_UINT16_LE (data + 8) == 4) { GST_READ_UINT16_LE (data + 8) == 4) {
@ -3849,7 +3852,7 @@ mmsh_type_find (GstTypeFind * tf, gpointer unused)
0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c 0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c
}; };
guint8 *data; const guint8 *data;
data = gst_type_find_peek (tf, 0, 2 + 2 + 4 + 2 + 2 + 16); data = gst_type_find_peek (tf, 0, 2 + 2 + 4 + 2 + 2 + 16);
if (data && data[0] == 0x24 && data[1] == 0x48 && if (data && data[0] == 0x24 && data[1] == 0x48 &&
@ -3871,7 +3874,7 @@ static GstStaticCaps dirac_caps = GST_STATIC_CAPS ("video/x-dirac");
static void static void
dirac_type_find (GstTypeFind * tf, gpointer unused) dirac_type_find (GstTypeFind * tf, gpointer unused)
{ {
guint8 *data = gst_type_find_peek (tf, 0, 8); const guint8 *data = gst_type_find_peek (tf, 0, 8);
if (data) { if (data) {
if (memcmp (data, "BBCD", 4) == 0 || memcmp (data, "KW-DIRAC", 8) == 0) { if (memcmp (data, "BBCD", 4) == 0 || memcmp (data, "KW-DIRAC", 8) == 0) {
@ -3892,7 +3895,7 @@ vivo_type_find (GstTypeFind * tf, gpointer unused)
static const guint8 vivo_marker[] = { 'V', 'e', 'r', 's', 'i', 'o', 'n', static const guint8 vivo_marker[] = { 'V', 'e', 'r', 's', 'i', 'o', 'n',
':', 'V', 'i', 'v', 'o', '/' ':', 'V', 'i', 'v', 'o', '/'
}; };
guint8 *data; const guint8 *data;
guint hdr_len, pos; guint hdr_len, pos;
data = gst_type_find_peek (tf, 0, 1024); data = gst_type_find_peek (tf, 0, 1024);
@ -3930,7 +3933,7 @@ xdgmime_typefind (GstTypeFind * find, gpointer user_data)
gchar *mimetype; gchar *mimetype;
gsize length = 16384; gsize length = 16384;
guint64 tf_length; guint64 tf_length;
guint8 *data; const guint8 *data;
gchar *tmp; gchar *tmp;
if ((tf_length = gst_type_find_get_length (find)) > 0) if ((tf_length = gst_type_find_get_length (find)) > 0)
@ -3982,7 +3985,7 @@ xdgmime_typefind (GstTypeFind * find, gpointer user_data)
static void static void
windows_icon_typefind (GstTypeFind * find, gpointer user_data) windows_icon_typefind (GstTypeFind * find, gpointer user_data)
{ {
guint8 *data; const guint8 *data;
gint64 datalen; gint64 datalen;
guint16 type, nimages; guint16 type, nimages;
gint32 size, offset; gint32 size, offset;
@ -4024,7 +4027,7 @@ windows_icon_typefind (GstTypeFind * find, gpointer user_data)
static void static void
wbmp_typefind (GstTypeFind * find, gpointer user_data) wbmp_typefind (GstTypeFind * find, gpointer user_data)
{ {
guint8 *data; const guint8 *data;
gint64 datalen; gint64 datalen;
guint w, h, size; guint w, h, size;
@ -4142,7 +4145,7 @@ static void
start_with_type_find (GstTypeFind * tf, gpointer private) start_with_type_find (GstTypeFind * tf, gpointer private)
{ {
GstTypeFindData *start_with = (GstTypeFindData *) private; GstTypeFindData *start_with = (GstTypeFindData *) private;
guint8 *data; const guint8 *data;
GST_LOG ("trying to find mime type %s with the first %u bytes of data", GST_LOG ("trying to find mime type %s with the first %u bytes of data",
gst_structure_get_name (gst_caps_get_structure (start_with->caps, 0)), gst_structure_get_name (gst_caps_get_structure (start_with->caps, 0)),
@ -4182,7 +4185,7 @@ static void
riff_type_find (GstTypeFind * tf, gpointer private) riff_type_find (GstTypeFind * tf, gpointer private)
{ {
GstTypeFindData *riff_data = (GstTypeFindData *) private; GstTypeFindData *riff_data = (GstTypeFindData *) private;
guint8 *data = gst_type_find_peek (tf, 0, 12); const guint8 *data = gst_type_find_peek (tf, 0, 12);
if (data && (memcmp (data, "RIFF", 4) == 0 || memcmp (data, "AVF0", 4) == 0)) { if (data && (memcmp (data, "RIFF", 4) == 0 || memcmp (data, "AVF0", 4) == 0)) {
data += 8; data += 8;