From: Carl Hetherington Date: Wed, 26 Aug 2015 22:23:08 +0000 (+0100) Subject: Another small analysis optimisation, and (I think) a bug fix to peak location. X-Git-Tag: v2.1.47~17 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=022f799739ce0bc2776c85b08d4974239c6ffd66 Another small analysis optimisation, and (I think) a bug fix to peak location. --- diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index 164c57b14..b45af646d 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -119,9 +119,10 @@ AnalyseAudioJob::analyse (shared_ptr b) int const frames = b->frames (); int const channels = b->channels (); - for (int i = 0; i < frames; ++i) { - for (int j = 0; j < channels; ++j) { - float s = b->data(j)[i]; + for (int j = 0; j < channels; ++j) { + float* data = b->data(j); + for (int i = 0; i < frames; ++i) { + float s = data[i]; float as = fabsf (s); if (as < 10e-7) { /* SafeStringStream can't serialise and recover inf or -inf, so prevent such @@ -136,13 +137,13 @@ AnalyseAudioJob::analyse (shared_ptr b) _overall_peak_frame = _done + i; } - if ((_done % _samples_per_point) == 0) { + if (((_done + i) % _samples_per_point) == 0) { _current[j][AudioPoint::RMS] = sqrt (_current[j][AudioPoint::RMS] / _samples_per_point); _analysis->add_point (j, _current[j]); _current[j] = AudioPoint (); } } - - ++_done; } + + _done += frames; }