| 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 |
| 11 #include "webrtc/common_audio/channel_buffer.h" | 11 #include "webrtc/common_audio/channel_buffer.h" |
| 12 | 12 |
| 13 #include "webrtc/base/checks.h" |
| 14 |
| 13 namespace webrtc { | 15 namespace webrtc { |
| 14 | 16 |
| 15 IFChannelBuffer::IFChannelBuffer(size_t num_frames, | 17 IFChannelBuffer::IFChannelBuffer(size_t num_frames, |
| 16 size_t num_channels, | 18 size_t num_channels, |
| 17 size_t num_bands) | 19 size_t num_bands) |
| 18 : ivalid_(true), | 20 : ivalid_(true), |
| 19 ibuf_(num_frames, num_channels, num_bands), | 21 ibuf_(num_frames, num_channels, num_bands), |
| 20 fvalid_(true), | 22 fvalid_(true), |
| 21 fbuf_(num_frames, num_channels, num_bands) {} | 23 fbuf_(num_frames, num_channels, num_bands) {} |
| 22 | 24 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 37 return &ibuf_; | 39 return &ibuf_; |
| 38 } | 40 } |
| 39 | 41 |
| 40 const ChannelBuffer<float>* IFChannelBuffer::fbuf_const() const { | 42 const ChannelBuffer<float>* IFChannelBuffer::fbuf_const() const { |
| 41 RefreshF(); | 43 RefreshF(); |
| 42 return &fbuf_; | 44 return &fbuf_; |
| 43 } | 45 } |
| 44 | 46 |
| 45 void IFChannelBuffer::RefreshF() const { | 47 void IFChannelBuffer::RefreshF() const { |
| 46 if (!fvalid_) { | 48 if (!fvalid_) { |
| 47 assert(ivalid_); | 49 RTC_DCHECK(ivalid_); |
| 48 const int16_t* const* int_channels = ibuf_.channels(); | 50 const int16_t* const* int_channels = ibuf_.channels(); |
| 49 float* const* float_channels = fbuf_.channels(); | 51 float* const* float_channels = fbuf_.channels(); |
| 50 for (size_t i = 0; i < ibuf_.num_channels(); ++i) { | 52 for (size_t i = 0; i < ibuf_.num_channels(); ++i) { |
| 51 for (size_t j = 0; j < ibuf_.num_frames(); ++j) { | 53 for (size_t j = 0; j < ibuf_.num_frames(); ++j) { |
| 52 float_channels[i][j] = int_channels[i][j]; | 54 float_channels[i][j] = int_channels[i][j]; |
| 53 } | 55 } |
| 54 } | 56 } |
| 55 fvalid_ = true; | 57 fvalid_ = true; |
| 56 } | 58 } |
| 57 } | 59 } |
| 58 | 60 |
| 59 void IFChannelBuffer::RefreshI() const { | 61 void IFChannelBuffer::RefreshI() const { |
| 60 if (!ivalid_) { | 62 if (!ivalid_) { |
| 61 assert(fvalid_); | 63 RTC_DCHECK(fvalid_); |
| 62 int16_t* const* int_channels = ibuf_.channels(); | 64 int16_t* const* int_channels = ibuf_.channels(); |
| 63 const float* const* float_channels = fbuf_.channels(); | 65 const float* const* float_channels = fbuf_.channels(); |
| 64 for (size_t i = 0; i < ibuf_.num_channels(); ++i) { | 66 for (size_t i = 0; i < ibuf_.num_channels(); ++i) { |
| 65 FloatS16ToS16(float_channels[i], | 67 FloatS16ToS16(float_channels[i], |
| 66 ibuf_.num_frames(), | 68 ibuf_.num_frames(), |
| 67 int_channels[i]); | 69 int_channels[i]); |
| 68 } | 70 } |
| 69 ivalid_ = true; | 71 ivalid_ = true; |
| 70 } | 72 } |
| 71 } | 73 } |
| 72 | 74 |
| 73 } // namespace webrtc | 75 } // namespace webrtc |
| OLD | NEW |