Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/block_framer.h" | |
| 12 | |
| 13 #include <algorithm> | |
| 14 | |
| 15 #include "webrtc/base/checks.h" | |
| 16 | |
| 17 namespace webrtc { | |
| 18 | |
| 19 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!
| |
| 20 : num_bands_(num_bands), | |
| 21 frame_length_(frame_length), | |
| 22 buffer_(num_bands_ * kMaxSize, 0.f), | |
| 23 buffer_size_(kBlockSize) {} | |
| 24 | |
| 25 BlockFramer::~BlockFramer() = default; | |
| 26 | |
| 27 void BlockFramer::InsertBlock(rtc::ArrayView<const float> block) { | |
| 28 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.
| |
| 29 for (size_t i = 0; i < num_bands_; ++i) { | |
| 30 rtc::ArrayView<const float> band = | |
| 31 block.subview(i * kBlockSize, kBlockSize); | |
| 32 std::copy(band.begin(), band.end(), | |
| 33 buffer_.begin() + i * kMaxSize + buffer_size_); | |
| 34 } | |
| 35 buffer_size_ += kBlockSize; | |
| 36 } | |
| 37 | |
| 38 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.
| |
| 39 RTC_DCHECK_LE(kSubFrameLength, buffer_size_); | |
| 40 RTC_DCHECK_LE(sub_frame_index * kSubFrameLength, frame_length_); | |
| 41 for (size_t i = 0; i < num_bands_; ++i) { | |
| 42 rtc::ArrayView<float> frame_view( | |
| 43 &frame[i][kSubFrameLength * sub_frame_index], kSubFrameLength); | |
| 44 std::copy(buffer_.begin() + i * kMaxSize, | |
| 45 buffer_.begin() + i * kMaxSize + kSubFrameLength, | |
| 46 frame_view.begin()); | |
| 47 } | |
| 48 buffer_size_ -= kSubFrameLength; | |
| 49 | |
| 50 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.
| |
| 51 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.
| |
| 52 for (size_t i = 0; i < num_bands_; ++i) { | |
| 53 std::copy(buffer_.begin() + i * kMaxSize + kSubFrameLength, | |
| 54 buffer_.begin() + i * kMaxSize + kSubFrameLength + buffer_size_, | |
| 55 buffer_.begin() + i * kMaxSize); | |
| 56 } | |
| 57 } | |
| 58 } | |
| 59 | |
| 60 } // namespace webrtc | |
| OLD | NEW |