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 |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 | 478 |
479 TEST_F(AudioDecoderPcmUTest, EncodeDecode) { | 479 TEST_F(AudioDecoderPcmUTest, EncodeDecode) { |
480 int tolerance = 251; | 480 int tolerance = 251; |
481 double mse = 1734.0; | 481 double mse = 1734.0; |
482 EXPECT_TRUE(CodecSupported(kDecoderPCMu)); | 482 EXPECT_TRUE(CodecSupported(kDecoderPCMu)); |
483 EncodeDecodeTest(data_length_, tolerance, mse); | 483 EncodeDecodeTest(data_length_, tolerance, mse); |
484 ReInitTest(); | 484 ReInitTest(); |
485 EXPECT_FALSE(decoder_->HasDecodePlc()); | 485 EXPECT_FALSE(decoder_->HasDecodePlc()); |
486 } | 486 } |
487 | 487 |
| 488 namespace { |
| 489 int SetAndGetTargetBitrate(AudioEncoder* audio_encoder, int rate) { |
| 490 audio_encoder->SetTargetBitrate(rate); |
| 491 return audio_encoder->GetTargetBitrate(); |
| 492 } |
| 493 void TestSetAndGetTargetBitratesWithFixedCodec(AudioEncoder* audio_encoder, |
| 494 int fixed_rate) { |
| 495 EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, 32000)); |
| 496 EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, fixed_rate - 1)); |
| 497 EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, fixed_rate)); |
| 498 EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, fixed_rate + 1)); |
| 499 } |
| 500 } // namespace |
| 501 |
| 502 TEST_F(AudioDecoderPcmUTest, SetTargetBitrate) { |
| 503 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 64000); |
| 504 } |
| 505 |
488 TEST_F(AudioDecoderPcmATest, EncodeDecode) { | 506 TEST_F(AudioDecoderPcmATest, EncodeDecode) { |
489 int tolerance = 308; | 507 int tolerance = 308; |
490 double mse = 1931.0; | 508 double mse = 1931.0; |
491 EXPECT_TRUE(CodecSupported(kDecoderPCMa)); | 509 EXPECT_TRUE(CodecSupported(kDecoderPCMa)); |
492 EncodeDecodeTest(data_length_, tolerance, mse); | 510 EncodeDecodeTest(data_length_, tolerance, mse); |
493 ReInitTest(); | 511 ReInitTest(); |
494 EXPECT_FALSE(decoder_->HasDecodePlc()); | 512 EXPECT_FALSE(decoder_->HasDecodePlc()); |
495 } | 513 } |
496 | 514 |
| 515 TEST_F(AudioDecoderPcmATest, SetTargetBitrate) { |
| 516 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 64000); |
| 517 } |
| 518 |
497 TEST_F(AudioDecoderPcm16BTest, EncodeDecode) { | 519 TEST_F(AudioDecoderPcm16BTest, EncodeDecode) { |
498 int tolerance = 0; | 520 int tolerance = 0; |
499 double mse = 0.0; | 521 double mse = 0.0; |
500 EXPECT_TRUE(CodecSupported(kDecoderPCM16B)); | 522 EXPECT_TRUE(CodecSupported(kDecoderPCM16B)); |
501 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bwb)); | 523 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bwb)); |
502 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb32kHz)); | 524 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb32kHz)); |
503 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb48kHz)); | 525 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb48kHz)); |
504 EncodeDecodeTest(2 * data_length_, tolerance, mse); | 526 EncodeDecodeTest(2 * data_length_, tolerance, mse); |
505 ReInitTest(); | 527 ReInitTest(); |
506 EXPECT_FALSE(decoder_->HasDecodePlc()); | 528 EXPECT_FALSE(decoder_->HasDecodePlc()); |
507 } | 529 } |
508 | 530 |
| 531 TEST_F(AudioDecoderPcm16BTest, SetTargetBitrate) { |
| 532 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), |
| 533 codec_input_rate_hz_ * 16); |
| 534 } |
| 535 |
509 TEST_F(AudioDecoderIlbcTest, EncodeDecode) { | 536 TEST_F(AudioDecoderIlbcTest, EncodeDecode) { |
510 int tolerance = 6808; | 537 int tolerance = 6808; |
511 double mse = 2.13e6; | 538 double mse = 2.13e6; |
512 int delay = 80; // Delay from input to output. | 539 int delay = 80; // Delay from input to output. |
513 EXPECT_TRUE(CodecSupported(kDecoderILBC)); | 540 EXPECT_TRUE(CodecSupported(kDecoderILBC)); |
514 EncodeDecodeTest(500, tolerance, mse, delay); | 541 EncodeDecodeTest(500, tolerance, mse, delay); |
515 ReInitTest(); | 542 ReInitTest(); |
516 EXPECT_TRUE(decoder_->HasDecodePlc()); | 543 EXPECT_TRUE(decoder_->HasDecodePlc()); |
517 DecodePlcTest(); | 544 DecodePlcTest(); |
518 } | 545 } |
519 | 546 |
| 547 TEST_F(AudioDecoderIlbcTest, SetTargetBitrate) { |
| 548 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 13333); |
| 549 } |
| 550 |
520 TEST_F(AudioDecoderIsacFloatTest, EncodeDecode) { | 551 TEST_F(AudioDecoderIsacFloatTest, EncodeDecode) { |
521 int tolerance = 3399; | 552 int tolerance = 3399; |
522 double mse = 434951.0; | 553 double mse = 434951.0; |
523 int delay = 48; // Delay from input to output. | 554 int delay = 48; // Delay from input to output. |
524 EXPECT_TRUE(CodecSupported(kDecoderISAC)); | 555 EXPECT_TRUE(CodecSupported(kDecoderISAC)); |
525 EncodeDecodeTest(0, tolerance, mse, delay); | 556 EncodeDecodeTest(0, tolerance, mse, delay); |
526 ReInitTest(); | 557 ReInitTest(); |
527 EXPECT_FALSE(decoder_->HasDecodePlc()); | 558 EXPECT_FALSE(decoder_->HasDecodePlc()); |
528 } | 559 } |
529 | 560 |
| 561 TEST_F(AudioDecoderIsacFloatTest, SetTargetBitrate) { |
| 562 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 32000); |
| 563 } |
| 564 |
530 TEST_F(AudioDecoderIsacSwbTest, EncodeDecode) { | 565 TEST_F(AudioDecoderIsacSwbTest, EncodeDecode) { |
531 int tolerance = 19757; | 566 int tolerance = 19757; |
532 double mse = 8.18e6; | 567 double mse = 8.18e6; |
533 int delay = 160; // Delay from input to output. | 568 int delay = 160; // Delay from input to output. |
534 EXPECT_TRUE(CodecSupported(kDecoderISACswb)); | 569 EXPECT_TRUE(CodecSupported(kDecoderISACswb)); |
535 EncodeDecodeTest(0, tolerance, mse, delay); | 570 EncodeDecodeTest(0, tolerance, mse, delay); |
536 ReInitTest(); | 571 ReInitTest(); |
537 EXPECT_FALSE(decoder_->HasDecodePlc()); | 572 EXPECT_FALSE(decoder_->HasDecodePlc()); |
538 } | 573 } |
539 | 574 |
| 575 TEST_F(AudioDecoderIsacSwbTest, SetTargetBitrate) { |
| 576 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 32000); |
| 577 } |
| 578 |
540 // Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4198 | 579 // Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4198 |
541 #if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64) | 580 #if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64) |
542 #define MAYBE_EncodeDecode DISABLED_EncodeDecode | 581 #define MAYBE_EncodeDecode DISABLED_EncodeDecode |
543 #else | 582 #else |
544 #define MAYBE_EncodeDecode EncodeDecode | 583 #define MAYBE_EncodeDecode EncodeDecode |
545 #endif | 584 #endif |
546 TEST_F(AudioDecoderIsacFixTest, MAYBE_EncodeDecode) { | 585 TEST_F(AudioDecoderIsacFixTest, MAYBE_EncodeDecode) { |
547 int tolerance = 11034; | 586 int tolerance = 11034; |
548 double mse = 3.46e6; | 587 double mse = 3.46e6; |
549 int delay = 54; // Delay from input to output. | 588 int delay = 54; // Delay from input to output. |
550 EXPECT_TRUE(CodecSupported(kDecoderISAC)); | 589 EXPECT_TRUE(CodecSupported(kDecoderISAC)); |
551 #ifdef WEBRTC_ANDROID | 590 #ifdef WEBRTC_ANDROID |
552 static const int kEncodedBytes = 685; | 591 static const int kEncodedBytes = 685; |
553 #else | 592 #else |
554 static const int kEncodedBytes = 671; | 593 static const int kEncodedBytes = 671; |
555 #endif | 594 #endif |
556 EncodeDecodeTest(kEncodedBytes, tolerance, mse, delay); | 595 EncodeDecodeTest(kEncodedBytes, tolerance, mse, delay); |
557 ReInitTest(); | 596 ReInitTest(); |
558 EXPECT_FALSE(decoder_->HasDecodePlc()); | 597 EXPECT_FALSE(decoder_->HasDecodePlc()); |
559 } | 598 } |
560 | 599 |
| 600 TEST_F(AudioDecoderIsacFixTest, SetTargetBitrate) { |
| 601 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 32000); |
| 602 } |
| 603 |
561 TEST_F(AudioDecoderG722Test, EncodeDecode) { | 604 TEST_F(AudioDecoderG722Test, EncodeDecode) { |
562 int tolerance = 6176; | 605 int tolerance = 6176; |
563 double mse = 238630.0; | 606 double mse = 238630.0; |
564 int delay = 22; // Delay from input to output. | 607 int delay = 22; // Delay from input to output. |
565 EXPECT_TRUE(CodecSupported(kDecoderG722)); | 608 EXPECT_TRUE(CodecSupported(kDecoderG722)); |
566 EncodeDecodeTest(data_length_ / 2, tolerance, mse, delay); | 609 EncodeDecodeTest(data_length_ / 2, tolerance, mse, delay); |
567 ReInitTest(); | 610 ReInitTest(); |
568 EXPECT_FALSE(decoder_->HasDecodePlc()); | 611 EXPECT_FALSE(decoder_->HasDecodePlc()); |
569 } | 612 } |
570 | 613 |
| 614 TEST_F(AudioDecoderG722Test, SetTargetBitrate) { |
| 615 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 64000); |
| 616 } |
| 617 |
571 TEST_F(AudioDecoderG722StereoTest, CreateAndDestroy) { | 618 TEST_F(AudioDecoderG722StereoTest, CreateAndDestroy) { |
572 EXPECT_TRUE(CodecSupported(kDecoderG722_2ch)); | 619 EXPECT_TRUE(CodecSupported(kDecoderG722_2ch)); |
573 } | 620 } |
574 | 621 |
575 TEST_F(AudioDecoderG722StereoTest, EncodeDecode) { | 622 TEST_F(AudioDecoderG722StereoTest, EncodeDecode) { |
576 int tolerance = 6176; | 623 int tolerance = 6176; |
577 int channel_diff_tolerance = 0; | 624 int channel_diff_tolerance = 0; |
578 double mse = 238630.0; | 625 double mse = 238630.0; |
579 int delay = 22; // Delay from input to output. | 626 int delay = 22; // Delay from input to output. |
580 EXPECT_TRUE(CodecSupported(kDecoderG722_2ch)); | 627 EXPECT_TRUE(CodecSupported(kDecoderG722_2ch)); |
581 EncodeDecodeTest(data_length_, tolerance, mse, delay, channel_diff_tolerance); | 628 EncodeDecodeTest(data_length_, tolerance, mse, delay, channel_diff_tolerance); |
582 ReInitTest(); | 629 ReInitTest(); |
583 EXPECT_FALSE(decoder_->HasDecodePlc()); | 630 EXPECT_FALSE(decoder_->HasDecodePlc()); |
584 } | 631 } |
585 | 632 |
| 633 TEST_F(AudioDecoderG722StereoTest, SetTargetBitrate) { |
| 634 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 128000); |
| 635 } |
| 636 |
586 TEST_F(AudioDecoderOpusTest, EncodeDecode) { | 637 TEST_F(AudioDecoderOpusTest, EncodeDecode) { |
587 int tolerance = 6176; | 638 int tolerance = 6176; |
588 double mse = 238630.0; | 639 double mse = 238630.0; |
589 int delay = 22; // Delay from input to output. | 640 int delay = 22; // Delay from input to output. |
590 EXPECT_TRUE(CodecSupported(kDecoderOpus)); | 641 EXPECT_TRUE(CodecSupported(kDecoderOpus)); |
591 EncodeDecodeTest(0, tolerance, mse, delay); | 642 EncodeDecodeTest(0, tolerance, mse, delay); |
592 ReInitTest(); | 643 ReInitTest(); |
593 EXPECT_FALSE(decoder_->HasDecodePlc()); | 644 EXPECT_FALSE(decoder_->HasDecodePlc()); |
594 } | 645 } |
595 | 646 |
| 647 namespace { |
| 648 void TestOpusSetTargetBitrates(AudioEncoder* audio_encoder) { |
| 649 EXPECT_EQ(500, SetAndGetTargetBitrate(audio_encoder, 499)); |
| 650 EXPECT_EQ(500, SetAndGetTargetBitrate(audio_encoder, 500)); |
| 651 EXPECT_EQ(32000, SetAndGetTargetBitrate(audio_encoder, 32000)); |
| 652 EXPECT_EQ(512000, SetAndGetTargetBitrate(audio_encoder, 512000)); |
| 653 EXPECT_EQ(512000, SetAndGetTargetBitrate(audio_encoder, 513000)); |
| 654 } |
| 655 } // namespace |
| 656 |
| 657 TEST_F(AudioDecoderOpusTest, SetTargetBitrate) { |
| 658 TestOpusSetTargetBitrates(audio_encoder_.get()); |
| 659 } |
| 660 |
596 TEST_F(AudioDecoderOpusStereoTest, EncodeDecode) { | 661 TEST_F(AudioDecoderOpusStereoTest, EncodeDecode) { |
597 int tolerance = 6176; | 662 int tolerance = 6176; |
598 int channel_diff_tolerance = 0; | 663 int channel_diff_tolerance = 0; |
599 double mse = 238630.0; | 664 double mse = 238630.0; |
600 int delay = 22; // Delay from input to output. | 665 int delay = 22; // Delay from input to output. |
601 EXPECT_TRUE(CodecSupported(kDecoderOpus_2ch)); | 666 EXPECT_TRUE(CodecSupported(kDecoderOpus_2ch)); |
602 EncodeDecodeTest(0, tolerance, mse, delay, channel_diff_tolerance); | 667 EncodeDecodeTest(0, tolerance, mse, delay, channel_diff_tolerance); |
603 ReInitTest(); | 668 ReInitTest(); |
604 EXPECT_FALSE(decoder_->HasDecodePlc()); | 669 EXPECT_FALSE(decoder_->HasDecodePlc()); |
605 } | 670 } |
606 | 671 |
| 672 TEST_F(AudioDecoderOpusStereoTest, SetTargetBitrate) { |
| 673 TestOpusSetTargetBitrates(audio_encoder_.get()); |
| 674 } |
| 675 |
607 TEST(AudioDecoder, CodecSampleRateHz) { | 676 TEST(AudioDecoder, CodecSampleRateHz) { |
608 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMu)); | 677 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMu)); |
609 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMa)); | 678 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMa)); |
610 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMu_2ch)); | 679 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMu_2ch)); |
611 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMa_2ch)); | 680 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMa_2ch)); |
612 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderILBC)); | 681 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderILBC)); |
613 EXPECT_EQ(16000, CodecSampleRateHz(kDecoderISAC)); | 682 EXPECT_EQ(16000, CodecSampleRateHz(kDecoderISAC)); |
614 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderISACswb)); | 683 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderISACswb)); |
615 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderISACfb)); | 684 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderISACfb)); |
616 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCM16B)); | 685 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCM16B)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 EXPECT_TRUE(CodecSupported(kDecoderCNGnb)); | 730 EXPECT_TRUE(CodecSupported(kDecoderCNGnb)); |
662 EXPECT_TRUE(CodecSupported(kDecoderCNGwb)); | 731 EXPECT_TRUE(CodecSupported(kDecoderCNGwb)); |
663 EXPECT_TRUE(CodecSupported(kDecoderCNGswb32kHz)); | 732 EXPECT_TRUE(CodecSupported(kDecoderCNGswb32kHz)); |
664 EXPECT_TRUE(CodecSupported(kDecoderCNGswb48kHz)); | 733 EXPECT_TRUE(CodecSupported(kDecoderCNGswb48kHz)); |
665 EXPECT_TRUE(CodecSupported(kDecoderArbitrary)); | 734 EXPECT_TRUE(CodecSupported(kDecoderArbitrary)); |
666 EXPECT_TRUE(CodecSupported(kDecoderOpus)); | 735 EXPECT_TRUE(CodecSupported(kDecoderOpus)); |
667 EXPECT_TRUE(CodecSupported(kDecoderOpus_2ch)); | 736 EXPECT_TRUE(CodecSupported(kDecoderOpus_2ch)); |
668 } | 737 } |
669 | 738 |
670 } // namespace webrtc | 739 } // namespace webrtc |
OLD | NEW |