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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 size_t input_samples, | 100 size_t 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 int encoded_bytes_int = WebRtcOpus_Encode(encoder, input_audio, input_samples, | 104 int encoded_bytes_int = WebRtcOpus_Encode(encoder, input_audio, input_samples, |
105 kMaxBytes, bitstream_); | 105 kMaxBytes, bitstream_); |
106 EXPECT_GE(encoded_bytes_int, 0); | 106 EXPECT_GE(encoded_bytes_int, 0); |
107 encoded_bytes_ = static_cast<size_t>(encoded_bytes_int); | 107 encoded_bytes_ = static_cast<size_t>(encoded_bytes_int); |
108 return WebRtcOpus_Decode(decoder, bitstream_, | 108 int est_len = WebRtcOpus_DurationEst(decoder, bitstream_, encoded_bytes_); |
109 encoded_bytes_, output_audio, | 109 int act_len = WebRtcOpus_Decode(decoder, bitstream_, |
110 audio_type); | 110 encoded_bytes_, output_audio, |
| 111 audio_type); |
| 112 EXPECT_EQ(est_len, act_len); |
| 113 return act_len; |
111 } | 114 } |
112 | 115 |
113 // Test if encoder/decoder can enter DTX mode properly and do not enter DTX when | 116 // Test if encoder/decoder can enter DTX mode properly and do not enter DTX when |
114 // they should not. This test is signal dependent. | 117 // they should not. This test is signal dependent. |
115 void OpusTest::TestDtxEffect(bool dtx) { | 118 void OpusTest::TestDtxEffect(bool dtx) { |
116 PrepareSpeechData(channels_, 20, 2000); | 119 PrepareSpeechData(channels_, 20, 2000); |
117 | 120 |
118 // Create encoder memory. | 121 // Create encoder memory. |
119 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 122 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
120 channels_, | 123 channels_, |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 617 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
615 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 618 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
616 } | 619 } |
617 | 620 |
618 INSTANTIATE_TEST_CASE_P(VariousMode, | 621 INSTANTIATE_TEST_CASE_P(VariousMode, |
619 OpusTest, | 622 OpusTest, |
620 Combine(Values(1, 2), Values(0, 1))); | 623 Combine(Values(1, 2), Values(0, 1))); |
621 | 624 |
622 | 625 |
623 } // namespace webrtc | 626 } // namespace webrtc |
OLD | NEW |