Implemented new "adaptive" Opus bitrate LUT.

This commit is contained in:
LoRd_MuldeR 2018-07-13 21:59:34 +02:00
parent 73899ea98c
commit a1f4f80c8d
2 changed files with 7 additions and 5 deletions

View File

@ -35,7 +35,7 @@
#define VER_LAMEXP_MINOR_LO 7 #define VER_LAMEXP_MINOR_LO 7
#define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 3 #define VER_LAMEXP_PATCH 3
#define VER_LAMEXP_BUILD 2144 #define VER_LAMEXP_BUILD 2146
#define VER_LAMEXP_CONFG 2134 #define VER_LAMEXP_CONFG 2134
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -35,6 +35,8 @@
#include <QDir> #include <QDir>
#include <QUUid> #include <QUUid>
static const int g_opusBitrateLUT[30] = { 8, 9, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 144, 160, 176, 192, 208, 224, 240, 256 };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Encoder Info // Encoder Info
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -62,7 +64,7 @@ class OpusEncoderInfo : public AbstractEncoderInfo
case SettingsModel::VBRMode: case SettingsModel::VBRMode:
case SettingsModel::ABRMode: case SettingsModel::ABRMode:
case SettingsModel::CBRMode: case SettingsModel::CBRMode:
return 32; return 30;
break; break;
default: default:
MUTILS_THROW("Bad RC mode specified!"); MUTILS_THROW("Bad RC mode specified!");
@ -76,7 +78,7 @@ class OpusEncoderInfo : public AbstractEncoderInfo
case SettingsModel::VBRMode: case SettingsModel::VBRMode:
case SettingsModel::ABRMode: case SettingsModel::ABRMode:
case SettingsModel::CBRMode: case SettingsModel::CBRMode:
return qBound(8, (index + 1) * 8, 256); return g_opusBitrateLUT[qBound(0, index, 29)];
break; break;
default: default:
MUTILS_THROW("Bad RC mode specified!"); MUTILS_THROW("Bad RC mode specified!");
@ -185,7 +187,7 @@ bool OpusEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
break; break;
} }
args << L1S("--bitrate") << QString::number(qBound(8, (m_configBitrate + 1) * 8, 256)); args << L1S("--bitrate") << QString::number(g_opusBitrateLUT[qBound(0, m_configBitrate, 29)]);
if(!metaInfo.title().isEmpty()) args << L1S("--title") << cleanTag(metaInfo.title()); if(!metaInfo.title().isEmpty()) args << L1S("--title") << cleanTag(metaInfo.title());
if(!metaInfo.artist().isEmpty()) args << L1S("--artist") << cleanTag(metaInfo.artist()); if(!metaInfo.artist().isEmpty()) args << L1S("--artist") << cleanTag(metaInfo.artist());