summaryrefslogtreecommitdiffstats
path: root/src/encoder
diff options
context:
space:
mode:
authorJosepMaJAZ <josepma@gmail.com>2017-03-21 20:40:54 +0100
committerJosepMaJAZ <josepma@gmail.com>2017-03-21 20:40:54 +0100
commitafaa3b7e287341ec1394b5a52688c3afff24f200 (patch)
treef40c3856a396f9efb7bd9ac1b870cf968f7c92be /src/encoder
parent6eb1515b6f95f334cb00f31a005dd34a164299ee (diff)
extracted constants and added comments
Diffstat (limited to 'src/encoder')
-rw-r--r--src/encoder/encodermp3.cpp18
-rw-r--r--src/encoder/encodermp3.h4
2 files changed, 20 insertions, 2 deletions
diff --git a/src/encoder/encodermp3.cpp b/src/encoder/encodermp3.cpp
index 3421c9f28c..ab3b293e81 100644
--- a/src/encoder/encodermp3.cpp
+++ b/src/encoder/encodermp3.cpp
@@ -23,6 +23,20 @@
#include "encoder/encodercallback.h"
#include "errordialoghandler.h"
+// Automatic thresholds for switching the encoder to mono
+// They have been choosen by testing and to keep the same number
+// of values for the slider.
+// The threshold of bitrate (CBR/ABR) at which the encoder
+// with switch to mono encoding
+const int EncoderMp3::MONO_BITRATE_TRESHOLD = 100;
+// The threshold of quality (VBR) at which the encoder
+// with switch to mono encoding. Values from 0 to 6 encode at 44Khz
+const int EncoderMp3::MONO_VBR_THRESHOLD = 8;
+// Quality offset to substract to the quality value when
+// switching to mono encoding.
+const int EncoderMp3::MONO_VBR_OFFSET = 4;
+
+
EncoderMp3::EncoderMp3(EncoderCallback* pCallback)
: m_lameFlags(nullptr),
m_bufferOut(nullptr),
@@ -255,7 +269,7 @@ void EncoderMp3::setEncoderSettings(const EncoderSettings& settings)
m_encoding_mode = (modeoption==0) ? vbr_off : (modeoption==1) ? vbr_abr : vbr_default;
if (m_encoding_mode == vbr_off) {
- if (m_bitrate > 100 ) {
+ if (m_bitrate > MONO_BITRATE_TRESHOLD ) {
m_stereo_mode = JOINT_STEREO;
} else {
m_stereo_mode = MONO;
@@ -263,7 +277,7 @@ void EncoderMp3::setEncoderSettings(const EncoderSettings& settings)
} else {
// Inverting range: vbr 0 best, 9 worst. slider 0 min to max.
int val = settings.getQualityValues().size() - 1 - settings.getQualityIndex();
- if (val < 8) {
+ if (val < MONO_VBR_THRESHOLD) {
m_stereo_mode = JOINT_STEREO;
m_vbr_index = val;
} else {
diff --git a/src/encoder/encodermp3.h b/src/encoder/encodermp3.h
index 0bd06498ae..9d53b46d23 100644
--- a/src/encoder/encodermp3.h
+++ b/src/encoder/encodermp3.h
@@ -19,6 +19,10 @@ class EncoderCallback;
class EncoderMp3 : public Encoder {
public:
+ static const int MONO_BITRATE_TRESHOLD;
+ static const int MONO_VBR_THRESHOLD;
+ static const int MONO_VBR_OFFSET;
+
EncoderMp3(EncoderCallback* callback=NULL);
virtual ~EncoderMp3();