1 /*
2 * Copyright (c) 2019, Alliance for Open Media. All rights reserved.
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11
12 #include <climits>
13 #include <vector>
14 #include "config/aom_config.h"
15 #include "gtest/gtest.h"
16 #include "test/codec_factory.h"
17 #include "test/datarate_test.h"
18 #include "test/encode_test_driver.h"
19 #include "test/i420_video_source.h"
20 #include "test/util.h"
21 #include "test/y4m_video_source.h"
22 #include "aom/aom_codec.h"
23 #include "av1/common/enums.h"
24 #include "av1/encoder/encoder.h"
25
26 namespace datarate_test {
27 namespace {
28
29 struct FrameInfo {
FrameInfodatarate_test::__anon1e68b69d0111::FrameInfo30 FrameInfo(aom_codec_pts_t _pts, unsigned int _w, unsigned int _h)
31 : pts(_pts), w(_w), h(_h) {}
32
33 aom_codec_pts_t pts;
34 unsigned int w;
35 unsigned int h;
36 };
37
38 class DatarateTestSVC
39 : public ::libaom_test::CodecTestWith4Params<libaom_test::TestMode, int,
40 unsigned int, int>,
41 public DatarateTest {
42 public:
DatarateTestSVC()43 DatarateTestSVC() : DatarateTest(GET_PARAM(0)) {
44 set_cpu_used_ = GET_PARAM(2);
45 aq_mode_ = GET_PARAM(3);
46 }
47
48 protected:
SetUp()49 void SetUp() override {
50 InitializeConfig(GET_PARAM(1));
51 ResetModel();
52 }
53
DecompressedFrameHook(const aom_image_t & img,aom_codec_pts_t pts)54 void DecompressedFrameHook(const aom_image_t &img,
55 aom_codec_pts_t pts) override {
56 frame_info_list_.push_back(FrameInfo(pts, img.d_w, img.d_h));
57 ++decoded_nframes_;
58 }
59
60 std::vector<FrameInfo> frame_info_list_;
61
GetNumSpatialLayers()62 int GetNumSpatialLayers() override { return number_spatial_layers_; }
63
ResetModel()64 void ResetModel() override {
65 DatarateTest::ResetModel();
66 layer_frame_cnt_ = 0;
67 superframe_cnt_ = 0;
68 number_temporal_layers_ = 1;
69 number_spatial_layers_ = 1;
70 for (int i = 0; i < AOM_MAX_LAYERS; i++) {
71 target_layer_bitrate_[i] = 0;
72 effective_datarate_tl[i] = 0.0;
73 }
74 memset(&layer_id_, 0, sizeof(aom_svc_layer_id_t));
75 memset(&svc_params_, 0, sizeof(aom_svc_params_t));
76 memset(&ref_frame_config_, 0, sizeof(aom_svc_ref_frame_config_t));
77 memset(&ref_frame_comp_pred_, 0, sizeof(aom_svc_ref_frame_comp_pred_t));
78 drop_frames_ = 0;
79 for (int i = 0; i < 1000; i++) drop_frames_list_[i] = 1000;
80 decoded_nframes_ = 0;
81 mismatch_nframes_ = 0;
82 mismatch_psnr_ = 0.0;
83 set_frame_level_er_ = 0;
84 multi_ref_ = 0;
85 use_fixed_mode_svc_ = 0;
86 comp_pred_ = 0;
87 dynamic_enable_disable_mode_ = 0;
88 intra_only_ = 0;
89 intra_only_single_layer_ = false;
90 frame_to_start_decoding_ = 0;
91 layer_to_decode_ = 0;
92 frame_sync_ = 0;
93 current_video_frame_ = 0;
94 screen_mode_ = 0;
95 rps_mode_ = 0;
96 rps_recovery_frame_ = 0;
97 user_define_frame_qp_ = 0;
98 set_speed_per_layer_ = false;
99 simulcast_mode_ = false;
100 use_last_as_scaled_ = false;
101 use_last_as_scaled_single_ref_ = false;
102 }
103
PreEncodeFrameHook(::libaom_test::VideoSource * video,::libaom_test::Encoder * encoder)104 void PreEncodeFrameHook(::libaom_test::VideoSource *video,
105 ::libaom_test::Encoder *encoder) override {
106 int spatial_layer_id = 0;
107 current_video_frame_ = video->frame();
108 // video->frame() is called every superframe, so we should condition
109 // this on layer_frame_cnt_ = 0, so we only do this once on the very
110 // first frame.
111 if (video->frame() == 0 && layer_frame_cnt_ == 0) {
112 initialize_svc(number_temporal_layers_, number_spatial_layers_,
113 &svc_params_);
114 if (dynamic_enable_disable_mode_ == 1) {
115 svc_params_.layer_target_bitrate[2] = 0;
116 cfg_.rc_target_bitrate -= target_layer_bitrate_[2];
117 }
118 encoder->Control(AV1E_SET_SVC_PARAMS, &svc_params_);
119 // TODO(aomedia:3032): Configure KSVC in fixed mode.
120 encoder->Control(AV1E_SET_ENABLE_ORDER_HINT, 0);
121 encoder->Control(AV1E_SET_ENABLE_TPL_MODEL, 0);
122 encoder->Control(AV1E_SET_DELTAQ_MODE, 0);
123 if (cfg_.g_threads > 1) {
124 if (auto_tiles_) {
125 encoder->Control(AV1E_SET_AUTO_TILES, 1);
126 } else {
127 encoder->Control(AV1E_SET_TILE_COLUMNS, tile_columns_);
128 encoder->Control(AV1E_SET_TILE_ROWS, tile_rows_);
129 }
130 encoder->Control(AV1E_SET_ROW_MT, 1);
131 }
132 if (screen_mode_) {
133 encoder->Control(AV1E_SET_TUNE_CONTENT, AOM_CONTENT_SCREEN);
134 }
135 encoder->Control(AV1E_SET_POSTENCODE_DROP_RTC, 1);
136 }
137 if (number_spatial_layers_ == 2) {
138 spatial_layer_id = (layer_frame_cnt_ % 2 == 0) ? 0 : 1;
139 } else if (number_spatial_layers_ == 3) {
140 spatial_layer_id = (layer_frame_cnt_ % 3 == 0) ? 0
141 : ((layer_frame_cnt_ - 1) % 3 == 0) ? 1
142 : 2;
143 }
144 // Set the reference/update flags, layer_id, and reference_map
145 // buffer index.
146 frame_flags_ = set_layer_pattern(
147 video->frame(), &layer_id_, &ref_frame_config_, &ref_frame_comp_pred_,
148 spatial_layer_id, multi_ref_, comp_pred_,
149 (video->frame() % cfg_.kf_max_dist) == 0, dynamic_enable_disable_mode_,
150 rps_mode_, rps_recovery_frame_, simulcast_mode_, use_last_as_scaled_,
151 use_last_as_scaled_single_ref_);
152 if (intra_only_ == 1 && frame_sync_ > 0) {
153 // Set an Intra-only frame on SL0 at frame_sync_.
154 // In order to allow decoding to start on SL0 in mid-sequence we need to
155 // set and refresh all the slots used on SL0 stream, which is 0 and 3
156 // for this test pattern. The other slots (1, 2, 4, 5) are used for the
157 // SL > 0 layers and these slotes are not refreshed on frame_sync_, so
158 // temporal prediction for the top layers can continue.
159 if (spatial_layer_id == 0 && video->frame() == frame_sync_) {
160 ref_frame_config_.ref_idx[0] = 0;
161 ref_frame_config_.ref_idx[3] = 3;
162 ref_frame_config_.refresh[0] = 1;
163 ref_frame_config_.refresh[3] = 1;
164 for (int i = 0; i < INTER_REFS_PER_FRAME; i++)
165 ref_frame_config_.reference[i] = 0;
166 }
167 }
168 if (intra_only_ && video->frame() == 50 && spatial_layer_id == 1) {
169 // Force an intra_only frame here, for SL1.
170 for (int i = 0; i < INTER_REFS_PER_FRAME; i++)
171 ref_frame_config_.reference[i] = 0;
172 }
173 encoder->Control(AV1E_SET_SVC_LAYER_ID, &layer_id_);
174 // The SET_SVC_REF_FRAME_CONFIG and AV1E_SET_SVC_REF_FRAME_COMP_PRED api is
175 // for the flexible SVC mode (i.e., use_fixed_mode_svc == 0).
176 if (!use_fixed_mode_svc_) {
177 encoder->Control(AV1E_SET_SVC_REF_FRAME_CONFIG, &ref_frame_config_);
178 encoder->Control(AV1E_SET_SVC_REF_FRAME_COMP_PRED, &ref_frame_comp_pred_);
179 }
180 if (set_speed_per_layer_) {
181 int speed_per_layer = 10;
182 if (layer_id_.spatial_layer_id == 0) {
183 // For for base SL0,TL0: use the speed the test loops over.
184 if (layer_id_.temporal_layer_id == 1) speed_per_layer = 7;
185 if (layer_id_.temporal_layer_id == 2) speed_per_layer = 8;
186 } else if (layer_id_.spatial_layer_id == 1) {
187 if (layer_id_.temporal_layer_id == 0) speed_per_layer = 7;
188 if (layer_id_.temporal_layer_id == 1) speed_per_layer = 8;
189 if (layer_id_.temporal_layer_id == 2) speed_per_layer = 9;
190 } else if (layer_id_.spatial_layer_id == 2) {
191 if (layer_id_.temporal_layer_id == 0) speed_per_layer = 8;
192 if (layer_id_.temporal_layer_id == 1) speed_per_layer = 9;
193 if (layer_id_.temporal_layer_id == 2) speed_per_layer = 10;
194 }
195 encoder->Control(AOME_SET_CPUUSED, speed_per_layer);
196 }
197 if (set_frame_level_er_) {
198 int mode =
199 (layer_id_.spatial_layer_id > 0 || layer_id_.temporal_layer_id > 0);
200 encoder->Control(AV1E_SET_ERROR_RESILIENT_MODE, mode);
201 }
202 if (dynamic_enable_disable_mode_ == 1) {
203 if (layer_frame_cnt_ == 300 && spatial_layer_id == 0) {
204 // Enable: set top spatial layer bitrate back to non-zero.
205 svc_params_.layer_target_bitrate[2] = target_layer_bitrate_[2];
206 cfg_.rc_target_bitrate += target_layer_bitrate_[2];
207 encoder->Config(&cfg_);
208 encoder->Control(AV1E_SET_SVC_PARAMS, &svc_params_);
209 }
210 } else if (dynamic_enable_disable_mode_ == 2) {
211 if (layer_frame_cnt_ == 300 && spatial_layer_id == 0) {
212 // Disable top spatial layer mid-stream.
213 svc_params_.layer_target_bitrate[2] = 0;
214 cfg_.rc_target_bitrate -= target_layer_bitrate_[2];
215 encoder->Config(&cfg_);
216 encoder->Control(AV1E_SET_SVC_PARAMS, &svc_params_);
217 } else if (layer_frame_cnt_ == 600 && spatial_layer_id == 0) {
218 // Enable top spatial layer mid-stream.
219 svc_params_.layer_target_bitrate[2] = target_layer_bitrate_[2];
220 cfg_.rc_target_bitrate += target_layer_bitrate_[2];
221 encoder->Config(&cfg_);
222 encoder->Control(AV1E_SET_SVC_PARAMS, &svc_params_);
223 }
224 }
225 layer_frame_cnt_++;
226 DatarateTest::PreEncodeFrameHook(video, encoder);
227
228 if (user_define_frame_qp_) {
229 frame_qp_ = rnd_.PseudoUniform(63);
230 encoder->Control(AV1E_SET_QUANTIZER_ONE_PASS, frame_qp_);
231 }
232 }
233
PostEncodeFrameHook(::libaom_test::Encoder * encoder)234 void PostEncodeFrameHook(::libaom_test::Encoder *encoder) override {
235 int num_operating_points;
236 encoder->Control(AV1E_GET_NUM_OPERATING_POINTS, &num_operating_points);
237 ASSERT_EQ(num_operating_points,
238 number_temporal_layers_ * number_spatial_layers_);
239
240 if (user_define_frame_qp_) {
241 if (current_video_frame_ >= static_cast<unsigned int>(total_frame_))
242 return;
243 int qp;
244 encoder->Control(AOME_GET_LAST_QUANTIZER_64, &qp);
245 ASSERT_EQ(qp, frame_qp_);
246 }
247 }
248
FramePktHook(const aom_codec_cx_pkt_t * pkt)249 void FramePktHook(const aom_codec_cx_pkt_t *pkt) override {
250 const size_t frame_size_in_bits = pkt->data.frame.sz * 8;
251 // Update the layer cumulative bitrate.
252 for (int i = layer_id_.temporal_layer_id; i < number_temporal_layers_;
253 i++) {
254 int layer = layer_id_.spatial_layer_id * number_temporal_layers_ + i;
255 effective_datarate_tl[layer] += 1.0 * frame_size_in_bits;
256 }
257 if (layer_id_.spatial_layer_id == number_spatial_layers_ - 1) {
258 last_pts_ = pkt->data.frame.pts;
259 superframe_cnt_++;
260 }
261 // For simulcast mode: verify that for first frame to start decoding,
262 // for SL > 0, are Intra-only frames (not Key), whereas SL0 is Key.
263 if (simulcast_mode_ && superframe_cnt_ == (int)frame_to_start_decoding_) {
264 if (layer_id_.spatial_layer_id > 0) {
265 EXPECT_NE(pkt->data.frame.flags & AOM_FRAME_IS_KEY, AOM_FRAME_IS_KEY);
266 } else if (layer_id_.spatial_layer_id == 0) {
267 EXPECT_EQ(pkt->data.frame.flags & AOM_FRAME_IS_KEY, AOM_FRAME_IS_KEY);
268 }
269 }
270 }
271
EndPassHook()272 void EndPassHook() override {
273 duration_ = ((last_pts_ + 1) * timebase_);
274 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
275 effective_datarate_tl[i] = (effective_datarate_tl[i] / 1000) / duration_;
276 }
277 }
278
DoDecode() const279 bool DoDecode() const override {
280 if (drop_frames_ > 0) {
281 for (unsigned int i = 0; i < drop_frames_; ++i) {
282 if (drop_frames_list_[i] == (unsigned int)superframe_cnt_) {
283 std::cout << " Skipping decoding frame: "
284 << drop_frames_list_[i] << "\n";
285 return false;
286 }
287 }
288 } else if (intra_only_ == 1) {
289 // Only start decoding at frames_to_start_decoding_.
290 if (current_video_frame_ < frame_to_start_decoding_) return false;
291 // Only decode base layer for 3SL, for layer_to_decode_ = 0.
292 if (layer_to_decode_ == 0 && frame_sync_ > 0 &&
293 (layer_frame_cnt_ - 1) % 3 != 0)
294 return false;
295 } else if (simulcast_mode_) {
296 // Only start decoding at frames_to_start_decoding_ and only
297 // for top spatial layer SL2 (layer_to_decode_).
298 if (current_video_frame_ < frame_to_start_decoding_) return false;
299 if (layer_id_.spatial_layer_id < (int)layer_to_decode_) return false;
300 }
301 return true;
302 }
303
MismatchHook(const aom_image_t * img1,const aom_image_t * img2)304 void MismatchHook(const aom_image_t *img1, const aom_image_t *img2) override {
305 double mismatch_psnr = compute_psnr(img1, img2);
306 mismatch_psnr_ += mismatch_psnr;
307 ++mismatch_nframes_;
308 }
309
GetMismatchFrames()310 unsigned int GetMismatchFrames() { return mismatch_nframes_; }
GetDecodedFrames()311 unsigned int GetDecodedFrames() { return decoded_nframes_; }
312
ref_config_rps(aom_svc_ref_frame_config_t * ref_frame_config,int frame_cnt,int rps_recovery_frame)313 static void ref_config_rps(aom_svc_ref_frame_config_t *ref_frame_config,
314 int frame_cnt, int rps_recovery_frame) {
315 // Pattern of 3 references with (ALTREF and GOLDEN) trailing
316 // LAST by 4 and 8 frame, with some switching logic to
317 // only predict from longer-term reference.
318 int last_idx = 0;
319 int last_idx_refresh = 0;
320 int gld_idx = 0;
321 int alt_ref_idx = 0;
322 const int lag_alt = 4;
323 const int lag_gld = 8;
324 const int sh = 8; // slots 0 - 7.
325 // Moving index slot for last: 0 - (sh - 1)
326 if (frame_cnt > 1) last_idx = (frame_cnt - 1) % sh;
327 // Moving index for refresh of last: one ahead for next frame.
328 last_idx_refresh = frame_cnt % sh;
329 // Moving index for gld_ref, lag behind current by lag_gld
330 if (frame_cnt > lag_gld) gld_idx = (frame_cnt - lag_gld) % sh;
331 // Moving index for alt_ref, lag behind LAST by lag_alt frames.
332 if (frame_cnt > lag_alt) alt_ref_idx = (frame_cnt - lag_alt) % sh;
333 // Set the ref_idx.
334 // Default all references (7) to slot for last.
335 // LAST_FRAME (0), LAST2_FRAME(1), LAST3_FRAME(2), GOLDEN_FRAME(3),
336 // BWDREF_FRAME(4), ALTREF2_FRAME(5), ALTREF_FRAME(6).
337 for (int i = 0; i < INTER_REFS_PER_FRAME; i++)
338 ref_frame_config->ref_idx[i] = last_idx;
339 // Set the ref_idx for the relevant references.
340 ref_frame_config->ref_idx[0] = last_idx;
341 ref_frame_config->ref_idx[1] = last_idx_refresh;
342 ref_frame_config->ref_idx[3] = gld_idx;
343 ref_frame_config->ref_idx[6] = alt_ref_idx;
344 // Refresh this slot, which will become LAST on next frame.
345 ref_frame_config->refresh[last_idx_refresh] = 1;
346 // Reference LAST, ALTREF, and GOLDEN
347 ref_frame_config->reference[0] = 1;
348 ref_frame_config->reference[6] = 1;
349 ref_frame_config->reference[3] = 1;
350 if (frame_cnt == rps_recovery_frame) {
351 // Switch to only reference GOLDEN at recovery_frame.
352 ref_frame_config->reference[0] = 0;
353 ref_frame_config->reference[6] = 0;
354 ref_frame_config->reference[3] = 1;
355 } else if (frame_cnt > rps_recovery_frame &&
356 frame_cnt < rps_recovery_frame + 8) {
357 // Go back to predicting from LAST, and after
358 // 8 frames (GOLDEN is 8 frames aways) go back
359 // to predicting off GOLDEN and ALTREF.
360 ref_frame_config->reference[0] = 1;
361 ref_frame_config->reference[6] = 0;
362 ref_frame_config->reference[3] = 0;
363 }
364 }
365
366 // Simulcast mode for 3 spatial and 3 temporal layers.
367 // No inter-layer predicton, only prediction is temporal and single
368 // reference (LAST).
369 // No overlap in buffer slots between spatial layers. So for example,
370 // SL0 only uses slots 0 and 1.
371 // SL1 only uses slots 2 and 3.
372 // SL2 only uses slots 4 and 5.
373 // All 7 references for each inter-frame must only access buffer slots
374 // for that spatial layer.
375 // On key (super)frames: SL1 and SL2 must have no references set
376 // and must refresh all the slots for that layer only (so 2 and 3
377 // for SL1, 4 and 5 for SL2). The base SL0 will be labelled internally
378 // as a Key frame (refresh all slots). SL1/SL2 will be labelled
379 // internally as Intra-only frames that allow that stream to be decoded.
380 // These conditions will allow for each spatial stream to be
381 // independently decodeable.
ref_config_simulcast3SL3TL(aom_svc_ref_frame_config_t * ref_frame_config,aom_svc_layer_id_t * layer_id,int is_key_frame,int superframe_cnt)382 static void ref_config_simulcast3SL3TL(
383 aom_svc_ref_frame_config_t *ref_frame_config,
384 aom_svc_layer_id_t *layer_id, int is_key_frame, int superframe_cnt) {
385 int i;
386 // Initialize all references to 0 (don't use reference).
387 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
388 ref_frame_config->reference[i] = 0;
389 // Initialize as no refresh/update for all slots.
390 for (i = 0; i < REF_FRAMES; i++) ref_frame_config->refresh[i] = 0;
391 for (i = 0; i < INTER_REFS_PER_FRAME; i++) ref_frame_config->ref_idx[i] = 0;
392
393 if (is_key_frame) {
394 if (layer_id->spatial_layer_id == 0) {
395 // Assign LAST/GOLDEN to slot 0/1.
396 // Refesh slots 0 and 1 for SL0.
397 // SL0: this will get set to KEY frame internally.
398 ref_frame_config->ref_idx[0] = 0;
399 ref_frame_config->ref_idx[3] = 1;
400 ref_frame_config->refresh[0] = 1;
401 ref_frame_config->refresh[1] = 1;
402 } else if (layer_id->spatial_layer_id == 1) {
403 // Assign LAST/GOLDEN to slot 2/3.
404 // Refesh slots 2 and 3 for SL1.
405 // This will get set to Intra-only frame internally.
406 ref_frame_config->ref_idx[0] = 2;
407 ref_frame_config->ref_idx[3] = 3;
408 ref_frame_config->refresh[2] = 1;
409 ref_frame_config->refresh[3] = 1;
410 } else if (layer_id->spatial_layer_id == 2) {
411 // Assign LAST/GOLDEN to slot 4/5.
412 // Refresh slots 4 and 5 for SL2.
413 // This will get set to Intra-only frame internally.
414 ref_frame_config->ref_idx[0] = 4;
415 ref_frame_config->ref_idx[3] = 5;
416 ref_frame_config->refresh[4] = 1;
417 ref_frame_config->refresh[5] = 1;
418 }
419 } else if (superframe_cnt % 4 == 0) {
420 // Base temporal layer: TL0
421 layer_id->temporal_layer_id = 0;
422 if (layer_id->spatial_layer_id == 0) { // SL0
423 // Reference LAST. Assign all references to either slot
424 // 0 or 1. Here we assign LAST to slot 0, all others to 1.
425 // Update slot 0 (LAST).
426 ref_frame_config->reference[0] = 1;
427 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
428 ref_frame_config->ref_idx[i] = 1;
429 ref_frame_config->ref_idx[0] = 0;
430 ref_frame_config->refresh[0] = 1;
431 } else if (layer_id->spatial_layer_id == 1) { // SL1
432 // Reference LAST. Assign all references to either slot
433 // 2 or 3. Here we assign LAST to slot 2, all others to 3.
434 // Update slot 2 (LAST).
435 ref_frame_config->reference[0] = 1;
436 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
437 ref_frame_config->ref_idx[i] = 3;
438 ref_frame_config->ref_idx[0] = 2;
439 ref_frame_config->refresh[2] = 1;
440 } else if (layer_id->spatial_layer_id == 2) { // SL2
441 // Reference LAST. Assign all references to either slot
442 // 4 or 5. Here we assign LAST to slot 4, all others to 5.
443 // Update slot 4 (LAST).
444 ref_frame_config->reference[0] = 1;
445 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
446 ref_frame_config->ref_idx[i] = 5;
447 ref_frame_config->ref_idx[0] = 4;
448 ref_frame_config->refresh[4] = 1;
449 }
450 } else if ((superframe_cnt - 1) % 4 == 0) {
451 // First top temporal enhancement layer: TL2
452 layer_id->temporal_layer_id = 2;
453 if (layer_id->spatial_layer_id == 0) { // SL0
454 // Reference LAST (slot 0). Assign other references to slot 1.
455 // No update/refresh on any slots.
456 ref_frame_config->reference[0] = 1;
457 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
458 ref_frame_config->ref_idx[i] = 1;
459 ref_frame_config->ref_idx[0] = 0;
460 } else if (layer_id->spatial_layer_id == 1) { // SL1
461 // Reference LAST (slot 2). Assign other references to slot 3.
462 // No update/refresh on any slots.
463 ref_frame_config->reference[0] = 1;
464 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
465 ref_frame_config->ref_idx[i] = 3;
466 ref_frame_config->ref_idx[0] = 2;
467 } else if (layer_id->spatial_layer_id == 2) { // SL2
468 // Reference LAST (slot 4). Assign other references to slot 4.
469 // No update/refresh on any slots.
470 ref_frame_config->reference[0] = 1;
471 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
472 ref_frame_config->ref_idx[i] = 5;
473 ref_frame_config->ref_idx[0] = 4;
474 }
475 } else if ((superframe_cnt - 2) % 4 == 0) {
476 // Middle temporal enhancement layer: TL1
477 layer_id->temporal_layer_id = 1;
478 if (layer_id->spatial_layer_id == 0) { // SL0
479 // Reference LAST (slot 0).
480 // Set GOLDEN to slot 1 and update slot 1.
481 // This will be used as reference for next TL2.
482 ref_frame_config->reference[0] = 1;
483 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
484 ref_frame_config->ref_idx[i] = 1;
485 ref_frame_config->ref_idx[0] = 0;
486 ref_frame_config->refresh[1] = 1;
487 } else if (layer_id->spatial_layer_id == 1) { // SL1
488 // Reference LAST (slot 2).
489 // Set GOLDEN to slot 3 and update slot 3.
490 // This will be used as reference for next TL2.
491 ref_frame_config->reference[0] = 1;
492 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
493 ref_frame_config->ref_idx[i] = 3;
494 ref_frame_config->ref_idx[0] = 2;
495 ref_frame_config->refresh[3] = 1;
496 } else if (layer_id->spatial_layer_id == 2) { // SL2
497 // Reference LAST (slot 4).
498 // Set GOLDEN to slot 5 and update slot 5.
499 // This will be used as reference for next TL2.
500 ref_frame_config->reference[0] = 1;
501 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
502 ref_frame_config->ref_idx[i] = 5;
503 ref_frame_config->ref_idx[0] = 4;
504 ref_frame_config->refresh[5] = 1;
505 }
506 } else if ((superframe_cnt - 3) % 4 == 0) {
507 // Second top temporal enhancement layer: TL2
508 layer_id->temporal_layer_id = 2;
509 if (layer_id->spatial_layer_id == 0) { // SL0
510 // Reference LAST (slot 1). Assign other references to slot 0.
511 // No update/refresh on any slots.
512 ref_frame_config->reference[0] = 1;
513 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
514 ref_frame_config->ref_idx[i] = 0;
515 ref_frame_config->ref_idx[0] = 1;
516 } else if (layer_id->spatial_layer_id == 1) { // SL1
517 // Reference LAST (slot 3). Assign other references to slot 2.
518 // No update/refresh on any slots.
519 ref_frame_config->reference[0] = 1;
520 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
521 ref_frame_config->ref_idx[i] = 2;
522 ref_frame_config->ref_idx[0] = 3;
523 } else if (layer_id->spatial_layer_id == 2) { // SL2
524 // Reference LAST (slot 5). Assign other references to slot 4.
525 // No update/refresh on any slots.
526 ref_frame_config->reference[0] = 1;
527 for (i = 0; i < INTER_REFS_PER_FRAME; i++)
528 ref_frame_config->ref_idx[i] = 4;
529 ref_frame_config->ref_idx[0] = 5;
530 }
531 }
532 }
533
534 // 3 spatial and 3 temporal layer.
535 // Overlap in the buffer slot updates: the slots 3 and 4 updated by
536 // first TL2 are reused for update in TL1 superframe.
ref_config_3SL3TL(aom_svc_ref_frame_config_t * ref_frame_config,aom_svc_layer_id_t * layer_id,int is_key_frame,int superframe_cnt)537 static void ref_config_3SL3TL(aom_svc_ref_frame_config_t *ref_frame_config,
538 aom_svc_layer_id_t *layer_id, int is_key_frame,
539 int superframe_cnt) {
540 if (superframe_cnt % 4 == 0) {
541 // Base temporal layer.
542 layer_id->temporal_layer_id = 0;
543 if (layer_id->spatial_layer_id == 0) {
544 // Reference LAST, update LAST.
545 // Set all buffer_idx to 0.
546 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 0;
547 ref_frame_config->refresh[0] = 1;
548 } else if (layer_id->spatial_layer_id == 1) {
549 // Reference LAST and GOLDEN. Set buffer_idx for LAST to slot 1,
550 // GOLDEN (and all other refs) to slot 0.
551 // Update slot 1 (LAST).
552 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 0;
553 ref_frame_config->ref_idx[0] = 1;
554 ref_frame_config->refresh[1] = 1;
555 } else if (layer_id->spatial_layer_id == 2) {
556 // Reference LAST and GOLDEN. Set buffer_idx for LAST to slot 2,
557 // GOLDEN (and all other refs) to slot 1.
558 // Update slot 2 (LAST).
559 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 1;
560 ref_frame_config->ref_idx[0] = 2;
561 ref_frame_config->refresh[2] = 1;
562 }
563 } else if ((superframe_cnt - 1) % 4 == 0) {
564 // First top temporal enhancement layer.
565 layer_id->temporal_layer_id = 2;
566 if (layer_id->spatial_layer_id == 0) {
567 // Reference LAST (slot 0).
568 // Set GOLDEN to slot 3 and update slot 3.
569 // Set all other buffer_idx to slot 0.
570 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 0;
571 ref_frame_config->ref_idx[3] = 3;
572 ref_frame_config->refresh[3] = 1;
573 } else if (layer_id->spatial_layer_id == 1) {
574 // Reference LAST and GOLDEN. Set buffer_idx for LAST to slot 1,
575 // GOLDEN (and all other refs) to slot 3.
576 // Set LAST2 to slot 4 and Update slot 4.
577 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 3;
578 ref_frame_config->ref_idx[0] = 1;
579 ref_frame_config->ref_idx[1] = 4;
580 ref_frame_config->refresh[4] = 1;
581 } else if (layer_id->spatial_layer_id == 2) {
582 // Reference LAST and GOLDEN. Set buffer_idx for LAST to slot 2,
583 // GOLDEN (and all other refs) to slot 4.
584 // No update.
585 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 4;
586 ref_frame_config->ref_idx[0] = 2;
587 }
588 } else if ((superframe_cnt - 2) % 4 == 0) {
589 // Middle temporal enhancement layer.
590 layer_id->temporal_layer_id = 1;
591 if (layer_id->spatial_layer_id == 0) {
592 // Reference LAST.
593 // Set all buffer_idx to 0.
594 // Set GOLDEN to slot 3 and update slot 3.
595 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 0;
596 ref_frame_config->ref_idx[3] = 3;
597 ref_frame_config->refresh[3] = 1;
598 } else if (layer_id->spatial_layer_id == 1) {
599 // Reference LAST and GOLDEN. Set buffer_idx for LAST to slot 1,
600 // GOLDEN (and all other refs) to slot 3.
601 // Set LAST2 to slot 4 and update slot 4.
602 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 3;
603 ref_frame_config->ref_idx[0] = 1;
604 ref_frame_config->ref_idx[2] = 4;
605 ref_frame_config->refresh[4] = 1;
606 } else if (layer_id->spatial_layer_id == 2) {
607 // Reference LAST and GOLDEN. Set buffer_idx for LAST to slot 2,
608 // GOLDEN (and all other refs) to slot 4.
609 // Set LAST2 to slot 5 and update slot 5.
610 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 4;
611 ref_frame_config->ref_idx[0] = 2;
612 ref_frame_config->ref_idx[2] = 5;
613 ref_frame_config->refresh[5] = 1;
614 }
615 } else if ((superframe_cnt - 3) % 4 == 0) {
616 // Second top temporal enhancement layer.
617 layer_id->temporal_layer_id = 2;
618 if (layer_id->spatial_layer_id == 0) {
619 // Set LAST to slot 3 and reference LAST.
620 // Set GOLDEN to slot 3 and update slot 3.
621 // Set all other buffer_idx to 0.
622 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 0;
623 ref_frame_config->ref_idx[0] = 3;
624 ref_frame_config->ref_idx[3] = 3;
625 ref_frame_config->refresh[3] = 1;
626 } else if (layer_id->spatial_layer_id == 1) {
627 // Reference LAST and GOLDEN. Set buffer_idx for LAST to slot 4,
628 // GOLDEN to slot 3. Set LAST2 to slot 4 and update slot 4.
629 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 0;
630 ref_frame_config->ref_idx[0] = 4;
631 ref_frame_config->ref_idx[3] = 3;
632 ref_frame_config->ref_idx[1] = 4;
633 ref_frame_config->refresh[4] = 1;
634 } else if (layer_id->spatial_layer_id == 2) {
635 // Reference LAST and GOLDEN. Set buffer_idx for LAST to slot 5,
636 // GOLDEN to slot 4. No update.
637 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 0;
638 ref_frame_config->ref_idx[0] = 5;
639 ref_frame_config->ref_idx[3] = 4;
640 }
641 }
642 if (layer_id->spatial_layer_id > 0) {
643 // Always reference GOLDEN (inter-layer prediction).
644 ref_frame_config->reference[3] = 1;
645 if (is_key_frame && layer_id->spatial_layer_id > 0) {
646 // On superframes whose base is key: remove LAST since GOLDEN
647 // is used as reference.
648 ref_frame_config->reference[0] = 0;
649 }
650 }
651 }
652
653 // Layer pattern configuration.
set_layer_pattern(int frame_cnt,aom_svc_layer_id_t * layer_id,aom_svc_ref_frame_config_t * ref_frame_config,aom_svc_ref_frame_comp_pred_t * ref_frame_comp_pred,int spatial_layer,int multi_ref,int comp_pred,int is_key_frame,int dynamic_enable_disable_mode,int rps_mode,int rps_recovery_frame,int simulcast_mode,bool use_last_as_scaled,bool use_last_as_scaled_single_ref)654 virtual int set_layer_pattern(
655 int frame_cnt, aom_svc_layer_id_t *layer_id,
656 aom_svc_ref_frame_config_t *ref_frame_config,
657 aom_svc_ref_frame_comp_pred_t *ref_frame_comp_pred, int spatial_layer,
658 int multi_ref, int comp_pred, int is_key_frame,
659 int dynamic_enable_disable_mode, int rps_mode, int rps_recovery_frame,
660 int simulcast_mode, bool use_last_as_scaled,
661 bool use_last_as_scaled_single_ref) {
662 int lag_index = 0;
663 int base_count = frame_cnt >> 2;
664 layer_id->spatial_layer_id = spatial_layer;
665 // Set the reference map buffer idx for the 7 references:
666 // LAST_FRAME (0), LAST2_FRAME(1), LAST3_FRAME(2), GOLDEN_FRAME(3),
667 // BWDREF_FRAME(4), ALTREF2_FRAME(5), ALTREF_FRAME(6).
668 for (int i = 0; i < INTER_REFS_PER_FRAME; i++) {
669 ref_frame_config->ref_idx[i] = i;
670 ref_frame_config->reference[i] = 0;
671 }
672 for (int i = 0; i < REF_FRAMES; i++) ref_frame_config->refresh[i] = 0;
673 if (comp_pred) {
674 ref_frame_comp_pred->use_comp_pred[0] = 1; // GOLDEN_LAST
675 ref_frame_comp_pred->use_comp_pred[1] = 1; // LAST2_LAST
676 ref_frame_comp_pred->use_comp_pred[2] = 1; // ALTREF_LAST
677 }
678 // Set layer_flags to 0 when using ref_frame_config->reference.
679 int layer_flags = 0;
680 // Always reference LAST.
681 ref_frame_config->reference[0] = 1;
682 if (number_temporal_layers_ == 1 && number_spatial_layers_ == 1) {
683 layer_id->temporal_layer_id = 0;
684 ref_frame_config->refresh[0] = 1;
685 if (rps_mode)
686 ref_config_rps(ref_frame_config, frame_cnt, rps_recovery_frame);
687 if (intra_only_single_layer_) {
688 // This repros the crash in Bug: 363016123.
689 ref_frame_config->ref_idx[0] = 0;
690 ref_frame_config->ref_idx[3] = 1;
691 ref_frame_config->ref_idx[6] = 2;
692 if (frame_cnt == 1) {
693 for (int i = 0; i < INTER_REFS_PER_FRAME; i++)
694 ref_frame_config->reference[i] = 0;
695 }
696 }
697 }
698 if (number_temporal_layers_ == 2 && number_spatial_layers_ == 1) {
699 // 2-temporal layer.
700 // 1 3 5
701 // 0 2 4
702 // Keep golden fixed at slot 3.
703 base_count = frame_cnt >> 1;
704 ref_frame_config->ref_idx[3] = 3;
705 // Cyclically refresh slots 5, 6, 7, for lag alt ref.
706 lag_index = 5;
707 if (base_count > 0) {
708 lag_index = 5 + (base_count % 3);
709 if (frame_cnt % 2 != 0) lag_index = 5 + ((base_count + 1) % 3);
710 }
711 // Set the altref slot to lag_index.
712 ref_frame_config->ref_idx[6] = lag_index;
713 if (frame_cnt % 2 == 0) {
714 layer_id->temporal_layer_id = 0;
715 // Update LAST on layer 0, reference LAST.
716 ref_frame_config->refresh[0] = 1;
717 ref_frame_config->reference[0] = 1;
718 // Refresh lag_index slot, needed for lagging golen.
719 ref_frame_config->refresh[lag_index] = 1;
720 // Refresh GOLDEN every x base layer frames.
721 if (base_count % 32 == 0) ref_frame_config->refresh[3] = 1;
722 } else {
723 layer_id->temporal_layer_id = 1;
724 // No updates on layer 1, reference LAST (TL0).
725 ref_frame_config->reference[0] = 1;
726 }
727 // Always reference golden and altref on TL0.
728 if (layer_id->temporal_layer_id == 0) {
729 ref_frame_config->reference[3] = 1;
730 ref_frame_config->reference[6] = 1;
731 }
732 } else if (number_temporal_layers_ == 3 && number_spatial_layers_ == 1) {
733 // 3-layer:
734 // 1 3 5 7
735 // 2 6
736 // 0 4 8
737 if (multi_ref) {
738 // Keep golden fixed at slot 3.
739 ref_frame_config->ref_idx[3] = 3;
740 // Cyclically refresh slots 4, 5, 6, 7, for lag altref.
741 lag_index = 4 + (base_count % 4);
742 // Set the altref slot to lag_index.
743 ref_frame_config->ref_idx[6] = lag_index;
744 }
745 if (frame_cnt % 4 == 0) {
746 // Base layer.
747 layer_id->temporal_layer_id = 0;
748 // Update LAST on layer 0, reference LAST and GF.
749 ref_frame_config->refresh[0] = 1;
750 ref_frame_config->reference[3] = 1;
751 if (multi_ref) {
752 // Refresh GOLDEN every x ~10 base layer frames.
753 if (base_count % 10 == 0) ref_frame_config->refresh[3] = 1;
754 // Refresh lag_index slot, needed for lagging altref.
755 ref_frame_config->refresh[lag_index] = 1;
756 }
757 } else if ((frame_cnt - 1) % 4 == 0) {
758 layer_id->temporal_layer_id = 2;
759 // First top layer: no updates, only reference LAST (TL0).
760 } else if ((frame_cnt - 2) % 4 == 0) {
761 layer_id->temporal_layer_id = 1;
762 // Middle layer (TL1): update LAST2, only reference LAST (TL0).
763 ref_frame_config->refresh[1] = 1;
764 } else if ((frame_cnt - 3) % 4 == 0) {
765 layer_id->temporal_layer_id = 2;
766 // Second top layer: no updates, only reference LAST.
767 // Set buffer idx for LAST to slot 1, since that was the slot
768 // updated in previous frame. So LAST is TL1 frame.
769 ref_frame_config->ref_idx[0] = 1;
770 ref_frame_config->ref_idx[1] = 0;
771 }
772 if (multi_ref) {
773 // Every frame can reference GOLDEN AND ALTREF.
774 ref_frame_config->reference[3] = 1;
775 ref_frame_config->reference[6] = 1;
776 }
777 } else if (number_temporal_layers_ == 1 && number_spatial_layers_ == 2) {
778 layer_id->temporal_layer_id = 0;
779 if (layer_id->spatial_layer_id == 0) {
780 // Reference LAST, update LAST. Keep LAST and GOLDEN in slots 0 and 3.
781 ref_frame_config->ref_idx[0] = 0;
782 ref_frame_config->ref_idx[3] = 3;
783 ref_frame_config->refresh[0] = 1;
784 } else if (layer_id->spatial_layer_id == 1) {
785 // Reference LAST and GOLDEN. Set buffer_idx for LAST to slot 3
786 // and GOLDEN to slot 0. Update slot 3 (LAST).
787 ref_frame_config->ref_idx[0] = 3;
788 ref_frame_config->ref_idx[3] = 0;
789 ref_frame_config->refresh[3] = 1;
790 }
791 // Reference GOLDEN.
792 if (layer_id->spatial_layer_id > 0) ref_frame_config->reference[3] = 1;
793 } else if (number_temporal_layers_ == 1 && number_spatial_layers_ == 3) {
794 // 3 spatial layers, 1 temporal.
795 // Note for this case , we set the buffer idx for all references to be
796 // either LAST or GOLDEN, which are always valid references, since decoder
797 // will check if any of the 7 references is valid scale in
798 // valid_ref_frame_size().
799 layer_id->temporal_layer_id = 0;
800 if (layer_id->spatial_layer_id == 0) {
801 // Reference LAST, update LAST. Set all other buffer_idx to 0.
802 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 0;
803 ref_frame_config->refresh[0] = 1;
804 } else if (layer_id->spatial_layer_id == 1) {
805 // Reference LAST and GOLDEN. Set buffer_idx for LAST to slot 1
806 // and GOLDEN (and all other refs) to slot 0.
807 // Update slot 1 (LAST).
808 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 0;
809 ref_frame_config->ref_idx[0] = 1;
810 if (use_last_as_scaled) {
811 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 1;
812 ref_frame_config->ref_idx[0] = 0;
813 ref_frame_config->ref_idx[3] = 1;
814 }
815 ref_frame_config->refresh[1] = 1;
816 } else if (layer_id->spatial_layer_id == 2) {
817 // Reference LAST and GOLDEN. Set buffer_idx for LAST to slot 2
818 // and GOLDEN (and all other refs) to slot 1.
819 // Update slot 2 (LAST).
820 for (int i = 0; i < 7; i++) ref_frame_config->ref_idx[i] = 1;
821 ref_frame_config->ref_idx[0] = 2;
822 ref_frame_config->refresh[2] = 1;
823 if (multi_ref) {
824 ref_frame_config->ref_idx[6] = 7;
825 ref_frame_config->reference[6] = 1;
826 if (base_count % 10 == 0) ref_frame_config->refresh[7] = 1;
827 }
828 }
829 // Reference GOLDEN.
830 if (layer_id->spatial_layer_id > 0) {
831 if (use_last_as_scaled_single_ref)
832 ref_frame_config->reference[3] = 0;
833 else
834 ref_frame_config->reference[3] = 1;
835 }
836 } else if (number_temporal_layers_ == 3 && number_spatial_layers_ == 3) {
837 if (simulcast_mode) {
838 ref_config_simulcast3SL3TL(ref_frame_config, layer_id, is_key_frame,
839 superframe_cnt_);
840 } else {
841 ref_config_3SL3TL(ref_frame_config, layer_id, is_key_frame,
842 superframe_cnt_);
843 // Allow for top spatial layer to use additional temporal reference.
844 // Additional reference is only updated on base temporal layer, every
845 // 10 TL0 frames here.
846 if (multi_ref && layer_id->spatial_layer_id == 2) {
847 ref_frame_config->ref_idx[6] = 7;
848 if (!is_key_frame) ref_frame_config->reference[6] = 1;
849 if (base_count % 10 == 0 && layer_id->temporal_layer_id == 0)
850 ref_frame_config->refresh[7] = 1;
851 }
852 }
853 }
854 // If the top spatial layer is first-time encoded in mid-sequence
855 // (i.e., dynamic_enable_disable_mode = 1), then don't predict from LAST,
856 // since it will have been last updated on first key frame (SL0) and so
857 // be different resolution from SL2.
858 if (dynamic_enable_disable_mode == 1 &&
859 layer_id->spatial_layer_id == number_spatial_layers_ - 1)
860 ref_frame_config->reference[0] = 0;
861 return layer_flags;
862 }
863
initialize_svc(int number_temporal_layers,int number_spatial_layers,aom_svc_params * svc_params)864 virtual void initialize_svc(int number_temporal_layers,
865 int number_spatial_layers,
866 aom_svc_params *svc_params) {
867 svc_params->number_spatial_layers = number_spatial_layers;
868 svc_params->number_temporal_layers = number_temporal_layers;
869 for (int i = 0; i < number_temporal_layers * number_spatial_layers; ++i) {
870 svc_params->max_quantizers[i] = 60;
871 svc_params->min_quantizers[i] = 2;
872 svc_params->layer_target_bitrate[i] = target_layer_bitrate_[i];
873 }
874 // Do at most 3 spatial or temporal layers here.
875 svc_params->framerate_factor[0] = 1;
876 if (number_temporal_layers == 2) {
877 svc_params->framerate_factor[0] = 2;
878 svc_params->framerate_factor[1] = 1;
879 } else if (number_temporal_layers == 3) {
880 svc_params->framerate_factor[0] = 4;
881 svc_params->framerate_factor[1] = 2;
882 svc_params->framerate_factor[2] = 1;
883 }
884 svc_params->scaling_factor_num[0] = 1;
885 svc_params->scaling_factor_den[0] = 1;
886 if (number_spatial_layers == 2) {
887 svc_params->scaling_factor_num[0] = 1;
888 svc_params->scaling_factor_den[0] = 2;
889 svc_params->scaling_factor_num[1] = 1;
890 svc_params->scaling_factor_den[1] = 1;
891 } else if (number_spatial_layers == 3) {
892 svc_params->scaling_factor_num[0] = 1;
893 svc_params->scaling_factor_den[0] = 4;
894 svc_params->scaling_factor_num[1] = 1;
895 svc_params->scaling_factor_den[1] = 2;
896 svc_params->scaling_factor_num[2] = 1;
897 svc_params->scaling_factor_den[2] = 1;
898 }
899 }
900
BasicRateTargetingSVC3TL1SLTest()901 virtual void BasicRateTargetingSVC3TL1SLTest() {
902 cfg_.rc_buf_initial_sz = 500;
903 cfg_.rc_buf_optimal_sz = 500;
904 cfg_.rc_buf_sz = 1000;
905 cfg_.rc_dropframe_thresh = 0;
906 cfg_.rc_min_quantizer = 0;
907 cfg_.rc_max_quantizer = 63;
908 cfg_.rc_end_usage = AOM_CBR;
909 cfg_.g_lag_in_frames = 0;
910 cfg_.g_error_resilient = 1;
911
912 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
913 288, 30, 1, 0, 300);
914 const int bitrate_array[2] = { 200, 550 };
915 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
916 ResetModel();
917 number_temporal_layers_ = 3;
918 target_layer_bitrate_[0] = 50 * cfg_.rc_target_bitrate / 100;
919 target_layer_bitrate_[1] = 70 * cfg_.rc_target_bitrate / 100;
920 target_layer_bitrate_[2] = cfg_.rc_target_bitrate;
921 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
922 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
923 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.60)
924 << " The datarate for the file is lower than target by too much!";
925 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
926 << " The datarate for the file is greater than target by too much!";
927 }
928 #if CONFIG_AV1_DECODER
929 // Top temporal layers are non_reference, so exlcude them from
930 // mismatch count, since loopfilter/cdef is not applied for these on
931 // encoder side, but is always applied on decoder.
932 // This means 150 = #frames(300) - #TL2_frames(150).
933 EXPECT_EQ((int)GetMismatchFrames(), 150);
934 #endif
935 }
936
SetFrameQpSVC3TL1SLTest()937 virtual void SetFrameQpSVC3TL1SLTest() {
938 cfg_.rc_buf_initial_sz = 500;
939 cfg_.rc_buf_optimal_sz = 500;
940 cfg_.rc_buf_sz = 1000;
941 cfg_.rc_dropframe_thresh = 0;
942 cfg_.rc_min_quantizer = 0;
943 cfg_.rc_max_quantizer = 63;
944 cfg_.rc_end_usage = AOM_CBR;
945 cfg_.g_lag_in_frames = 0;
946 cfg_.g_error_resilient = 1;
947
948 user_define_frame_qp_ = 1;
949 total_frame_ = 300;
950
951 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
952 288, 30, 1, 0, 300);
953 const int bitrate_array[2] = { 200, 550 };
954 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
955 ResetModel();
956 number_temporal_layers_ = 3;
957 target_layer_bitrate_[0] = 50 * cfg_.rc_target_bitrate / 100;
958 target_layer_bitrate_[1] = 70 * cfg_.rc_target_bitrate / 100;
959 target_layer_bitrate_[2] = cfg_.rc_target_bitrate;
960 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
961 }
962
SetFrameQpSVC3TL3SLTest()963 virtual void SetFrameQpSVC3TL3SLTest() {
964 cfg_.rc_buf_initial_sz = 500;
965 cfg_.rc_buf_optimal_sz = 500;
966 cfg_.rc_buf_sz = 1000;
967 cfg_.rc_dropframe_thresh = 0;
968 cfg_.rc_min_quantizer = 0;
969 cfg_.rc_max_quantizer = 63;
970 cfg_.rc_end_usage = AOM_CBR;
971 cfg_.g_lag_in_frames = 0;
972 cfg_.g_error_resilient = 0;
973
974 user_define_frame_qp_ = 1;
975 total_frame_ = 300;
976
977 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
978 288, 30, 1, 0, 300);
979 const int bitrate_array[2] = { 600, 1200 };
980 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
981 ResetModel();
982 number_temporal_layers_ = 3;
983 number_spatial_layers_ = 3;
984 // SL0
985 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
986 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
987 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
988 target_layer_bitrate_[2] = bitrate_sl0;
989 // SL1
990 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
991 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
992 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
993 target_layer_bitrate_[5] = bitrate_sl1;
994 // SL2
995 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
996 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
997 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
998 target_layer_bitrate_[8] = bitrate_sl2;
999 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1000 }
1001
BasicRateTargetingSVC3TL1SLScreenTest()1002 virtual void BasicRateTargetingSVC3TL1SLScreenTest() {
1003 cfg_.rc_buf_initial_sz = 500;
1004 cfg_.rc_buf_optimal_sz = 500;
1005 cfg_.rc_buf_sz = 1000;
1006 cfg_.rc_dropframe_thresh = 0;
1007 cfg_.rc_min_quantizer = 0;
1008 cfg_.rc_max_quantizer = 63;
1009 cfg_.rc_end_usage = AOM_CBR;
1010 cfg_.g_lag_in_frames = 0;
1011 cfg_.g_error_resilient = 0;
1012
1013 ::libaom_test::Y4mVideoSource video("screendata.y4m", 0, 60);
1014
1015 const int bitrate_array[2] = { 1000, 1500 };
1016 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1017 ResetModel();
1018 screen_mode_ = 1;
1019 number_temporal_layers_ = 3;
1020 number_spatial_layers_ = 1;
1021 target_layer_bitrate_[0] = 50 * cfg_.rc_target_bitrate / 100;
1022 target_layer_bitrate_[1] = 70 * cfg_.rc_target_bitrate / 100;
1023 target_layer_bitrate_[2] = cfg_.rc_target_bitrate;
1024 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1025 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1026 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.40)
1027 << " The datarate for the file is lower than target by too much!";
1028 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 2.0)
1029 << " The datarate for the file is greater than target by too much!";
1030 }
1031 #if CONFIG_AV1_DECODER
1032 // Top temporal layers are non_reference, so exlcude them from
1033 // mismatch count, since loopfilter/cdef is not applied for these on
1034 // encoder side, but is always applied on decoder.
1035 // This means 30 = #frames(60) - #TL2_frames(30).
1036 // We use LE for screen since loopfilter level can become very small
1037 // or zero and then the frame is not a mismatch.
1038 EXPECT_LE((int)GetMismatchFrames(), 30);
1039 #endif
1040 }
1041
BasicRateTargetingSVC2TL1SLScreenDropFrameTest()1042 virtual void BasicRateTargetingSVC2TL1SLScreenDropFrameTest() {
1043 cfg_.rc_buf_initial_sz = 50;
1044 cfg_.rc_buf_optimal_sz = 50;
1045 cfg_.rc_buf_sz = 100;
1046 cfg_.rc_dropframe_thresh = 30;
1047 cfg_.rc_min_quantizer = 0;
1048 cfg_.rc_max_quantizer = 52;
1049 cfg_.rc_end_usage = AOM_CBR;
1050 cfg_.g_lag_in_frames = 0;
1051 cfg_.g_error_resilient = 0;
1052
1053 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1054 288, 30, 1, 0, 300);
1055
1056 const int bitrate_array[2] = { 60, 100 };
1057 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1058 ResetModel();
1059 screen_mode_ = 1;
1060 number_temporal_layers_ = 2;
1061 number_spatial_layers_ = 1;
1062 target_layer_bitrate_[0] = 60 * cfg_.rc_target_bitrate / 100;
1063 target_layer_bitrate_[1] = cfg_.rc_target_bitrate;
1064 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1065 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1066 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.75)
1067 << " The datarate for the file is lower than target by too much!";
1068 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.8)
1069 << " The datarate for the file is greater than target by too much!";
1070 }
1071 #if CONFIG_AV1_DECODER
1072 // Top temporal layers are non_reference, so exlcude them from
1073 // mismatch count, since loopfilter/cdef is not applied for these on
1074 // encoder side, but is always applied on decoder.
1075 // This means 300 = #frames(300) - #TL2_frames(150).
1076 // We use LE for screen since loopfilter level can become very small
1077 // or zero and then the frame is not a mismatch.
1078 EXPECT_LE((int)GetMismatchFrames(), 150);
1079 #endif
1080 }
1081
BasicRateTargetingSVC1TL3SLScreenTest()1082 virtual void BasicRateTargetingSVC1TL3SLScreenTest() {
1083 cfg_.rc_buf_initial_sz = 500;
1084 cfg_.rc_buf_optimal_sz = 500;
1085 cfg_.rc_buf_sz = 1000;
1086 cfg_.rc_dropframe_thresh = 0;
1087 cfg_.rc_min_quantizer = 0;
1088 cfg_.rc_max_quantizer = 63;
1089 cfg_.rc_end_usage = AOM_CBR;
1090 cfg_.g_lag_in_frames = 0;
1091 cfg_.g_error_resilient = 0;
1092
1093 ::libaom_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 0, 60);
1094
1095 const int bitrate_array[2] = { 800, 1200 };
1096 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1097 ResetModel();
1098 screen_mode_ = 1;
1099 number_temporal_layers_ = 1;
1100 number_spatial_layers_ = 3;
1101 target_layer_bitrate_[0] = 30 * cfg_.rc_target_bitrate / 100;
1102 target_layer_bitrate_[1] = 60 * cfg_.rc_target_bitrate / 100;
1103 target_layer_bitrate_[2] = cfg_.rc_target_bitrate;
1104 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1105 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1106 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.50)
1107 << " The datarate for the file is lower than target by too much!";
1108 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.5)
1109 << " The datarate for the file is greater than target by too much!";
1110 }
1111 #if CONFIG_AV1_DECODER
1112 EXPECT_EQ((int)GetMismatchFrames(), 0);
1113 #endif
1114 }
1115
BasicRateTargetingSVC1TL1SLScreenScCutsMotionTest()1116 virtual void BasicRateTargetingSVC1TL1SLScreenScCutsMotionTest() {
1117 cfg_.rc_buf_initial_sz = 500;
1118 cfg_.rc_buf_optimal_sz = 500;
1119 cfg_.rc_buf_sz = 1000;
1120 cfg_.rc_dropframe_thresh = 0;
1121 cfg_.rc_min_quantizer = 0;
1122 cfg_.rc_max_quantizer = 63;
1123 cfg_.rc_end_usage = AOM_CBR;
1124 cfg_.g_lag_in_frames = 0;
1125 cfg_.g_error_resilient = 0;
1126
1127 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1128 288, 30, 1, 0, 300);
1129
1130 const int bitrate_array[2] = { 200, 500 };
1131 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1132 ResetModel();
1133 screen_mode_ = 1;
1134 number_temporal_layers_ = 1;
1135 number_spatial_layers_ = 1;
1136 target_layer_bitrate_[0] = cfg_.rc_target_bitrate;
1137 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1138 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1139 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.40)
1140 << " The datarate for the file is lower than target by too much!";
1141 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.7)
1142 << " The datarate for the file is greater than target by too much!";
1143 }
1144 #if CONFIG_AV1_DECODER
1145 EXPECT_EQ((int)GetMismatchFrames(), 0);
1146 #endif
1147 }
1148
BasicRateTargetingSVC3TL1SLResizeTest()1149 virtual void BasicRateTargetingSVC3TL1SLResizeTest() {
1150 cfg_.rc_buf_initial_sz = 500;
1151 cfg_.rc_buf_optimal_sz = 500;
1152 cfg_.rc_buf_sz = 1000;
1153 cfg_.rc_dropframe_thresh = 0;
1154 cfg_.rc_min_quantizer = 0;
1155 cfg_.rc_max_quantizer = 63;
1156 cfg_.rc_end_usage = AOM_CBR;
1157 cfg_.g_lag_in_frames = 0;
1158 cfg_.g_error_resilient = 0;
1159 cfg_.rc_resize_mode = RESIZE_DYNAMIC;
1160
1161 ::libaom_test::I420VideoSource video("niklas_640_480_30.yuv", 640, 480, 30,
1162 1, 0, 400);
1163 cfg_.g_w = 640;
1164 cfg_.g_h = 480;
1165 const int bitrate_array[2] = { 80, 90 };
1166 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1167 ResetModel();
1168 number_temporal_layers_ = 3;
1169 target_layer_bitrate_[0] = 50 * cfg_.rc_target_bitrate / 100;
1170 target_layer_bitrate_[1] = 70 * cfg_.rc_target_bitrate / 100;
1171 target_layer_bitrate_[2] = cfg_.rc_target_bitrate;
1172 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1173 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1174 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.80)
1175 << " The datarate for the file is lower than target by too much!";
1176 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
1177 << " The datarate for the file is greater than target by too much!";
1178 }
1179 #if CONFIG_AV1_DECODER
1180 unsigned int last_w = cfg_.g_w;
1181 unsigned int last_h = cfg_.g_h;
1182 int resize_down_count = 0;
1183 for (std::vector<FrameInfo>::const_iterator info = frame_info_list_.begin();
1184 info != frame_info_list_.end(); ++info) {
1185 if (info->w != last_w || info->h != last_h) {
1186 // Verify that resize down occurs.
1187 ASSERT_LT(info->w, last_w);
1188 ASSERT_LT(info->h, last_h);
1189 last_w = info->w;
1190 last_h = info->h;
1191 resize_down_count++;
1192 }
1193 }
1194 // Must be at least one resize down.
1195 ASSERT_GE(resize_down_count, 1);
1196 #else
1197 printf("Warning: AV1 decoder unavailable, unable to check resize count!\n");
1198 #endif
1199 }
1200
BasicRateTargetingSVC1TL2SLTest()1201 virtual void BasicRateTargetingSVC1TL2SLTest() {
1202 cfg_.rc_buf_initial_sz = 500;
1203 cfg_.rc_buf_optimal_sz = 500;
1204 cfg_.rc_buf_sz = 1000;
1205 cfg_.rc_dropframe_thresh = 0;
1206 cfg_.rc_min_quantizer = 0;
1207 cfg_.rc_max_quantizer = 63;
1208 cfg_.rc_end_usage = AOM_CBR;
1209 cfg_.g_lag_in_frames = 0;
1210 cfg_.g_error_resilient = 0;
1211
1212 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1213 288, 30, 1, 0, 300);
1214 const int bitrate_array[2] = { 300, 600 };
1215 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1216 ResetModel();
1217 number_temporal_layers_ = 1;
1218 number_spatial_layers_ = 2;
1219 target_layer_bitrate_[0] = 2 * cfg_.rc_target_bitrate / 4;
1220 target_layer_bitrate_[1] = 2 * cfg_.rc_target_bitrate / 4;
1221 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1222 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1223 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.80)
1224 << " The datarate for the file is lower than target by too much!";
1225 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
1226 << " The datarate for the file is greater than target by too much!";
1227 }
1228 }
1229
BasicRateTargetingSVC3TL3SLIntraStartDecodeBaseMidSeq()1230 virtual void BasicRateTargetingSVC3TL3SLIntraStartDecodeBaseMidSeq() {
1231 cfg_.rc_buf_initial_sz = 500;
1232 cfg_.rc_buf_optimal_sz = 500;
1233 cfg_.rc_buf_sz = 1000;
1234 cfg_.rc_dropframe_thresh = 0;
1235 cfg_.rc_min_quantizer = 0;
1236 cfg_.rc_max_quantizer = 56;
1237 cfg_.rc_end_usage = AOM_CBR;
1238 cfg_.g_lag_in_frames = 0;
1239 cfg_.g_error_resilient = 0;
1240 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1241 288, 30, 1, 0, 300);
1242 const int bitrate_array[2] = { 500, 1000 };
1243 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1244 ResetModel();
1245 intra_only_ = 1;
1246 frame_sync_ = 20;
1247 frame_to_start_decoding_ = frame_sync_;
1248 layer_to_decode_ = 0;
1249 number_temporal_layers_ = 3;
1250 number_spatial_layers_ = 3;
1251 // SL0
1252 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
1253 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
1254 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
1255 target_layer_bitrate_[2] = bitrate_sl0;
1256 // SL1
1257 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
1258 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
1259 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
1260 target_layer_bitrate_[5] = bitrate_sl1;
1261 // SL2
1262 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
1263 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
1264 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
1265 target_layer_bitrate_[8] = bitrate_sl2;
1266 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1267 // Only check datarate on SL0 - this is layer that is decoded starting at
1268 // frame_to_start_decoding_.
1269 for (int i = 0; i < number_temporal_layers_; i++) {
1270 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.50)
1271 << " The datarate for the file is lower than target by too much!";
1272 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
1273 << " The datarate for the file is greater than target by too much!";
1274 }
1275 #if CONFIG_AV1_DECODER
1276 // Only base spatial layer is decoded and there are no non-referenece
1277 // frames on S0, so #mismatch must be 0.
1278 EXPECT_EQ((int)GetMismatchFrames(), 0);
1279 #endif
1280 }
1281
BasicRateTargetingSVC3TL3SLIntraMidSeqDecodeAll()1282 virtual void BasicRateTargetingSVC3TL3SLIntraMidSeqDecodeAll() {
1283 cfg_.rc_buf_initial_sz = 500;
1284 cfg_.rc_buf_optimal_sz = 500;
1285 cfg_.rc_buf_sz = 1000;
1286 cfg_.rc_dropframe_thresh = 0;
1287 cfg_.rc_min_quantizer = 0;
1288 cfg_.rc_max_quantizer = 56;
1289 cfg_.rc_end_usage = AOM_CBR;
1290 cfg_.g_lag_in_frames = 0;
1291 cfg_.g_error_resilient = 0;
1292 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1293 288, 30, 1, 0, 300);
1294 const int bitrate_array[2] = { 500, 1000 };
1295 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1296 ResetModel();
1297 intra_only_ = 1;
1298 frame_sync_ = 20;
1299 frame_to_start_decoding_ = 0;
1300 layer_to_decode_ = 3;
1301 number_temporal_layers_ = 3;
1302 number_spatial_layers_ = 3;
1303 // SL0
1304 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
1305 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
1306 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
1307 target_layer_bitrate_[2] = bitrate_sl0;
1308 // SL1
1309 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
1310 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
1311 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
1312 target_layer_bitrate_[5] = bitrate_sl1;
1313 // SL2
1314 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
1315 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
1316 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
1317 target_layer_bitrate_[8] = bitrate_sl2;
1318 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1319 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1320 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.585)
1321 << " The datarate for the file is lower than target by too much!";
1322 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
1323 << " The datarate for the file is greater than target by too much!";
1324 }
1325 #if CONFIG_AV1_DECODER
1326 // All 3 spatial layers are decoded, starting at frame 0, so there are
1327 // and there 300/2 = 150 non-reference frames, so mismatch is 150.
1328 EXPECT_EQ((int)GetMismatchFrames(), 150);
1329 #endif
1330 }
1331
BasicRateTargetingSVC3TL3SLSimulcast()1332 virtual void BasicRateTargetingSVC3TL3SLSimulcast() {
1333 cfg_.rc_buf_initial_sz = 500;
1334 cfg_.rc_buf_optimal_sz = 500;
1335 cfg_.rc_buf_sz = 1000;
1336 cfg_.rc_dropframe_thresh = 0;
1337 cfg_.rc_min_quantizer = 0;
1338 cfg_.rc_max_quantizer = 56;
1339 cfg_.rc_end_usage = AOM_CBR;
1340 cfg_.g_lag_in_frames = 0;
1341 cfg_.g_error_resilient = 0;
1342 cfg_.kf_max_dist = 150;
1343 cfg_.kf_min_dist = 150;
1344 int num_frames = 300;
1345 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1346 288, 30, 1, 0, num_frames);
1347 const int bitrate_array[2] = { 500, 1000 };
1348 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1349 ResetModel();
1350 simulcast_mode_ = 1;
1351 frame_to_start_decoding_ = cfg_.kf_max_dist;
1352 layer_to_decode_ = 2; // SL2
1353 number_temporal_layers_ = 3;
1354 number_spatial_layers_ = 3;
1355 // SL0
1356 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
1357 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
1358 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
1359 target_layer_bitrate_[2] = bitrate_sl0;
1360 // SL1
1361 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
1362 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
1363 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
1364 target_layer_bitrate_[5] = bitrate_sl1;
1365 // SL2
1366 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
1367 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
1368 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
1369 target_layer_bitrate_[8] = bitrate_sl2;
1370 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1371 // Only SL2 layer is decoded.
1372 for (int tl = 0; tl < number_temporal_layers_; tl++) {
1373 int i = layer_to_decode_ * number_temporal_layers_ + tl;
1374 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.6)
1375 << " The datarate for the file is lower than target by too much!";
1376 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.7)
1377 << " The datarate for the file is greater than target by too much!";
1378 }
1379 #if CONFIG_AV1_DECODER
1380 // Only top spatial layer (SL2) is decoded, starting at frame 150
1381 // (frame_to_start_decoding_), so there (300 - 150) / 2 = 75
1382 // non-reference frames, so mismatch is 75.
1383 int num_mismatch = (num_frames - frame_to_start_decoding_) / 2;
1384 EXPECT_EQ((int)GetMismatchFrames(), num_mismatch);
1385 #endif
1386 }
1387
BasicRateTargetingSVC1TL2SLIntraOnlyTest()1388 virtual void BasicRateTargetingSVC1TL2SLIntraOnlyTest() {
1389 cfg_.rc_buf_initial_sz = 500;
1390 cfg_.rc_buf_optimal_sz = 500;
1391 cfg_.rc_buf_sz = 1000;
1392 cfg_.rc_dropframe_thresh = 0;
1393 cfg_.rc_min_quantizer = 0;
1394 cfg_.rc_max_quantizer = 63;
1395 cfg_.rc_end_usage = AOM_CBR;
1396 cfg_.g_lag_in_frames = 0;
1397 cfg_.g_error_resilient = 0;
1398
1399 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1400 288, 30, 1, 0, 300);
1401 const int bitrate_array[2] = { 300, 600 };
1402 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1403 ResetModel();
1404 intra_only_ = 1;
1405 number_temporal_layers_ = 1;
1406 number_spatial_layers_ = 2;
1407 target_layer_bitrate_[0] = 2 * cfg_.rc_target_bitrate / 4;
1408 target_layer_bitrate_[1] = 2 * cfg_.rc_target_bitrate / 4;
1409 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1410 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1411 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.80)
1412 << " The datarate for the file is lower than target by too much!";
1413 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
1414 << " The datarate for the file is greater than target by too much!";
1415 }
1416 }
1417
BasicRateTargetingSVC1TL1SLIntraOnlyTest()1418 virtual void BasicRateTargetingSVC1TL1SLIntraOnlyTest() {
1419 cfg_.rc_buf_initial_sz = 500;
1420 cfg_.rc_buf_optimal_sz = 500;
1421 cfg_.rc_buf_sz = 1000;
1422 cfg_.rc_dropframe_thresh = 0;
1423 cfg_.rc_min_quantizer = 0;
1424 cfg_.rc_max_quantizer = 63;
1425 cfg_.rc_end_usage = AOM_CBR;
1426 cfg_.g_lag_in_frames = 0;
1427 cfg_.g_error_resilient = 0;
1428
1429 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1430 288, 30, 1, 0, 300);
1431 const int bitrate_array[2] = { 300, 600 };
1432 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1433 ResetModel();
1434 intra_only_single_layer_ = true;
1435 number_temporal_layers_ = 1;
1436 number_spatial_layers_ = 1;
1437 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1438 ASSERT_GE(effective_datarate_tl[0], cfg_.rc_target_bitrate * 0.80)
1439 << " The datarate for the file is lower than target by too much!";
1440 ASSERT_LE(effective_datarate_tl[0], cfg_.rc_target_bitrate * 1.60)
1441 << " The datarate for the file is greater than target by too much!";
1442 }
1443
BasicRateTargetingSVC1TL3SLTest()1444 virtual void BasicRateTargetingSVC1TL3SLTest() {
1445 cfg_.rc_buf_initial_sz = 500;
1446 cfg_.rc_buf_optimal_sz = 500;
1447 cfg_.rc_buf_sz = 1000;
1448 cfg_.rc_dropframe_thresh = 0;
1449 cfg_.rc_min_quantizer = 0;
1450 cfg_.rc_max_quantizer = 63;
1451 cfg_.rc_end_usage = AOM_CBR;
1452 cfg_.g_lag_in_frames = 0;
1453 cfg_.g_error_resilient = 0;
1454
1455 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1456 288, 30, 1, 0, 300);
1457 const int bitrate_array[2] = { 500, 1000 };
1458 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1459 ResetModel();
1460 number_temporal_layers_ = 1;
1461 number_spatial_layers_ = 3;
1462 target_layer_bitrate_[0] = 1 * cfg_.rc_target_bitrate / 8;
1463 target_layer_bitrate_[1] = 3 * cfg_.rc_target_bitrate / 8;
1464 target_layer_bitrate_[2] = 4 * cfg_.rc_target_bitrate / 8;
1465 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1466 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1467 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.80)
1468 << " The datarate for the file is lower than target by too much!";
1469 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.38)
1470 << " The datarate for the file is greater than target by too much!";
1471 }
1472 }
1473
BasicRateTargetingSVC1TL3SLLastIsScaledTest()1474 virtual void BasicRateTargetingSVC1TL3SLLastIsScaledTest() {
1475 cfg_.rc_buf_initial_sz = 500;
1476 cfg_.rc_buf_optimal_sz = 500;
1477 cfg_.rc_buf_sz = 1000;
1478 cfg_.rc_dropframe_thresh = 0;
1479 cfg_.rc_min_quantizer = 0;
1480 cfg_.rc_max_quantizer = 63;
1481 cfg_.rc_end_usage = AOM_CBR;
1482 cfg_.g_lag_in_frames = 0;
1483 cfg_.g_error_resilient = 0;
1484
1485 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1486 288, 30, 1, 0, 300);
1487 const int bitrate_array[2] = { 500, 1000 };
1488 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1489 ResetModel();
1490 number_temporal_layers_ = 1;
1491 number_spatial_layers_ = 3;
1492 use_last_as_scaled_ = true;
1493 target_layer_bitrate_[0] = 1 * cfg_.rc_target_bitrate / 8;
1494 target_layer_bitrate_[1] = 3 * cfg_.rc_target_bitrate / 8;
1495 target_layer_bitrate_[2] = 4 * cfg_.rc_target_bitrate / 8;
1496 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1497 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1498 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.80)
1499 << " The datarate for the file is lower than target by too much!";
1500 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.38)
1501 << " The datarate for the file is greater than target by too much!";
1502 }
1503 }
1504
BasicRateTargetingSVC1TL3SLLastIsScaledSingleRefTest()1505 virtual void BasicRateTargetingSVC1TL3SLLastIsScaledSingleRefTest() {
1506 cfg_.rc_buf_initial_sz = 500;
1507 cfg_.rc_buf_optimal_sz = 500;
1508 cfg_.rc_buf_sz = 1000;
1509 cfg_.rc_dropframe_thresh = 0;
1510 cfg_.rc_min_quantizer = 0;
1511 cfg_.rc_max_quantizer = 63;
1512 cfg_.rc_end_usage = AOM_CBR;
1513 cfg_.g_lag_in_frames = 0;
1514 cfg_.g_error_resilient = 0;
1515
1516 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1517 288, 30, 1, 0, 300);
1518 const int bitrate_array[2] = { 500, 1000 };
1519 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1520 ResetModel();
1521 number_temporal_layers_ = 1;
1522 number_spatial_layers_ = 3;
1523 use_last_as_scaled_ = true;
1524 use_last_as_scaled_single_ref_ = true;
1525 target_layer_bitrate_[0] = 1 * cfg_.rc_target_bitrate / 8;
1526 target_layer_bitrate_[1] = 3 * cfg_.rc_target_bitrate / 8;
1527 target_layer_bitrate_[2] = 4 * cfg_.rc_target_bitrate / 8;
1528 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1529 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1530 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.80)
1531 << " The datarate for the file is lower than target by too much!";
1532 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.38)
1533 << " The datarate for the file is greater than target by too much!";
1534 }
1535 }
1536
BasicRateTargetingSVC1TL3SLMultiRefTest()1537 virtual void BasicRateTargetingSVC1TL3SLMultiRefTest() {
1538 cfg_.rc_buf_initial_sz = 500;
1539 cfg_.rc_buf_optimal_sz = 500;
1540 cfg_.rc_buf_sz = 1000;
1541 cfg_.rc_dropframe_thresh = 0;
1542 cfg_.rc_min_quantizer = 0;
1543 cfg_.rc_max_quantizer = 63;
1544 cfg_.rc_end_usage = AOM_CBR;
1545 cfg_.g_lag_in_frames = 0;
1546 cfg_.g_error_resilient = 0;
1547
1548 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1549 288, 30, 1, 0, 300);
1550 const int bitrate_array[2] = { 500, 1000 };
1551 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1552 ResetModel();
1553 multi_ref_ = 1;
1554 number_temporal_layers_ = 1;
1555 number_spatial_layers_ = 3;
1556 target_layer_bitrate_[0] = 1 * cfg_.rc_target_bitrate / 8;
1557 target_layer_bitrate_[1] = 3 * cfg_.rc_target_bitrate / 8;
1558 target_layer_bitrate_[2] = 4 * cfg_.rc_target_bitrate / 8;
1559 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1560 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1561 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.80)
1562 << " The datarate for the file is lower than target by too much!";
1563 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.38)
1564 << " The datarate for the file is greater than target by too much!";
1565 }
1566 }
1567
BasicRateTargetingSVC3TL3SLTest()1568 virtual void BasicRateTargetingSVC3TL3SLTest() {
1569 cfg_.rc_buf_initial_sz = 500;
1570 cfg_.rc_buf_optimal_sz = 500;
1571 cfg_.rc_buf_sz = 1000;
1572 cfg_.rc_dropframe_thresh = 0;
1573 cfg_.rc_min_quantizer = 0;
1574 cfg_.rc_max_quantizer = 63;
1575 cfg_.rc_end_usage = AOM_CBR;
1576 cfg_.g_lag_in_frames = 0;
1577 cfg_.g_error_resilient = 0;
1578
1579 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1580 288, 30, 1, 0, 300);
1581 const int bitrate_array[2] = { 600, 1200 };
1582 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1583 ResetModel();
1584 number_temporal_layers_ = 3;
1585 number_spatial_layers_ = 3;
1586 // SL0
1587 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
1588 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
1589 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
1590 target_layer_bitrate_[2] = bitrate_sl0;
1591 // SL1
1592 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
1593 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
1594 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
1595 target_layer_bitrate_[5] = bitrate_sl1;
1596 // SL2
1597 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
1598 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
1599 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
1600 target_layer_bitrate_[8] = bitrate_sl2;
1601 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1602 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1603 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.50)
1604 << " The datarate for the file is lower than target by too much!";
1605 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.38)
1606 << " The datarate for the file is greater than target by too much!";
1607 }
1608 }
1609
BasicRateTargetingSVC3TL3SLHDTest()1610 virtual void BasicRateTargetingSVC3TL3SLHDTest() {
1611 cfg_.rc_buf_initial_sz = 500;
1612 cfg_.rc_buf_optimal_sz = 500;
1613 cfg_.rc_buf_sz = 1000;
1614 cfg_.rc_dropframe_thresh = 0;
1615 cfg_.rc_min_quantizer = 0;
1616 cfg_.rc_max_quantizer = 63;
1617 cfg_.rc_end_usage = AOM_CBR;
1618 cfg_.g_lag_in_frames = 0;
1619 cfg_.g_error_resilient = 0;
1620
1621 ::libaom_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 0, 60);
1622 const int bitrate_array[2] = { 600, 1200 };
1623 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1624 ResetModel();
1625 number_temporal_layers_ = 3;
1626 number_spatial_layers_ = 3;
1627 // SL0
1628 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
1629 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
1630 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
1631 target_layer_bitrate_[2] = bitrate_sl0;
1632 // SL1
1633 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
1634 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
1635 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
1636 target_layer_bitrate_[5] = bitrate_sl1;
1637 // SL2
1638 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
1639 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
1640 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
1641 target_layer_bitrate_[8] = bitrate_sl2;
1642 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1643 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1644 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.70)
1645 << " The datarate for the file is lower than target by too much!";
1646 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.45)
1647 << " The datarate for the file is greater than target by too much!";
1648 }
1649 }
1650
BasicRateTargetingFixedModeSVC3TL3SLHDTest()1651 virtual void BasicRateTargetingFixedModeSVC3TL3SLHDTest() {
1652 cfg_.rc_buf_initial_sz = 500;
1653 cfg_.rc_buf_optimal_sz = 500;
1654 cfg_.rc_buf_sz = 1000;
1655 cfg_.rc_dropframe_thresh = 0;
1656 cfg_.rc_min_quantizer = 0;
1657 cfg_.rc_max_quantizer = 63;
1658 cfg_.rc_end_usage = AOM_CBR;
1659 cfg_.g_lag_in_frames = 0;
1660 cfg_.g_error_resilient = 0;
1661
1662 ::libaom_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 0, 60);
1663 const int bitrate_array[2] = { 600, 1200 };
1664 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1665 ResetModel();
1666 number_temporal_layers_ = 3;
1667 number_spatial_layers_ = 3;
1668 use_fixed_mode_svc_ = 1;
1669 // SL0
1670 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
1671 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
1672 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
1673 target_layer_bitrate_[2] = bitrate_sl0;
1674 // SL1
1675 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
1676 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
1677 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
1678 target_layer_bitrate_[5] = bitrate_sl1;
1679 // SL2
1680 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
1681 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
1682 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
1683 target_layer_bitrate_[8] = bitrate_sl2;
1684 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1685 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1686 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.70)
1687 << " The datarate for the file is lower than target by too much!";
1688 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.45)
1689 << " The datarate for the file is greater than target by too much!";
1690 }
1691 }
1692
BasicRateTargetingSVC3TL3SLMultiThreadSpeedPerLayerTest()1693 virtual void BasicRateTargetingSVC3TL3SLMultiThreadSpeedPerLayerTest() {
1694 cfg_.rc_buf_initial_sz = 500;
1695 cfg_.rc_buf_optimal_sz = 500;
1696 cfg_.rc_buf_sz = 1000;
1697 cfg_.rc_dropframe_thresh = 0;
1698 cfg_.rc_min_quantizer = 0;
1699 cfg_.rc_max_quantizer = 63;
1700 cfg_.rc_end_usage = AOM_CBR;
1701 cfg_.g_lag_in_frames = 0;
1702 cfg_.g_error_resilient = 0;
1703 cfg_.g_threads = 2;
1704 ::libaom_test::I420VideoSource video("niklas_640_480_30.yuv", 640, 480, 30,
1705 1, 0, 400);
1706 cfg_.g_w = 640;
1707 cfg_.g_h = 480;
1708 const int bitrate_array[2] = { 600, 1200 };
1709 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1710 ResetModel();
1711 tile_columns_ = 1;
1712 tile_rows_ = 0;
1713 set_speed_per_layer_ = true;
1714 number_temporal_layers_ = 3;
1715 number_spatial_layers_ = 3;
1716 // SL0
1717 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
1718 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
1719 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
1720 target_layer_bitrate_[2] = bitrate_sl0;
1721 // SL1
1722 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
1723 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
1724 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
1725 target_layer_bitrate_[5] = bitrate_sl1;
1726 // SL2
1727 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
1728 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
1729 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
1730 target_layer_bitrate_[8] = bitrate_sl2;
1731 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1732 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1733 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.70)
1734 << " The datarate for the file is lower than target by too much!";
1735 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.45)
1736 << " The datarate for the file is greater than target by too much!";
1737 }
1738 }
1739
BasicRateTargetingSVC3TL3SLHDMultiThread2Test()1740 virtual void BasicRateTargetingSVC3TL3SLHDMultiThread2Test() {
1741 cfg_.rc_buf_initial_sz = 500;
1742 cfg_.rc_buf_optimal_sz = 500;
1743 cfg_.rc_buf_sz = 1000;
1744 cfg_.rc_dropframe_thresh = 0;
1745 cfg_.rc_min_quantizer = 0;
1746 cfg_.rc_max_quantizer = 63;
1747 cfg_.rc_end_usage = AOM_CBR;
1748 cfg_.g_lag_in_frames = 0;
1749 cfg_.g_error_resilient = 0;
1750 cfg_.g_threads = 2;
1751
1752 ::libaom_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 0, 60);
1753 const int bitrate_array[2] = { 600, 1200 };
1754 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1755 ResetModel();
1756 tile_columns_ = 1;
1757 tile_rows_ = 0;
1758 number_temporal_layers_ = 3;
1759 number_spatial_layers_ = 3;
1760 // SL0
1761 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
1762 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
1763 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
1764 target_layer_bitrate_[2] = bitrate_sl0;
1765 // SL1
1766 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
1767 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
1768 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
1769 target_layer_bitrate_[5] = bitrate_sl1;
1770 // SL2
1771 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
1772 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
1773 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
1774 target_layer_bitrate_[8] = bitrate_sl2;
1775 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1776 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1777 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.70)
1778 << " The datarate for the file is lower than target by too much!";
1779 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.45)
1780 << " The datarate for the file is greater than target by too much!";
1781 }
1782 }
1783
BasicRateTargetingSVC2TL1SLHDMultiThread4Test()1784 virtual void BasicRateTargetingSVC2TL1SLHDMultiThread4Test() {
1785 cfg_.rc_buf_initial_sz = 500;
1786 cfg_.rc_buf_optimal_sz = 500;
1787 cfg_.rc_buf_sz = 1000;
1788 cfg_.rc_dropframe_thresh = 0;
1789 cfg_.rc_min_quantizer = 0;
1790 cfg_.rc_max_quantizer = 63;
1791 cfg_.rc_end_usage = AOM_CBR;
1792 cfg_.g_lag_in_frames = 0;
1793 cfg_.g_error_resilient = 0;
1794 cfg_.g_threads = 4;
1795
1796 ::libaom_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 0, 60);
1797 const int bitrate_array[2] = { 600, 1200 };
1798 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1799 ResetModel();
1800 tile_columns_ = 1;
1801 tile_rows_ = 1;
1802 number_temporal_layers_ = 2;
1803 number_spatial_layers_ = 1;
1804 target_layer_bitrate_[0] = 60 * cfg_.rc_target_bitrate / 100;
1805 target_layer_bitrate_[1] = cfg_.rc_target_bitrate;
1806 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1807 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1808 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.70)
1809 << " The datarate for the file is lower than target by too much!";
1810 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.45)
1811 << " The datarate for the file is greater than target by too much!";
1812 }
1813 }
1814
BasicRateTargetingSVC2TL1SLHDMultiThread4AutoTilesTest()1815 virtual void BasicRateTargetingSVC2TL1SLHDMultiThread4AutoTilesTest() {
1816 cfg_.rc_buf_initial_sz = 500;
1817 cfg_.rc_buf_optimal_sz = 500;
1818 cfg_.rc_buf_sz = 1000;
1819 cfg_.rc_dropframe_thresh = 0;
1820 cfg_.rc_min_quantizer = 0;
1821 cfg_.rc_max_quantizer = 63;
1822 cfg_.rc_end_usage = AOM_CBR;
1823 cfg_.g_lag_in_frames = 0;
1824 cfg_.g_error_resilient = 0;
1825 cfg_.g_threads = 4;
1826
1827 ::libaom_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 0, 60);
1828 const int bitrate_array[2] = { 600, 1200 };
1829 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1830 ResetModel();
1831 auto_tiles_ = 1;
1832 number_temporal_layers_ = 2;
1833 number_spatial_layers_ = 1;
1834 target_layer_bitrate_[0] = 60 * cfg_.rc_target_bitrate / 100;
1835 target_layer_bitrate_[1] = cfg_.rc_target_bitrate;
1836 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1837 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1838 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.70)
1839 << " The datarate for the file is lower than target by too much!";
1840 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.45)
1841 << " The datarate for the file is greater than target by too much!";
1842 }
1843 }
1844
BasicRateTargetingSVC3TL3SLHDMultiThread4Test()1845 virtual void BasicRateTargetingSVC3TL3SLHDMultiThread4Test() {
1846 cfg_.rc_buf_initial_sz = 500;
1847 cfg_.rc_buf_optimal_sz = 500;
1848 cfg_.rc_buf_sz = 1000;
1849 cfg_.rc_dropframe_thresh = 0;
1850 cfg_.rc_min_quantizer = 0;
1851 cfg_.rc_max_quantizer = 63;
1852 cfg_.rc_end_usage = AOM_CBR;
1853 cfg_.g_lag_in_frames = 0;
1854 cfg_.g_error_resilient = 0;
1855 cfg_.g_threads = 4;
1856
1857 ::libaom_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 0, 60);
1858 const int bitrate_array[2] = { 600, 1200 };
1859 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1860 ResetModel();
1861 tile_columns_ = 1;
1862 tile_rows_ = 1;
1863 number_temporal_layers_ = 3;
1864 number_spatial_layers_ = 3;
1865 // SL0
1866 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
1867 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
1868 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
1869 target_layer_bitrate_[2] = bitrate_sl0;
1870 // SL1
1871 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
1872 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
1873 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
1874 target_layer_bitrate_[5] = bitrate_sl1;
1875 // SL2
1876 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
1877 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
1878 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
1879 target_layer_bitrate_[8] = bitrate_sl2;
1880 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1881 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1882 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.70)
1883 << " The datarate for the file is lower than target by too much!";
1884 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.45)
1885 << " The datarate for the file is greater than target by too much!";
1886 }
1887 }
1888
BasicRateTargetingSVC3TL3SLHDMultiRefTest()1889 virtual void BasicRateTargetingSVC3TL3SLHDMultiRefTest() {
1890 cfg_.rc_buf_initial_sz = 500;
1891 cfg_.rc_buf_optimal_sz = 500;
1892 cfg_.rc_buf_sz = 1000;
1893 cfg_.rc_dropframe_thresh = 0;
1894 cfg_.rc_min_quantizer = 0;
1895 cfg_.rc_max_quantizer = 63;
1896 cfg_.rc_end_usage = AOM_CBR;
1897 cfg_.g_lag_in_frames = 0;
1898 cfg_.g_error_resilient = 0;
1899
1900 ::libaom_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 0, 60);
1901 const int bitrate_array[2] = { 600, 1200 };
1902 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1903 ResetModel();
1904 multi_ref_ = 1;
1905 number_temporal_layers_ = 3;
1906 number_spatial_layers_ = 3;
1907 // SL0
1908 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
1909 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
1910 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
1911 target_layer_bitrate_[2] = bitrate_sl0;
1912 // SL1
1913 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
1914 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
1915 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
1916 target_layer_bitrate_[5] = bitrate_sl1;
1917 // SL2
1918 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
1919 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
1920 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
1921 target_layer_bitrate_[8] = bitrate_sl2;
1922 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1923 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1924 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.70)
1925 << " The datarate for the file is lower than target by too much!";
1926 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.45)
1927 << " The datarate for the file is greater than target by too much!";
1928 }
1929 }
1930
BasicRateTargetingSVC3TL3SLKfTest()1931 virtual void BasicRateTargetingSVC3TL3SLKfTest() {
1932 cfg_.rc_buf_initial_sz = 500;
1933 cfg_.rc_buf_optimal_sz = 500;
1934 cfg_.rc_buf_sz = 1000;
1935 cfg_.rc_dropframe_thresh = 0;
1936 cfg_.rc_min_quantizer = 0;
1937 cfg_.rc_max_quantizer = 63;
1938 cfg_.rc_end_usage = AOM_CBR;
1939 cfg_.g_lag_in_frames = 0;
1940 cfg_.g_error_resilient = 0;
1941 cfg_.kf_mode = AOM_KF_AUTO;
1942 cfg_.kf_min_dist = cfg_.kf_max_dist = 100;
1943
1944 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
1945 288, 30, 1, 0, 300);
1946 const int bitrate_array[2] = { 600, 1200 };
1947 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1948 ResetModel();
1949 number_temporal_layers_ = 3;
1950 number_spatial_layers_ = 3;
1951 // SL0
1952 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
1953 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
1954 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
1955 target_layer_bitrate_[2] = bitrate_sl0;
1956 // SL1
1957 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
1958 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
1959 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
1960 target_layer_bitrate_[5] = bitrate_sl1;
1961 // SL2
1962 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
1963 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
1964 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
1965 target_layer_bitrate_[8] = bitrate_sl2;
1966 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
1967 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
1968 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.55)
1969 << " The datarate for the file is lower than target by too much!";
1970 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.4)
1971 << " The datarate for the file is greater than target by too much!";
1972 }
1973 }
1974
BasicRateTargeting444SVC3TL3SLTest()1975 virtual void BasicRateTargeting444SVC3TL3SLTest() {
1976 cfg_.rc_buf_initial_sz = 500;
1977 cfg_.rc_buf_optimal_sz = 500;
1978 cfg_.rc_buf_sz = 1000;
1979 cfg_.rc_dropframe_thresh = 0;
1980 cfg_.rc_min_quantizer = 0;
1981 cfg_.rc_max_quantizer = 63;
1982 cfg_.rc_end_usage = AOM_CBR;
1983 cfg_.g_lag_in_frames = 0;
1984 cfg_.g_error_resilient = 0;
1985 cfg_.g_profile = 1;
1986
1987 ::libaom_test::Y4mVideoSource video("rush_hour_444.y4m", 0, 140);
1988
1989 const int bitrate_array[2] = { 600, 1200 };
1990 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
1991 ResetModel();
1992 number_temporal_layers_ = 3;
1993 number_spatial_layers_ = 3;
1994 // SL0
1995 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
1996 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
1997 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
1998 target_layer_bitrate_[2] = bitrate_sl0;
1999 // SL1
2000 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
2001 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
2002 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
2003 target_layer_bitrate_[5] = bitrate_sl1;
2004 // SL2
2005 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
2006 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
2007 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
2008 target_layer_bitrate_[8] = bitrate_sl2;
2009 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
2010 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
2011 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.70)
2012 << " The datarate for the file is lower than target by too much!";
2013 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.38)
2014 << " The datarate for the file is greater than target by too much!";
2015 }
2016 }
2017
BasicRateTargetingSVC3TL1SLMultiRefDropAllEnhTest()2018 virtual void BasicRateTargetingSVC3TL1SLMultiRefDropAllEnhTest() {
2019 cfg_.rc_buf_initial_sz = 500;
2020 cfg_.rc_buf_optimal_sz = 500;
2021 cfg_.rc_buf_sz = 1000;
2022 cfg_.rc_dropframe_thresh = 0;
2023 cfg_.rc_min_quantizer = 0;
2024 cfg_.rc_max_quantizer = 63;
2025 cfg_.rc_end_usage = AOM_CBR;
2026 cfg_.g_lag_in_frames = 0;
2027 // error_resilient can set to off/0, since for SVC the context update
2028 // is done per-layer.
2029 cfg_.g_error_resilient = 0;
2030
2031 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
2032 288, 30, 1, 0, 300);
2033 const int bitrate_array[2] = { 200, 550 };
2034 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
2035 ResetModel();
2036 multi_ref_ = 1;
2037 // Drop TL1 and TL2: #frames(300) - #TL0.
2038 drop_frames_ = 300 - 300 / 4;
2039 int n = 0;
2040 for (int i = 0; i < 300; i++) {
2041 if (i % 4 != 0) {
2042 drop_frames_list_[n] = i;
2043 n++;
2044 }
2045 }
2046 number_temporal_layers_ = 3;
2047 target_layer_bitrate_[0] = 50 * cfg_.rc_target_bitrate / 100;
2048 target_layer_bitrate_[1] = 70 * cfg_.rc_target_bitrate / 100;
2049 target_layer_bitrate_[2] = cfg_.rc_target_bitrate;
2050 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
2051 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
2052 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.60)
2053 << " The datarate for the file is lower than target by too much!";
2054 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
2055 << " The datarate for the file is greater than target by too much!";
2056 }
2057 #if CONFIG_AV1_DECODER
2058 // Test that no mismatches have been found.
2059 std::cout << " Decoded frames: " << GetDecodedFrames() << "\n";
2060 std::cout << " Mismatch frames: " << GetMismatchFrames() << "\n";
2061 EXPECT_EQ(300 - GetDecodedFrames(), drop_frames_);
2062 EXPECT_EQ((int)GetMismatchFrames(), 0);
2063 #endif
2064 }
2065
BasicRateTargetingSVC3TL1SLDropAllEnhTest()2066 virtual void BasicRateTargetingSVC3TL1SLDropAllEnhTest() {
2067 cfg_.rc_buf_initial_sz = 500;
2068 cfg_.rc_buf_optimal_sz = 500;
2069 cfg_.rc_buf_sz = 1000;
2070 cfg_.rc_dropframe_thresh = 0;
2071 cfg_.rc_min_quantizer = 0;
2072 cfg_.rc_max_quantizer = 63;
2073 cfg_.rc_end_usage = AOM_CBR;
2074 cfg_.g_lag_in_frames = 0;
2075 // error_resilient can set to off/0, since for SVC the context update
2076 // is done per-layer.
2077 cfg_.g_error_resilient = 0;
2078
2079 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
2080 288, 30, 1, 0, 300);
2081 const int bitrate_array[2] = { 200, 550 };
2082 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
2083 ResetModel();
2084 // Drop TL1 and TL2: #frames(300) - #TL0.
2085 drop_frames_ = 300 - 300 / 4;
2086 int n = 0;
2087 for (int i = 0; i < 300; i++) {
2088 if (i % 4 != 0) {
2089 drop_frames_list_[n] = i;
2090 n++;
2091 }
2092 }
2093 number_temporal_layers_ = 3;
2094 target_layer_bitrate_[0] = 50 * cfg_.rc_target_bitrate / 100;
2095 target_layer_bitrate_[1] = 70 * cfg_.rc_target_bitrate / 100;
2096 target_layer_bitrate_[2] = cfg_.rc_target_bitrate;
2097 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
2098 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
2099 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.60)
2100 << " The datarate for the file is lower than target by too much!";
2101 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
2102 << " The datarate for the file is greater than target by too much!";
2103 }
2104 #if CONFIG_AV1_DECODER
2105 // Test that no mismatches have been found.
2106 std::cout << " Decoded frames: " << GetDecodedFrames() << "\n";
2107 std::cout << " Mismatch frames: " << GetMismatchFrames() << "\n";
2108 EXPECT_EQ(300 - GetDecodedFrames(), drop_frames_);
2109 EXPECT_EQ((int)GetMismatchFrames(), 0);
2110 #endif
2111 }
2112
BasicRateTargetingSVC3TL1SLDropTL2EnhTest()2113 virtual void BasicRateTargetingSVC3TL1SLDropTL2EnhTest() {
2114 cfg_.rc_buf_initial_sz = 500;
2115 cfg_.rc_buf_optimal_sz = 500;
2116 cfg_.rc_buf_sz = 1000;
2117 cfg_.rc_dropframe_thresh = 0;
2118 cfg_.rc_min_quantizer = 0;
2119 cfg_.rc_max_quantizer = 63;
2120 cfg_.rc_end_usage = AOM_CBR;
2121 cfg_.g_lag_in_frames = 0;
2122 // error_resilient for sequence can be off/0, since dropped frames (TL2)
2123 // are non-reference frames.
2124 cfg_.g_error_resilient = 0;
2125
2126 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
2127 288, 30, 1, 0, 300);
2128 const int bitrate_array[2] = { 200, 550 };
2129 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
2130 ResetModel();
2131 // Drop TL2: #frames(300) - (#TL0 + #TL1).
2132 drop_frames_ = 300 - 300 / 2;
2133 int n = 0;
2134 for (int i = 0; i < 300; i++) {
2135 if (i % 2 != 0) {
2136 drop_frames_list_[n] = i;
2137 n++;
2138 }
2139 }
2140 number_temporal_layers_ = 3;
2141 target_layer_bitrate_[0] = 50 * cfg_.rc_target_bitrate / 100;
2142 target_layer_bitrate_[1] = 70 * cfg_.rc_target_bitrate / 100;
2143 target_layer_bitrate_[2] = cfg_.rc_target_bitrate;
2144 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
2145 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
2146 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.60)
2147 << " The datarate for the file is lower than target by too much!";
2148 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
2149 << " The datarate for the file is greater than target by too much!";
2150 }
2151 #if CONFIG_AV1_DECODER
2152 // Test that no mismatches have been found.
2153 std::cout << " Decoded frames: " << GetDecodedFrames() << "\n";
2154 std::cout << " Mismatch frames: " << GetMismatchFrames() << "\n";
2155 EXPECT_EQ(300 - GetDecodedFrames(), drop_frames_);
2156 EXPECT_EQ((int)GetMismatchFrames(), 0);
2157 #endif
2158 }
2159
BasicRateTargetingSVC3TL1SLDropAllEnhFrameERTest()2160 virtual void BasicRateTargetingSVC3TL1SLDropAllEnhFrameERTest() {
2161 cfg_.rc_buf_initial_sz = 500;
2162 cfg_.rc_buf_optimal_sz = 500;
2163 cfg_.rc_buf_sz = 1000;
2164 cfg_.rc_dropframe_thresh = 0;
2165 cfg_.rc_min_quantizer = 0;
2166 cfg_.rc_max_quantizer = 63;
2167 cfg_.rc_end_usage = AOM_CBR;
2168 cfg_.g_lag_in_frames = 0;
2169
2170 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
2171 288, 30, 1, 0, 300);
2172 const int bitrate_array[2] = { 200, 550 };
2173 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
2174 ResetModel();
2175 // Set error_resilience at frame level, with codec control,
2176 // on/1 for enahancement layers and off/0 for base layer frames.
2177 set_frame_level_er_ = 1;
2178
2179 // Drop TL1 and TL2: #frames(300) - #TL0.
2180 drop_frames_ = 300 - 300 / 4;
2181 int n = 0;
2182 for (int i = 0; i < 300; i++) {
2183 if (i % 4 != 0) {
2184 drop_frames_list_[n] = i;
2185 n++;
2186 }
2187 }
2188 number_temporal_layers_ = 3;
2189 target_layer_bitrate_[0] = 50 * cfg_.rc_target_bitrate / 100;
2190 target_layer_bitrate_[1] = 70 * cfg_.rc_target_bitrate / 100;
2191 target_layer_bitrate_[2] = cfg_.rc_target_bitrate;
2192 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
2193 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
2194 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.60)
2195 << " The datarate for the file is lower than target by too much!";
2196 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
2197 << " The datarate for the file is greater than target by too much!";
2198 }
2199 #if CONFIG_AV1_DECODER
2200 // Test that no mismatches have been found.
2201 std::cout << " Decoded frames: " << GetDecodedFrames() << "\n";
2202 std::cout << " Mismatch frames: " << GetMismatchFrames() << "\n";
2203 EXPECT_EQ(300 - GetDecodedFrames(), drop_frames_);
2204 EXPECT_EQ((int)GetMismatchFrames(), 0);
2205 #endif
2206 }
2207
BasicRateTargetingSVC3TL1SLDropSetEnhFrameERTest()2208 virtual void BasicRateTargetingSVC3TL1SLDropSetEnhFrameERTest() {
2209 cfg_.rc_buf_initial_sz = 500;
2210 cfg_.rc_buf_optimal_sz = 500;
2211 cfg_.rc_buf_sz = 1000;
2212 cfg_.rc_dropframe_thresh = 0;
2213 cfg_.rc_min_quantizer = 0;
2214 cfg_.rc_max_quantizer = 63;
2215 cfg_.rc_end_usage = AOM_CBR;
2216 cfg_.g_lag_in_frames = 0;
2217
2218 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
2219 288, 30, 1, 0, 300);
2220 const int bitrate_array[2] = { 200, 550 };
2221 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
2222 ResetModel();
2223 // Set error_resilience at frame level, with codec control,
2224 // on/1 for enahancement layers and off/0 for base layer frames.
2225 set_frame_level_er_ = 1;
2226
2227 // Drop TL1 and TL2: for part of sequence. Start at first TL2 at
2228 // frame 101, and end at second T2 at frame 199. Frame 200 is TL0,
2229 // so we can continue decoding without mismatch (since LAST is the
2230 // only reference and error_resilient = 1 on TL1/TL2 frames).
2231 int n = 0;
2232 #if CONFIG_AV1_DECODER
2233 int num_nonref = 300 / 2;
2234 #endif
2235 for (int i = 101; i < 200; i++) {
2236 if (i % 4 != 0) {
2237 drop_frames_list_[n] = i;
2238 n++;
2239 #if CONFIG_AV1_DECODER
2240 if (i % 2 != 0) num_nonref -= 1;
2241 #endif
2242 }
2243 }
2244 drop_frames_ = n;
2245 number_temporal_layers_ = 3;
2246 target_layer_bitrate_[0] = 50 * cfg_.rc_target_bitrate / 100;
2247 target_layer_bitrate_[1] = 70 * cfg_.rc_target_bitrate / 100;
2248 target_layer_bitrate_[2] = cfg_.rc_target_bitrate;
2249 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
2250 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
2251 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.60)
2252 << " The datarate for the file is lower than target by too much!";
2253 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
2254 << " The datarate for the file is greater than target by too much!";
2255 }
2256 #if CONFIG_AV1_DECODER
2257 // Test that no mismatches have been found.
2258 std::cout << " Decoded frames: " << GetDecodedFrames() << "\n";
2259 std::cout << " Mismatch frames: " << GetMismatchFrames() << "\n";
2260 EXPECT_EQ(300 - GetDecodedFrames(), drop_frames_);
2261 EXPECT_EQ((int)GetMismatchFrames(), num_nonref);
2262 #endif
2263 }
2264
BasicRateTargetingSVC2TL1SLDropSetEnhER0Test()2265 virtual void BasicRateTargetingSVC2TL1SLDropSetEnhER0Test() {
2266 cfg_.rc_buf_initial_sz = 500;
2267 cfg_.rc_buf_optimal_sz = 500;
2268 cfg_.rc_buf_sz = 1000;
2269 cfg_.rc_dropframe_thresh = 0;
2270 cfg_.rc_min_quantizer = 0;
2271 cfg_.rc_max_quantizer = 63;
2272 cfg_.rc_end_usage = AOM_CBR;
2273 cfg_.g_lag_in_frames = 0;
2274
2275 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
2276 288, 30, 1, 0, 300);
2277 const int bitrate_array[2] = { 200, 550 };
2278 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
2279 ResetModel();
2280
2281 // Set error_resilience off.
2282 cfg_.g_error_resilient = 0;
2283
2284 // Drop TL1: for part of sequence. Start at first TL1 at
2285 // frame 101, and end at frame 199. Frame 200 is TL0,
2286 // so we can continue decoding without mismatch (since LAST is the
2287 // only reference).
2288 int n = 0;
2289 #if CONFIG_AV1_DECODER
2290 int num_nonref = 300 / 2;
2291 #endif
2292 for (int i = 101; i < 200; i++) {
2293 if (i % 2 != 0) {
2294 drop_frames_list_[n] = i;
2295 n++;
2296 #if CONFIG_AV1_DECODER
2297 if (i % 2 != 0) num_nonref -= 1;
2298 #endif
2299 }
2300 }
2301 drop_frames_ = n;
2302 number_temporal_layers_ = 2;
2303 target_layer_bitrate_[0] = 70 * cfg_.rc_target_bitrate / 100;
2304 target_layer_bitrate_[1] = cfg_.rc_target_bitrate;
2305 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
2306 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
2307 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.60)
2308 << " The datarate for the file is lower than target by too much!";
2309 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
2310 << " The datarate for the file is greater than target by too much!";
2311 }
2312 #if CONFIG_AV1_DECODER
2313 // Test that no mismatches have been found.
2314 std::cout << " Decoded frames: " << GetDecodedFrames() << "\n";
2315 std::cout << " Mismatch frames: " << GetMismatchFrames() << "\n";
2316 EXPECT_EQ(300 - GetDecodedFrames(), drop_frames_);
2317 EXPECT_EQ((int)GetMismatchFrames(), num_nonref);
2318 #endif
2319 }
2320
BasicRateTargetingSVC3TL1SLDropSetEnhER0Test()2321 virtual void BasicRateTargetingSVC3TL1SLDropSetEnhER0Test() {
2322 cfg_.rc_buf_initial_sz = 500;
2323 cfg_.rc_buf_optimal_sz = 500;
2324 cfg_.rc_buf_sz = 1000;
2325 cfg_.rc_dropframe_thresh = 0;
2326 cfg_.rc_min_quantizer = 0;
2327 cfg_.rc_max_quantizer = 63;
2328 cfg_.rc_end_usage = AOM_CBR;
2329 cfg_.g_lag_in_frames = 0;
2330
2331 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
2332 288, 30, 1, 0, 300);
2333 const int bitrate_array[2] = { 200, 550 };
2334 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
2335 ResetModel();
2336
2337 // Set error_resilience off.
2338 cfg_.g_error_resilient = 0;
2339
2340 // Drop TL1 and TL2: for part of sequence. Start at first TL2 at
2341 // frame 101, and end at second T2 at frame 199. Frame 200 is TL0,
2342 // so we can continue decoding without mismatch (since LAST is the
2343 // only reference).
2344 int n = 0;
2345 #if CONFIG_AV1_DECODER
2346 int num_nonref = 300 / 2;
2347 #endif
2348 for (int i = 101; i < 200; i++) {
2349 if (i % 4 != 0) {
2350 drop_frames_list_[n] = i;
2351 n++;
2352 #if CONFIG_AV1_DECODER
2353 if (i % 2 != 0) num_nonref -= 1;
2354 #endif
2355 }
2356 }
2357 drop_frames_ = n;
2358 number_temporal_layers_ = 3;
2359 target_layer_bitrate_[0] = 50 * cfg_.rc_target_bitrate / 100;
2360 target_layer_bitrate_[1] = 70 * cfg_.rc_target_bitrate / 100;
2361 target_layer_bitrate_[2] = cfg_.rc_target_bitrate;
2362 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
2363 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
2364 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.60)
2365 << " The datarate for the file is lower than target by too much!";
2366 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
2367 << " The datarate for the file is greater than target by too much!";
2368 }
2369 #if CONFIG_AV1_DECODER
2370 // Test that no mismatches have been found.
2371 std::cout << " Decoded frames: " << GetDecodedFrames() << "\n";
2372 std::cout << " Mismatch frames: " << GetMismatchFrames() << "\n";
2373 EXPECT_EQ(300 - GetDecodedFrames(), drop_frames_);
2374 EXPECT_EQ((int)GetMismatchFrames(), num_nonref);
2375 #endif
2376 }
2377
BasicRateTargetingSVC3TL3SLDropSetEnhER0Test()2378 virtual void BasicRateTargetingSVC3TL3SLDropSetEnhER0Test() {
2379 cfg_.rc_buf_initial_sz = 500;
2380 cfg_.rc_buf_optimal_sz = 500;
2381 cfg_.rc_buf_sz = 1000;
2382 cfg_.rc_dropframe_thresh = 0;
2383 cfg_.rc_min_quantizer = 0;
2384 cfg_.rc_max_quantizer = 63;
2385 cfg_.rc_end_usage = AOM_CBR;
2386 cfg_.g_lag_in_frames = 0;
2387 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
2388 288, 30, 1, 0, 300);
2389 const int bitrate_array[2] = { 200, 550 };
2390 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
2391 ResetModel();
2392 // Set error_resilience off.
2393 cfg_.g_error_resilient = 0;
2394 // Drop TL1 and TL2: for part of sequence. Start at first TL2 at
2395 // frame 101, and end at second T2 at frame 199. Frame 200 is TL0,
2396 // so we can continue decoding without mismatch (since LAST is the
2397 // only reference).
2398 // Drop here means drop whole superframe.
2399 int n = 0;
2400 #if CONFIG_AV1_DECODER
2401 int num_nonref = 300 / 2;
2402 #endif
2403 for (int i = 101; i < 200; i++) {
2404 if (i % 4 != 0) {
2405 drop_frames_list_[n] = i;
2406 n++;
2407 #if CONFIG_AV1_DECODER
2408 if (i % 2 != 0) num_nonref -= 1;
2409 #endif
2410 }
2411 }
2412 number_temporal_layers_ = 3;
2413 number_spatial_layers_ = 3;
2414 multi_ref_ = 1;
2415 drop_frames_ = n * number_spatial_layers_;
2416 // SL0
2417 const int bitrate_sl0 = 1 * cfg_.rc_target_bitrate / 8;
2418 target_layer_bitrate_[0] = 50 * bitrate_sl0 / 100;
2419 target_layer_bitrate_[1] = 70 * bitrate_sl0 / 100;
2420 target_layer_bitrate_[2] = bitrate_sl0;
2421 // SL1
2422 const int bitrate_sl1 = 3 * cfg_.rc_target_bitrate / 8;
2423 target_layer_bitrate_[3] = 50 * bitrate_sl1 / 100;
2424 target_layer_bitrate_[4] = 70 * bitrate_sl1 / 100;
2425 target_layer_bitrate_[5] = bitrate_sl1;
2426 // SL2
2427 const int bitrate_sl2 = 4 * cfg_.rc_target_bitrate / 8;
2428 target_layer_bitrate_[6] = 50 * bitrate_sl2 / 100;
2429 target_layer_bitrate_[7] = 70 * bitrate_sl2 / 100;
2430 target_layer_bitrate_[8] = bitrate_sl2;
2431 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
2432 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
2433 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.60)
2434 << " The datarate for the file is lower than target by too much!";
2435 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
2436 << " The datarate for the file is greater than target by too much!";
2437 }
2438 #if CONFIG_AV1_DECODER
2439 // Test that no mismatches have been found.
2440 std::cout << " Decoded frames: " << GetDecodedFrames() << "\n";
2441 std::cout << " Mismatch frames: " << GetMismatchFrames() << "\n";
2442 EXPECT_EQ(300 * number_spatial_layers_ - GetDecodedFrames(), drop_frames_);
2443 EXPECT_EQ((int)GetMismatchFrames(), num_nonref);
2444 #endif
2445 }
2446
BasicRateTargetingSVC3TL1SLMultiRefCompoundTest()2447 virtual void BasicRateTargetingSVC3TL1SLMultiRefCompoundTest() {
2448 cfg_.rc_buf_initial_sz = 500;
2449 cfg_.rc_buf_optimal_sz = 500;
2450 cfg_.rc_buf_sz = 1000;
2451 cfg_.rc_dropframe_thresh = 0;
2452 cfg_.rc_min_quantizer = 0;
2453 cfg_.rc_max_quantizer = 63;
2454 cfg_.rc_end_usage = AOM_CBR;
2455 cfg_.g_lag_in_frames = 0;
2456 cfg_.g_error_resilient = 0;
2457
2458 ::libaom_test::I420VideoSource video("niklas_640_480_30.yuv", 640, 480, 30,
2459 1, 0, 400);
2460 cfg_.g_w = 640;
2461 cfg_.g_h = 480;
2462 const int bitrate_array[2] = { 400, 800 };
2463 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
2464 ResetModel();
2465 multi_ref_ = 1;
2466 comp_pred_ = 1;
2467 number_temporal_layers_ = 3;
2468 number_spatial_layers_ = 1;
2469 target_layer_bitrate_[0] = 50 * cfg_.rc_target_bitrate / 100;
2470 target_layer_bitrate_[1] = 70 * cfg_.rc_target_bitrate / 100;
2471 target_layer_bitrate_[2] = cfg_.rc_target_bitrate;
2472 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
2473 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
2474 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.80)
2475 << " The datarate for the file is lower than target by too much!";
2476 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
2477 << " The datarate for the file is greater than target by too much!";
2478 }
2479 }
2480
BasicRateTargetingSVC1TL3SLDynEnablTest()2481 virtual void BasicRateTargetingSVC1TL3SLDynEnablTest() {
2482 cfg_.rc_buf_initial_sz = 500;
2483 cfg_.rc_buf_optimal_sz = 500;
2484 cfg_.rc_buf_sz = 1000;
2485 cfg_.rc_dropframe_thresh = 0;
2486 cfg_.rc_min_quantizer = 0;
2487 cfg_.rc_max_quantizer = 63;
2488 cfg_.rc_end_usage = AOM_CBR;
2489 cfg_.g_lag_in_frames = 0;
2490 cfg_.g_error_resilient = 0;
2491
2492 ::libaom_test::I420VideoSource video("niklas_640_480_30.yuv", 640, 480, 30,
2493 1, 0, 400);
2494 const int bitrate_array[2] = { 500, 1000 };
2495 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
2496 ResetModel();
2497 number_temporal_layers_ = 1;
2498 number_spatial_layers_ = 3;
2499 target_layer_bitrate_[0] = 1 * cfg_.rc_target_bitrate / 8;
2500 target_layer_bitrate_[1] = 3 * cfg_.rc_target_bitrate / 8;
2501 target_layer_bitrate_[2] = 4 * cfg_.rc_target_bitrate / 8;
2502 dynamic_enable_disable_mode_ = 1;
2503 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
2504 // No need to check RC on top layer which is disabled part of the time.
2505 for (int i = 0; i < number_spatial_layers_ - 1; i++) {
2506 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.80)
2507 << " The datarate for the file is lower than target by too much!";
2508 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.38)
2509 << " The datarate for the file is greater than target by too much!";
2510 }
2511 }
2512
BasicRateTargetingSVC1TL3SLDynDisEnablTest()2513 virtual void BasicRateTargetingSVC1TL3SLDynDisEnablTest() {
2514 cfg_.rc_buf_initial_sz = 500;
2515 cfg_.rc_buf_optimal_sz = 500;
2516 cfg_.rc_buf_sz = 1000;
2517 cfg_.rc_dropframe_thresh = 0;
2518 cfg_.rc_min_quantizer = 0;
2519 cfg_.rc_max_quantizer = 63;
2520 cfg_.rc_end_usage = AOM_CBR;
2521 cfg_.g_lag_in_frames = 0;
2522 cfg_.g_error_resilient = 0;
2523
2524 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
2525 288, 30, 1, 0, 300);
2526 const int bitrate_array[2] = { 500, 1000 };
2527 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
2528 ResetModel();
2529 number_temporal_layers_ = 1;
2530 number_spatial_layers_ = 3;
2531 target_layer_bitrate_[0] = 1 * cfg_.rc_target_bitrate / 8;
2532 target_layer_bitrate_[1] = 3 * cfg_.rc_target_bitrate / 8;
2533 target_layer_bitrate_[2] = 4 * cfg_.rc_target_bitrate / 8;
2534 dynamic_enable_disable_mode_ = 2;
2535 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
2536 // No need to check RC on top layer which is disabled part of the time.
2537 for (int i = 0; i < number_spatial_layers_ - 1; i++) {
2538 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.80)
2539 << " The datarate for the file is lower than target by too much!";
2540 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.38)
2541 << " The datarate for the file is greater than target by too much!";
2542 }
2543 }
2544
BasicRateTargetingRPS1TL1SLDropFramesTest()2545 virtual void BasicRateTargetingRPS1TL1SLDropFramesTest() {
2546 cfg_.rc_buf_initial_sz = 500;
2547 cfg_.rc_buf_optimal_sz = 500;
2548 cfg_.rc_buf_sz = 1000;
2549 cfg_.rc_dropframe_thresh = 0;
2550 cfg_.rc_min_quantizer = 0;
2551 cfg_.rc_max_quantizer = 63;
2552 cfg_.rc_end_usage = AOM_CBR;
2553 cfg_.g_lag_in_frames = 0;
2554
2555 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
2556 288, 30, 1, 0, 300);
2557 const int bitrate_array[2] = { 100, 300 };
2558 cfg_.rc_target_bitrate = bitrate_array[GET_PARAM(4)];
2559 ResetModel();
2560 rps_mode_ = 1;
2561 rps_recovery_frame_ = 100;
2562 cfg_.g_error_resilient = 0;
2563 // Drop x frames before the recovery frames (where the reference
2564 // is switched to an older reference (golden or altref).
2565 // GOLDEN is 8 frames behind (for the rps pattern example) so we can't
2566 // drop more than 8 frames recovery frame, so choose x = 7.
2567 int n = 0;
2568 for (int i = rps_recovery_frame_ - 7; i < rps_recovery_frame_; i++) {
2569 drop_frames_list_[n] = i;
2570 n++;
2571 }
2572 drop_frames_ = n;
2573 number_spatial_layers_ = 1;
2574 number_temporal_layers_ = 1;
2575 target_layer_bitrate_[0] = cfg_.rc_target_bitrate;
2576 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
2577 for (int i = 0; i < number_temporal_layers_ * number_spatial_layers_; i++) {
2578 ASSERT_GE(effective_datarate_tl[i], target_layer_bitrate_[i] * 0.60)
2579 << " The datarate for the file is lower than target by too much!";
2580 ASSERT_LE(effective_datarate_tl[i], target_layer_bitrate_[i] * 1.60)
2581 << " The datarate for the file is greater than target by too much!";
2582 }
2583 #if CONFIG_AV1_DECODER
2584 // Test that no mismatches have been found.
2585 std::cout << " Decoded frames: " << GetDecodedFrames() << "\n";
2586 std::cout << " Mismatch frames: " << GetMismatchFrames() << "\n";
2587 EXPECT_EQ(300 - GetDecodedFrames(), drop_frames_);
2588 EXPECT_EQ((int)GetMismatchFrames(), 0);
2589 #endif
2590 }
2591
2592 int layer_frame_cnt_;
2593 int superframe_cnt_;
2594 int number_temporal_layers_;
2595 int number_spatial_layers_;
2596 // Allow for up to 3 temporal layers.
2597 int target_layer_bitrate_[AOM_MAX_LAYERS];
2598 aom_svc_params_t svc_params_;
2599 aom_svc_ref_frame_config_t ref_frame_config_;
2600 aom_svc_ref_frame_comp_pred_t ref_frame_comp_pred_;
2601 aom_svc_layer_id_t layer_id_;
2602 double effective_datarate_tl[AOM_MAX_LAYERS];
2603 unsigned int drop_frames_;
2604 unsigned int drop_frames_list_[1000];
2605 unsigned int mismatch_nframes_;
2606 unsigned int decoded_nframes_;
2607 double mismatch_psnr_;
2608 int set_frame_level_er_;
2609 int multi_ref_;
2610 int use_fixed_mode_svc_;
2611 int comp_pred_;
2612 int dynamic_enable_disable_mode_;
2613 int intra_only_;
2614 int intra_only_single_layer_;
2615 unsigned int frame_to_start_decoding_;
2616 unsigned int layer_to_decode_;
2617 unsigned int frame_sync_;
2618 unsigned int current_video_frame_;
2619 int screen_mode_;
2620 int rps_mode_;
2621 int rps_recovery_frame_;
2622 int simulcast_mode_;
2623 bool use_last_as_scaled_;
2624 bool use_last_as_scaled_single_ref_;
2625
2626 int user_define_frame_qp_;
2627 int frame_qp_;
2628 int total_frame_;
2629 bool set_speed_per_layer_;
2630 libaom_test::ACMRandom rnd_;
2631 };
2632
2633 // Check basic rate targeting for CBR, for 3 temporal layers, 1 spatial.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC3TL1SL)2634 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL1SL) {
2635 BasicRateTargetingSVC3TL1SLTest();
2636 }
2637
TEST_P(DatarateTestSVC,SetFrameQpSVC3TL1SL)2638 TEST_P(DatarateTestSVC, SetFrameQpSVC3TL1SL) { SetFrameQpSVC3TL1SLTest(); }
2639
TEST_P(DatarateTestSVC,SetFrameQpSVC3TL3SL)2640 TEST_P(DatarateTestSVC, SetFrameQpSVC3TL3SL) { SetFrameQpSVC3TL3SLTest(); }
2641
2642 // Check basic rate targeting for CBR, for 3 temporal layers, 1 spatial
2643 // for screen mode.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC3TL1SLScreen)2644 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL1SLScreen) {
2645 BasicRateTargetingSVC3TL1SLScreenTest();
2646 }
2647
2648 // Check basic rate targeting for CBR, for 2 temporal layers, 1 spatial
2649 // for screen mode, with frame dropper on at low bitrates. Use small
2650 // values of rc_buf_initial/optimal/sz to trigger postencode frame drop.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC2TL1SLScreenDropFrame)2651 TEST_P(DatarateTestSVC, BasicRateTargetingSVC2TL1SLScreenDropFrame) {
2652 BasicRateTargetingSVC2TL1SLScreenDropFrameTest();
2653 }
2654
2655 // Check basic rate targeting for CBR, for 3 spatial layers, 1 temporal
2656 // for screen mode.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC1TL3SLScreen)2657 TEST_P(DatarateTestSVC, BasicRateTargetingSVC1TL3SLScreen) {
2658 BasicRateTargetingSVC1TL3SLScreenTest();
2659 }
2660
2661 // Check basic rate targeting for CBR, for 1 temporal layer, 1 spatial
2662 // for screen mode, with source with many scene cuts and motion.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC1TL1SLScreenScCutsMotion)2663 TEST_P(DatarateTestSVC, BasicRateTargetingSVC1TL1SLScreenScCutsMotion) {
2664 BasicRateTargetingSVC1TL1SLScreenScCutsMotionTest();
2665 }
2666
2667 // Check basic rate targeting for CBR, for 3 temporal layers, 1 spatial,
2668 // with dynamic resize on. Encode at very low bitrate and check that
2669 // there is at least one resize (down) event.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC3TL1SLResize)2670 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL1SLResize) {
2671 BasicRateTargetingSVC3TL1SLResizeTest();
2672 }
2673
2674 // Check basic rate targeting for CBR, for 2 spatial layers, 1 temporal.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC1TL2SL)2675 TEST_P(DatarateTestSVC, BasicRateTargetingSVC1TL2SL) {
2676 BasicRateTargetingSVC1TL2SLTest();
2677 }
2678
2679 // Check basic rate targeting for CBR, for 3 spatial layers, 3 temporal,
2680 // with Intra-only frame inserted in the stream. Verify that we can start
2681 // decoding the SL0 stream at the intra_only frame in mid-sequence.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC3TL3SLIntraStartDecodeBaseMidSeq)2682 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL3SLIntraStartDecodeBaseMidSeq) {
2683 BasicRateTargetingSVC3TL3SLIntraStartDecodeBaseMidSeq();
2684 }
2685
2686 // Check basic rate targeting for CBR, for 3spatial layers, 3 temporal,
2687 // with Intra-only frame inserted in the stream. Verify that we can
2688 // decode all frames and layers with no mismatch.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC3TL3SLIntraMidSeqDecodeAll)2689 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL3SLIntraMidSeqDecodeAll) {
2690 BasicRateTargetingSVC3TL3SLIntraMidSeqDecodeAll();
2691 }
2692
2693 // Check simulcast mode for 3 spatial layers, 3 temporal,
2694 // Key frame is inserted on base SLO in mid-stream, and verify that the
2695 // top spatial layer (SL2) case be decoded, starting with an Intra-only frame.
2696 // Verify that we can decode all frames for SL2 with no mismatch.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC3TL3SLSimulcast)2697 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL3SLSimulcast) {
2698 BasicRateTargetingSVC3TL3SLSimulcast();
2699 }
2700
2701 // Check basic rate targeting for CBR, for 2 spatial layers, 1 temporal,
2702 // with Intra-only frame inserted in the stream.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC1TL2SLIntraOnly)2703 TEST_P(DatarateTestSVC, BasicRateTargetingSVC1TL2SLIntraOnly) {
2704 BasicRateTargetingSVC1TL2SLIntraOnlyTest();
2705 }
2706
2707 // Check basic rate targeting for CBR, for 1 spatial layers, 1 temporal,
2708 // with Intra-only frame (frame with no references) inserted in the stream.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC1TL1SLIntraOnly)2709 TEST_P(DatarateTestSVC, BasicRateTargetingSVC1TL1SLIntraOnly) {
2710 BasicRateTargetingSVC1TL1SLIntraOnlyTest();
2711 }
2712
2713 // Check basic rate targeting for CBR, for 3 spatial layers, 1 temporal.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC1TL3SL)2714 TEST_P(DatarateTestSVC, BasicRateTargetingSVC1TL3SL) {
2715 BasicRateTargetingSVC1TL3SLTest();
2716 }
2717
2718 // Check basic rate targeting for CBR, for 3 spatial layers, 1 temporal.
2719 // Force the spatial reference to be LAST, with a second temporal
2720 // reference (GOLDEN).
TEST_P(DatarateTestSVC,BasicRateTargetingSVC1TL3SLLastIsScaled)2721 TEST_P(DatarateTestSVC, BasicRateTargetingSVC1TL3SLLastIsScaled) {
2722 BasicRateTargetingSVC1TL3SLLastIsScaledTest();
2723 }
2724
2725 // Check basic rate targeting for CBR, for 3 spatial layers, 1 temporal.
2726 // Force the spatial reference to be LAST, and force only 1 reference.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC1TL3SLastIsScaledSingleRef)2727 TEST_P(DatarateTestSVC, BasicRateTargetingSVC1TL3SLastIsScaledSingleRef) {
2728 BasicRateTargetingSVC1TL3SLLastIsScaledSingleRefTest();
2729 }
2730
2731 // Check basic rate targeting for CBR, for 3 spatial layers, 1 temporal,
2732 // with additional temporal reference for top spatial layer.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC1TL3SLMultiRef)2733 TEST_P(DatarateTestSVC, BasicRateTargetingSVC1TL3SLMultiRef) {
2734 BasicRateTargetingSVC1TL3SLMultiRefTest();
2735 }
2736
2737 // Check basic rate targeting for CBR, for 3 spatial, 3 temporal layers.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC3TL3SL)2738 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL3SL) {
2739 BasicRateTargetingSVC3TL3SLTest();
2740 }
2741
2742 // Check basic rate targeting for CBR, for 3 spatial, 3 temporal layers.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC3TL3SLHD)2743 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL3SLHD) {
2744 BasicRateTargetingSVC3TL3SLHDTest();
2745 }
2746
2747 // Check basic rate targeting for CBR, for 3 spatial, 3 temporal layers,
2748 // for fixed mode SVC.
TEST_P(DatarateTestSVC,BasicRateTargetingFixedModeSVC3TL3SLHD)2749 TEST_P(DatarateTestSVC, BasicRateTargetingFixedModeSVC3TL3SLHD) {
2750 BasicRateTargetingFixedModeSVC3TL3SLHDTest();
2751 }
2752
2753 // Check basic rate targeting for CBR, for 3 spatial, 3 temporal layers,
2754 // for 2 threads, 2 tile_columns, row-mt enabled, and different speed
2755 // per layer.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC3TL3SLMultiThreadSpeedPerLayer)2756 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL3SLMultiThreadSpeedPerLayer) {
2757 BasicRateTargetingSVC3TL3SLMultiThreadSpeedPerLayerTest();
2758 }
2759
2760 // Check basic rate targeting for CBR, for 3 spatial, 3 temporal layers,
2761 // for 2 threads, 2 tile_columns, row-mt enabled.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC3TL3SLHDMultiThread2)2762 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL3SLHDMultiThread2) {
2763 BasicRateTargetingSVC3TL3SLHDMultiThread2Test();
2764 }
2765
2766 // Check basic rate targeting for CBR, for 1 spatial, 2 temporal layers,
2767 // for 4 threads, 2 tile_columns, 2 tiles_rows, row-mt enabled.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC2TL1SLHDMultiThread4)2768 TEST_P(DatarateTestSVC, BasicRateTargetingSVC2TL1SLHDMultiThread4) {
2769 BasicRateTargetingSVC2TL1SLHDMultiThread4Test();
2770 }
2771
2772 // Check basic rate targeting for CBR, for 1 spatial, 2 temporal layers,
2773 // for 4 threads, row-mt enabled, and auto_tiling enabled.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC2TL1SLHDMultiThread4AutoTiles)2774 TEST_P(DatarateTestSVC, BasicRateTargetingSVC2TL1SLHDMultiThread4AutoTiles) {
2775 BasicRateTargetingSVC2TL1SLHDMultiThread4AutoTilesTest();
2776 }
2777 // Check basic rate targeting for CBR, for 3 spatial, 3 temporal layers,
2778 // for 4 threads, 2 tile_columns, 2 tiles_rows, row-mt enabled.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC3TL3SLHDMultiThread4)2779 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL3SLHDMultiThread4) {
2780 BasicRateTargetingSVC3TL3SLHDMultiThread4Test();
2781 }
2782
2783 // Check basic rate targeting for CBR, for 3 spatial, 3 temporal layers,
2784 // with additional temporal reference for top spatial layer.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC3TL3SLHDMultiRef)2785 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL3SLHDMultiRef) {
2786 BasicRateTargetingSVC3TL3SLHDMultiRefTest();
2787 }
2788
2789 // Check basic rate targeting for CBR, for 3 spatial, 3 temporal layers,
2790 // for auto key frame mode with short key frame period.
TEST_P(DatarateTestSVC,BasicRateTargetingSVC3TL3SLKf)2791 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL3SLKf) {
2792 BasicRateTargetingSVC3TL3SLKfTest();
2793 }
2794
2795 // Check basic rate targeting for CBR, for 3 spatial, 3 temporal layers,
2796 // for 4:4:4 input.
2797 #if defined(CONFIG_MAX_DECODE_PROFILE) && CONFIG_MAX_DECODE_PROFILE < 1
TEST_P(DatarateTestSVC,DISABLED_BasicRateTargeting444SVC3TL3SL)2798 TEST_P(DatarateTestSVC, DISABLED_BasicRateTargeting444SVC3TL3SL) {
2799 #else
2800 TEST_P(DatarateTestSVC, BasicRateTargeting444SVC3TL3SL) {
2801 #endif
2802 BasicRateTargeting444SVC3TL3SLTest();
2803 }
2804
2805 // Check basic rate targeting for CBR, for 3 temporal layers, 1 spatial layer,
2806 // with dropping of all enhancement layers (TL 1 and TL2). Check that the base
2807 // layer (TL0) can still be decodeable (with no mismatch) with the
2808 // error_resilient flag set to 0. This test used the pattern with multiple
2809 // references (last, golden, and altref), updated on base layer.
2810 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL1SLMultiRefDropAllEnh) {
2811 BasicRateTargetingSVC3TL1SLMultiRefDropAllEnhTest();
2812 }
2813
2814 // Check basic rate targeting for CBR, for 3 temporal layers, 1 spatial layer,
2815 // with dropping of all enhancement layers (TL 1 and TL2). Check that the base
2816 // layer (TL0) can still be decodeable (with no mismatch) with the
2817 // error_resilient flag set to 0.
2818 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL1SLDropAllEnh) {
2819 BasicRateTargetingSVC3TL1SLDropAllEnhTest();
2820 }
2821
2822 // Check basic rate targeting for CBR, for 3 temporal layers, 1 spatial layer,
2823 // with dropping of the TL2 enhancement layer, which are non-reference
2824 // (droppble) frames. For the base layer (TL0) and TL1 to still be decodeable
2825 // (with no mismatch), the error_resilient_flag may be off (set to 0),
2826 // since TL2 are non-reference frames.
2827 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL1SLDropTL2Enh) {
2828 BasicRateTargetingSVC3TL1SLDropTL2EnhTest();
2829 }
2830
2831 // Check basic rate targeting for CBR, for 3 temporal layers, 1 spatial layer,
2832 // with dropping of all enhancement layers (TL 1 and TL2). Test that the
2833 // error_resilient flag can be set at frame level, with on/1 on
2834 // enhancement layers and off/0 on base layer.
2835 // This allows for successful decoding after dropping enhancement layer frames.
2836 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL1SLDropAllEnhFrameER) {
2837 BasicRateTargetingSVC3TL1SLDropAllEnhFrameERTest();
2838 }
2839
2840 // Check basic rate targeting for CBR, for 3 temporal layers, 1 spatial layer,
2841 // with dropping set of enhancement layers (TL 1 and TL2) in middle of sequence.
2842 // Test that the error_resilient flag can be set at frame level, with on/1 on
2843 // enhancement layers and off/0 on base layer.
2844 // This allows for successful decoding after dropping a set enhancement layer
2845 // frames in the sequence.
2846 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL1SLDropSetEnhFrameER) {
2847 BasicRateTargetingSVC3TL1SLDropSetEnhFrameERTest();
2848 }
2849
2850 // Check basic rate targeting for CBR, for 2 temporal layers, 1 spatial layer,
2851 // with dropping set of enhancement layers (TL 1) in middle of sequence.
2852 // Test that the error_resilient flag can be 0/off for all frames.
2853 // This allows for successful decoding after dropping a set enhancement layer
2854 // frames in the sequence.
2855 TEST_P(DatarateTestSVC, BasicRateTargetingSVC2TL1SLDropSetEnhER0) {
2856 BasicRateTargetingSVC2TL1SLDropSetEnhER0Test();
2857 }
2858
2859 // Check basic rate targeting for CBR, for 3 temporal layers, 1 spatial layer,
2860 // with dropping set of enhancement layers (TL 1 and TL2) in middle of sequence.
2861 // Test that the error_resilient flag can be 0/off for all frames.
2862 // This allows for successful decoding after dropping a set enhancement layer
2863 // frames in the sequence.
2864 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL1SLDropSetEnhER0) {
2865 BasicRateTargetingSVC3TL1SLDropSetEnhER0Test();
2866 }
2867
2868 // Check basic rate targeting for CBR, for 3 temporal layers, 3 spatial layers,
2869 // with dropping set of enhancement layers (superframe TL 1 and TL2) in middle
2870 // of sequence. Test that the error_resilient flag can be 0/off for all frames.
2871 // This allows for successful decoding after dropping a set enhancement layer
2872 // frames in the sequence.
2873 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL3SLDropSetEnhER0) {
2874 BasicRateTargetingSVC3TL3SLDropSetEnhER0Test();
2875 }
2876
2877 // Check basic rate targeting for CBR, for 3 temporal layers, 1 spatial layer,
2878 // with compound prediction on, for pattern with two additional refereces
2879 // (golden and altref), both updated on base TLO frames.
2880 TEST_P(DatarateTestSVC, BasicRateTargetingSVC3TL1SLMultiRefCompound) {
2881 BasicRateTargetingSVC3TL1SLMultiRefCompoundTest();
2882 }
2883
2884 // Check basic rate targeting for CBR, for 3 spatial layers, 1 temporal,
2885 // with the top spatial layer starting disabled (0 bitrate) and then
2886 // dynamically enabled after x frames with nonzero bitrate.
2887 TEST_P(DatarateTestSVC, BasicRateTargetingSVC1TL3SLDynEnabl) {
2888 BasicRateTargetingSVC1TL3SLDynEnablTest();
2889 }
2890
2891 // Check basic rate targeting for CBR, for 3 spatial layers, 1 temporal,
2892 // with the top spatial layer dynamically disabled snd enabled during the
2893 // middle of the sequence.
2894 TEST_P(DatarateTestSVC, BasicRateTargetingSVC1TL3SLDynDisEnabl) {
2895 BasicRateTargetingSVC1TL3SLDynDisEnablTest();
2896 }
2897
2898 // Check basic rate targeting and encoder/decodermismatch, for RPS
2899 // with 1 layer. A number of consecutive frames are lost midway in
2900 // sequence, and encoder resorts to a longer term reference to recovery
2901 // and continue decoding successfully.
2902 TEST_P(DatarateTestSVC, BasicRateTargetingRPS1TL1SLDropFrames) {
2903 BasicRateTargetingRPS1TL1SLDropFramesTest();
2904 }
2905
2906 TEST(SvcParams, BitrateOverflow) {
2907 uint8_t buf[6] = { 0 };
2908 aom_image_t img;
2909 aom_codec_ctx_t enc;
2910 aom_codec_enc_cfg_t cfg;
2911
2912 EXPECT_EQ(&img, aom_img_wrap(&img, AOM_IMG_FMT_I420, 1, 1, 1, buf));
2913
2914 aom_codec_iface_t *const iface = aom_codec_av1_cx();
2915 EXPECT_EQ(aom_codec_enc_config_default(iface, &cfg, AOM_USAGE_REALTIME),
2916 AOM_CODEC_OK);
2917 cfg.g_w = 1;
2918 cfg.g_h = 1;
2919 ASSERT_EQ(aom_codec_enc_init(&enc, iface, &cfg, 0), AOM_CODEC_OK);
2920
2921 aom_svc_params_t svc_params = {};
2922 svc_params.framerate_factor[0] = 1;
2923 svc_params.framerate_factor[1] = 2;
2924 svc_params.number_spatial_layers = 1;
2925 svc_params.number_temporal_layers = 2;
2926 svc_params.layer_target_bitrate[0] = INT_MAX;
2927 svc_params.layer_target_bitrate[1] = INT_MAX;
2928 EXPECT_EQ(aom_codec_control(&enc, AV1E_SET_SVC_PARAMS, &svc_params),
2929 AOM_CODEC_OK);
2930 EXPECT_EQ(
2931 aom_codec_encode(&enc, &img, /*pts=*/0, /*duration=*/1, /*flags=*/0),
2932 AOM_CODEC_OK);
2933 EXPECT_EQ(aom_codec_encode(&enc, /*img=*/nullptr, /*pts=*/0, /*duration=*/0,
2934 /*flags=*/0),
2935 AOM_CODEC_OK);
2936 EXPECT_EQ(aom_codec_destroy(&enc), AOM_CODEC_OK);
2937 }
2938
2939 AV1_INSTANTIATE_TEST_SUITE(DatarateTestSVC,
2940 ::testing::Values(::libaom_test::kRealTime),
2941 ::testing::Range(7, 12), ::testing::Values(0, 3),
2942 ::testing::Values(0, 1));
2943
2944 } // namespace
2945 } // namespace datarate_test
2946