Updated Opus binaries. Also added option to disable the resampling in Opus decoder (i.e. always output 48.000 Hz).

This commit is contained in:
LoRd_MuldeR 2013-01-18 01:08:58 +01:00
parent 491bf5f135
commit 5b57083210
16 changed files with 179 additions and 21 deletions

View File

@ -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 <io.h>
# include <fcntl.h>
# 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;i<last_spin_len;i++)fprintf(stderr," ");
- if(inopt.total_samples_per_channel>0 && inopt.total_samples_per_channel<nb_encoded){
- snprintf(sbuf,54,"\r[%c] %02d%% ",spinner[last_spin&3],
- (int)floor(nb_encoded/(double)(inopt.total_samples_per_channel+inopt.skip)*100.));
- }else{
- snprintf(sbuf,54,"\r[%c] ",spinner[last_spin&3]);
- }
- last_spin_len=strlen(sbuf);
- snprintf(sbuf+last_spin_len,54-last_spin_len,
- "%02d:%02d:%02d.%02d %4.3gx realtime, %5.4gkbit/s",
+ snprintf(sbuf,54,"\r[%c] %02d:%02d:%02d.%02d (%.f%%) %4.3gx realtime, %5.4gkbit/s",
+ spinner[last_spin&3],
(int)(coded_seconds/3600),(int)(coded_seconds/60)%60,
(int)(coded_seconds)%60,(int)(coded_seconds*100)%100,
- coded_seconds/wall_time,
+ percent*100.0,coded_seconds/wall_time,
estbitrate/1000.);
fprintf(stderr,"%s",sbuf);
fflush(stderr);

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 7
#define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 1
#define VER_LAMEXP_BUILD 1226
#define VER_LAMEXP_BUILD 1227
///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!)

View File

@ -29,7 +29,7 @@ class AbstractDecoder : public AbstractTool
public:
AbstractDecoder(void);
~AbstractDecoder(void);
virtual ~AbstractDecoder(void);
//Internal decoder API
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag) = 0;

View File

@ -28,6 +28,8 @@
#include <QRegExp>
#include <QUuid>
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);

View File

@ -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;
};

View File

@ -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();

View File

@ -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;

View File

@ -32,29 +32,31 @@
#include <QStringList>
#include <QLocale>
#include <QRegExp>
#include <QReadWriteLock>
#include <QReadLocker>
#include <QWriteLocker>
////////////////////////////////////////////////////////////
//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);

View File

@ -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;
};
///////////////////////////////////////////////////////////////////////////////

View File

@ -39,6 +39,7 @@
#include "Decoder_Opus.h"
#include "Decoder_WMA.h"
#include "PlaylistImporter.h"
#include "Model_Settings.h"
#include <QString>
#include <QStringList>
@ -116,3 +117,8 @@ QStringList DecoderRegistry::getSupportedTypes(void)
return types;
}
void DecoderRegistry::configureDecoders(const SettingsModel *settings)
{
OpusDecoder::setDisableResampling(settings->opusDisableResample());
}

View File

@ -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);
};

View File

@ -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},