diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2021-07-10 11:15:29 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2021-07-10 11:15:29 +0000 |
| commit | eea32106a49f5eea25793b3d9cf62d264e6167cf (patch) | |
| tree | 9b3621e5ea468375217ff3d84fb8416f04fdc7bd | |
| parent | 47b188eb8c0bf2c5012cbf08bff6f465e1593355 (diff) | |
| download | qmmp-eea32106a49f5eea25793b3d9cf62d264e6167cf.tar.gz qmmp-eea32106a49f5eea25793b3d9cf62d264e6167cf.tar.bz2 qmmp-eea32106a49f5eea25793b3d9cf62d264e6167cf.zip | |
qsui: added waveform seekbar optimization (Linearithmik, #1086)
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@10151 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/plugins/Ui/qsui/qsuiwaveformseekbar.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/plugins/Ui/qsui/qsuiwaveformseekbar.cpp b/src/plugins/Ui/qsui/qsuiwaveformseekbar.cpp index 59f05c206..f098c729a 100644 --- a/src/plugins/Ui/qsui/qsuiwaveformseekbar.cpp +++ b/src/plugins/Ui/qsui/qsuiwaveformseekbar.cpp @@ -448,26 +448,30 @@ void QSUiWaveformScanner::run() float *rms = new float[m_ap.channels()]{ 0 }; int counter = 0; int channels = m_ap.channels(); + float value = 0.f; while (!m_user_stop) { m_mutex.unlock(); qint64 len = m_decoder->read(tmp, sizeof(tmp)); if(len > 0) { - converter.toFloat(tmp, out, len / m_ap.sampleSize()); + auto sample_count = len / m_ap.sampleSize(); + converter.toFloat(tmp, out, sample_count); - for(uint sample = 0; sample < len / m_ap.sampleSize(); sample++) + for(uint sample = 0; sample < sample_count - channels; sample += channels) { - int ch = sample % channels; - min[ch] = qMin(min[ch], out[sample]); - max[ch] = qMax(max[ch], out[sample]); - rms[ch] += (out[sample] * out[sample]); - - counter++; + for(int ch = 0; ch < channels; ++ch) + { + value = out[sample + ch]; + min[ch] = qMin(min[ch], value); + max[ch] = qMax(max[ch], value); + rms[ch] += (value * value); + } + counter += channels; if(counter >= samplesPerValue) { m_mutex.lock(); - for(ch = 0; ch < channels; ++ch) + for(int ch = 0; ch < channels; ++ch) { m_data << max[ch] * 1000; m_data << min[ch] * 1000; |
