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