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 | 10 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 break; | 352 break; |
353 case 1: | 353 case 1: |
354 ++tl1_frames; | 354 ++tl1_frames; |
355 break; | 355 break; |
356 default: | 356 default: |
357 abort(); | 357 abort(); |
358 } | 358 } |
359 } | 359 } |
360 } | 360 } |
361 | 361 |
362 EXPECT_EQ(5, tl0_frames); | 362 EXPECT_EQ(50, tl0_frames + tl1_frames); |
363 EXPECT_EQ(45, tl1_frames); | |
364 EXPECT_EQ(50, dropped_frames); | 363 EXPECT_EQ(50, dropped_frames); |
365 } | 364 } |
366 | 365 |
367 TEST_F(ScreenshareLayerTest, TargetBitrateCappedByTL0) { | 366 TEST_F(ScreenshareLayerTest, TargetBitrateCappedByTL0) { |
368 vpx_codec_enc_cfg_t cfg; | 367 vpx_codec_enc_cfg_t cfg; |
369 layers_->ConfigureBitrates(100, 1000, 5, &cfg); | 368 layers_->ConfigureBitrates(100, 1000, 5, &cfg); |
370 | 369 |
371 EXPECT_EQ(static_cast<unsigned int>( | 370 EXPECT_EQ(static_cast<unsigned int>( |
372 ScreenshareLayers::kMaxTL0FpsReduction * 100 + 0.5), | 371 ScreenshareLayers::kMaxTL0FpsReduction * 100 + 0.5), |
373 cfg.rc_target_bitrate); | 372 cfg.rc_target_bitrate); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 layers_->FrameEncoded(frame_size_, timestamp, kDefaultQp); | 433 layers_->FrameEncoded(frame_size_, timestamp, kDefaultQp); |
435 | 434 |
436 layers_->EncodeFlags(timestamp); | 435 layers_->EncodeFlags(timestamp); |
437 timestamp += kTimestampDelta5Fps; | 436 timestamp += kTimestampDelta5Fps; |
438 EXPECT_TRUE(layers_->UpdateConfiguration(&cfg)); | 437 EXPECT_TRUE(layers_->UpdateConfiguration(&cfg)); |
439 layers_->PopulateCodecSpecific(false, &vp8_info, timestamp); | 438 layers_->PopulateCodecSpecific(false, &vp8_info, timestamp); |
440 EXPECT_EQ(cfg.rc_max_quantizer, static_cast<unsigned int>(kDefaultQp)); | 439 EXPECT_EQ(cfg.rc_max_quantizer, static_cast<unsigned int>(kDefaultQp)); |
441 layers_->FrameEncoded(frame_size_, timestamp, kDefaultQp); | 440 layers_->FrameEncoded(frame_size_, timestamp, kDefaultQp); |
442 } | 441 } |
443 | 442 |
| 443 TEST_F(ScreenshareLayerTest, RespectsMaxIntervalBetweenFrames) { |
| 444 const int kLowBitrateKbps = 50; |
| 445 const int kLargeFrameSizeBytes = 100000; |
| 446 const uint32_t kStartTimestamp = 1234; |
| 447 |
| 448 vpx_codec_enc_cfg_t cfg; |
| 449 layers_->ConfigureBitrates(kLowBitrateKbps, kLowBitrateKbps, 5, &cfg); |
| 450 |
| 451 EXPECT_EQ(ScreenshareLayers::kTl0Flags, |
| 452 layers_->EncodeFlags(kStartTimestamp)); |
| 453 layers_->FrameEncoded(kLargeFrameSizeBytes, kStartTimestamp, kDefaultQp); |
| 454 |
| 455 const uint32_t kTwoSecondsLater = |
| 456 kStartTimestamp + (ScreenshareLayers::kMaxFrameIntervalMs * 90); |
| 457 |
| 458 // Sanity check, repayment time should exceed kMaxFrameIntervalMs. |
| 459 ASSERT_GT(kStartTimestamp + 90 * (kLargeFrameSizeBytes * 8) / kLowBitrateKbps, |
| 460 kStartTimestamp + (ScreenshareLayers::kMaxFrameIntervalMs * 90)); |
| 461 |
| 462 EXPECT_EQ(-1, layers_->EncodeFlags(kTwoSecondsLater)); |
| 463 // More than two seconds has passed since last frame, one should be emitted |
| 464 // even if bitrate target is then exceeded. |
| 465 EXPECT_EQ(ScreenshareLayers::kTl0Flags, |
| 466 layers_->EncodeFlags(kTwoSecondsLater + 90)); |
| 467 } |
| 468 |
444 TEST_F(ScreenshareLayerTest, UpdatesHistograms) { | 469 TEST_F(ScreenshareLayerTest, UpdatesHistograms) { |
445 ConfigureBitrates(); | 470 ConfigureBitrates(); |
446 vpx_codec_enc_cfg_t cfg; | 471 vpx_codec_enc_cfg_t cfg; |
447 cfg.rc_max_quantizer = kDefaultQp; | 472 cfg.rc_max_quantizer = kDefaultQp; |
448 bool trigger_drop = false; | 473 bool trigger_drop = false; |
449 bool dropped_frame = false; | 474 bool dropped_frame = false; |
450 bool overshoot = false; | 475 bool overshoot = false; |
451 const int kTl0Qp = 35; | 476 const int kTl0Qp = 35; |
452 const int kTl1Qp = 30; | 477 const int kTl1Qp = 30; |
453 for (int64_t timestamp = 0; | 478 for (int64_t timestamp = 0; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 test::LastHistogramSample("WebRTC.Video.Screenshare.Layer1.Qp")); | 545 test::LastHistogramSample("WebRTC.Video.Screenshare.Layer1.Qp")); |
521 EXPECT_EQ(kDefaultTl0BitrateKbps, | 546 EXPECT_EQ(kDefaultTl0BitrateKbps, |
522 test::LastHistogramSample( | 547 test::LastHistogramSample( |
523 "WebRTC.Video.Screenshare.Layer0.TargetBitrate")); | 548 "WebRTC.Video.Screenshare.Layer0.TargetBitrate")); |
524 EXPECT_EQ(kDefaultTl1BitrateKbps, | 549 EXPECT_EQ(kDefaultTl1BitrateKbps, |
525 test::LastHistogramSample( | 550 test::LastHistogramSample( |
526 "WebRTC.Video.Screenshare.Layer1.TargetBitrate")); | 551 "WebRTC.Video.Screenshare.Layer1.TargetBitrate")); |
527 } | 552 } |
528 | 553 |
529 } // namespace webrtc | 554 } // namespace webrtc |
OLD | NEW |