OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 ConfigureStream(kDefaultWidth / 2, kDefaultHeight / 2, kMaxBitrates[1], | 217 ConfigureStream(kDefaultWidth / 2, kDefaultHeight / 2, kMaxBitrates[1], |
218 kMinBitrates[1], kTargetBitrates[1], | 218 kMinBitrates[1], kTargetBitrates[1], |
219 &settings->simulcastStream[1], temporal_layer_profile[1]); | 219 &settings->simulcastStream[1], temporal_layer_profile[1]); |
220 ConfigureStream(kDefaultWidth, kDefaultHeight, kMaxBitrates[2], | 220 ConfigureStream(kDefaultWidth, kDefaultHeight, kMaxBitrates[2], |
221 kMinBitrates[2], kTargetBitrates[2], | 221 kMinBitrates[2], kTargetBitrates[2], |
222 &settings->simulcastStream[2], temporal_layer_profile[2]); | 222 &settings->simulcastStream[2], temporal_layer_profile[2]); |
223 settings->VP8()->resilience = kResilientStream; | 223 settings->VP8()->resilience = kResilientStream; |
224 settings->VP8()->denoisingOn = true; | 224 settings->VP8()->denoisingOn = true; |
225 settings->VP8()->errorConcealmentOn = false; | 225 settings->VP8()->errorConcealmentOn = false; |
226 settings->VP8()->automaticResizeOn = false; | 226 settings->VP8()->automaticResizeOn = false; |
227 settings->VP8()->feedbackModeOn = false; | |
228 settings->VP8()->frameDroppingOn = true; | 227 settings->VP8()->frameDroppingOn = true; |
229 settings->VP8()->keyFrameInterval = 3000; | 228 settings->VP8()->keyFrameInterval = 3000; |
230 } | 229 } |
231 | 230 |
232 static void ConfigureStream(int width, | 231 static void ConfigureStream(int width, |
233 int height, | 232 int height, |
234 int max_bitrate, | 233 int max_bitrate, |
235 int min_bitrate, | 234 int min_bitrate, |
236 int target_bitrate, | 235 int target_bitrate, |
237 SimulcastStream* stream, | 236 SimulcastStream* stream, |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 new VideoFrame(input_buffer_, 0, 0, webrtc::kVideoRotation_0)); | 564 new VideoFrame(input_buffer_, 0, 0, webrtc::kVideoRotation_0)); |
566 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, &frame_types)); | 565 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, &frame_types)); |
567 } | 566 } |
568 | 567 |
569 void TestSwitchingToOneStream() { SwitchingToOneStream(1024, 768); } | 568 void TestSwitchingToOneStream() { SwitchingToOneStream(1024, 768); } |
570 | 569 |
571 void TestSwitchingToOneOddStream() { SwitchingToOneStream(1023, 769); } | 570 void TestSwitchingToOneOddStream() { SwitchingToOneStream(1023, 769); } |
572 | 571 |
573 void TestSwitchingToOneSmallStream() { SwitchingToOneStream(4, 4); } | 572 void TestSwitchingToOneSmallStream() { SwitchingToOneStream(4, 4); } |
574 | 573 |
575 void TestRPSIEncoder() { | |
576 Vp8TestEncodedImageCallback encoder_callback; | |
577 encoder_->RegisterEncodeCompleteCallback(&encoder_callback); | |
578 | |
579 SetRates(kMaxBitrates[2], 30); // To get all three streams. | |
580 | |
581 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, NULL)); | |
582 int picture_id = -1; | |
583 int temporal_layer = -1; | |
584 bool layer_sync = false; | |
585 encoder_callback.GetLastEncodedFrameInfo(&picture_id, &temporal_layer, | |
586 &layer_sync, 0); | |
587 EXPECT_EQ(0, temporal_layer); | |
588 EXPECT_TRUE(layer_sync); | |
589 int key_frame_picture_id = picture_id; | |
590 | |
591 input_frame_->set_timestamp(input_frame_->timestamp() + 3000); | |
592 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, NULL)); | |
593 encoder_callback.GetLastEncodedFrameInfo(&picture_id, &temporal_layer, | |
594 &layer_sync, 0); | |
595 EXPECT_EQ(2, temporal_layer); | |
596 EXPECT_TRUE(layer_sync); | |
597 | |
598 input_frame_->set_timestamp(input_frame_->timestamp() + 3000); | |
599 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, NULL)); | |
600 encoder_callback.GetLastEncodedFrameInfo(&picture_id, &temporal_layer, | |
601 &layer_sync, 0); | |
602 EXPECT_EQ(1, temporal_layer); | |
603 EXPECT_TRUE(layer_sync); | |
604 | |
605 input_frame_->set_timestamp(input_frame_->timestamp() + 3000); | |
606 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, NULL)); | |
607 encoder_callback.GetLastEncodedFrameInfo(&picture_id, &temporal_layer, | |
608 &layer_sync, 0); | |
609 EXPECT_EQ(2, temporal_layer); | |
610 EXPECT_FALSE(layer_sync); | |
611 | |
612 CodecSpecificInfo codec_specific; | |
613 codec_specific.codecType = kVideoCodecVP8; | |
614 codec_specific.codecSpecific.VP8.hasReceivedRPSI = true; | |
615 | |
616 // Must match last key frame to trigger. | |
617 codec_specific.codecSpecific.VP8.pictureIdRPSI = key_frame_picture_id; | |
618 | |
619 input_frame_->set_timestamp(input_frame_->timestamp() + 3000); | |
620 EXPECT_EQ(0, encoder_->Encode(*input_frame_, &codec_specific, NULL)); | |
621 encoder_callback.GetLastEncodedFrameInfo(&picture_id, &temporal_layer, | |
622 &layer_sync, 0); | |
623 | |
624 EXPECT_EQ(0, temporal_layer); | |
625 EXPECT_TRUE(layer_sync); | |
626 | |
627 // Must match last key frame to trigger, test bad id. | |
628 codec_specific.codecSpecific.VP8.pictureIdRPSI = key_frame_picture_id + 17; | |
629 | |
630 input_frame_->set_timestamp(input_frame_->timestamp() + 3000); | |
631 EXPECT_EQ(0, encoder_->Encode(*input_frame_, &codec_specific, NULL)); | |
632 encoder_callback.GetLastEncodedFrameInfo(&picture_id, &temporal_layer, | |
633 &layer_sync, 0); | |
634 | |
635 EXPECT_EQ(2, temporal_layer); | |
636 // The previous frame was a base layer sync (since it was a frame that | |
637 // only predicts from key frame and hence resets the temporal pattern), | |
638 // so this frame (the next one) must have |layer_sync| set to true. | |
639 EXPECT_TRUE(layer_sync); | |
640 } | |
641 | |
642 void TestRPSIEncodeDecode() { | |
643 Vp8TestEncodedImageCallback encoder_callback; | |
644 Vp8TestDecodedImageCallback decoder_callback; | |
645 encoder_->RegisterEncodeCompleteCallback(&encoder_callback); | |
646 decoder_->RegisterDecodeCompleteCallback(&decoder_callback); | |
647 | |
648 SetRates(kMaxBitrates[2], 30); // To get all three streams. | |
649 | |
650 // Set color. | |
651 int plane_offset[kNumOfPlanes]; | |
652 plane_offset[kYPlane] = kColorY; | |
653 plane_offset[kUPlane] = kColorU; | |
654 plane_offset[kVPlane] = kColorV; | |
655 CreateImage(input_buffer_, plane_offset); | |
656 | |
657 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, NULL)); | |
658 int picture_id = -1; | |
659 int temporal_layer = -1; | |
660 bool layer_sync = false; | |
661 encoder_callback.GetLastEncodedFrameInfo(&picture_id, &temporal_layer, | |
662 &layer_sync, 0); | |
663 EXPECT_EQ(0, temporal_layer); | |
664 EXPECT_TRUE(layer_sync); | |
665 int key_frame_picture_id = picture_id; | |
666 | |
667 // Change color. | |
668 plane_offset[kYPlane] += 1; | |
669 plane_offset[kUPlane] += 1; | |
670 plane_offset[kVPlane] += 1; | |
671 CreateImage(input_buffer_, plane_offset); | |
672 input_frame_->set_timestamp(input_frame_->timestamp() + 3000); | |
673 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, NULL)); | |
674 | |
675 // Change color. | |
676 plane_offset[kYPlane] += 1; | |
677 plane_offset[kUPlane] += 1; | |
678 plane_offset[kVPlane] += 1; | |
679 CreateImage(input_buffer_, plane_offset); | |
680 | |
681 input_frame_->set_timestamp(input_frame_->timestamp() + 3000); | |
682 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, NULL)); | |
683 | |
684 // Change color. | |
685 plane_offset[kYPlane] += 1; | |
686 plane_offset[kUPlane] += 1; | |
687 plane_offset[kVPlane] += 1; | |
688 CreateImage(input_buffer_, plane_offset); | |
689 | |
690 input_frame_->set_timestamp(input_frame_->timestamp() + 3000); | |
691 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, NULL)); | |
692 | |
693 CodecSpecificInfo codec_specific; | |
694 codec_specific.codecType = kVideoCodecVP8; | |
695 codec_specific.codecSpecific.VP8.hasReceivedRPSI = true; | |
696 // Must match last key frame to trigger. | |
697 codec_specific.codecSpecific.VP8.pictureIdRPSI = key_frame_picture_id; | |
698 | |
699 // Change color back to original. | |
700 plane_offset[kYPlane] = kColorY; | |
701 plane_offset[kUPlane] = kColorU; | |
702 plane_offset[kVPlane] = kColorV; | |
703 CreateImage(input_buffer_, plane_offset); | |
704 | |
705 input_frame_->set_timestamp(input_frame_->timestamp() + 3000); | |
706 EXPECT_EQ(0, encoder_->Encode(*input_frame_, &codec_specific, NULL)); | |
707 | |
708 EncodedImage encoded_frame; | |
709 encoder_callback.GetLastEncodedKeyFrame(&encoded_frame); | |
710 decoder_->Decode(encoded_frame, false, NULL); | |
711 encoder_callback.GetLastEncodedFrame(&encoded_frame); | |
712 decoder_->Decode(encoded_frame, false, NULL); | |
713 EXPECT_EQ(2, decoder_callback.DecodedFrames()); | |
714 } | |
715 | |
716 // Test the layer pattern and sync flag for various spatial-temporal patterns. | 574 // Test the layer pattern and sync flag for various spatial-temporal patterns. |
717 // 3-3-3 pattern: 3 temporal layers for all spatial streams, so same | 575 // 3-3-3 pattern: 3 temporal layers for all spatial streams, so same |
718 // temporal_layer id and layer_sync is expected for all streams. | 576 // temporal_layer id and layer_sync is expected for all streams. |
719 void TestSaptioTemporalLayers333PatternEncoder() { | 577 void TestSaptioTemporalLayers333PatternEncoder() { |
720 Vp8TestEncodedImageCallback encoder_callback; | 578 Vp8TestEncodedImageCallback encoder_callback; |
721 encoder_->RegisterEncodeCompleteCallback(&encoder_callback); | 579 encoder_->RegisterEncodeCompleteCallback(&encoder_callback); |
722 SetRates(kMaxBitrates[2], 30); // To get all three streams. | 580 SetRates(kMaxBitrates[2], 30); // To get all three streams. |
723 | 581 |
724 int expected_temporal_idx[3] = {-1, -1, -1}; | 582 int expected_temporal_idx[3] = {-1, -1, -1}; |
725 bool expected_layer_sync[3] = {false, false, false}; | 583 bool expected_layer_sync[3] = {false, false, false}; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 VideoCodec settings_; | 748 VideoCodec settings_; |
891 rtc::scoped_refptr<I420Buffer> input_buffer_; | 749 rtc::scoped_refptr<I420Buffer> input_buffer_; |
892 std::unique_ptr<VideoFrame> input_frame_; | 750 std::unique_ptr<VideoFrame> input_frame_; |
893 std::unique_ptr<SimulcastRateAllocator> rate_allocator_; | 751 std::unique_ptr<SimulcastRateAllocator> rate_allocator_; |
894 }; | 752 }; |
895 | 753 |
896 } // namespace testing | 754 } // namespace testing |
897 } // namespace webrtc | 755 } // namespace webrtc |
898 | 756 |
899 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_ | 757 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_ |
OLD | NEW |