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

Side by Side Diff: webrtc/voice_engine/utility.cc

Issue 1338833002: Fix the maximum native sample rate in AudioProcessing (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix 44k1 sample rate Created 5 years, 3 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 int codec_num_channels, 78 int codec_num_channels,
79 int codec_rate_hz, 79 int codec_rate_hz,
80 int16_t* mono_buffer, 80 int16_t* mono_buffer,
81 PushResampler<int16_t>* resampler, 81 PushResampler<int16_t>* resampler,
82 AudioFrame* dst_af) { 82 AudioFrame* dst_af) {
83 assert(samples_per_channel <= kMaxMonoDataSizeSamples); 83 assert(samples_per_channel <= kMaxMonoDataSizeSamples);
84 assert(num_channels == 1 || num_channels == 2); 84 assert(num_channels == 1 || num_channels == 2);
85 assert(codec_num_channels == 1 || codec_num_channels == 2); 85 assert(codec_num_channels == 1 || codec_num_channels == 2);
86 dst_af->Reset(); 86 dst_af->Reset();
87 87
88 // Never upsample the capture signal here. This should be done at the 88 // Chose the lowest native sample rate which is higher or equal than at least
89 // end of the send chain. 89 // one of the input or codec rates.
90 int destination_rate = std::min(codec_rate_hz, sample_rate_hz); 90 int destination_rate;
Andrew MacDonald 2015/09/16 02:35:08 I think you should move this to transmit_mixer.cc
aluebs-webrtc 2015/09/16 03:02:53 What do you mean with "do the whole thing" in one
Andrew MacDonald 2015/09/16 04:04:08 Mainly, I don't like that both DownConvertToCodecF
aluebs-webrtc 2015/09/22 01:35:29 Agreed. I didn't move it to the float interface, s
Andrew MacDonald 2015/09/23 02:35:52 What you have looks good. Thanks for the cleanup.
91 for (size_t i = 0; i < kNumAudioProcNativeSampleRates; ++i) {
hlundin-webrtc 2015/09/16 13:45:49 Nit: You can use a C++11 range-based for loop here
aluebs-webrtc 2015/09/22 01:35:29 Since now it is defined in the header and declared
92 destination_rate = kAudioProcNativeSampleRatesHz[i];
93 if (destination_rate >= sample_rate_hz ||
94 destination_rate >= codec_rate_hz) {
95 break;
96 }
97 }
91 98
92 // If no stereo codecs are in use, we downmix a stereo stream from the 99 // If no stereo codecs are in use, we downmix a stereo stream from the
93 // device early in the chain, before resampling. 100 // device early in the chain, before resampling.
94 if (num_channels == 2 && codec_num_channels == 1) { 101 if (num_channels == 2 && codec_num_channels == 1) {
95 AudioFrameOperations::StereoToMono(src_data, samples_per_channel, 102 AudioFrameOperations::StereoToMono(src_data, samples_per_channel,
96 mono_buffer); 103 mono_buffer);
97 src_data = mono_buffer; 104 src_data = mono_buffer;
98 num_channels = 1; 105 num_channels = 1;
99 } 106 }
100 107
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 int32_t temp = 0; 157 int32_t temp = 0;
151 for (size_t i = 0; i < source_len; ++i) { 158 for (size_t i = 0; i < source_len; ++i) {
152 temp = source[i] + target[i]; 159 temp = source[i] + target[i];
153 target[i] = WebRtcSpl_SatW32ToW16(temp); 160 target[i] = WebRtcSpl_SatW32ToW16(temp);
154 } 161 }
155 } 162 }
156 } 163 }
157 164
158 } // namespace voe 165 } // namespace voe
159 } // namespace webrtc 166 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698