diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-04-06 16:56:39 +0200 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-04-06 17:00:48 +0200 |
commit | 0c4bd3a9c4258f222c9cfda65efff0353496263c (patch) | |
tree | 137161a295590574294512a47d80214168971013 | |
parent | fe756b65deed38a82de2d6097a2bd4798f7cd0eb (diff) | |
download | rockbox-0c4bd3a9c4258f222c9cfda65efff0353496263c.tar.gz rockbox-0c4bd3a9c4258f222c9cfda65efff0353496263c.zip |
libmp3lame encoder: don't retrieve settings for each run.
Retrieve the encoder settings only when creating the object or when saving.
Avoids unnecessary overhead by accessing the settings object on each encoder
call, which also clutters the system trace log.
Change-Id: If64e5d1d5ac8f1d4b0afd1bc4851e455fc7e64c2
-rw-r--r-- | rbutil/rbutilqt/base/encoderlame.cpp | 13 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/encoderlame.h | 2 |
2 files changed, 11 insertions, 4 deletions
diff --git a/rbutil/rbutilqt/base/encoderlame.cpp b/rbutil/rbutilqt/base/encoderlame.cpp index 9550eb5681..6cc93ff742 100644 --- a/rbutil/rbutilqt/base/encoderlame.cpp +++ b/rbutil/rbutilqt/base/encoderlame.cpp | |||
@@ -51,6 +51,9 @@ EncoderLame::EncoderLame(QObject *parent) : EncoderBase(parent) | |||
51 | SYMBOLRESOLVE(lame_close, int (*)(lame_global_flags*)); | 51 | SYMBOLRESOLVE(lame_close, int (*)(lame_global_flags*)); |
52 | 52 | ||
53 | qDebug() << "[EncoderLame] libmp3lame loaded:" << lib->isLoaded(); | 53 | qDebug() << "[EncoderLame] libmp3lame loaded:" << lib->isLoaded(); |
54 | |||
55 | m_encoderVolume = RbSettings::subValue("lame", RbSettings::EncoderVolume).toDouble(); | ||
56 | m_encoderQuality = RbSettings::subValue("lame", RbSettings::EncoderQuality).toDouble(); | ||
54 | m_symbolsResolved = true; | 57 | m_symbolsResolved = true; |
55 | } | 58 | } |
56 | 59 | ||
@@ -87,6 +90,10 @@ void EncoderLame::saveSettings() | |||
87 | getSetting(VOLUME)->current().toDouble()); | 90 | getSetting(VOLUME)->current().toDouble()); |
88 | RbSettings::setSubValue("lame", RbSettings::EncoderQuality, | 91 | RbSettings::setSubValue("lame", RbSettings::EncoderQuality, |
89 | getSetting(QUALITY)->current().toDouble()); | 92 | getSetting(QUALITY)->current().toDouble()); |
93 | m_encoderVolume = | ||
94 | RbSettings::subValue("lame", RbSettings::EncoderVolume).toDouble(); | ||
95 | m_encoderQuality = | ||
96 | RbSettings::subValue("lame", RbSettings::EncoderQuality).toDouble(); | ||
90 | } | 97 | } |
91 | } | 98 | } |
92 | 99 | ||
@@ -128,13 +135,11 @@ bool EncoderLame::encode(QString input,QString output) | |||
128 | gfp = m_lame_init(); | 135 | gfp = m_lame_init(); |
129 | m_lame_set_out_samplerate(gfp, 12000); // resample to 12kHz | 136 | m_lame_set_out_samplerate(gfp, 12000); // resample to 12kHz |
130 | // scale input volume | 137 | // scale input volume |
131 | m_lame_set_scale(gfp, | 138 | m_lame_set_scale(gfp, m_encoderVolume); |
132 | RbSettings::subValue("lame", RbSettings::EncoderVolume).toDouble()); | ||
133 | m_lame_set_mode(gfp, MONO); // mono output mode | 139 | m_lame_set_mode(gfp, MONO); // mono output mode |
134 | m_lame_set_VBR(gfp, vbr_default); // enable default VBR mode | 140 | m_lame_set_VBR(gfp, vbr_default); // enable default VBR mode |
135 | // VBR quality | 141 | // VBR quality |
136 | m_lame_set_VBR_quality(gfp, | 142 | m_lame_set_VBR_quality(gfp, m_encoderQuality); |
137 | RbSettings::subValue("lame", RbSettings::EncoderQuality).toDouble()); | ||
138 | m_lame_set_VBR_max_bitrate_kbps(gfp, 64); // maximum bitrate 64kbps | 143 | m_lame_set_VBR_max_bitrate_kbps(gfp, 64); // maximum bitrate 64kbps |
139 | m_lame_set_bWriteVbrTag(gfp, 0); // disable LAME tag. | 144 | m_lame_set_bWriteVbrTag(gfp, 0); // disable LAME tag. |
140 | 145 | ||
diff --git a/rbutil/rbutilqt/base/encoderlame.h b/rbutil/rbutilqt/base/encoderlame.h index 8b9444589a..a8651f0cda 100644 --- a/rbutil/rbutilqt/base/encoderlame.h +++ b/rbutil/rbutilqt/base/encoderlame.h | |||
@@ -64,6 +64,8 @@ class EncoderLame : public EncoderBase | |||
64 | int (*m_lame_close)(lame_global_flags*); | 64 | int (*m_lame_close)(lame_global_flags*); |
65 | 65 | ||
66 | bool m_symbolsResolved; | 66 | bool m_symbolsResolved; |
67 | double m_encoderVolume; | ||
68 | double m_encoderQuality; | ||
67 | }; | 69 | }; |
68 | 70 | ||
69 | #endif | 71 | #endif |