Skip to content

Commit

Permalink
Another fix for MP3 slowdown
Browse files Browse the repository at this point in the history
- Error message "inconsistent original bit"
  • Loading branch information
schnaader committed Apr 9, 2019
1 parent 314429b commit 7ebe71c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion precomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ long long suppress_mp3_type_until[16];
long long suppress_mp3_big_value_pairs_sum;
long long suppress_mp3_non_zero_padbits_sum;
long long suppress_mp3_inconsistent_emphasis_sum;
long long suppress_mp3_inconsistent_original_bit;
long long mp3_parsing_cache_second_frame;
long long mp3_parsing_cache_n;
long long mp3_parsing_cache_mp3_length;
Expand Down Expand Up @@ -643,6 +644,7 @@ int init(int argc, char* argv[]) {
suppress_mp3_big_value_pairs_sum = -1;
suppress_mp3_non_zero_padbits_sum = -1;
suppress_mp3_inconsistent_emphasis_sum = -1;
suppress_mp3_inconsistent_original_bit = -1;
mp3_parsing_cache_second_frame = -1;

// init LZMA filters
Expand Down Expand Up @@ -1332,6 +1334,7 @@ int init_comfort(int argc, char* argv[]) {
suppress_mp3_big_value_pairs_sum = -1;
suppress_mp3_non_zero_padbits_sum = -1;
suppress_mp3_inconsistent_emphasis_sum = -1;
suppress_mp3_inconsistent_original_bit = -1;
mp3_parsing_cache_second_frame = -1;

// init LZMA filters
Expand Down Expand Up @@ -4272,7 +4275,8 @@ bool compress_file(float min_percent, float max_percent) {
// sums of position and length of last MP3 errors are suppressed to avoid slowdowns
if ((suppress_mp3_big_value_pairs_sum != position_length_sum)
&& (suppress_mp3_non_zero_padbits_sum != position_length_sum)
&& (suppress_mp3_inconsistent_emphasis_sum != position_length_sum)) {
&& (suppress_mp3_inconsistent_emphasis_sum != position_length_sum)
&& (suppress_mp3_inconsistent_original_bit != position_length_sum)) {
try_decompression_mp3(mp3_length);
}
} else if (type > 0) {
Expand Down Expand Up @@ -6746,6 +6750,11 @@ void try_decompression_mp3 (long long mp3_length) {
if (DEBUG_MODE) {
cout << "Ignoring following streams with position/length sum " << suppress_mp3_inconsistent_emphasis_sum << " to avoid slowdown" << endl;
}
} else if ((!recompress_success) && (strncmp(recompress_msg, "inconsistent original bit", 25) == 0)) {
suppress_mp3_inconsistent_original_bit = saved_input_file_pos + mp3_length;
if (DEBUG_MODE) {
cout << "Ignoring following streams with position/length sum " << suppress_mp3_inconsistent_original_bit << " to avoid slowdown" << endl;
}
}

decompressed_streams_count++;
Expand Down Expand Up @@ -7611,6 +7620,7 @@ void recursion_push() {
recursion_stack_push(&suppress_mp3_big_value_pairs_sum, sizeof(suppress_mp3_big_value_pairs_sum));
recursion_stack_push(&suppress_mp3_non_zero_padbits_sum, sizeof(suppress_mp3_non_zero_padbits_sum));
recursion_stack_push(&suppress_mp3_inconsistent_emphasis_sum, sizeof(suppress_mp3_inconsistent_emphasis_sum));
recursion_stack_push(&suppress_mp3_inconsistent_original_bit, sizeof(suppress_mp3_inconsistent_original_bit));
recursion_stack_push(&mp3_parsing_cache_second_frame, sizeof(mp3_parsing_cache_second_frame));
recursion_stack_push(&mp3_parsing_cache_n, sizeof(mp3_parsing_cache_n));
recursion_stack_push(&mp3_parsing_cache_mp3_length, sizeof(mp3_parsing_cache_mp3_length));
Expand All @@ -7632,6 +7642,7 @@ void recursion_pop() {
recursion_stack_pop(&mp3_parsing_cache_mp3_length, sizeof(mp3_parsing_cache_mp3_length));
recursion_stack_pop(&mp3_parsing_cache_n, sizeof(mp3_parsing_cache_n));
recursion_stack_pop(&mp3_parsing_cache_second_frame, sizeof(mp3_parsing_cache_second_frame));
recursion_stack_pop(&suppress_mp3_inconsistent_original_bit, sizeof(suppress_mp3_inconsistent_original_bit));
recursion_stack_pop(&suppress_mp3_inconsistent_emphasis_sum, sizeof(suppress_mp3_inconsistent_emphasis_sum));
recursion_stack_pop(&suppress_mp3_non_zero_padbits_sum, sizeof(suppress_mp3_non_zero_padbits_sum));
recursion_stack_pop(&suppress_mp3_big_value_pairs_sum, sizeof(suppress_mp3_big_value_pairs_sum));
Expand Down Expand Up @@ -7751,6 +7762,8 @@ recursion_result recursion_compress(long long compressed_bytes, long long decomp
suppress_mp3_big_value_pairs_sum = -1;
suppress_mp3_non_zero_padbits_sum = -1;
suppress_mp3_inconsistent_emphasis_sum = -1;
suppress_mp3_inconsistent_original_bit = -1;

mp3_parsing_cache_second_frame = -1;

// disable compression-on-the-fly in recursion - we don't want compressed compressed streams
Expand Down

0 comments on commit 7ebe71c

Please sign in to comment.