Commit 3edfebea authored by Raymond Toy's avatar Raymond Toy Committed by Commit Bot

Split DelayNode processing into a-rate and k-rate functions

This CL jsut splits the processing for a DelayNode into separate
routines to handle a-rate and k-rate processing.

This is a first step at vectorizing delay node.

No functional changes.

Bug: 1087071
Change-Id: Ia12bad0748e608eb4e20bd86b07b7bd4f1e54c2a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2227335Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775129}
parent 6fbef2d7
...@@ -81,7 +81,7 @@ double AudioDelayDSPKernel::DelayTime(float sample_rate) { ...@@ -81,7 +81,7 @@ double AudioDelayDSPKernel::DelayTime(float sample_rate) {
return desired_delay_frames_ / sample_rate; return desired_delay_frames_ / sample_rate;
} }
void AudioDelayDSPKernel::Process(const float* source, void AudioDelayDSPKernel::ProcessARate(const float* source,
float* destination, float* destination,
uint32_t frames_to_process) { uint32_t frames_to_process) {
int buffer_length = buffer_.size(); int buffer_length = buffer_.size();
...@@ -96,7 +96,6 @@ void AudioDelayDSPKernel::Process(const float* source, ...@@ -96,7 +96,6 @@ void AudioDelayDSPKernel::Process(const float* source,
float sample_rate = this->SampleRate(); float sample_rate = this->SampleRate();
double max_time = MaxDelayTime(); double max_time = MaxDelayTime();
if (HasSampleAccurateValues() && IsAudioRate()) {
float* delay_times = delay_times_.Data(); float* delay_times = delay_times_.Data();
CalculateSampleAccurateValues(delay_times, frames_to_process); CalculateSampleAccurateValues(delay_times, frames_to_process);
...@@ -139,7 +138,23 @@ void AudioDelayDSPKernel::Process(const float* source, ...@@ -139,7 +138,23 @@ void AudioDelayDSPKernel::Process(const float* source,
} }
write_index_ = w_index; write_index_ = w_index;
} else { }
void AudioDelayDSPKernel::ProcessKRate(const float* source,
float* destination,
uint32_t frames_to_process) {
int buffer_length = buffer_.size();
float* buffer = buffer_.Data();
DCHECK(buffer_length);
DCHECK(source);
DCHECK(destination);
DCHECK_GE(write_index_, 0);
DCHECK_LT(write_index_, buffer_length);
float sample_rate = this->SampleRate();
double max_time = MaxDelayTime();
// This is basically the same as above, but optimized for the case where the // This is basically the same as above, but optimized for the case where the
// delay time is constant for the current render. // delay time is constant for the current render.
// //
...@@ -192,6 +207,15 @@ void AudioDelayDSPKernel::Process(const float* source, ...@@ -192,6 +207,15 @@ void AudioDelayDSPKernel::Process(const float* source,
} }
write_index_ = w - buffer; write_index_ = w - buffer;
}
void AudioDelayDSPKernel::Process(const float* source,
float* destination,
uint32_t frames_to_process) {
if (HasSampleAccurateValues() && IsAudioRate()) {
ProcessARate(source, destination, frames_to_process);
} else {
ProcessKRate(source, destination, frames_to_process);
} }
} }
......
...@@ -35,9 +35,22 @@ class PLATFORM_EXPORT AudioDelayDSPKernel : public AudioDSPKernel { ...@@ -35,9 +35,22 @@ class PLATFORM_EXPORT AudioDelayDSPKernel : public AudioDSPKernel {
public: public:
AudioDelayDSPKernel(double max_delay_time, float sample_rate); AudioDelayDSPKernel(double max_delay_time, float sample_rate);
// Process the delay. Basically dispatches to either ProcessKRate or
// ProcessARate.
void Process(const float* source, void Process(const float* source,
float* destination, float* destination,
uint32_t frames_to_process) override; uint32_t frames_to_process) override;
// Handles k-rate processing
void ProcessKRate(const float* source,
float* destination,
uint32_t frames_to_process);
// Handles a-rate processing
void ProcessARate(const float* source,
float* destination,
uint32_t frames_to_process);
void Reset() override; void Reset() override;
float MaxDelayTime() const { return max_delay_time_; } float MaxDelayTime() const { return max_delay_time_; }
......
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