Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(963)

Side by Side Diff: webrtc/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc

Issue 1193513006: In screenshare mode, suppress VP8 bitrate overshoot and increase quality (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 21 matching lines...) Expand all
32 VP8_EFLAG_NO_UPD_LAST; 32 VP8_EFLAG_NO_UPD_LAST;
33 const int kFlagsTL1Sync = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF | 33 const int kFlagsTL1Sync = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF |
34 VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST; 34 VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
35 35
36 class ScreenshareLayersFT : public ScreenshareLayers { 36 class ScreenshareLayersFT : public ScreenshareLayers {
37 public: 37 public:
38 ScreenshareLayersFT(int num_temporal_layers, 38 ScreenshareLayersFT(int num_temporal_layers,
39 uint8_t initial_tl0_pic_idx, 39 uint8_t initial_tl0_pic_idx,
40 FrameDropper* tl0_frame_dropper, 40 FrameDropper* tl0_frame_dropper,
41 FrameDropper* tl1_frame_dropper) 41 FrameDropper* tl1_frame_dropper)
42 : ScreenshareLayers(num_temporal_layers, 42 : ScreenshareLayers(num_temporal_layers, initial_tl0_pic_idx) {}
43 initial_tl0_pic_idx,
44 tl0_frame_dropper,
45 tl1_frame_dropper) {}
46 virtual ~ScreenshareLayersFT() {} 43 virtual ~ScreenshareLayersFT() {}
47 }; 44 };
48 45
49 class ScreenshareLayerTest : public ::testing::Test { 46 class ScreenshareLayerTest : public ::testing::Test {
50 protected: 47 protected:
51 void SetEncodeExpectations(bool drop_tl0, bool drop_tl1, int framerate) { 48 void SetEncodeExpectations(bool drop_tl0, bool drop_tl1, int framerate) {
52 EXPECT_CALL(tl0_frame_dropper_, DropFrame()) 49 EXPECT_CALL(tl0_frame_dropper_, DropFrame())
53 .Times(1) 50 .Times(1)
54 .WillRepeatedly(Return(drop_tl0)); 51 .WillRepeatedly(Return(drop_tl0));
55 if (drop_tl0) { 52 if (drop_tl0) {
(...skipping 22 matching lines...) Expand all
78 .Times(1); 75 .Times(1);
79 } 76 }
80 } 77 }
81 78
82 void EncodeFrame(uint32_t timestamp, 79 void EncodeFrame(uint32_t timestamp,
83 bool base_sync, 80 bool base_sync,
84 CodecSpecificInfoVP8* vp8_info, 81 CodecSpecificInfoVP8* vp8_info,
85 int* flags) { 82 int* flags) {
86 *flags = layers_->EncodeFlags(timestamp); 83 *flags = layers_->EncodeFlags(timestamp);
87 layers_->PopulateCodecSpecific(base_sync, vp8_info, timestamp); 84 layers_->PopulateCodecSpecific(base_sync, vp8_info, timestamp);
88 layers_->FrameEncoded(kFrameSize, timestamp); 85 layers_->FrameEncoded(kFrameSize, timestamp, -1);
89 } 86 }
90 87
91 NiceMock<MockFrameDropper> tl0_frame_dropper_; 88 NiceMock<MockFrameDropper> tl0_frame_dropper_;
92 NiceMock<MockFrameDropper> tl1_frame_dropper_; 89 NiceMock<MockFrameDropper> tl1_frame_dropper_;
93 rtc::scoped_ptr<ScreenshareLayersFT> layers_; 90 rtc::scoped_ptr<ScreenshareLayersFT> layers_;
94 }; 91 };
95 92
96 TEST_F(ScreenshareLayerTest, 1Layer) { 93 TEST_F(ScreenshareLayerTest, 1Layer) {
97 layers_.reset( 94 layers_.reset(
98 new ScreenshareLayersFT(1, 0, &tl0_frame_dropper_, &tl1_frame_dropper_)); 95 new ScreenshareLayersFT(1, 0, &tl0_frame_dropper_, &tl1_frame_dropper_));
99 EXPECT_TRUE(layers_->ConfigureBitrates(100, 1000, 5, NULL)); 96 EXPECT_TRUE(layers_->ConfigureBitrates(100, 1000, 5, NULL));
100 int flags = 0; 97 int flags = 0;
101 uint32_t timestamp = 0; 98 uint32_t timestamp = 0;
102 CodecSpecificInfoVP8 vp8_info; 99 CodecSpecificInfoVP8 vp8_info;
103 // One layer screenshare should not use the frame dropper as all frames will 100 // One layer screenshare should not use the frame dropper as all frames will
104 // belong to the base layer. 101 // belong to the base layer.
105 EXPECT_CALL(tl0_frame_dropper_, DropFrame()) 102 EXPECT_CALL(tl0_frame_dropper_, DropFrame())
106 .Times(0); 103 .Times(0);
107 EXPECT_CALL(tl1_frame_dropper_, DropFrame()) 104 EXPECT_CALL(tl1_frame_dropper_, DropFrame())
108 .Times(0); 105 .Times(0);
109 flags = layers_->EncodeFlags(timestamp); 106 flags = layers_->EncodeFlags(timestamp);
110 EXPECT_EQ(0, flags); 107 EXPECT_EQ(0, flags);
111 layers_->PopulateCodecSpecific(false, &vp8_info, timestamp); 108 layers_->PopulateCodecSpecific(false, &vp8_info, timestamp);
112 EXPECT_EQ(static_cast<uint8_t>(kNoTemporalIdx), vp8_info.temporalIdx); 109 EXPECT_EQ(static_cast<uint8_t>(kNoTemporalIdx), vp8_info.temporalIdx);
113 EXPECT_FALSE(vp8_info.layerSync); 110 EXPECT_FALSE(vp8_info.layerSync);
114 EXPECT_EQ(kNoTl0PicIdx, vp8_info.tl0PicIdx); 111 EXPECT_EQ(kNoTl0PicIdx, vp8_info.tl0PicIdx);
115 layers_->FrameEncoded(kFrameSize, timestamp); 112 layers_->FrameEncoded(kFrameSize, timestamp, -1);
116 113
117 EXPECT_CALL(tl0_frame_dropper_, DropFrame()) 114 EXPECT_CALL(tl0_frame_dropper_, DropFrame())
118 .Times(0); 115 .Times(0);
119 EXPECT_CALL(tl1_frame_dropper_, DropFrame()) 116 EXPECT_CALL(tl1_frame_dropper_, DropFrame())
120 .Times(0); 117 .Times(0);
121 flags = layers_->EncodeFlags(timestamp); 118 flags = layers_->EncodeFlags(timestamp);
122 EXPECT_EQ(0, flags); 119 EXPECT_EQ(0, flags);
123 timestamp += kTimestampDelta5Fps; 120 timestamp += kTimestampDelta5Fps;
124 layers_->PopulateCodecSpecific(false, &vp8_info, timestamp); 121 layers_->PopulateCodecSpecific(false, &vp8_info, timestamp);
125 EXPECT_EQ(static_cast<uint8_t>(kNoTemporalIdx), vp8_info.temporalIdx); 122 EXPECT_EQ(static_cast<uint8_t>(kNoTemporalIdx), vp8_info.temporalIdx);
126 EXPECT_FALSE(vp8_info.layerSync); 123 EXPECT_FALSE(vp8_info.layerSync);
127 EXPECT_EQ(kNoTl0PicIdx, vp8_info.tl0PicIdx); 124 EXPECT_EQ(kNoTl0PicIdx, vp8_info.tl0PicIdx);
128 layers_->FrameEncoded(kFrameSize, timestamp); 125 layers_->FrameEncoded(kFrameSize, timestamp, -1);
129 } 126 }
130 127
131 TEST_F(ScreenshareLayerTest, 2Layer) { 128 TEST_F(ScreenshareLayerTest, 2Layer) {
132 layers_.reset( 129 layers_.reset(
133 new ScreenshareLayersFT(2, 0, &tl0_frame_dropper_, &tl1_frame_dropper_)); 130 new ScreenshareLayersFT(2, 0, &tl0_frame_dropper_, &tl1_frame_dropper_));
134 EXPECT_TRUE(layers_->ConfigureBitrates(100, 1000, 5, NULL)); 131 EXPECT_TRUE(layers_->ConfigureBitrates(100, 1000, 5, NULL));
135 int flags = 0; 132 int flags = 0;
136 uint32_t timestamp = 0; 133 uint32_t timestamp = 0;
137 uint8_t expected_tl0_idx = 0; 134 uint8_t expected_tl0_idx = 0;
138 CodecSpecificInfoVP8 vp8_info; 135 CodecSpecificInfoVP8 vp8_info;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 TEST_F(ScreenshareLayerTest, TargetBitrateBelowTL0) { 278 TEST_F(ScreenshareLayerTest, TargetBitrateBelowTL0) {
282 layers_.reset( 279 layers_.reset(
283 new ScreenshareLayersFT(2, 0, &tl0_frame_dropper_, &tl1_frame_dropper_)); 280 new ScreenshareLayersFT(2, 0, &tl0_frame_dropper_, &tl1_frame_dropper_));
284 vpx_codec_enc_cfg_t cfg; 281 vpx_codec_enc_cfg_t cfg;
285 layers_->ConfigureBitrates(100, 100, 5, &cfg); 282 layers_->ConfigureBitrates(100, 100, 5, &cfg);
286 283
287 EXPECT_EQ(100U, cfg.rc_target_bitrate); 284 EXPECT_EQ(100U, cfg.rc_target_bitrate);
288 } 285 }
289 286
290 } // namespace webrtc 287 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698