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 |
| 11 #include <memory> |
10 #include <string> | 12 #include <string> |
11 | 13 |
12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
14 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" | 16 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" |
15 #include "webrtc/modules/audio_coding/codecs/opus/opus_inst.h" | 17 #include "webrtc/modules/audio_coding/codecs/opus/opus_inst.h" |
16 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" | 18 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" |
17 #include "webrtc/test/testsupport/fileutils.h" | 19 #include "webrtc/test/testsupport/fileutils.h" |
18 | 20 |
19 namespace webrtc { | 21 namespace webrtc { |
(...skipping 609 matching lines...) Loading... |
629 | 631 |
630 // Set bitrate. | 632 // Set bitrate. |
631 EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, | 633 EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, |
632 channels_ == 1 ? 32000 : 64000)); | 634 channels_ == 1 ? 32000 : 64000)); |
633 | 635 |
634 // Check number of channels for decoder. | 636 // Check number of channels for decoder. |
635 EXPECT_EQ(channels_, WebRtcOpus_DecoderChannels(opus_decoder_)); | 637 EXPECT_EQ(channels_, WebRtcOpus_DecoderChannels(opus_decoder_)); |
636 | 638 |
637 // Encode & decode. | 639 // Encode & decode. |
638 int16_t audio_type; | 640 int16_t audio_type; |
639 rtc::scoped_ptr<int16_t[]> output_data_decode( | 641 std::unique_ptr<int16_t[]> output_data_decode( |
640 new int16_t[kPackets * kOpus20msFrameSamples * channels_]); | 642 new int16_t[kPackets * kOpus20msFrameSamples * channels_]); |
641 OpusRepacketizer* rp = opus_repacketizer_create(); | 643 OpusRepacketizer* rp = opus_repacketizer_create(); |
642 | 644 |
643 for (int idx = 0; idx < kPackets; idx++) { | 645 for (int idx = 0; idx < kPackets; idx++) { |
644 auto speech_block = speech_data_.GetNextBlock(); | 646 auto speech_block = speech_data_.GetNextBlock(); |
645 encoded_bytes_ = | 647 encoded_bytes_ = |
646 WebRtcOpus_Encode(opus_encoder_, speech_block.data(), | 648 WebRtcOpus_Encode(opus_encoder_, speech_block.data(), |
647 rtc::CheckedDivExact(speech_block.size(), channels_), | 649 rtc::CheckedDivExact(speech_block.size(), channels_), |
648 kMaxBytes, bitstream_); | 650 kMaxBytes, bitstream_); |
649 EXPECT_EQ(OPUS_OK, opus_repacketizer_cat(rp, bitstream_, encoded_bytes_)); | 651 EXPECT_EQ(OPUS_OK, opus_repacketizer_cat(rp, bitstream_, encoded_bytes_)); |
(...skipping 15 matching lines...) Loading... |
665 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 667 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
666 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 668 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
667 } | 669 } |
668 | 670 |
669 INSTANTIATE_TEST_CASE_P(VariousMode, | 671 INSTANTIATE_TEST_CASE_P(VariousMode, |
670 OpusTest, | 672 OpusTest, |
671 Combine(Values(1, 2), Values(0, 1))); | 673 Combine(Values(1, 2), Values(0, 1))); |
672 | 674 |
673 | 675 |
674 } // namespace webrtc | 676 } // namespace webrtc |
OLD | NEW |