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

Side by Side Diff: webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc

Issue 1168753002: Match existing type usage better. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 6 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 109
110 int AudioEncoderOpus::NumChannels() const { 110 int AudioEncoderOpus::NumChannels() const {
111 return num_channels_; 111 return num_channels_;
112 } 112 }
113 113
114 size_t AudioEncoderOpus::MaxEncodedBytes() const { 114 size_t AudioEncoderOpus::MaxEncodedBytes() const {
115 // Calculate the number of bytes we expect the encoder to produce, 115 // Calculate the number of bytes we expect the encoder to produce,
116 // then multiply by two to give a wide margin for error. 116 // then multiply by two to give a wide margin for error.
117 int frame_size_ms = num_10ms_frames_per_packet_ * 10; 117 int frame_size_ms = num_10ms_frames_per_packet_ * 10;
118 int bytes_per_millisecond = bitrate_bps_ / (1000 * 8) + 1; 118 size_t bytes_per_millisecond =
119 size_t approx_encoded_bytes = 119 static_cast<size_t>(bitrate_bps_ / (1000 * 8) + 1);
120 static_cast<size_t>(frame_size_ms * bytes_per_millisecond); 120 size_t approx_encoded_bytes = frame_size_ms * bytes_per_millisecond;
121 return 2 * approx_encoded_bytes; 121 return 2 * approx_encoded_bytes;
122 } 122 }
123 123
124 int AudioEncoderOpus::Num10MsFramesInNextPacket() const { 124 int AudioEncoderOpus::Num10MsFramesInNextPacket() const {
125 return num_10ms_frames_per_packet_; 125 return num_10ms_frames_per_packet_;
126 } 126 }
127 127
128 int AudioEncoderOpus::Max10MsFramesInAPacket() const { 128 int AudioEncoderOpus::Max10MsFramesInAPacket() const {
129 return num_10ms_frames_per_packet_; 129 return num_10ms_frames_per_packet_;
130 } 130 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 static_cast<size_t>(num_10ms_frames_per_packet_) * 199 static_cast<size_t>(num_10ms_frames_per_packet_) *
200 samples_per_10ms_frame_); 200 samples_per_10ms_frame_);
201 int16_t status = WebRtcOpus_Encode( 201 int16_t status = WebRtcOpus_Encode(
202 inst_, &input_buffer_[0], 202 inst_, &input_buffer_[0],
203 rtc::CheckedDivExact(CastInt16(input_buffer_.size()), 203 rtc::CheckedDivExact(CastInt16(input_buffer_.size()),
204 static_cast<int16_t>(num_channels_)), 204 static_cast<int16_t>(num_channels_)),
205 ClampInt16(max_encoded_bytes), encoded); 205 ClampInt16(max_encoded_bytes), encoded);
206 CHECK_GE(status, 0); // Fails only if fed invalid data. 206 CHECK_GE(status, 0); // Fails only if fed invalid data.
207 input_buffer_.clear(); 207 input_buffer_.clear();
208 EncodedInfo info; 208 EncodedInfo info;
209 info.encoded_bytes = status; 209 info.encoded_bytes = static_cast<size_t>(status);
210 info.encoded_timestamp = first_timestamp_in_buffer_; 210 info.encoded_timestamp = first_timestamp_in_buffer_;
211 info.payload_type = payload_type_; 211 info.payload_type = payload_type_;
212 info.send_even_if_empty = true; // Allows Opus to send empty packets. 212 info.send_even_if_empty = true; // Allows Opus to send empty packets.
213 info.speech = (status > 0); 213 info.speech = (status > 0);
214 return info; 214 return info;
215 } 215 }
216 216
217 namespace { 217 namespace {
218 AudioEncoderOpus::Config CreateConfig(const CodecInst& codec_inst) { 218 AudioEncoderOpus::Config CreateConfig(const CodecInst& codec_inst) {
219 AudioEncoderOpus::Config config; 219 AudioEncoderOpus::Config config;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 return Reconstruct(conf); 256 return Reconstruct(conf);
257 } 257 }
258 258
259 bool AudioEncoderMutableOpus::SetMaxPlaybackRate(int frequency_hz) { 259 bool AudioEncoderMutableOpus::SetMaxPlaybackRate(int frequency_hz) {
260 auto conf = config(); 260 auto conf = config();
261 conf.max_playback_rate_hz = frequency_hz; 261 conf.max_playback_rate_hz = frequency_hz;
262 return Reconstruct(conf); 262 return Reconstruct(conf);
263 } 263 }
264 264
265 } // namespace webrtc 265 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698