OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 /* | 11 /* |
12 * This file contains the splitting filter functions. | 12 * This file contains the splitting filter functions. |
13 * | 13 * |
14 */ | 14 */ |
15 | 15 |
| 16 #include "webrtc/base/checks.h" |
16 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 17 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
17 | 18 |
18 #include <assert.h> | |
19 | |
20 // Maximum number of samples in a low/high-band frame. | 19 // Maximum number of samples in a low/high-band frame. |
21 enum | 20 enum |
22 { | 21 { |
23 kMaxBandFrameLength = 320 // 10 ms at 64 kHz. | 22 kMaxBandFrameLength = 320 // 10 ms at 64 kHz. |
24 }; | 23 }; |
25 | 24 |
26 // QMF filter coefficients in Q16. | 25 // QMF filter coefficients in Q16. |
27 static const uint16_t WebRtcSpl_kAllPassFilter1[3] = {6418, 36982, 57261}; | 26 static const uint16_t WebRtcSpl_kAllPassFilter1[3] = {6418, 36982, 57261}; |
28 static const uint16_t WebRtcSpl_kAllPassFilter2[3] = {21333, 49062, 63010}; | 27 static const uint16_t WebRtcSpl_kAllPassFilter2[3] = {21333, 49062, 63010}; |
29 | 28 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 int32_t* filter_state1, int32_t* filter_state2) | 128 int32_t* filter_state1, int32_t* filter_state2) |
130 { | 129 { |
131 size_t i; | 130 size_t i; |
132 int16_t k; | 131 int16_t k; |
133 int32_t tmp; | 132 int32_t tmp; |
134 int32_t half_in1[kMaxBandFrameLength]; | 133 int32_t half_in1[kMaxBandFrameLength]; |
135 int32_t half_in2[kMaxBandFrameLength]; | 134 int32_t half_in2[kMaxBandFrameLength]; |
136 int32_t filter1[kMaxBandFrameLength]; | 135 int32_t filter1[kMaxBandFrameLength]; |
137 int32_t filter2[kMaxBandFrameLength]; | 136 int32_t filter2[kMaxBandFrameLength]; |
138 const size_t band_length = in_data_length / 2; | 137 const size_t band_length = in_data_length / 2; |
139 assert(in_data_length % 2 == 0); | 138 RTC_DCHECK_EQ(0, in_data_length % 2); |
140 assert(band_length <= kMaxBandFrameLength); | 139 RTC_DCHECK_LE(band_length, kMaxBandFrameLength); |
141 | 140 |
142 // Split even and odd samples. Also shift them to Q10. | 141 // Split even and odd samples. Also shift them to Q10. |
143 for (i = 0, k = 0; i < band_length; i++, k += 2) | 142 for (i = 0, k = 0; i < band_length; i++, k += 2) |
144 { | 143 { |
145 half_in2[i] = WEBRTC_SPL_LSHIFT_W32((int32_t)in_data[k], 10); | 144 half_in2[i] = WEBRTC_SPL_LSHIFT_W32((int32_t)in_data[k], 10); |
146 half_in1[i] = WEBRTC_SPL_LSHIFT_W32((int32_t)in_data[k + 1], 10); | 145 half_in1[i] = WEBRTC_SPL_LSHIFT_W32((int32_t)in_data[k + 1], 10); |
147 } | 146 } |
148 | 147 |
149 // All pass filter even and odd samples, independently. | 148 // All pass filter even and odd samples, independently. |
150 WebRtcSpl_AllPassQMF(half_in1, band_length, filter1, | 149 WebRtcSpl_AllPassQMF(half_in1, band_length, filter1, |
(...skipping 17 matching lines...) Expand all Loading... |
168 size_t band_length, int16_t* out_data, | 167 size_t band_length, int16_t* out_data, |
169 int32_t* filter_state1, int32_t* filter_state2) | 168 int32_t* filter_state1, int32_t* filter_state2) |
170 { | 169 { |
171 int32_t tmp; | 170 int32_t tmp; |
172 int32_t half_in1[kMaxBandFrameLength]; | 171 int32_t half_in1[kMaxBandFrameLength]; |
173 int32_t half_in2[kMaxBandFrameLength]; | 172 int32_t half_in2[kMaxBandFrameLength]; |
174 int32_t filter1[kMaxBandFrameLength]; | 173 int32_t filter1[kMaxBandFrameLength]; |
175 int32_t filter2[kMaxBandFrameLength]; | 174 int32_t filter2[kMaxBandFrameLength]; |
176 size_t i; | 175 size_t i; |
177 int16_t k; | 176 int16_t k; |
178 assert(band_length <= kMaxBandFrameLength); | 177 RTC_DCHECK_LE(band_length, kMaxBandFrameLength); |
179 | 178 |
180 // Obtain the sum and difference channels out of upper and lower-band channe
ls. | 179 // Obtain the sum and difference channels out of upper and lower-band channe
ls. |
181 // Also shift to Q10 domain. | 180 // Also shift to Q10 domain. |
182 for (i = 0; i < band_length; i++) | 181 for (i = 0; i < band_length; i++) |
183 { | 182 { |
184 tmp = (int32_t)low_band[i] + (int32_t)high_band[i]; | 183 tmp = (int32_t)low_band[i] + (int32_t)high_band[i]; |
185 half_in1[i] = tmp * (1 << 10); | 184 half_in1[i] = tmp * (1 << 10); |
186 tmp = (int32_t)low_band[i] - (int32_t)high_band[i]; | 185 tmp = (int32_t)low_band[i] - (int32_t)high_band[i]; |
187 half_in2[i] = tmp * (1 << 10); | 186 half_in2[i] = tmp * (1 << 10); |
188 } | 187 } |
(...skipping 10 matching lines...) Expand all Loading... |
199 for (i = 0, k = 0; i < band_length; i++) | 198 for (i = 0, k = 0; i < band_length; i++) |
200 { | 199 { |
201 tmp = (filter2[i] + 512) >> 10; | 200 tmp = (filter2[i] + 512) >> 10; |
202 out_data[k++] = WebRtcSpl_SatW32ToW16(tmp); | 201 out_data[k++] = WebRtcSpl_SatW32ToW16(tmp); |
203 | 202 |
204 tmp = (filter1[i] + 512) >> 10; | 203 tmp = (filter1[i] + 512) >> 10; |
205 out_data[k++] = WebRtcSpl_SatW32ToW16(tmp); | 204 out_data[k++] = WebRtcSpl_SatW32ToW16(tmp); |
206 } | 205 } |
207 | 206 |
208 } | 207 } |
OLD | NEW |