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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 encoder_->RegisterEncodeCompleteCallback(&encoder_callback_); | 258 encoder_->RegisterEncodeCompleteCallback(&encoder_callback_); |
259 decoder_->RegisterDecodeCompleteCallback(&decoder_callback_); | 259 decoder_->RegisterDecodeCompleteCallback(&decoder_callback_); |
260 DefaultSettings(&settings_, temporal_layer_profile); | 260 DefaultSettings(&settings_, temporal_layer_profile); |
261 SetUpRateAllocator(); | 261 SetUpRateAllocator(); |
262 EXPECT_EQ(0, encoder_->InitEncode(&settings_, 1, 1200)); | 262 EXPECT_EQ(0, encoder_->InitEncode(&settings_, 1, 1200)); |
263 EXPECT_EQ(0, decoder_->InitDecode(&settings_, 1)); | 263 EXPECT_EQ(0, decoder_->InitDecode(&settings_, 1)); |
264 int half_width = (kDefaultWidth + 1) / 2; | 264 int half_width = (kDefaultWidth + 1) / 2; |
265 input_buffer_ = I420Buffer::Create(kDefaultWidth, kDefaultHeight, | 265 input_buffer_ = I420Buffer::Create(kDefaultWidth, kDefaultHeight, |
266 kDefaultWidth, half_width, half_width); | 266 kDefaultWidth, half_width, half_width); |
267 input_buffer_->InitializeData(); | 267 input_buffer_->InitializeData(); |
268 input_frame_.reset( | 268 input_frame_.reset(new VideoFrame(input_buffer_, 0, 0, |
269 new VideoFrame(input_buffer_, 0, 0, webrtc::kVideoRotation_0)); | 269 webrtc::kVideoRotation_0, |
| 270 webrtc::kVideoContent_Default)); |
270 } | 271 } |
271 | 272 |
272 void SetUpRateAllocator() { | 273 void SetUpRateAllocator() { |
273 TemporalLayersFactory* tl_factory = new TemporalLayersFactory(); | 274 TemporalLayersFactory* tl_factory = new TemporalLayersFactory(); |
274 rate_allocator_.reset(new SimulcastRateAllocator( | 275 rate_allocator_.reset(new SimulcastRateAllocator( |
275 settings_, std::unique_ptr<TemporalLayersFactory>(tl_factory))); | 276 settings_, std::unique_ptr<TemporalLayersFactory>(tl_factory))); |
276 settings_.VP8()->tl_factory = tl_factory; | 277 settings_.VP8()->tl_factory = tl_factory; |
277 } | 278 } |
278 | 279 |
279 void SetRates(uint32_t bitrate_kbps, uint32_t fps) { | 280 void SetRates(uint32_t bitrate_kbps, uint32_t fps) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 settings_.simulcastStream[i].maxBitrate = 0; | 513 settings_.simulcastStream[i].maxBitrate = 0; |
513 settings_.simulcastStream[i].width = settings_.width; | 514 settings_.simulcastStream[i].width = settings_.width; |
514 settings_.simulcastStream[i].height = settings_.height; | 515 settings_.simulcastStream[i].height = settings_.height; |
515 } | 516 } |
516 // Setting input image to new resolution. | 517 // Setting input image to new resolution. |
517 int half_width = (settings_.width + 1) / 2; | 518 int half_width = (settings_.width + 1) / 2; |
518 input_buffer_ = I420Buffer::Create(settings_.width, settings_.height, | 519 input_buffer_ = I420Buffer::Create(settings_.width, settings_.height, |
519 settings_.width, half_width, half_width); | 520 settings_.width, half_width, half_width); |
520 input_buffer_->InitializeData(); | 521 input_buffer_->InitializeData(); |
521 | 522 |
522 input_frame_.reset( | 523 input_frame_.reset(new VideoFrame(input_buffer_, 0, 0, |
523 new VideoFrame(input_buffer_, 0, 0, webrtc::kVideoRotation_0)); | 524 webrtc::kVideoRotation_0, |
| 525 webrtc::kVideoContent_Default)); |
524 | 526 |
525 // The for loop above did not set the bitrate of the highest layer. | 527 // The for loop above did not set the bitrate of the highest layer. |
526 settings_.simulcastStream[settings_.numberOfSimulcastStreams - 1] | 528 settings_.simulcastStream[settings_.numberOfSimulcastStreams - 1] |
527 .maxBitrate = 0; | 529 .maxBitrate = 0; |
528 // The highest layer has to correspond to the non-simulcast resolution. | 530 // The highest layer has to correspond to the non-simulcast resolution. |
529 settings_.simulcastStream[settings_.numberOfSimulcastStreams - 1].width = | 531 settings_.simulcastStream[settings_.numberOfSimulcastStreams - 1].width = |
530 settings_.width; | 532 settings_.width; |
531 settings_.simulcastStream[settings_.numberOfSimulcastStreams - 1].height = | 533 settings_.simulcastStream[settings_.numberOfSimulcastStreams - 1].height = |
532 settings_.height; | 534 settings_.height; |
533 SetUpRateAllocator(); | 535 SetUpRateAllocator(); |
(...skipping 20 matching lines...) Expand all Loading... |
554 settings_.startBitrate = kMinBitrates[0]; | 556 settings_.startBitrate = kMinBitrates[0]; |
555 SetUpRateAllocator(); | 557 SetUpRateAllocator(); |
556 EXPECT_EQ(0, encoder_->InitEncode(&settings_, 1, 1200)); | 558 EXPECT_EQ(0, encoder_->InitEncode(&settings_, 1, 1200)); |
557 SetRates(settings_.startBitrate, 30); | 559 SetRates(settings_.startBitrate, 30); |
558 ExpectStreams(kVideoFrameKey, 1); | 560 ExpectStreams(kVideoFrameKey, 1); |
559 // Resize |input_frame_| to the new resolution. | 561 // Resize |input_frame_| to the new resolution. |
560 half_width = (settings_.width + 1) / 2; | 562 half_width = (settings_.width + 1) / 2; |
561 input_buffer_ = I420Buffer::Create(settings_.width, settings_.height, | 563 input_buffer_ = I420Buffer::Create(settings_.width, settings_.height, |
562 settings_.width, half_width, half_width); | 564 settings_.width, half_width, half_width); |
563 input_buffer_->InitializeData(); | 565 input_buffer_->InitializeData(); |
564 input_frame_.reset( | 566 input_frame_.reset(new VideoFrame(input_buffer_, 0, 0, |
565 new VideoFrame(input_buffer_, 0, 0, webrtc::kVideoRotation_0)); | 567 webrtc::kVideoRotation_0, |
| 568 webrtc::kVideoContent_Default)); |
566 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, &frame_types)); | 569 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, &frame_types)); |
567 } | 570 } |
568 | 571 |
569 void TestSwitchingToOneStream() { SwitchingToOneStream(1024, 768); } | 572 void TestSwitchingToOneStream() { SwitchingToOneStream(1024, 768); } |
570 | 573 |
571 void TestSwitchingToOneOddStream() { SwitchingToOneStream(1023, 769); } | 574 void TestSwitchingToOneOddStream() { SwitchingToOneStream(1023, 769); } |
572 | 575 |
573 void TestSwitchingToOneSmallStream() { SwitchingToOneStream(4, 4); } | 576 void TestSwitchingToOneSmallStream() { SwitchingToOneStream(4, 4); } |
574 | 577 |
575 void TestRPSIEncoder() { | 578 void TestRPSIEncoder() { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 encoder_->RegisterEncodeCompleteCallback(&encoder_callback); | 850 encoder_->RegisterEncodeCompleteCallback(&encoder_callback); |
848 decoder_->RegisterDecodeCompleteCallback(&decoder_callback); | 851 decoder_->RegisterDecodeCompleteCallback(&decoder_callback); |
849 | 852 |
850 SetRates(kMaxBitrates[2], 30); // To get all three streams. | 853 SetRates(kMaxBitrates[2], 30); // To get all three streams. |
851 // Setting two (possibly) problematic use cases for stride: | 854 // Setting two (possibly) problematic use cases for stride: |
852 // 1. stride > width 2. stride_y != stride_uv/2 | 855 // 1. stride > width 2. stride_y != stride_uv/2 |
853 int stride_y = kDefaultWidth + 20; | 856 int stride_y = kDefaultWidth + 20; |
854 int stride_uv = ((kDefaultWidth + 1) / 2) + 5; | 857 int stride_uv = ((kDefaultWidth + 1) / 2) + 5; |
855 input_buffer_ = I420Buffer::Create(kDefaultWidth, kDefaultHeight, stride_y, | 858 input_buffer_ = I420Buffer::Create(kDefaultWidth, kDefaultHeight, stride_y, |
856 stride_uv, stride_uv); | 859 stride_uv, stride_uv); |
857 input_frame_.reset( | 860 input_frame_.reset(new VideoFrame(input_buffer_, 0, 0, |
858 new VideoFrame(input_buffer_, 0, 0, webrtc::kVideoRotation_0)); | 861 webrtc::kVideoRotation_0, |
| 862 webrtc::kVideoContent_Default)); |
859 | 863 |
860 // Set color. | 864 // Set color. |
861 int plane_offset[kNumOfPlanes]; | 865 int plane_offset[kNumOfPlanes]; |
862 plane_offset[kYPlane] = kColorY; | 866 plane_offset[kYPlane] = kColorY; |
863 plane_offset[kUPlane] = kColorU; | 867 plane_offset[kUPlane] = kColorU; |
864 plane_offset[kVPlane] = kColorV; | 868 plane_offset[kVPlane] = kColorV; |
865 CreateImage(input_buffer_, plane_offset); | 869 CreateImage(input_buffer_, plane_offset); |
866 | 870 |
867 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, NULL)); | 871 EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL, NULL)); |
868 | 872 |
(...skipping 21 matching lines...) Expand all Loading... |
890 VideoCodec settings_; | 894 VideoCodec settings_; |
891 rtc::scoped_refptr<I420Buffer> input_buffer_; | 895 rtc::scoped_refptr<I420Buffer> input_buffer_; |
892 std::unique_ptr<VideoFrame> input_frame_; | 896 std::unique_ptr<VideoFrame> input_frame_; |
893 std::unique_ptr<SimulcastRateAllocator> rate_allocator_; | 897 std::unique_ptr<SimulcastRateAllocator> rate_allocator_; |
894 }; | 898 }; |
895 | 899 |
896 } // namespace testing | 900 } // namespace testing |
897 } // namespace webrtc | 901 } // namespace webrtc |
898 | 902 |
899 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_ | 903 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_ |
OLD | NEW |