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

Side by Side Diff: webrtc/modules/audio_coding/main/test/opus_test.cc

Issue 1179953003: Revert "Upconvert various types to int." (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // Sometimes we need to loop over the audio vector to produce the right 266 // Sometimes we need to loop over the audio vector to produce the right
267 // number of packets. 267 // number of packets.
268 int loop_encode = (written_samples - read_samples) / 268 int loop_encode = (written_samples - read_samples) /
269 (channels * frame_length); 269 (channels * frame_length);
270 270
271 if (loop_encode > 0) { 271 if (loop_encode > 0) {
272 const int kMaxBytes = 1000; // Maximum number of bytes for one packet. 272 const int kMaxBytes = 1000; // Maximum number of bytes for one packet.
273 int16_t bitstream_len_byte; 273 int16_t bitstream_len_byte;
274 uint8_t bitstream[kMaxBytes]; 274 uint8_t bitstream[kMaxBytes];
275 for (int i = 0; i < loop_encode; i++) { 275 for (int i = 0; i < loop_encode; i++) {
276 int bitstream_len_byte_int = WebRtcOpus_Encode( 276 if (channels == 1) {
277 (channels == 1) ? opus_mono_encoder_ : opus_stereo_encoder_, 277 bitstream_len_byte = WebRtcOpus_Encode(
278 &audio[read_samples], frame_length, kMaxBytes, bitstream); 278 opus_mono_encoder_, &audio[read_samples],
279 ASSERT_GT(bitstream_len_byte_int, -1); 279 frame_length, kMaxBytes, bitstream);
280 bitstream_len_byte = static_cast<int16_t>(bitstream_len_byte_int); 280 ASSERT_GT(bitstream_len_byte, -1);
281 } else {
282 bitstream_len_byte = WebRtcOpus_Encode(
283 opus_stereo_encoder_, &audio[read_samples],
284 frame_length, kMaxBytes, bitstream);
285 ASSERT_GT(bitstream_len_byte, -1);
286 }
281 287
282 // Simulate packet loss by setting |packet_loss_| to "true" in 288 // Simulate packet loss by setting |packet_loss_| to "true" in
283 // |percent_loss| percent of the loops. 289 // |percent_loss| percent of the loops.
284 // TODO(tlegrand): Move handling of loss simulation to TestPackStereo. 290 // TODO(tlegrand): Move handling of loss simulation to TestPackStereo.
285 if (percent_loss > 0) { 291 if (percent_loss > 0) {
286 if (counter_ == floor((100 / percent_loss) + 0.5)) { 292 if (counter_ == floor((100 / percent_loss) + 0.5)) {
287 counter_ = 0; 293 counter_ = 0;
288 lost_packet = true; 294 lost_packet = true;
289 channel->set_lost_packet(true); 295 channel->set_lost_packet(true);
290 } else { 296 } else {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 out_file_.Open(file_name, 48000, "wb"); 377 out_file_.Open(file_name, 48000, "wb");
372 file_stream.str(""); 378 file_stream.str("");
373 file_name = file_stream.str(); 379 file_name = file_stream.str();
374 file_stream << webrtc::test::OutputPath() << "opusstandalone_out_" 380 file_stream << webrtc::test::OutputPath() << "opusstandalone_out_"
375 << test_number << ".pcm"; 381 << test_number << ".pcm";
376 file_name = file_stream.str(); 382 file_name = file_stream.str();
377 out_file_standalone_.Open(file_name, 48000, "wb"); 383 out_file_standalone_.Open(file_name, 48000, "wb");
378 } 384 }
379 385
380 } // namespace webrtc 386 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/codecs/opus/opus_interface.c ('k') | webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698