Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(728)

Unified Diff: webrtc/modules/audio_processing/aec3/block_framer.cc

Issue 2584493002: Added first layer of the echo canceller 3 functionality (Closed)
Patch Set: Restricted the AnalyzeRender access, added ability to add external reporting of echo failure, and o… Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/aec3/block_framer.cc
diff --git a/webrtc/modules/audio_processing/aec3/block_framer.cc b/webrtc/modules/audio_processing/aec3/block_framer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0a92856373b87b1cfe71c5c1c92ce35a7310abde
--- /dev/null
+++ b/webrtc/modules/audio_processing/aec3/block_framer.cc
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/modules/audio_processing/aec3/block_framer.h"
+
+#include <algorithm>
+
+#include "webrtc/base/checks.h"
+
+namespace webrtc {
+
+BlockFramer::BlockFramer(size_t num_bands, size_t frame_length)
hlundin-webrtc 2016/12/16 10:04:46 I'm having some issues with the implementation of
aleloi 2016/12/16 15:04:31 +1 Does anybody know if we have a stock circular b
peah-webrtc 2016/12/20 10:10:24 We have a stock circular buffer available, but tha
peah-webrtc 2016/12/20 10:10:24 Good point! I altered to vectors of vectors. Rega
aleloi 2016/12/20 15:55:35 Acknowledged. The new version looks very good!
peah-webrtc 2016/12/21 23:13:48 Great!
+ : num_bands_(num_bands),
+ frame_length_(frame_length),
+ buffer_(num_bands_ * kMaxSize, 0.f),
+ buffer_size_(kBlockSize) {}
+
+BlockFramer::~BlockFramer() = default;
+
+void BlockFramer::InsertBlock(rtc::ArrayView<const float> block) {
+ RTC_DCHECK_LE(buffer_size_ + kBlockSize, kMaxSize);
aleloi 2016/12/16 15:04:31 There is an assumption here that the block is (at
peah-webrtc 2016/12/20 10:10:24 Done.
+ for (size_t i = 0; i < num_bands_; ++i) {
+ rtc::ArrayView<const float> band =
+ block.subview(i * kBlockSize, kBlockSize);
+ std::copy(band.begin(), band.end(),
+ buffer_.begin() + i * kMaxSize + buffer_size_);
+ }
+ buffer_size_ += kBlockSize;
+}
+
+void BlockFramer::ExtractFrame(size_t sub_frame_index, float* const* frame) {
aleloi 2016/12/16 15:04:31 Is there some way to avoid the naked pointers in t
peah-webrtc 2016/12/20 10:10:24 That is a great point! I did that instead by wrapp
aleloi 2016/12/20 15:55:35 Acknowledged.
peah-webrtc 2016/12/21 23:13:48 Acknowledged.
+ RTC_DCHECK_LE(kSubFrameLength, buffer_size_);
+ RTC_DCHECK_LE(sub_frame_index * kSubFrameLength, frame_length_);
+ for (size_t i = 0; i < num_bands_; ++i) {
+ rtc::ArrayView<float> frame_view(
+ &frame[i][kSubFrameLength * sub_frame_index], kSubFrameLength);
+ std::copy(buffer_.begin() + i * kMaxSize,
+ buffer_.begin() + i * kMaxSize + kSubFrameLength,
+ frame_view.begin());
+ }
+ buffer_size_ -= kSubFrameLength;
+
+ if (buffer_size_ > 0) {
hlundin-webrtc 2016/12/16 10:04:46 Add a comment that the code below shifts the remai
peah-webrtc 2016/12/20 10:10:24 Done.
+ RTC_DCHECK_LE(buffer_size_, kMaxSize);
hlundin-webrtc 2016/12/16 10:04:46 This should always be true; move up to beginning o
peah-webrtc 2016/12/20 10:10:24 Done.
+ for (size_t i = 0; i < num_bands_; ++i) {
+ std::copy(buffer_.begin() + i * kMaxSize + kSubFrameLength,
+ buffer_.begin() + i * kMaxSize + kSubFrameLength + buffer_size_,
+ buffer_.begin() + i * kMaxSize);
+ }
+ }
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698