Commit ff172cd3 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Improve fft based speed sync performance by avoiding std::vector.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 0ecc093f
......@@ -358,13 +358,16 @@ SpeedSync::compare_bits_fft (FFTProcessor& fft_processor, BitValue *bit_values,
window[i] *= 2.0 / window_weight;
}
const size_t n_bands = Params::max_band - Params::min_band + 1;
float fft_out_db[n_bands * in_data_sub.n_channels()];
for (auto si = sync_bits.begin(); si != sync_bits.end(); si++)
{
int pos = ((offset / steps_per_frame) + si->frame) * sub_frame_size * relative_speed_inv;
if (pos >= 0 && size_t (pos + sub_frame_size) < in_data_sub.n_frames())
{
vector<float> fft_out_db;
int out_db_index = 0;
for (int ch = 0; ch < in_data_sub.n_channels(); ch++)
{
......@@ -378,7 +381,7 @@ SpeedSync::compare_bits_fft (FFTProcessor& fft_processor, BitValue *bit_values,
{
const float min_db = -96;
fft_out_db.push_back (db_from_complex (out[i * 2], out[i * 2 + 1], min_db));
fft_out_db[out_db_index++] = db_from_complex (out[i * 2], out[i * 2 + 1], min_db);
}
}
auto& bv = bit_values[si->bit];
......@@ -515,7 +518,7 @@ score_smooth_find_best (const vector<SpeedSync::Score>& in_scores, double step,
double best_speed = 0;
double best_quality = 0;
static constexpr bool debug = true;
static constexpr bool debug = false;
if (debug)
{
for (auto s : scores)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment