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

Unified Diff: webrtc/common_audio/resampler/push_resampler.cc

Issue 1230503003: Update a ton of audio code to use size_t more correctly and in general reduce (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/common_audio/resampler/push_resampler.cc
diff --git a/webrtc/common_audio/resampler/push_resampler.cc b/webrtc/common_audio/resampler/push_resampler.cc
index 973c8f74f765e85cd7d51b01500fa356dd9a6d81..566acdeaa3c7ac670a768104f62a33546830c7c2 100644
--- a/webrtc/common_audio/resampler/push_resampler.cc
+++ b/webrtc/common_audio/resampler/push_resampler.cc
@@ -47,8 +47,10 @@ int PushResampler<T>::InitializeIfNeeded(int src_sample_rate_hz,
dst_sample_rate_hz_ = dst_sample_rate_hz;
num_channels_ = num_channels;
- const int src_size_10ms_mono = src_sample_rate_hz / 100;
- const int dst_size_10ms_mono = dst_sample_rate_hz / 100;
+ const size_t src_size_10ms_mono =
+ static_cast<size_t>(src_sample_rate_hz / 100);
+ const size_t dst_size_10ms_mono =
+ static_cast<size_t>(dst_sample_rate_hz / 100);
sinc_resampler_.reset(new PushSincResampler(src_size_10ms_mono,
dst_size_10ms_mono));
if (num_channels_ == 2) {
@@ -64,10 +66,12 @@ int PushResampler<T>::InitializeIfNeeded(int src_sample_rate_hz,
}
template <typename T>
-int PushResampler<T>::Resample(const T* src, int src_length, T* dst,
- int dst_capacity) {
- const int src_size_10ms = src_sample_rate_hz_ * num_channels_ / 100;
- const int dst_size_10ms = dst_sample_rate_hz_ * num_channels_ / 100;
+int PushResampler<T>::Resample(const T* src, size_t src_length, T* dst,
+ size_t dst_capacity) {
+ const size_t src_size_10ms =
+ static_cast<size_t>(src_sample_rate_hz_ * num_channels_ / 100);
+ const size_t dst_size_10ms =
+ static_cast<size_t>(dst_sample_rate_hz_ * num_channels_ / 100);
if (src_length != src_size_10ms || dst_capacity < dst_size_10ms)
return -1;
@@ -75,15 +79,15 @@ int PushResampler<T>::Resample(const T* src, int src_length, T* dst,
// The old resampler provides this memcpy facility in the case of matching
// sample rates, so reproduce it here for the sinc resampler.
memcpy(dst, src, src_length * sizeof(T));
- return src_length;
+ return static_cast<int>(src_length);
}
if (num_channels_ == 2) {
- const int src_length_mono = src_length / num_channels_;
- const int dst_capacity_mono = dst_capacity / num_channels_;
+ const size_t src_length_mono = src_length / num_channels_;
+ const size_t dst_capacity_mono = dst_capacity / num_channels_;
T* deinterleaved[] = {src_left_.get(), src_right_.get()};
Deinterleave(src, src_length_mono, num_channels_, deinterleaved);
- int dst_length_mono =
+ size_t dst_length_mono =
sinc_resampler_->Resample(src_left_.get(), src_length_mono,
dst_left_.get(), dst_capacity_mono);
sinc_resampler_right_->Resample(src_right_.get(), src_length_mono,
@@ -92,9 +96,10 @@ int PushResampler<T>::Resample(const T* src, int src_length, T* dst,
deinterleaved[0] = dst_left_.get();
deinterleaved[1] = dst_right_.get();
Interleave(deinterleaved, dst_length_mono, num_channels_, dst);
- return dst_length_mono * num_channels_;
+ return static_cast<int>(dst_length_mono * num_channels_);
} else {
- return sinc_resampler_->Resample(src, src_length, dst, dst_capacity);
+ return static_cast<int>(
+ sinc_resampler_->Resample(src, src_length, dst, dst_capacity));
}
}
« no previous file with comments | « webrtc/common_audio/resampler/include/resampler.h ('k') | webrtc/common_audio/resampler/push_sinc_resampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698