typefinding: tighten checks for 'freeform mp3' a little

Freeform mp3s typically have bitrates higher than the
otherwise max allowed rate. Prevents misdetection of
some truetype font files as mp3.

https://bugzilla.gnome.org/show_bug.cgi?id=732923
This commit is contained in:
Tim-Philipp Müller 2014-08-24 22:36:59 +01:00
parent 4a69d6ba3b
commit f14494f425

View file

@ -1255,6 +1255,7 @@ mp3_type_frame_length_from_header (guint32 header, guint * put_layer,
channels = (mode == 3) ? 1 : 2; channels = (mode == 3) ? 1 : 2;
samplerate = mp3types_freqs[version > 0 ? version - 1 : 0][samplerate]; samplerate = mp3types_freqs[version > 0 ? version - 1 : 0][samplerate];
if (bitrate == 0) { if (bitrate == 0) {
/* possible freeform mp3 */
if (layer == 1) { if (layer == 1) {
length *= 4; length *= 4;
length += possible_free_framelen; length += possible_free_framelen;
@ -1264,6 +1265,11 @@ mp3_type_frame_length_from_header (guint32 header, guint * put_layer,
bitrate = length * samplerate / bitrate = length * samplerate /
((layer == 3 && version != 3) ? 72000 : 144000); ((layer == 3 && version != 3) ? 72000 : 144000);
} }
/* freeform mp3 should have a higher-than-usually-allowed bitrate */
GST_LOG ("calculated bitrate: %u, max usually: %u", bitrate,
mp3types_bitrates[version == 3 ? 0 : 1][layer - 1][14]);
if (bitrate < mp3types_bitrates[version == 3 ? 0 : 1][layer - 1][14])
return 0;
} else { } else {
/* calculating */ /* calculating */
bitrate = mp3types_bitrates[version == 3 ? 0 : 1][layer - 1][bitrate]; bitrate = mp3types_bitrates[version == 3 ? 0 : 1][layer - 1][bitrate];