From: Sebastian Dröge Date: Mon, 13 Oct 2008 07:52:41 +0000 (+0000) Subject: gst/typefind/gsttypefindfunctions.c: Improve FLAC-without-headers typefinding by... X-Git-Tag: 1.19.3~511^2~10249 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=862fd1d50f7b1a0746bda9b5267c979fdffc11b2;p=platform%2Fupstream%2Fgstreamer.git gst/typefind/gsttypefindfunctions.c: Improve FLAC-without-headers typefinding by looking at most of the frame header ... Original commit message from CVS: * gst/typefind/gsttypefindfunctions.c: (flac_type_find): Improve FLAC-without-headers typefinding by looking at most of the frame header and checking if invalid values are used. Should prevent quite some false positives compared to the old version which only check if the first 14 bits are set. --- diff --git a/ChangeLog b/ChangeLog index e360c90..b77c967 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-10-13 Sebastian Dröge + + * gst/typefind/gsttypefindfunctions.c: (flac_type_find): + Improve FLAC-without-headers typefinding by looking at most of the + frame header and checking if invalid values are used. Should prevent + quite some false positives compared to the old version which only + check if the first 14 bits are set. + 2008-10-11 Stefan Kost * sys/xvimage/xvimagesink.c: diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index 90ee1ae..a02981f 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -541,13 +541,35 @@ flac_type_find (GstTypeFind * tf, gpointer unused) /* flac without headers */ /* 64K should be enough */ while (c.offset < (64 * 1024)) { - if (G_UNLIKELY (!data_scan_ctx_ensure_data (tf, &c, 2))) + if (G_UNLIKELY (!data_scan_ctx_ensure_data (tf, &c, 3))) break; if (data[0] == 0xff && (data[1] >> 2) == 0x3e) { + /* bit 15 must be 0 */ + if (((data[1] >> 1) & 0x01) == 0x01) + continue; + + /* blocksize must be != 0x00 */ + if ((data[2] >> 4) == 0x00) + continue; + + /* samplerate must be != 0x0f */ + if ((data[2] & 0x0f) == 0x0f) + continue; + + /* channel assignment must be < 11 */ + if ((data[3] >> 4) >= 11) + continue; + + /* sample size must be != 0x07 */ + if (((data[3] >> 1) & 0x07) == 0x07) + continue; + + /* next bit must be 0 */ + if ((data[3] & 0x01) == 0x01) + continue; + gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, FLAC_CAPS); - /* TODO: maybe check more parts of the frame header - * to lower the risk of false positives */ return; } data_scan_ctx_advance (tf, &c, 1);