From a1f4f80c8d8304bc4d584b083c5e472fc2b5a5a0 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Fri, 13 Jul 2018 21:59:34 +0200 Subject: [PATCH] Implemented new "adaptive" Opus bitrate LUT. --- src/Config.h | 2 +- src/Encoder_Opus.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Config.h b/src/Config.h index 0b709f2b..ae60dadb 100644 --- a/src/Config.h +++ b/src/Config.h @@ -35,7 +35,7 @@ #define VER_LAMEXP_MINOR_LO 7 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 3 -#define VER_LAMEXP_BUILD 2144 +#define VER_LAMEXP_BUILD 2146 #define VER_LAMEXP_CONFG 2134 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Encoder_Opus.cpp b/src/Encoder_Opus.cpp index fd984a0b..67e68afd 100644 --- a/src/Encoder_Opus.cpp +++ b/src/Encoder_Opus.cpp @@ -35,6 +35,8 @@ #include #include +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 /////////////////////////////////////////////////////////////////////////////// @@ -62,7 +64,7 @@ class OpusEncoderInfo : public AbstractEncoderInfo case SettingsModel::VBRMode: case SettingsModel::ABRMode: case SettingsModel::CBRMode: - return 32; + return 30; break; default: MUTILS_THROW("Bad RC mode specified!"); @@ -76,7 +78,7 @@ class OpusEncoderInfo : public AbstractEncoderInfo case SettingsModel::VBRMode: case SettingsModel::ABRMode: case SettingsModel::CBRMode: - return qBound(8, (index + 1) * 8, 256); + return g_opusBitrateLUT[qBound(0, index, 29)]; break; default: MUTILS_THROW("Bad RC mode specified!"); @@ -184,8 +186,8 @@ bool OpusEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf args << L1S("--framesize") << L1S("60"); 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.artist().isEmpty()) args << L1S("--artist") << cleanTag(metaInfo.artist());