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

Side by Side Diff: webrtc/modules/audio_coding/acm2/acm_resampler.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) 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 10 matching lines...) Expand all
21 21
22 ACMResampler::ACMResampler() { 22 ACMResampler::ACMResampler() {
23 } 23 }
24 24
25 ACMResampler::~ACMResampler() { 25 ACMResampler::~ACMResampler() {
26 } 26 }
27 27
28 int ACMResampler::Resample10Msec(const int16_t* in_audio, 28 int ACMResampler::Resample10Msec(const int16_t* in_audio,
29 int in_freq_hz, 29 int in_freq_hz,
30 int out_freq_hz, 30 int out_freq_hz,
31 int num_audio_channels, 31 size_t num_audio_channels,
32 size_t out_capacity_samples, 32 size_t out_capacity_samples,
33 int16_t* out_audio) { 33 int16_t* out_audio) {
34 size_t in_length = static_cast<size_t>(in_freq_hz * num_audio_channels / 100); 34 size_t in_length = in_freq_hz * num_audio_channels / 100;
35 if (in_freq_hz == out_freq_hz) { 35 if (in_freq_hz == out_freq_hz) {
36 if (out_capacity_samples < in_length) { 36 if (out_capacity_samples < in_length) {
37 assert(false); 37 assert(false);
38 return -1; 38 return -1;
39 } 39 }
40 memcpy(out_audio, in_audio, in_length * sizeof(int16_t)); 40 memcpy(out_audio, in_audio, in_length * sizeof(int16_t));
41 return static_cast<int>(in_length / num_audio_channels); 41 return static_cast<int>(in_length / num_audio_channels);
42 } 42 }
43 43
44 if (resampler_.InitializeIfNeeded(in_freq_hz, out_freq_hz, 44 if (resampler_.InitializeIfNeeded(in_freq_hz, out_freq_hz,
45 num_audio_channels) != 0) { 45 num_audio_channels) != 0) {
46 LOG(LS_ERROR) << "InitializeIfNeeded(" << in_freq_hz << ", " << out_freq_hz 46 LOG(LS_ERROR) << "InitializeIfNeeded(" << in_freq_hz << ", " << out_freq_hz
47 << ", " << num_audio_channels << ") failed."; 47 << ", " << num_audio_channels << ") failed.";
48 return -1; 48 return -1;
49 } 49 }
50 50
51 int out_length = 51 int out_length =
52 resampler_.Resample(in_audio, in_length, out_audio, out_capacity_samples); 52 resampler_.Resample(in_audio, in_length, out_audio, out_capacity_samples);
53 if (out_length == -1) { 53 if (out_length == -1) {
54 LOG(LS_ERROR) << "Resample(" << in_audio << ", " << in_length << ", " 54 LOG(LS_ERROR) << "Resample(" << in_audio << ", " << in_length << ", "
55 << out_audio << ", " << out_capacity_samples << ") failed."; 55 << out_audio << ", " << out_capacity_samples << ") failed.";
56 return -1; 56 return -1;
57 } 57 }
58 58
59 return out_length / num_audio_channels; 59 return static_cast<int>(out_length / num_audio_channels);
60 } 60 }
61 61
62 } // namespace acm2 62 } // namespace acm2
63 } // namespace webrtc 63 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/acm2/acm_resampler.h ('k') | webrtc/modules/audio_coding/acm2/audio_coding_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698