From ff680417db4a3ff3cc9aefca9d9db8ae450254ed Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Fri, 22 Jan 2016 07:43:26 +0100 Subject: [PATCH] Only allow MPEG-1, Layer III as first frame This prevents passing the frames to packMP3 for each frame which slows down the process for non-MPEG-1, Layer III MP3s --- precomp.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/precomp.cpp b/precomp.cpp index d7b404b..ae448ab 100644 --- a/precomp.cpp +++ b/precomp.cpp @@ -125,6 +125,7 @@ const char* pjglib_version_info( void ); //PackMP3 things +#include "contrib/packjpg/bitops.h" // for MBITS #include "contrib/packmp3/pmp3tbl.h" // function to convert MP3 to PMP and vice versa @@ -4052,7 +4053,10 @@ bool compress_file(float min_percent, float max_percent) { protection = (in[1] >> 0) & 0x1; samples = (in[2] >> 2) & 0x3; channels = (in[3] >> 6) & 0x3; - } else if ( + // type must be MPEG-1, Layer III, packMP3 won't process any other files + int type = MBITS( in[1], 5, 1 ); + if ( type != MPEG1_LAYER_III ) break; + } else if ( (mpeg != ((in[1] >> 3) & 0x3)) || (layer != ((in[1] >> 1) & 0x3)) || (protection != ((in[1] >> 0) & 0x1)) ||