Corrections of the render buffering scheme in AEC3 to ensure causality
This CL modifies the refactored render buffering scheme in AEC3 so that: -A non-causal state can never occur which means that situations with nonrecoverable echo should not occur. -For a stable audio pipeline with a predefined API call jitter, render overruns and underruns can never occur. Bug: webrtc:8629,chromium:793305 Change-Id: I06ba1c368f92db95274090b08475dd02dbb85145 Reviewed-on: https://webrtc-review.googlesource.com/29861 Commit-Queue: Per Åhgren <peah@webrtc.org> Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21215}
This commit is contained in:
@ -24,17 +24,20 @@ struct FftBuffer {
|
||||
explicit FftBuffer(size_t size);
|
||||
~FftBuffer();
|
||||
|
||||
size_t IncIndex(size_t index) {
|
||||
return index < buffer.size() - 1 ? index + 1 : 0;
|
||||
int IncIndex(int index) const {
|
||||
RTC_DCHECK_EQ(buffer.size(), static_cast<size_t>(size));
|
||||
return index < size - 1 ? index + 1 : 0;
|
||||
}
|
||||
|
||||
size_t DecIndex(size_t index) {
|
||||
return index > 0 ? index - 1 : buffer.size() - 1;
|
||||
int DecIndex(int index) const {
|
||||
RTC_DCHECK_EQ(buffer.size(), static_cast<size_t>(size));
|
||||
return index > 0 ? index - 1 : size - 1;
|
||||
}
|
||||
|
||||
size_t OffsetIndex(size_t index, int offset) {
|
||||
int OffsetIndex(int index, int offset) const {
|
||||
RTC_DCHECK_GE(buffer.size(), offset);
|
||||
return (buffer.size() + index + offset) % buffer.size();
|
||||
RTC_DCHECK_EQ(buffer.size(), static_cast<size_t>(size));
|
||||
return (size + index + offset) % size;
|
||||
}
|
||||
|
||||
void UpdateWriteIndex(int offset) { write = OffsetIndex(write, offset); }
|
||||
@ -44,9 +47,10 @@ struct FftBuffer {
|
||||
void IncReadIndex() { read = IncIndex(read); }
|
||||
void DecReadIndex() { read = DecIndex(read); }
|
||||
|
||||
const int size;
|
||||
std::vector<FftData> buffer;
|
||||
size_t write = 0;
|
||||
size_t read = 0;
|
||||
int write = 0;
|
||||
int read = 0;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user