OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
11 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" | 11 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 #include <stdlib.h> | 14 #include <stdlib.h> |
15 | 15 |
16 #include <memory> | 16 #include <memory> |
17 #include <string> | 17 #include <string> |
18 #include <vector> | 18 #include <vector> |
19 | 19 |
| 20 #include "webrtc/api/audio_codecs/opus/audio_encoder_opus.h" |
20 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" | 21 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" |
21 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h" | 22 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h" |
22 #include "webrtc/modules/audio_coding/codecs/g722/audio_decoder_g722.h" | 23 #include "webrtc/modules/audio_coding/codecs/g722/audio_decoder_g722.h" |
23 #include "webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.h" | 24 #include "webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.h" |
24 #include "webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h" | 25 #include "webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h" |
25 #include "webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" | 26 #include "webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" |
26 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_decoder_isac
fix.h" | 27 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_decoder_isac
fix.h" |
27 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_encoder_isac
fix.h" | 28 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_encoder_isac
fix.h" |
28 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_decoder_isa
c.h" | 29 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_decoder_isa
c.h" |
29 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa
c.h" | 30 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa
c.h" |
30 #include "webrtc/modules/audio_coding/codecs/opus/audio_decoder_opus.h" | 31 #include "webrtc/modules/audio_coding/codecs/opus/audio_decoder_opus.h" |
31 #include "webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h" | |
32 #include "webrtc/modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h" | 32 #include "webrtc/modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h" |
33 #include "webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h" | 33 #include "webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h" |
34 #include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h" | 34 #include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h" |
35 #include "webrtc/test/gtest.h" | 35 #include "webrtc/test/gtest.h" |
36 #include "webrtc/test/testsupport/fileutils.h" | 36 #include "webrtc/test/testsupport/fileutils.h" |
37 | 37 |
38 namespace webrtc { | 38 namespace webrtc { |
39 | 39 |
40 namespace { | 40 namespace { |
41 // The absolute difference between the input and output (the first channel) is | 41 // The absolute difference between the input and output (the first channel) is |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 } | 427 } |
428 }; | 428 }; |
429 | 429 |
430 class AudioDecoderOpusTest : public AudioDecoderTest { | 430 class AudioDecoderOpusTest : public AudioDecoderTest { |
431 protected: | 431 protected: |
432 AudioDecoderOpusTest() : AudioDecoderTest() { | 432 AudioDecoderOpusTest() : AudioDecoderTest() { |
433 codec_input_rate_hz_ = 48000; | 433 codec_input_rate_hz_ = 48000; |
434 frame_size_ = 480; | 434 frame_size_ = 480; |
435 data_length_ = 10 * frame_size_; | 435 data_length_ = 10 * frame_size_; |
436 decoder_ = new AudioDecoderOpus(1); | 436 decoder_ = new AudioDecoderOpus(1); |
437 AudioEncoderOpus::Config config; | 437 AudioEncoderOpusConfig config; |
438 config.frame_size_ms = static_cast<int>(frame_size_) / 48; | 438 config.frame_size_ms = static_cast<int>(frame_size_) / 48; |
439 config.payload_type = payload_type_; | 439 config.application = AudioEncoderOpusConfig::ApplicationMode::kVoip; |
440 config.application = AudioEncoderOpus::kVoip; | 440 audio_encoder_ = AudioEncoderOpus::MakeAudioEncoder(config, payload_type_); |
441 audio_encoder_.reset(new AudioEncoderOpus(config)); | |
442 } | 441 } |
443 }; | 442 }; |
444 | 443 |
445 class AudioDecoderOpusStereoTest : public AudioDecoderOpusTest { | 444 class AudioDecoderOpusStereoTest : public AudioDecoderOpusTest { |
446 protected: | 445 protected: |
447 AudioDecoderOpusStereoTest() : AudioDecoderOpusTest() { | 446 AudioDecoderOpusStereoTest() : AudioDecoderOpusTest() { |
448 channels_ = 2; | 447 channels_ = 2; |
449 delete decoder_; | 448 delete decoder_; |
450 decoder_ = new AudioDecoderOpus(2); | 449 decoder_ = new AudioDecoderOpus(2); |
451 AudioEncoderOpus::Config config; | 450 AudioEncoderOpusConfig config; |
452 config.frame_size_ms = static_cast<int>(frame_size_) / 48; | 451 config.frame_size_ms = static_cast<int>(frame_size_) / 48; |
453 config.num_channels = 2; | 452 config.num_channels = 2; |
454 config.payload_type = payload_type_; | 453 config.application = AudioEncoderOpusConfig::ApplicationMode::kAudio; |
455 config.application = AudioEncoderOpus::kAudio; | 454 audio_encoder_ = AudioEncoderOpus::MakeAudioEncoder(config, payload_type_); |
456 audio_encoder_.reset(new AudioEncoderOpus(config)); | |
457 } | 455 } |
458 }; | 456 }; |
459 | 457 |
460 TEST_F(AudioDecoderPcmUTest, EncodeDecode) { | 458 TEST_F(AudioDecoderPcmUTest, EncodeDecode) { |
461 int tolerance = 251; | 459 int tolerance = 251; |
462 double mse = 1734.0; | 460 double mse = 1734.0; |
463 EncodeDecodeTest(data_length_, tolerance, mse); | 461 EncodeDecodeTest(data_length_, tolerance, mse); |
464 ReInitTest(); | 462 ReInitTest(); |
465 EXPECT_FALSE(decoder_->HasDecodePlc()); | 463 EXPECT_FALSE(decoder_->HasDecodePlc()); |
466 } | 464 } |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGnb)); | 685 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGnb)); |
688 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGwb)); | 686 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGwb)); |
689 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGswb32kHz)); | 687 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGswb32kHz)); |
690 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGswb48kHz)); | 688 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGswb48kHz)); |
691 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderArbitrary)); | 689 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderArbitrary)); |
692 EXPECT_EQ(has_opus, CodecSupported(NetEqDecoder::kDecoderOpus)); | 690 EXPECT_EQ(has_opus, CodecSupported(NetEqDecoder::kDecoderOpus)); |
693 EXPECT_EQ(has_opus, CodecSupported(NetEqDecoder::kDecoderOpus_2ch)); | 691 EXPECT_EQ(has_opus, CodecSupported(NetEqDecoder::kDecoderOpus_2ch)); |
694 } | 692 } |
695 | 693 |
696 } // namespace webrtc | 694 } // namespace webrtc |
OLD | NEW |