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

Unified Diff: webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc

Issue 1316523002: Convert channel counts to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Rebase onto cleanup change Created 5 years 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/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
diff --git a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
index 26c78388613b5d505c158a433b00864173f5440e..032323b55bbeadc3653124c13421c747a84cb74d 100644
--- a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
+++ b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
@@ -20,11 +20,13 @@ namespace webrtc {
namespace {
-int16_t NumSamplesPerFrame(int num_channels,
+int16_t NumSamplesPerFrame(size_t num_channels,
int frame_size_ms,
int sample_rate_hz) {
- int samples_per_frame = num_channels * frame_size_ms * sample_rate_hz / 1000;
- RTC_CHECK_LE(samples_per_frame, std::numeric_limits<int16_t>::max())
+ size_t samples_per_frame =
minyue-webrtc 2015/12/29 10:42:47 but why not casting |num_channels| to int and keep
Peter Kasting 2015/12/30 00:55:45 What? How can that be negative? You'd have to ha
minyue-webrtc 2016/01/04 09:06:02 sorry for ambiguity. I meant that there is no chec
Peter Kasting 2016/01/04 19:49:42 Looking at its use, it should be, yes. I can make
minyue-webrtc 2016/01/04 22:03:18 I guess that check is to make sure that casting on
Peter Kasting 2016/01/08 02:45:06 I simplified everything to just do this calculatio
+ num_channels * frame_size_ms * sample_rate_hz / 1000;
+ RTC_CHECK_LE(samples_per_frame,
+ static_cast<size_t>(std::numeric_limits<int16_t>::max()))
<< "Frame size too large.";
return static_cast<int16_t>(samples_per_frame);
}
@@ -70,7 +72,7 @@ int AudioEncoderPcm::SampleRateHz() const {
return sample_rate_hz_;
}
-int AudioEncoderPcm::NumChannels() const {
+size_t AudioEncoderPcm::NumChannels() const {
return num_channels_;
}

Powered by Google App Engine
This is Rietveld 408576698