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