| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 class NoopCallback : public webrtc::LappedTransform::Callback { | 23 class NoopCallback : public webrtc::LappedTransform::Callback { |
| 24 public: | 24 public: |
| 25 NoopCallback() : block_num_(0) {} | 25 NoopCallback() : block_num_(0) {} |
| 26 | 26 |
| 27 virtual void ProcessAudioBlock(const complex<float>* const* in_block, | 27 virtual void ProcessAudioBlock(const complex<float>* const* in_block, |
| 28 int in_channels, | 28 int in_channels, |
| 29 size_t frames, | 29 size_t frames, |
| 30 int out_channels, | 30 int out_channels, |
| 31 complex<float>* const* out_block) { | 31 complex<float>* const* out_block) { |
| 32 CHECK_EQ(in_channels, out_channels); | 32 RTC_CHECK_EQ(in_channels, out_channels); |
| 33 for (int i = 0; i < out_channels; ++i) { | 33 for (int i = 0; i < out_channels; ++i) { |
| 34 memcpy(out_block[i], in_block[i], sizeof(**in_block) * frames); | 34 memcpy(out_block[i], in_block[i], sizeof(**in_block) * frames); |
| 35 } | 35 } |
| 36 ++block_num_; | 36 ++block_num_; |
| 37 } | 37 } |
| 38 | 38 |
| 39 int block_num() { | 39 int block_num() { |
| 40 return block_num_; | 40 return block_num_; |
| 41 } | 41 } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 int block_num_; | 44 int block_num_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class FftCheckerCallback : public webrtc::LappedTransform::Callback { | 47 class FftCheckerCallback : public webrtc::LappedTransform::Callback { |
| 48 public: | 48 public: |
| 49 FftCheckerCallback() : block_num_(0) {} | 49 FftCheckerCallback() : block_num_(0) {} |
| 50 | 50 |
| 51 virtual void ProcessAudioBlock(const complex<float>* const* in_block, | 51 virtual void ProcessAudioBlock(const complex<float>* const* in_block, |
| 52 int in_channels, | 52 int in_channels, |
| 53 size_t frames, | 53 size_t frames, |
| 54 int out_channels, | 54 int out_channels, |
| 55 complex<float>* const* out_block) { | 55 complex<float>* const* out_block) { |
| 56 CHECK_EQ(in_channels, out_channels); | 56 RTC_CHECK_EQ(in_channels, out_channels); |
| 57 | 57 |
| 58 size_t full_length = (frames - 1) * 2; | 58 size_t full_length = (frames - 1) * 2; |
| 59 ++block_num_; | 59 ++block_num_; |
| 60 | 60 |
| 61 if (block_num_ > 0) { | 61 if (block_num_ > 0) { |
| 62 ASSERT_NEAR(in_block[0][0].real(), static_cast<float>(full_length), | 62 ASSERT_NEAR(in_block[0][0].real(), static_cast<float>(full_length), |
| 63 1e-5f); | 63 1e-5f); |
| 64 ASSERT_NEAR(in_block[0][0].imag(), 0.0f, 1e-5f); | 64 ASSERT_NEAR(in_block[0][0].imag(), 0.0f, 1e-5f); |
| 65 for (size_t i = 1; i < frames; ++i) { | 65 for (size_t i = 1; i < frames; ++i) { |
| 66 ASSERT_NEAR(in_block[0][i].real(), 0.0f, 1e-5f); | 66 ASSERT_NEAR(in_block[0][i].real(), 0.0f, 1e-5f); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 { | 199 { |
| 200 const size_t kExpectedChunkLength = 160; | 200 const size_t kExpectedChunkLength = 160; |
| 201 const LappedTransform trans(1, 1, kExpectedChunkLength, window, | 201 const LappedTransform trans(1, 1, kExpectedChunkLength, window, |
| 202 kBlockLength, kBlockLength, &call); | 202 kBlockLength, kBlockLength, &call); |
| 203 | 203 |
| 204 EXPECT_EQ(kExpectedChunkLength, trans.chunk_length()); | 204 EXPECT_EQ(kExpectedChunkLength, trans.chunk_length()); |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 | 207 |
| 208 } // namespace webrtc | 208 } // namespace webrtc |
| OLD | NEW |