OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 |
| 11 #include "webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h" |
11 #include "vpx/vp8cx.h" | 12 #include "vpx/vp8cx.h" |
12 #include "vpx/vpx_encoder.h" | 13 #include "vpx/vpx_encoder.h" |
13 #include "webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h" | 14 #include "webrtc/modules/video_coding/codecs/vp8/vp8_impl.h" |
14 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 15 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
15 #include "webrtc/test/gtest.h" | 16 #include "webrtc/test/gtest.h" |
16 | 17 |
17 namespace webrtc { | 18 namespace webrtc { |
18 | 19 |
19 enum { | 20 enum { |
20 kTemporalUpdateLast = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF | | 21 kTemporalUpdateLast = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF | |
21 VP8_EFLAG_NO_REF_GF | | 22 VP8_EFLAG_NO_REF_GF | |
22 VP8_EFLAG_NO_REF_ARF, | 23 VP8_EFLAG_NO_REF_ARF, |
23 kTemporalUpdateGoldenWithoutDependency = | 24 kTemporalUpdateGoldenWithoutDependency = |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 }; | 77 }; |
77 int expected_temporal_idx[16] = {0, 1, 0, 1, 0, 1, 0, 1, | 78 int expected_temporal_idx[16] = {0, 1, 0, 1, 0, 1, 0, 1, |
78 0, 1, 0, 1, 0, 1, 0, 1}; | 79 0, 1, 0, 1, 0, 1, 0, 1}; |
79 | 80 |
80 bool expected_layer_sync[16] = {false, true, false, false, false, false, | 81 bool expected_layer_sync[16] = {false, true, false, false, false, false, |
81 false, false, false, true, false, false, | 82 false, false, false, true, false, false, |
82 false, false, false, false}; | 83 false, false, false, false}; |
83 | 84 |
84 uint32_t timestamp = 0; | 85 uint32_t timestamp = 0; |
85 for (int i = 0; i < 16; ++i) { | 86 for (int i = 0; i < 16; ++i) { |
86 EXPECT_EQ(expected_flags[i], tl.EncodeFlags(timestamp)); | 87 TemporalReferences tl_config = tl.UpdateLayerConfig(timestamp); |
| 88 EXPECT_EQ(expected_flags[i], VP8EncoderImpl::EncodeFlags(tl_config)); |
87 tl.PopulateCodecSpecific(false, &vp8_info, 0); | 89 tl.PopulateCodecSpecific(false, &vp8_info, 0); |
88 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); | 90 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); |
89 EXPECT_EQ(expected_layer_sync[i], vp8_info.layerSync); | 91 EXPECT_EQ(expected_layer_sync[i], vp8_info.layerSync); |
90 timestamp += 3000; | 92 timestamp += 3000; |
91 } | 93 } |
92 } | 94 } |
93 | 95 |
94 TEST(TemporalLayersTest, 3Layers) { | 96 TEST(TemporalLayersTest, 3Layers) { |
95 DefaultTemporalLayers tl(3, 0); | 97 DefaultTemporalLayers tl(3, 0); |
96 vpx_codec_enc_cfg_t cfg; | 98 vpx_codec_enc_cfg_t cfg; |
(...skipping 21 matching lines...) Expand all Loading... |
118 }; | 120 }; |
119 int expected_temporal_idx[16] = {0, 2, 1, 2, 0, 2, 1, 2, | 121 int expected_temporal_idx[16] = {0, 2, 1, 2, 0, 2, 1, 2, |
120 0, 2, 1, 2, 0, 2, 1, 2}; | 122 0, 2, 1, 2, 0, 2, 1, 2}; |
121 | 123 |
122 bool expected_layer_sync[16] = {false, true, true, false, false, false, | 124 bool expected_layer_sync[16] = {false, true, true, false, false, false, |
123 false, false, false, true, true, false, | 125 false, false, false, true, true, false, |
124 false, false, false, false}; | 126 false, false, false, false}; |
125 | 127 |
126 unsigned int timestamp = 0; | 128 unsigned int timestamp = 0; |
127 for (int i = 0; i < 16; ++i) { | 129 for (int i = 0; i < 16; ++i) { |
128 EXPECT_EQ(expected_flags[i], tl.EncodeFlags(timestamp)); | 130 TemporalReferences tl_config = tl.UpdateLayerConfig(timestamp); |
| 131 EXPECT_EQ(expected_flags[i], VP8EncoderImpl::EncodeFlags(tl_config)); |
129 tl.PopulateCodecSpecific(false, &vp8_info, 0); | 132 tl.PopulateCodecSpecific(false, &vp8_info, 0); |
130 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); | 133 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); |
131 EXPECT_EQ(expected_layer_sync[i], vp8_info.layerSync); | 134 EXPECT_EQ(expected_layer_sync[i], vp8_info.layerSync); |
132 timestamp += 3000; | 135 timestamp += 3000; |
133 } | 136 } |
134 } | 137 } |
135 | 138 |
136 TEST(TemporalLayersTest, 4Layers) { | 139 TEST(TemporalLayersTest, 4Layers) { |
137 DefaultTemporalLayers tl(4, 0); | 140 DefaultTemporalLayers tl(4, 0); |
138 vpx_codec_enc_cfg_t cfg; | 141 vpx_codec_enc_cfg_t cfg; |
(...skipping 20 matching lines...) Expand all Loading... |
159 }; | 162 }; |
160 int expected_temporal_idx[16] = {0, 3, 2, 3, 1, 3, 2, 3, | 163 int expected_temporal_idx[16] = {0, 3, 2, 3, 1, 3, 2, 3, |
161 0, 3, 2, 3, 1, 3, 2, 3}; | 164 0, 3, 2, 3, 1, 3, 2, 3}; |
162 | 165 |
163 bool expected_layer_sync[16] = {false, true, true, true, true, true, | 166 bool expected_layer_sync[16] = {false, true, true, true, true, true, |
164 false, true, false, true, false, true, | 167 false, true, false, true, false, true, |
165 false, true, false, true}; | 168 false, true, false, true}; |
166 | 169 |
167 uint32_t timestamp = 0; | 170 uint32_t timestamp = 0; |
168 for (int i = 0; i < 16; ++i) { | 171 for (int i = 0; i < 16; ++i) { |
169 EXPECT_EQ(expected_flags[i], tl.EncodeFlags(timestamp)); | 172 TemporalReferences tl_config = tl.UpdateLayerConfig(timestamp); |
| 173 EXPECT_EQ(expected_flags[i], VP8EncoderImpl::EncodeFlags(tl_config)); |
170 tl.PopulateCodecSpecific(false, &vp8_info, 0); | 174 tl.PopulateCodecSpecific(false, &vp8_info, 0); |
171 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); | 175 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); |
172 EXPECT_EQ(expected_layer_sync[i], vp8_info.layerSync); | 176 EXPECT_EQ(expected_layer_sync[i], vp8_info.layerSync); |
173 timestamp += 3000; | 177 timestamp += 3000; |
174 } | 178 } |
175 } | 179 } |
176 | 180 |
177 TEST(TemporalLayersTest, KeyFrame) { | 181 TEST(TemporalLayersTest, KeyFrame) { |
178 DefaultTemporalLayers tl(3, 0); | 182 DefaultTemporalLayers tl(3, 0); |
179 vpx_codec_enc_cfg_t cfg; | 183 vpx_codec_enc_cfg_t cfg; |
180 CodecSpecificInfoVP8 vp8_info; | 184 CodecSpecificInfoVP8 vp8_info; |
181 tl.OnRatesUpdated(500, 500, 30); | 185 tl.OnRatesUpdated(500, 500, 30); |
182 tl.UpdateConfiguration(&cfg); | 186 tl.UpdateConfiguration(&cfg); |
183 | 187 |
184 int expected_flags[8] = { | 188 int expected_flags[8] = { |
185 kTemporalUpdateLastAndGoldenRefAltRef, | 189 kTemporalUpdateLastAndGoldenRefAltRef, |
186 kTemporalUpdateNoneNoRefGolden, | 190 kTemporalUpdateNoneNoRefGolden, |
187 kTemporalUpdateGoldenWithoutDependencyRefAltRef, | 191 kTemporalUpdateGoldenWithoutDependencyRefAltRef, |
188 kTemporalUpdateNone, | 192 kTemporalUpdateNone, |
189 kTemporalUpdateLastRefAltRef, | 193 kTemporalUpdateLastRefAltRef, |
190 kTemporalUpdateNone, | 194 kTemporalUpdateNone, |
191 kTemporalUpdateGoldenRefAltRef, | 195 kTemporalUpdateGoldenRefAltRef, |
192 kTemporalUpdateNone, | 196 kTemporalUpdateNone, |
193 }; | 197 }; |
194 int expected_temporal_idx[8] = {0, 0, 0, 0, 0, 0, 0, 2}; | 198 int expected_temporal_idx[8] = {0, 0, 0, 0, 0, 0, 0, 2}; |
195 | 199 |
196 uint32_t timestamp = 0; | 200 uint32_t timestamp = 0; |
197 for (int i = 0; i < 7; ++i) { | 201 for (int i = 0; i < 7; ++i) { |
198 EXPECT_EQ(expected_flags[i], tl.EncodeFlags(timestamp)); | 202 TemporalReferences tl_config = tl.UpdateLayerConfig(timestamp); |
| 203 EXPECT_EQ(expected_flags[i], VP8EncoderImpl::EncodeFlags(tl_config)); |
199 tl.PopulateCodecSpecific(true, &vp8_info, 0); | 204 tl.PopulateCodecSpecific(true, &vp8_info, 0); |
200 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); | 205 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); |
201 EXPECT_EQ(true, vp8_info.layerSync); | 206 EXPECT_EQ(true, vp8_info.layerSync); |
202 timestamp += 3000; | 207 timestamp += 3000; |
203 } | 208 } |
204 EXPECT_EQ(expected_flags[7], tl.EncodeFlags(timestamp)); | 209 TemporalReferences tl_config = tl.UpdateLayerConfig(timestamp); |
| 210 EXPECT_EQ(expected_flags[7], VP8EncoderImpl::EncodeFlags(tl_config)); |
205 tl.PopulateCodecSpecific(false, &vp8_info, 0); | 211 tl.PopulateCodecSpecific(false, &vp8_info, 0); |
206 EXPECT_EQ(expected_temporal_idx[7], vp8_info.temporalIdx); | 212 EXPECT_EQ(expected_temporal_idx[7], vp8_info.temporalIdx); |
207 EXPECT_EQ(true, vp8_info.layerSync); | 213 EXPECT_EQ(true, vp8_info.layerSync); |
208 } | 214 } |
209 } // namespace webrtc | 215 } // namespace webrtc |
OLD | NEW |