Commit 83aab16e authored by Stefan Westerfeld's avatar Stefan Westerfeld

Support processing multiple blocks in limiter inner loop.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent a0075f54
......@@ -3,5 +3,4 @@ possible improvements:
limiter:
- flush
- allow processing multiple blocks in inner loop
- interpolate scale factor directly
......@@ -36,13 +36,17 @@ Limiter::process (const vector<float>& samples)
buffer.insert (buffer.end(), samples.begin(), samples.end());
/* need at least two complete blocks in buffer to produce output */
if (buffer.size() / n_channels < 2 * block_size)
const uint buffered_blocks = buffer.size() / n_channels / block_size;
if (buffered_blocks < 2)
return {};
vector<float> out (block_size * n_channels);
const uint blocks_todo = buffered_blocks - 1;
process_block (&buffer[0], &out[0]);
buffer.erase (buffer.begin(), buffer.begin() + block_size * n_channels);
vector<float> out (blocks_todo * block_size * n_channels);
for (uint b = 0; b < blocks_todo; b++)
process_block (&buffer[b * block_size * n_channels], &out[b * block_size * n_channels]);
buffer.erase (buffer.begin(), buffer.begin() + blocks_todo * block_size * n_channels);
return out;
}
......
......@@ -36,7 +36,7 @@ perf()
int n_frames = 0;
double start = gettime();
for (int i = 0; i < 10000; i++)
for (int i = 0; i < 100000; i++)
{
n_frames += samples.size() / 2;
vector<float> out_samples = limiter.process (samples);
......
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