diff --git a/etc/Patches/OpusTools-Git20130118-Progress+NoResample.diff b/etc/Patches/OpusTools-Git20130118-Progress+NoResample.diff new file mode 100644 index 00000000..24eb521d --- /dev/null +++ b/etc/Patches/OpusTools-Git20130118-Progress+NoResample.diff @@ -0,0 +1,122 @@ + src/opusdec.c | 24 +++++++++++++++++++++--- + src/opusenc.c | 17 +++++++---------- + 2 files changed, 134 insertions(+), 71 deletions(-) + +diff --git a/src/opusdec.c b/src/opusdec.c +index 397ecb5..ac5a79d 100644 +--- a/src/opusdec.c ++++ b/src/opusdec.c +@@ -57,6 +57,7 @@ + # include + # include + # define I64FORMAT "I64d" ++# define ftello64(_x) _ftelli64((_x)) + #else + # define I64FORMAT "lld" + # define fopen_utf8(_x,_y) fopen((_x),(_y)) +@@ -658,6 +659,7 @@ int main(int argc, char **argv) + {"force-wav", no_argument, NULL, 0}, + {"packet-loss", required_argument, NULL, 0}, + {"save-range", required_argument, NULL, 0}, ++ {"no-resample", no_argument, NULL, 0}, + {0, 0, 0, 0} + }; + ogg_sync_state oy; +@@ -667,6 +669,7 @@ int main(int argc, char **argv) + int close_in=0; + int eos=0; + ogg_int64_t audio_size=0; ++ ogg_int64_t input_size=0; + double last_coded_seconds=0; + float loss_percent=-1; + float manual_gain=0; +@@ -681,6 +684,7 @@ int main(int argc, char **argv) + int dither=1; + shapestate shapemem; + SpeexResamplerState *resampler=NULL; ++ int no_resample = 0; + float gain=1; + int streams=0; + size_t last_spin=0; +@@ -742,7 +746,10 @@ int main(int argc, char **argv) + forcewav=1; + } else if (strcmp(long_options[option_index].name,"rate")==0) + { +- rate=atoi (optarg); ++ rate=((no_resample) ? 48000 : atoi(optarg)); ++ } else if (strcmp(long_options[option_index].name,"no-resample")==0) ++ { ++ no_resample=1; rate=48000; + } else if (strcmp(long_options[option_index].name,"gain")==0) + { + manual_gain=atof (optarg); +@@ -824,6 +831,16 @@ int main(int argc, char **argv) + close_in=1; + } + ++ /*detect input size*/ ++ if(fin != stdin) ++ { ++ struct _stat64 info; ++ if(_fstati64(_fileno(fin), &info) == 0) ++ { ++ input_size = info.st_size; ++ } ++ } ++ + /* .opus files use the Ogg container to provide framing and timekeeping. + * http://tools.ietf.org/html/draft-terriberry-oggopus + * The easiest way to decode the Ogg container is to use libogg, so +@@ -971,10 +988,11 @@ int main(int argc, char **argv) + /*Display a progress spinner while decoding.*/ + static const char spinner[]="|/-\\"; + double coded_seconds = (double)audio_size/(channels*rate*sizeof(short)); ++ double percent = (input_size>0) ? ((double)ftello64(fin))/((double)input_size) : 0.0; + if(coded_seconds>=last_coded_seconds+1){ +- fprintf(stderr,"\r[%c] %02d:%02d:%02d", spinner[last_spin&3], ++ fprintf(stderr,"\r[%c] %02d:%02d:%02d (%.f%%)", spinner[last_spin&3], + (int)(coded_seconds/3600),(int)(coded_seconds/60)%60, +- (int)(coded_seconds)%60); ++ (int)(coded_seconds)%60,percent*100.0); + fflush(stderr); + last_spin++; + last_coded_seconds=coded_seconds; +diff --git a/src/opusenc.c b/src/opusenc.c +index 749760a..2b472b0 100644 +--- a/src/opusenc.c ++++ b/src/opusenc.c +@@ -954,6 +954,7 @@ int main(int argc, char **argv) + double estbitrate; + double coded_seconds=nb_encoded/(double)coding_rate; + double wall_time=(stop_time-start_time)+1e-6; ++ double percent = 0.0; + char sbuf[55]; + static const char spinner[]="|/-\\"; + if(!with_hard_cbr){ +@@ -961,20 +962,16 @@ int main(int argc, char **argv) + estbitrate=(total_bytes*8.0/coded_seconds)*tweight+ + bitrate*(1.-tweight); + }else estbitrate=nbBytes*8*((double)coding_rate/frame_size); ++ if(inopt.total_samples_per_channel>0){ ++ percent = ((double)nb_encoded) / ((double)inopt.total_samples_per_channel); ++ } + fprintf(stderr,"\r"); + for(i=0;i0 && inopt.total_samples_per_channel #include +bool OpusDecoder::m_disableResampling = false; + OpusDecoder::OpusDecoder(void) : m_binary(lamexp_lookup_tool("opusdec.exe")) @@ -47,6 +49,11 @@ bool OpusDecoder::decode(const QString &sourceFile, const QString &outputFile, v QProcess process; QStringList args; + if(m_disableResampling) + { + args << "--no-resample"; + } + args << QDir::toNativeSeparators(sourceFile); args << QDir::toNativeSeparators(outputFile); diff --git a/src/Decoder_Opus.h b/src/Decoder_Opus.h index 825ec8ef..6f208535 100644 --- a/src/Decoder_Opus.h +++ b/src/Decoder_Opus.h @@ -33,6 +33,11 @@ public: static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static QStringList supportedTypes(void); + static void setDisableResampling(bool disableResample) { m_disableResampling = disableResample; } + private: const QString m_binary; + + //Options + static bool m_disableResampling; }; diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index 942255fa..a5e53d0e 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -44,6 +44,7 @@ #include "Encoder_Vorbis.h" #include "Encoder_Opus.h" #include "Encoder_Wave.h" +#include "Registry_Decoder.h" #include "Filter_Downmix.h" #include "Filter_Normalize.h" #include "Filter_Resample.h" @@ -483,7 +484,9 @@ void ProcessingDialog::initEncoding(void) m_userAborted = false; m_forcedAbort = false; m_playList.clear(); - + + DecoderRegistry::configureDecoders(m_settings); + CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor(Qt::white)); SET_PROGRESS_TEXT(tr("Encoding files, please wait...")); m_progressIndicator->start(); diff --git a/src/Encoder_Abstract.h b/src/Encoder_Abstract.h index 17f97b0b..489736cc 100644 --- a/src/Encoder_Abstract.h +++ b/src/Encoder_Abstract.h @@ -34,7 +34,7 @@ class AbstractEncoder : public AbstractTool public: AbstractEncoder(void); - ~AbstractEncoder(void); + virtual ~AbstractEncoder(void); //Internal encoder API virtual bool encode(const QString &sourceFile, const AudioFileModel &metaInfo, const QString &outputFile, volatile bool *abortFlag) = 0; diff --git a/src/Model_Settings.cpp b/src/Model_Settings.cpp index b1403a83..ec53282e 100644 --- a/src/Model_Settings.cpp +++ b/src/Model_Settings.cpp @@ -32,29 +32,31 @@ #include #include #include - +#include +#include +#include //////////////////////////////////////////////////////////// //Macros //////////////////////////////////////////////////////////// #define LAMEXP_MAKE_OPTION_I(OPT,DEF) \ -int SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF).toInt(); } \ +int SettingsModel::OPT(void) const { return m_settings->value(g_settingsId_##OPT, DEF).toInt(); } \ void SettingsModel::OPT(int value) { m_settings->setValue(g_settingsId_##OPT, value); } \ int SettingsModel::OPT##Default(void) { return DEF; } #define LAMEXP_MAKE_OPTION_S(OPT,DEF) \ -QString SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF).toString().trimmed(); } \ +QString SettingsModel::OPT(void) const { return m_settings->value(g_settingsId_##OPT, DEF).toString().trimmed(); } \ void SettingsModel::OPT(const QString &value) { m_settings->setValue(g_settingsId_##OPT, value); } \ QString SettingsModel::OPT##Default(void) { return DEF; } #define LAMEXP_MAKE_OPTION_B(OPT,DEF) \ -bool SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF).toBool(); } \ +bool SettingsModel::OPT(void) const { return m_settings->value(g_settingsId_##OPT, DEF).toBool(); } \ void SettingsModel::OPT(bool value) { m_settings->setValue(g_settingsId_##OPT, value); } \ bool SettingsModel::OPT##Default(void) { return DEF; } #define LAMEXP_MAKE_OPTION_U(OPT,DEF) \ -unsigned int SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF).toUInt(); } \ +unsigned int SettingsModel::OPT(void) const { return m_settings->value(g_settingsId_##OPT, DEF).toUInt(); } \ void SettingsModel::OPT(unsigned int value) { m_settings->setValue(g_settingsId_##OPT, value); } \ unsigned int SettingsModel::OPT##Default(void) { return DEF; } @@ -105,6 +107,7 @@ LAMEXP_MAKE_ID(aacEncProfile, "AdvancedOptions/AACEnc/ForceProfile"); LAMEXP_MAKE_ID(opusOptimizeFor, "AdvancedOptions/Opus/OptimizeForSignalType"); LAMEXP_MAKE_ID(opusComplexity, "AdvancedOptions/Opus/EncodingComplexity"); LAMEXP_MAKE_ID(opusFramesize, "AdvancedOptions/Opus/FrameSize"); +LAMEXP_MAKE_ID(opusDisableResample, "AdvancedOptions/Opus/DisableResample"); LAMEXP_MAKE_ID(normalizationFilterEnabled, "AdvancedOptions/VolumeNormalization/Enabled"); LAMEXP_MAKE_ID(normalizationFilterMaxVolume, "AdvancedOptions/VolumeNormalization/MaxVolume"); LAMEXP_MAKE_ID(normalizationFilterEqualizationMode, "AdvancedOptions/VolumeNormalization/EqualizationMode"); @@ -131,13 +134,13 @@ const int SettingsModel::mp3Bitrates[15] = {32, 40, 48, 56, 64, 80, 96, 112, 128 const int SettingsModel::ac3Bitrates[20] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640, -1}; const int SettingsModel::samplingRates[8] = {0, 16000, 22050, 24000, 32000, 44100, 48000, -1}; +static QReadWriteLock s_lock; + //////////////////////////////////////////////////////////// // Constructor //////////////////////////////////////////////////////////// SettingsModel::SettingsModel(void) -: - m_defaultLanguage(NULL) { QString configPath = "LameXP.ini"; @@ -291,13 +294,21 @@ void SettingsModel::syncNow(void) // Private Functions //////////////////////////////////////////////////////////// -QString SettingsModel::defaultLanguage(void) +QString *SettingsModel::m_defaultLanguage = NULL; + +QString SettingsModel::defaultLanguage(void) const { + QReadLocker readLock(&s_lock); + if(m_defaultLanguage) { return *m_defaultLanguage; } + //Acquire write lock now + readLock.unlock(); + QWriteLocker writeLock(&s_lock); + //Detect system langauge QLocale systemLanguage= QLocale::system(); qDebug("[Locale]"); @@ -409,6 +420,7 @@ LAMEXP_MAKE_OPTION_I(aftenExponentSearchSize, 8); LAMEXP_MAKE_OPTION_I(opusOptimizeFor, 0); LAMEXP_MAKE_OPTION_I(opusComplexity, 10); LAMEXP_MAKE_OPTION_I(opusFramesize, 3); +LAMEXP_MAKE_OPTION_B(opusDisableResample, false); LAMEXP_MAKE_OPTION_B(normalizationFilterEnabled, false) LAMEXP_MAKE_OPTION_I(normalizationFilterMaxVolume, -50) LAMEXP_MAKE_OPTION_I(normalizationFilterEqualizationMode, 0); diff --git a/src/Model_Settings.h b/src/Model_Settings.h index b0dabdc3..40e3da92 100644 --- a/src/Model_Settings.h +++ b/src/Model_Settings.h @@ -27,22 +27,22 @@ class QString; /////////////////////////////////////////////////////////////////////////////// #define LAMEXP_MAKE_OPTION_I(OPT) \ -int OPT(void); \ +int OPT(void) const; \ void OPT(int value); \ int OPT##Default(void); #define LAMEXP_MAKE_OPTION_S(OPT) \ -QString OPT(void); \ +QString OPT(void) const; \ void OPT(const QString &value); \ QString OPT##Default(void); #define LAMEXP_MAKE_OPTION_B(OPT) \ -bool OPT(void); \ +bool OPT(void) const; \ void OPT(bool value); \ bool OPT##Default(void); #define LAMEXP_MAKE_OPTION_U(OPT) \ -unsigned int OPT(void); \ +unsigned int OPT(void) const; \ void OPT(unsigned int value); \ unsigned int OPT##Default(void); @@ -122,6 +122,7 @@ public: LAMEXP_MAKE_OPTION_I(opusOptimizeFor); LAMEXP_MAKE_OPTION_I(opusComplexity); LAMEXP_MAKE_OPTION_I(opusFramesize); + LAMEXP_MAKE_OPTION_B(opusDisableResample); LAMEXP_MAKE_OPTION_B(normalizationFilterEnabled); LAMEXP_MAKE_OPTION_I(normalizationFilterMaxVolume); LAMEXP_MAKE_OPTION_I(normalizationFilterEqualizationMode); @@ -150,9 +151,9 @@ public: private: QSettings *m_settings; - QString *m_defaultLanguage; - QString defaultLanguage(void); QString initDirectory(const QString &path); + static QString *m_defaultLanguage; + QString defaultLanguage(void) const; }; /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Registry_Decoder.cpp b/src/Registry_Decoder.cpp index 160d37ad..a53a100a 100644 --- a/src/Registry_Decoder.cpp +++ b/src/Registry_Decoder.cpp @@ -39,6 +39,7 @@ #include "Decoder_Opus.h" #include "Decoder_WMA.h" #include "PlaylistImporter.h" +#include "Model_Settings.h" #include #include @@ -116,3 +117,8 @@ QStringList DecoderRegistry::getSupportedTypes(void) return types; } + +void DecoderRegistry::configureDecoders(const SettingsModel *settings) +{ + OpusDecoder::setDisableResampling(settings->opusDisableResample()); +} diff --git a/src/Registry_Decoder.h b/src/Registry_Decoder.h index d3563a81..d2d2e7ce 100644 --- a/src/Registry_Decoder.h +++ b/src/Registry_Decoder.h @@ -26,12 +26,14 @@ class QString; class QStringList; class AbstractDecoder; +class SettingsModel; class DecoderRegistry : public QObject { Q_OBJECT public: + static void configureDecoders(const SettingsModel *settings); static AbstractDecoder *lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static QStringList DecoderRegistry::getSupportedTypes(void); }; diff --git a/src/Tools.h b/src/Tools.h index ab8c1473..b6d8c695 100644 --- a/src/Tools.h +++ b/src/Tools.h @@ -59,7 +59,7 @@ g_lamexp_tools[] = {"7c249f507b96967bedabdd7e631638807a7595ebff58eaaadf63530783d515eda9660bc2b1a0457fddae7e3eaef8a074", CPU_TYPE_ALL_ALL, "elevator.exe", UINT_MAX}, {"bbc262cfe9c48633e5f1780d30347d7663075cfd7bdc76347cce3b1191d62f788d9b91bc63dffae2f66d1759d5849e92", CPU_TYPE_ALL_ALL, "faad.exe", 27}, {"4f3a905b5b77ea49a7b302ab0a028ab115270e1b285caafbc35013ffc1de64bdec4488b561ef497c4befae952759a9dd", CPU_TYPE_ALL_ALL, "flac.exe", 121}, - {"d098a6b2fc2abd2cbd817fc1cb0b6a7a1d96e917e26504cd000a02ed2bcd63bb5ae8e206f4c476cbae48a4a0a5b04cb1", CPU_TYPE_ALL_ALL, "gpgv.exe", 1412}, + {"52e213df29da215c59e82cd4fefb290aa2842280383fd59ffaa06cb2c58f1081b0dbd7b6e57f69fe3a872b6e7dd0c1cf", CPU_TYPE_ALL_ALL, "gpgv.exe", 1413}, {"19c9dbe9089491c1f59ae48016d95d4336c4d3743577db4e782d8b59eca3b2bda6ed8f92f9004f88f434935b79e4974b", CPU_TYPE_ALL_ALL, "gpgv.gpg", UINT_MAX}, {"53cfab3896a47d48f523315f475fa07856d468ad1aefcc8cce19c18cdf509e2f92840dab92a442995df36d941cb7a6ca", CPU_TYPE_ALL_GEN, "lame.i386.exe", 3995}, {"9511e7ef2ad10de05386eedf7f14d637edab894a53dacd2f8f15c6f8ed582f12c25fb5bf88438e62c46b8eb92e7634b2", CPU_TYPE_ALL_SSE, "lame.sse2.exe", 3995}, @@ -72,8 +72,8 @@ g_lamexp_tools[] = {"8b68461f38410421be30cc895e94e63184daa6f2cb20eb110b66b376b48141838a09bc920efeb1c49de79dd0770ce41b", CPU_TYPE_X86_GEN, "oggenc2.i386.exe", 287603}, {"20648f83cc637cada481143d48c437ced8423e9a0aae01dbce860cd97fb1ce4000e314f3a5395d1eafd8e154a8e74d08", CPU_TYPE_X86_SSE, "oggenc2.sse2.exe", 287603}, {"e1da48055a57bae41d6a1a0dc08b86831c121e85c07aa60aae4196997b166a08cfb7265d9f0f289f445ad73bce28d81f", CPU_TYPE_X64_ALL, "oggenc2.x64.exe", 287603}, - {"7cff3801328ecae545d5e8c64bae5fd55fd0dca17117b47910779d06991fd3eb920d72c00599aa05d9709c03983d1d7b", CPU_TYPE_ALL_ALL, "opusdec.exe", 20130117}, - {"b427f7f078bd54b97ff73b71244e0060ce59dcfae7d7e4f25c7a653f5b7dc42325b7e7edd9ec3c4cdae2407f47272884", CPU_TYPE_ALL_ALL, "opusenc.exe", 20130117}, + {"9d6c5f841a8ad571873e33608484584ae4d51441a2ae4c3a961c5e9f49eadeaed5c4c56d47e0b530846f0366e4b9bb37", CPU_TYPE_ALL_ALL, "opusdec.exe", 20130118}, + {"d1fc38b83e078571a211af7f9c2608ad059d22b2b7c0f089f2a1000fd7000da3bd09d3f86f52859b8746572b00ae3cf1", CPU_TYPE_ALL_ALL, "opusenc.exe", 20130118}, {"bdfa8dec142b6327a33af6bb314d7beb924588d1b73f2ef3f46b31fa6046fe2f4e64ca78b025b7eb9290a78320e2aa57", CPU_TYPE_ALL_ALL, "refalac.exe", 56}, {"d041b60de6c5c6e77cbad84440db57bbeb021af59dd0f7bebd3ede047d9e2ddc2a0c14179472687ba91063743d23e337", CPU_TYPE_ALL_ALL, "shorten.exe", 361}, {"81633b4808ff13e25249aac038ed97570aaeea2bbffacf0f3905514064d1b82d141a6b04f63f1a913e4d09b2d892aea0", CPU_TYPE_ALL_ALL, "sox.exe", 1440},