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