Commit 87e13157 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Optimize watermark synthesis loop.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 76376c3f
...@@ -694,14 +694,19 @@ add_watermark (const string& infile, const string& outfile, const string& bits) ...@@ -694,14 +694,19 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
/* mix watermark signal to output frame */ /* mix watermark signal to output frame */
vector<float> fft_delta_out = ifft (fft_delta_spect[f * wav_data.n_channels() + ch]); vector<float> fft_delta_out = ifft (fft_delta_spect[f * wav_data.n_channels() + ch]);
int last_frame_start = (f - 1) * Params::frame_size; for (int dframe = -1; dframe <= 1; dframe++)
for (int i = 0; i < int (synth_window.size()); i++)
{ {
int pos = (last_frame_start + i) * wav_data.n_channels() + ch; const int wstart = (dframe + 1) * Params::frame_size;
if (pos >= 0 && pos < int (out_signal.size())) if (f + dframe > 0 && f + dframe < frame_count (wav_data))
{ {
out_signal[pos] += fft_delta_out[i % Params::frame_size] * synth_window[i]; int pos = (f + dframe) * Params::frame_size * wav_data.n_channels() + ch;
for (size_t x = 0; x < Params::frame_size; x++)
{
out_signal[pos] += fft_delta_out[x] * synth_window[wstart + x];
pos += wav_data.n_channels();
}
} }
} }
} }
......
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