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

Side by Side Diff: webrtc/modules/audio_processing/aec3/frame_blocker.cc

Issue 2584493002: Added first layer of the echo canceller 3 functionality (Closed)
Patch Set: Changes in response to reviewer comments Created 3 years, 12 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/audio_processing/aec3/frame_blocker.h"
12
13 #include <algorithm>
14
15 #include "webrtc/base/checks.h"
16 #include "webrtc/modules/audio_processing/aec3/aec3_constants.h"
17
18 namespace webrtc {
19
20 FrameBlocker::FrameBlocker(size_t num_bands)
21 : num_bands_(num_bands),
22 buffer_(num_bands_, std::vector<float>(kBlockSize, 0.f)) {
hlundin-webrtc 2016/12/20 15:10:36 Instead of setting up vectors of length kBlockSize
peah-webrtc 2016/12/21 23:13:53 Nice one! Done.
23 for (auto& b : buffer_) {
24 b.resize(0);
aleloi 2016/12/20 15:55:35 I think this should be done in the member initiali
peah-webrtc 2016/12/21 23:13:53 I want to ensure that the reserved space is proper
25 }
26 }
27
28 FrameBlocker::~FrameBlocker() = default;
29
30 void FrameBlocker::InsertSubFrameAndExtractBlock(
31 rtc::ArrayView<rtc::ArrayView<const float>> sub_frame,
32 std::vector<std::vector<float>>* block) {
33 RTC_DCHECK_EQ(num_bands_, block->size());
34 RTC_DCHECK_EQ(num_bands_, sub_frame.size());
35 for (size_t i = 0; i < num_bands_; ++i) {
36 RTC_DCHECK_GE(kBlockSize - 16, buffer_[i].size());
37 RTC_DCHECK_EQ(kBlockSize, (*block)[i].size());
38 RTC_DCHECK_EQ(kSubFrameLength, sub_frame[i].size());
39 const int samples_to_block = kBlockSize - buffer_[i].size();
40 std::copy(buffer_[i].begin(), buffer_[i].end(), (*block)[i].begin());
hlundin-webrtc 2016/12/20 15:10:36 You can use vector::insert here too.
peah-webrtc 2016/12/21 23:13:53 Done.
41 std::copy(sub_frame[i].begin(), sub_frame[i].begin() + samples_to_block,
hlundin-webrtc 2016/12/20 15:10:36 And here.
peah-webrtc 2016/12/21 23:13:53 Done.
42 (*block)[i].begin() + buffer_[i].size());
43 buffer_[i].resize(kSubFrameLength - samples_to_block);
44 std::copy(sub_frame[i].begin() + samples_to_block, sub_frame[i].end(),
hlundin-webrtc 2016/12/20 15:10:36 And here, and skip the resize.
peah-webrtc 2016/12/21 23:13:53 Nice! There is still a resize needed to zero thoug
45 buffer_[i].begin());
46 }
47 }
48
49 bool FrameBlocker::IsBlockAvailable() {
aleloi 2016/12/20 15:55:35 const
peah-webrtc 2016/12/21 23:13:53 Done.
50 return kBlockSize == buffer_[0].size();
51 }
52
53 void FrameBlocker::ExtractBlock(std::vector<std::vector<float>>* block) {
54 RTC_DCHECK_EQ(num_bands_, block->size());
55 RTC_DCHECK(IsBlockAvailable());
56 for (size_t i = 0; i < num_bands_; ++i) {
57 RTC_DCHECK_EQ(kBlockSize, buffer_[i].size());
58 RTC_DCHECK_EQ(kBlockSize, (*block)[i].size());
59 std::copy(buffer_[i].begin(), buffer_[i].end(), (*block)[i].begin());
hlundin-webrtc 2016/12/20 15:10:36 vector::insert
peah-webrtc 2016/12/21 23:13:53 Done.
60 buffer_[i].resize(0);
hlundin-webrtc 2016/12/20 15:10:36 clear()
peah-webrtc 2016/12/21 23:13:53 This sounds a bit dangerous. Are we sure that ther
hlundin-webrtc 2016/12/22 10:23:56 http://en.cppreference.com/w/cpp/container/vector/
peah-webrtc 2017/01/02 08:45:10 Thanks! I agree. I'll change to clear. Done.
61 }
62 }
63
64 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698