Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: webrtc/modules/audio_processing/splitting_filter.cc

Issue 1316523002: Convert channel counts to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix compile Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/modules/audio_processing/splitting_filter.h" 11 #include "webrtc/modules/audio_processing/splitting_filter.h"
12 12
13 #include "webrtc/base/checks.h" 13 #include "webrtc/base/checks.h"
14 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 14 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
15 #include "webrtc/common_audio/channel_buffer.h" 15 #include "webrtc/common_audio/channel_buffer.h"
16 16
17 namespace webrtc { 17 namespace webrtc {
18 18
19 SplittingFilter::SplittingFilter(int num_channels, 19 SplittingFilter::SplittingFilter(size_t num_channels,
20 size_t num_bands, 20 size_t num_bands,
21 size_t num_frames) 21 size_t num_frames)
22 : num_bands_(num_bands) { 22 : num_bands_(num_bands) {
23 RTC_CHECK(num_bands_ == 2 || num_bands_ == 3); 23 RTC_CHECK(num_bands_ == 2 || num_bands_ == 3);
24 if (num_bands_ == 2) { 24 if (num_bands_ == 2) {
25 two_bands_states_.resize(num_channels); 25 two_bands_states_.resize(num_channels);
26 } else if (num_bands_ == 3) { 26 } else if (num_bands_ == 3) {
27 for (int i = 0; i < num_channels; ++i) { 27 for (size_t i = 0; i < num_channels; ++i) {
28 three_band_filter_banks_.push_back(new ThreeBandFilterBank(num_frames)); 28 three_band_filter_banks_.push_back(new ThreeBandFilterBank(num_frames));
29 } 29 }
30 } 30 }
31 } 31 }
32 32
33 void SplittingFilter::Analysis(const IFChannelBuffer* data, 33 void SplittingFilter::Analysis(const IFChannelBuffer* data,
34 IFChannelBuffer* bands) { 34 IFChannelBuffer* bands) {
35 RTC_DCHECK_EQ(num_bands_, bands->num_bands()); 35 RTC_DCHECK_EQ(num_bands_, bands->num_bands());
36 RTC_DCHECK_EQ(data->num_channels(), bands->num_channels()); 36 RTC_DCHECK_EQ(data->num_channels(), bands->num_channels());
37 RTC_DCHECK_EQ(data->num_frames(), 37 RTC_DCHECK_EQ(data->num_frames(),
(...skipping 13 matching lines...) Expand all
51 bands->num_frames_per_band() * bands->num_bands()); 51 bands->num_frames_per_band() * bands->num_bands());
52 if (bands->num_bands() == 2) { 52 if (bands->num_bands() == 2) {
53 TwoBandsSynthesis(bands, data); 53 TwoBandsSynthesis(bands, data);
54 } else if (bands->num_bands() == 3) { 54 } else if (bands->num_bands() == 3) {
55 ThreeBandsSynthesis(bands, data); 55 ThreeBandsSynthesis(bands, data);
56 } 56 }
57 } 57 }
58 58
59 void SplittingFilter::TwoBandsAnalysis(const IFChannelBuffer* data, 59 void SplittingFilter::TwoBandsAnalysis(const IFChannelBuffer* data,
60 IFChannelBuffer* bands) { 60 IFChannelBuffer* bands) {
61 RTC_DCHECK_EQ(static_cast<int>(two_bands_states_.size()), 61 RTC_DCHECK_EQ(two_bands_states_.size(), data->num_channels());
62 data->num_channels());
63 for (size_t i = 0; i < two_bands_states_.size(); ++i) { 62 for (size_t i = 0; i < two_bands_states_.size(); ++i) {
64 WebRtcSpl_AnalysisQMF(data->ibuf_const()->channels()[i], 63 WebRtcSpl_AnalysisQMF(data->ibuf_const()->channels()[i],
65 data->num_frames(), 64 data->num_frames(),
66 bands->ibuf()->channels(0)[i], 65 bands->ibuf()->channels(0)[i],
67 bands->ibuf()->channels(1)[i], 66 bands->ibuf()->channels(1)[i],
68 two_bands_states_[i].analysis_state1, 67 two_bands_states_[i].analysis_state1,
69 two_bands_states_[i].analysis_state2); 68 two_bands_states_[i].analysis_state2);
70 } 69 }
71 } 70 }
72 71
73 void SplittingFilter::TwoBandsSynthesis(const IFChannelBuffer* bands, 72 void SplittingFilter::TwoBandsSynthesis(const IFChannelBuffer* bands,
74 IFChannelBuffer* data) { 73 IFChannelBuffer* data) {
75 RTC_DCHECK_EQ(static_cast<int>(two_bands_states_.size()), 74 RTC_DCHECK_EQ(two_bands_states_.size(), data->num_channels());
76 data->num_channels());
77 for (size_t i = 0; i < two_bands_states_.size(); ++i) { 75 for (size_t i = 0; i < two_bands_states_.size(); ++i) {
78 WebRtcSpl_SynthesisQMF(bands->ibuf_const()->channels(0)[i], 76 WebRtcSpl_SynthesisQMF(bands->ibuf_const()->channels(0)[i],
79 bands->ibuf_const()->channels(1)[i], 77 bands->ibuf_const()->channels(1)[i],
80 bands->num_frames_per_band(), 78 bands->num_frames_per_band(),
81 data->ibuf()->channels()[i], 79 data->ibuf()->channels()[i],
82 two_bands_states_[i].synthesis_state1, 80 two_bands_states_[i].synthesis_state1,
83 two_bands_states_[i].synthesis_state2); 81 two_bands_states_[i].synthesis_state2);
84 } 82 }
85 } 83 }
86 84
87 void SplittingFilter::ThreeBandsAnalysis(const IFChannelBuffer* data, 85 void SplittingFilter::ThreeBandsAnalysis(const IFChannelBuffer* data,
88 IFChannelBuffer* bands) { 86 IFChannelBuffer* bands) {
89 RTC_DCHECK_EQ(static_cast<int>(three_band_filter_banks_.size()), 87 RTC_DCHECK_EQ(three_band_filter_banks_.size(), data->num_channels());
90 data->num_channels());
91 for (size_t i = 0; i < three_band_filter_banks_.size(); ++i) { 88 for (size_t i = 0; i < three_band_filter_banks_.size(); ++i) {
92 three_band_filter_banks_[i]->Analysis(data->fbuf_const()->channels()[i], 89 three_band_filter_banks_[i]->Analysis(data->fbuf_const()->channels()[i],
93 data->num_frames(), 90 data->num_frames(),
94 bands->fbuf()->bands(i)); 91 bands->fbuf()->bands(i));
95 } 92 }
96 } 93 }
97 94
98 void SplittingFilter::ThreeBandsSynthesis(const IFChannelBuffer* bands, 95 void SplittingFilter::ThreeBandsSynthesis(const IFChannelBuffer* bands,
99 IFChannelBuffer* data) { 96 IFChannelBuffer* data) {
100 RTC_DCHECK_EQ(static_cast<int>(three_band_filter_banks_.size()), 97 RTC_DCHECK_EQ(three_band_filter_banks_.size(), data->num_channels());
101 data->num_channels());
102 for (size_t i = 0; i < three_band_filter_banks_.size(); ++i) { 98 for (size_t i = 0; i < three_band_filter_banks_.size(); ++i) {
103 three_band_filter_banks_[i]->Synthesis(bands->fbuf_const()->bands(i), 99 three_band_filter_banks_[i]->Synthesis(bands->fbuf_const()->bands(i),
104 bands->num_frames_per_band(), 100 bands->num_frames_per_band(),
105 data->fbuf()->channels()[i]); 101 data->fbuf()->channels()[i]);
106 } 102 }
107 } 103 }
108 104
109 } // namespace webrtc 105 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/splitting_filter.h ('k') | webrtc/modules/audio_processing/test/audio_file_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698