Removing all external access to the integer sample data in AudioBuffer
This CL removes all external access to the integer sample data in the AudioBuffer class. It also removes the API in AudioBuffer that provides this. The purpose of this is to pave the way for removing the sample duplicating and implicit conversions between integer and floating point sample formats which is done inside the AudioBuffer. Bug: webrtc:10882 Change-Id: I1438b691bcef98278aef8e3c63624c367c2d12e9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/149162 Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org> Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Commit-Queue: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28912}
This commit is contained in:
@ -74,6 +74,27 @@ void RmsLevel::Analyze(rtc::ArrayView<const int16_t> data) {
|
||||
max_sum_square_ = std::max(max_sum_square_, sum_square);
|
||||
}
|
||||
|
||||
void RmsLevel::Analyze(rtc::ArrayView<const float> data) {
|
||||
if (data.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CheckBlockSize(data.size());
|
||||
|
||||
float sum_square = 0.f;
|
||||
|
||||
for (float data_k : data) {
|
||||
int16_t tmp =
|
||||
static_cast<int16_t>(std::min(std::max(data_k, -32768.f), 32767.f));
|
||||
sum_square += tmp * tmp;
|
||||
}
|
||||
RTC_DCHECK_GE(sum_square, 0.f);
|
||||
sum_square_ += sum_square;
|
||||
sample_count_ += data.size();
|
||||
|
||||
max_sum_square_ = std::max(max_sum_square_, sum_square);
|
||||
}
|
||||
|
||||
void RmsLevel::AnalyzeMuted(size_t length) {
|
||||
CheckBlockSize(length);
|
||||
sample_count_ += length;
|
||||
|
||||
Reference in New Issue
Block a user