From c8dc5a09809c47ada99bc05d7696ed31eff447fa Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Mon, 11 Apr 2016 13:26:35 +0200 Subject: [PATCH] Parsing of unsupported MP3 streams improved - For supported MP3 streams, all frame header information must be the same for the whole stream. - For unsupported MP3 streams, this has been removed and only the stream type has to be the same. This will lead to some more false positives, but give longer streams, so the log is not bloated with thousands small false positives --- precomp.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/precomp.cpp b/precomp.cpp index 6509dd2..aad2b3f 100644 --- a/precomp.cpp +++ b/precomp.cpp @@ -3705,13 +3705,19 @@ bool compress_file(float min_percent, float max_percent) { if ((type != MPEG1_LAYER_III) && (saved_input_file_pos <= suppress_mp3_type_until[type])) { break; } - } else if ( - (mpeg != ((in[1] >> 3) & 0x3)) || - (layer != ((in[1] >> 1) & 0x3)) || - (protection != ((in[1] >> 0) & 0x1)) || - (samples != ((in[2] >> 2) & 0x3)) || - (channels != ((in[3] >> 6) & 0x3)) || - (type != MBITS( in[1], 5, 1))) break; + } else { + if (type == MPEG1_LAYER_III) { // supported MP3 type, all header information must be identical to the first frame + if ( + (mpeg != ((in[1] >> 3) & 0x3)) || + (layer != ((in[1] >> 1) & 0x3)) || + (protection != ((in[1] >> 0) & 0x1)) || + (samples != ((in[2] >> 2) & 0x3)) || + (channels != ((in[3] >> 6) & 0x3)) || + (type != MBITS( in[1], 5, 1))) break; + } else { // unsupported type, compare only type, ignore the other header information to get a longer stream + if (type != MBITS( in[1], 5, 1)) break; + } + } bits = (in[2] >> 4) & 0xF; padding = (in[2] >> 1) & 0x1;