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

Side by Side Diff: webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.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
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 static_cast<size_t>(config_.bitrate_bps / (1000 * 8) + 1); 107 static_cast<size_t>(config_.bitrate_bps / (1000 * 8) + 1);
108 const size_t approx_encoded_bytes = 108 const size_t approx_encoded_bytes =
109 Num10msFramesPerPacket() * 10 * bytes_per_millisecond; 109 Num10msFramesPerPacket() * 10 * bytes_per_millisecond;
110 return 2 * approx_encoded_bytes; 110 return 2 * approx_encoded_bytes;
111 } 111 }
112 112
113 int AudioEncoderOpus::SampleRateHz() const { 113 int AudioEncoderOpus::SampleRateHz() const {
114 return kSampleRateHz; 114 return kSampleRateHz;
115 } 115 }
116 116
117 int AudioEncoderOpus::NumChannels() const { 117 size_t AudioEncoderOpus::NumChannels() const {
118 return config_.num_channels; 118 return config_.num_channels;
119 } 119 }
120 120
121 size_t AudioEncoderOpus::Num10MsFramesInNextPacket() const { 121 size_t AudioEncoderOpus::Num10MsFramesInNextPacket() const {
122 return Num10msFramesPerPacket(); 122 return Num10msFramesPerPacket();
123 } 123 }
124 124
125 size_t AudioEncoderOpus::Max10MsFramesInAPacket() const { 125 size_t AudioEncoderOpus::Max10MsFramesInAPacket() const {
126 return Num10msFramesPerPacket(); 126 return Num10msFramesPerPacket();
127 } 127 }
(...skipping 12 matching lines...) Expand all
140 RTC_DCHECK_EQ(SamplesPer10msFrame(), audio.size()); 140 RTC_DCHECK_EQ(SamplesPer10msFrame(), audio.size());
141 input_buffer_.insert(input_buffer_.end(), audio.cbegin(), audio.cend()); 141 input_buffer_.insert(input_buffer_.end(), audio.cbegin(), audio.cend());
142 if (input_buffer_.size() < 142 if (input_buffer_.size() <
143 (Num10msFramesPerPacket() * SamplesPer10msFrame())) { 143 (Num10msFramesPerPacket() * SamplesPer10msFrame())) {
144 return EncodedInfo(); 144 return EncodedInfo();
145 } 145 }
146 RTC_CHECK_EQ(input_buffer_.size(), 146 RTC_CHECK_EQ(input_buffer_.size(),
147 Num10msFramesPerPacket() * SamplesPer10msFrame()); 147 Num10msFramesPerPacket() * SamplesPer10msFrame());
148 int status = WebRtcOpus_Encode( 148 int status = WebRtcOpus_Encode(
149 inst_, &input_buffer_[0], 149 inst_, &input_buffer_[0],
150 rtc::CheckedDivExact(input_buffer_.size(), 150 rtc::CheckedDivExact(input_buffer_.size(), config_.num_channels),
151 static_cast<size_t>(config_.num_channels)),
152 rtc::saturated_cast<int16_t>(max_encoded_bytes), encoded); 151 rtc::saturated_cast<int16_t>(max_encoded_bytes), encoded);
153 RTC_CHECK_GE(status, 0); // Fails only if fed invalid data. 152 RTC_CHECK_GE(status, 0); // Fails only if fed invalid data.
154 input_buffer_.clear(); 153 input_buffer_.clear();
155 EncodedInfo info; 154 EncodedInfo info;
156 info.encoded_bytes = static_cast<size_t>(status); 155 info.encoded_bytes = static_cast<size_t>(status);
157 info.encoded_timestamp = first_timestamp_in_buffer_; 156 info.encoded_timestamp = first_timestamp_in_buffer_;
158 info.payload_type = config_.payload_type; 157 info.payload_type = config_.payload_type;
159 info.send_even_if_empty = true; // Allows Opus to send empty packets. 158 info.send_even_if_empty = true; // Allows Opus to send empty packets.
160 info.speech = (status > 0); 159 info.speech = (status > 0);
161 return info; 160 return info;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 RTC_CHECK_EQ(0, WebRtcOpus_DisableDtx(inst_)); 247 RTC_CHECK_EQ(0, WebRtcOpus_DisableDtx(inst_));
249 } 248 }
250 RTC_CHECK_EQ(0, 249 RTC_CHECK_EQ(0,
251 WebRtcOpus_SetPacketLossRate( 250 WebRtcOpus_SetPacketLossRate(
252 inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5))); 251 inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5)));
253 config_ = config; 252 config_ = config;
254 return true; 253 return true;
255 } 254 }
256 255
257 } // namespace webrtc 256 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h ('k') | webrtc/modules/audio_coding/codecs/opus/opus_fec_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698