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

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

Issue 1174813003: Prepare to convert various types to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix MSVC warning 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 #include <string> 10 #include <string>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 int OpusTest::EncodeDecode(WebRtcOpusEncInst* encoder, 98 int OpusTest::EncodeDecode(WebRtcOpusEncInst* encoder,
99 const int16_t* input_audio, 99 const int16_t* input_audio,
100 const int input_samples, 100 const int input_samples,
101 WebRtcOpusDecInst* decoder, 101 WebRtcOpusDecInst* decoder,
102 int16_t* output_audio, 102 int16_t* output_audio,
103 int16_t* audio_type) { 103 int16_t* audio_type) {
104 encoded_bytes_ = WebRtcOpus_Encode(encoder, 104 encoded_bytes_ = WebRtcOpus_Encode(encoder,
105 input_audio, 105 input_audio,
106 input_samples, kMaxBytes, 106 input_samples, kMaxBytes,
107 bitstream_); 107 bitstream_);
108 EXPECT_GE(encoded_bytes_, 0);
108 return WebRtcOpus_Decode(decoder, bitstream_, 109 return WebRtcOpus_Decode(decoder, bitstream_,
109 encoded_bytes_, output_audio, 110 encoded_bytes_, output_audio,
110 audio_type); 111 audio_type);
111 } 112 }
112 113
113 // Test if encoder/decoder can enter DTX mode properly and do not enter DTX when 114 // Test if encoder/decoder can enter DTX mode properly and do not enter DTX when
114 // they should not. This test is signal dependent. 115 // they should not. This test is signal dependent.
115 void OpusTest::TestDtxEffect(bool dtx) { 116 void OpusTest::TestDtxEffect(bool dtx) {
116 PrepareSpeechData(channels_, 20, 2000); 117 PrepareSpeechData(channels_, 20, 2000);
117 118
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, 532 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
532 channels_, 533 channels_,
533 application_)); 534 application_));
534 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); 535 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_));
535 536
536 // 10 ms. We use only first 10 ms of a 20 ms block. 537 // 10 ms. We use only first 10 ms of a 20 ms block.
537 encoded_bytes_ = WebRtcOpus_Encode(opus_encoder_, 538 encoded_bytes_ = WebRtcOpus_Encode(opus_encoder_,
538 speech_data_.GetNextBlock(), 539 speech_data_.GetNextBlock(),
539 kOpus10msFrameSamples, kMaxBytes, 540 kOpus10msFrameSamples, kMaxBytes,
540 bitstream_); 541 bitstream_);
542 EXPECT_GE(encoded_bytes_, 0);
541 EXPECT_EQ(kOpus10msFrameSamples, 543 EXPECT_EQ(kOpus10msFrameSamples,
542 WebRtcOpus_DurationEst(opus_decoder_, bitstream_, 544 WebRtcOpus_DurationEst(opus_decoder_, bitstream_,
543 encoded_bytes_)); 545 encoded_bytes_));
544 546
545 // 20 ms 547 // 20 ms
546 encoded_bytes_ = WebRtcOpus_Encode(opus_encoder_, 548 encoded_bytes_ = WebRtcOpus_Encode(opus_encoder_,
547 speech_data_.GetNextBlock(), 549 speech_data_.GetNextBlock(),
548 kOpus20msFrameSamples, kMaxBytes, 550 kOpus20msFrameSamples, kMaxBytes,
549 bitstream_); 551 bitstream_);
552 EXPECT_GE(encoded_bytes_, 0);
550 EXPECT_EQ(kOpus20msFrameSamples, 553 EXPECT_EQ(kOpus20msFrameSamples,
551 WebRtcOpus_DurationEst(opus_decoder_, bitstream_, 554 WebRtcOpus_DurationEst(opus_decoder_, bitstream_,
552 encoded_bytes_)); 555 encoded_bytes_));
553 556
554 // Free memory. 557 // Free memory.
555 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); 558 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_));
556 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); 559 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_));
557 } 560 }
558 561
559 TEST_P(OpusTest, OpusDecodeRepacketized) { 562 TEST_P(OpusTest, OpusDecodeRepacketized) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); 606 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_));
604 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); 607 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_));
605 } 608 }
606 609
607 INSTANTIATE_TEST_CASE_P(VariousMode, 610 INSTANTIATE_TEST_CASE_P(VariousMode,
608 OpusTest, 611 OpusTest,
609 Combine(Values(1, 2), Values(0, 1))); 612 Combine(Values(1, 2), Values(0, 1)));
610 613
611 614
612 } // namespace webrtc 615 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698