1 /*
2 * Copyright (c) 2016, 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 <string>
13 #include <vector>
14 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
15 #include "test/codec_factory.h"
16 #include "test/encode_test_driver.h"
17 #include "test/md5_helper.h"
18 #include "test/util.h"
19 #include "test/y4m_video_source.h"
20 #include "test/yuv_video_source.h"
21 #include "av1/encoder/firstpass.h"
22
23 namespace {
24 const unsigned int kCqLevel = 18;
25
26 #if !CONFIG_REALTIME_ONLY
27 const size_t kFirstPassStatsSz = sizeof(FIRSTPASS_STATS);
28 class AVxFirstPassEncoderThreadTest
29 : public ::libaom_test::CodecTestWith4Params<libaom_test::TestMode, int,
30 int, int>,
31 public ::libaom_test::EncoderTest {
32 protected:
AVxFirstPassEncoderThreadTest()33 AVxFirstPassEncoderThreadTest()
34 : EncoderTest(GET_PARAM(0)), encoder_initialized_(false),
35 encoding_mode_(GET_PARAM(1)), set_cpu_used_(GET_PARAM(2)),
36 tile_rows_(GET_PARAM(3)), tile_cols_(GET_PARAM(4)) {
37 init_flags_ = AOM_CODEC_USE_PSNR;
38
39 row_mt_ = 1;
40 firstpass_stats_.buf = nullptr;
41 firstpass_stats_.sz = 0;
42 }
~AVxFirstPassEncoderThreadTest()43 ~AVxFirstPassEncoderThreadTest() override { free(firstpass_stats_.buf); }
44
SetUp()45 void SetUp() override {
46 InitializeConfig(encoding_mode_);
47
48 cfg_.g_lag_in_frames = 35;
49 cfg_.rc_end_usage = AOM_VBR;
50 cfg_.rc_2pass_vbr_minsection_pct = 5;
51 cfg_.rc_2pass_vbr_maxsection_pct = 2000;
52 cfg_.rc_max_quantizer = 56;
53 cfg_.rc_min_quantizer = 0;
54 }
55
BeginPassHook(unsigned int)56 void BeginPassHook(unsigned int /*pass*/) override {
57 encoder_initialized_ = false;
58 abort_ = false;
59 }
60
EndPassHook()61 void EndPassHook() override {
62 // For first pass stats test, only run first pass encoder.
63 if (cfg_.g_pass == AOM_RC_FIRST_PASS) abort_ = true;
64 }
65
PreEncodeFrameHook(::libaom_test::VideoSource *,::libaom_test::Encoder * encoder)66 void PreEncodeFrameHook(::libaom_test::VideoSource * /*video*/,
67 ::libaom_test::Encoder *encoder) override {
68 if (!encoder_initialized_) {
69 // Encode in 2-pass mode.
70 SetTileSize(encoder);
71 encoder->Control(AV1E_SET_ROW_MT, row_mt_);
72 encoder->Control(AOME_SET_CPUUSED, set_cpu_used_);
73 encoder->Control(AOME_SET_ENABLEAUTOALTREF, 1);
74 encoder->Control(AOME_SET_ARNR_MAXFRAMES, 7);
75 encoder->Control(AOME_SET_ARNR_STRENGTH, 5);
76 encoder->Control(AV1E_SET_FRAME_PARALLEL_DECODING, 0);
77
78 encoder_initialized_ = true;
79 }
80 }
81
SetTileSize(libaom_test::Encoder * encoder)82 virtual void SetTileSize(libaom_test::Encoder *encoder) {
83 encoder->Control(AV1E_SET_TILE_COLUMNS, tile_cols_);
84 encoder->Control(AV1E_SET_TILE_ROWS, tile_rows_);
85 }
86
StatsPktHook(const aom_codec_cx_pkt_t * pkt)87 void StatsPktHook(const aom_codec_cx_pkt_t *pkt) override {
88 const uint8_t *const pkt_buf =
89 reinterpret_cast<uint8_t *>(pkt->data.twopass_stats.buf);
90 const size_t pkt_size = pkt->data.twopass_stats.sz;
91
92 // First pass stats size equals sizeof(FIRSTPASS_STATS)
93 EXPECT_EQ(pkt_size, kFirstPassStatsSz)
94 << "Error: First pass stats size doesn't equal kFirstPassStatsSz";
95
96 firstpass_stats_.buf =
97 realloc(firstpass_stats_.buf, firstpass_stats_.sz + pkt_size);
98 ASSERT_NE(firstpass_stats_.buf, nullptr);
99 memcpy((uint8_t *)firstpass_stats_.buf + firstpass_stats_.sz, pkt_buf,
100 pkt_size);
101 firstpass_stats_.sz += pkt_size;
102 }
103
104 bool encoder_initialized_;
105 ::libaom_test::TestMode encoding_mode_;
106 int set_cpu_used_;
107 int tile_rows_;
108 int tile_cols_;
109 int row_mt_;
110 aom_fixed_buf_t firstpass_stats_;
111 };
112
compare_fp_stats_md5(aom_fixed_buf_t * fp_stats)113 static void compare_fp_stats_md5(aom_fixed_buf_t *fp_stats) {
114 // fp_stats consists of 2 set of first pass encoding stats. These 2 set of
115 // stats are compared to check if the stats match.
116 uint8_t *stats1 = reinterpret_cast<uint8_t *>(fp_stats->buf);
117 uint8_t *stats2 = stats1 + fp_stats->sz / 2;
118 ::libaom_test::MD5 md5_row_mt_0, md5_row_mt_1;
119
120 md5_row_mt_0.Add(stats1, fp_stats->sz / 2);
121 const char *md5_row_mt_0_str = md5_row_mt_0.Get();
122
123 md5_row_mt_1.Add(stats2, fp_stats->sz / 2);
124 const char *md5_row_mt_1_str = md5_row_mt_1.Get();
125
126 // Check md5 match.
127 ASSERT_STREQ(md5_row_mt_0_str, md5_row_mt_1_str)
128 << "MD5 checksums don't match";
129 }
130
TEST_P(AVxFirstPassEncoderThreadTest,FirstPassStatsTest)131 TEST_P(AVxFirstPassEncoderThreadTest, FirstPassStatsTest) {
132 ::libaom_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 0, 60);
133 aom_fixed_buf_t firstpass_stats;
134 size_t single_run_sz;
135
136 cfg_.rc_target_bitrate = 1000;
137
138 // 5 encodes will be run:
139 // 1. row_mt_=0 and threads=1
140 // 2. row_mt_=1 and threads=1
141 // 3. row_mt_=1 and threads=2
142 // 4. row_mt_=1 and threads=4
143 // 5. row_mt_=1 and threads=8
144
145 // 4 comparisons will be made:
146 // 1. Between run 1 and run 2.
147 // 2. Between run 2 and run 3.
148 // 3. Between run 3 and run 4.
149 // 4. Between run 4 and run 5.
150
151 // Test row_mt_: 0 vs 1 at single thread case(threads = 1)
152 cfg_.g_threads = 1;
153
154 row_mt_ = 0;
155 init_flags_ = AOM_CODEC_USE_PSNR;
156 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
157
158 row_mt_ = 1;
159 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
160
161 firstpass_stats.buf = firstpass_stats_.buf;
162 firstpass_stats.sz = firstpass_stats_.sz;
163 single_run_sz = firstpass_stats_.sz / 2;
164
165 // Compare to check if using or not using row-mt are bit exact.
166 // Comparison 1 (between row_mt_=0 and row_mt_=1).
167 ASSERT_NO_FATAL_FAILURE(compare_fp_stats_md5(&firstpass_stats));
168
169 // Test single thread vs multiple threads
170 row_mt_ = 1;
171
172 cfg_.g_threads = 2;
173 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
174
175 // offset to the 2nd and 3rd run.
176 firstpass_stats.buf = reinterpret_cast<void *>(
177 reinterpret_cast<uint8_t *>(firstpass_stats_.buf) + single_run_sz);
178
179 // Compare to check if single-thread and multi-thread stats are bit exact.
180 // Comparison 2 (between threads=1 and threads=2).
181 ASSERT_NO_FATAL_FAILURE(compare_fp_stats_md5(&firstpass_stats));
182
183 cfg_.g_threads = 4;
184 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
185
186 // offset to the 3rd and 4th run
187 firstpass_stats.buf = reinterpret_cast<void *>(
188 reinterpret_cast<uint8_t *>(firstpass_stats_.buf) + single_run_sz * 2);
189
190 // Comparison 3 (between threads=2 and threads=4).
191 ASSERT_NO_FATAL_FAILURE(compare_fp_stats_md5(&firstpass_stats));
192
193 cfg_.g_threads = 8;
194 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
195
196 // offset to the 4th and 5th run.
197 firstpass_stats.buf = reinterpret_cast<void *>(
198 reinterpret_cast<uint8_t *>(firstpass_stats_.buf) + single_run_sz * 3);
199
200 // Comparison 4 (between threads=4 and threads=8).
201 compare_fp_stats_md5(&firstpass_stats);
202 }
203 #endif // !CONFIG_REALTIME_ONLY
204
205 class AVxEncoderThreadTest
206 : public ::libaom_test::CodecTestWith5Params<libaom_test::TestMode, int,
207 int, int, int>,
208 public ::libaom_test::EncoderTest {
209 protected:
AVxEncoderThreadTest()210 AVxEncoderThreadTest()
211 : EncoderTest(GET_PARAM(0)), encoder_initialized_(false),
212 encoding_mode_(GET_PARAM(1)), set_cpu_used_(GET_PARAM(2)),
213 tile_cols_(GET_PARAM(3)), tile_rows_(GET_PARAM(4)),
214 row_mt_(GET_PARAM(5)) {
215 init_flags_ = AOM_CODEC_USE_PSNR;
216 aom_codec_dec_cfg_t cfg = aom_codec_dec_cfg_t();
217 cfg.w = 1280;
218 cfg.h = 720;
219 cfg.allow_lowbitdepth = 1;
220 decoder_ = codec_->CreateDecoder(cfg, 0);
221 if (decoder_->IsAV1()) {
222 decoder_->Control(AV1_SET_DECODE_TILE_ROW, -1);
223 decoder_->Control(AV1_SET_DECODE_TILE_COL, -1);
224 }
225
226 size_enc_.clear();
227 md5_dec_.clear();
228 md5_enc_.clear();
229 }
~AVxEncoderThreadTest()230 ~AVxEncoderThreadTest() override { delete decoder_; }
231
SetUp()232 void SetUp() override {
233 InitializeConfig(encoding_mode_);
234
235 if (encoding_mode_ == ::libaom_test::kOnePassGood ||
236 encoding_mode_ == ::libaom_test::kTwoPassGood) {
237 cfg_.g_lag_in_frames = 6;
238 cfg_.rc_2pass_vbr_minsection_pct = 5;
239 cfg_.rc_2pass_vbr_maxsection_pct = 2000;
240 } else if (encoding_mode_ == ::libaom_test::kRealTime) {
241 cfg_.g_error_resilient = 1;
242 }
243 cfg_.rc_max_quantizer = 56;
244 cfg_.rc_min_quantizer = 0;
245 }
246
BeginPassHook(unsigned int)247 void BeginPassHook(unsigned int /*pass*/) override {
248 encoder_initialized_ = false;
249 }
250
PreEncodeFrameHook(::libaom_test::VideoSource *,::libaom_test::Encoder * encoder)251 void PreEncodeFrameHook(::libaom_test::VideoSource * /*video*/,
252 ::libaom_test::Encoder *encoder) override {
253 if (!encoder_initialized_) {
254 SetTileSize(encoder);
255 encoder->Control(AOME_SET_CPUUSED, set_cpu_used_);
256 encoder->Control(AV1E_SET_ROW_MT, row_mt_);
257 if (encoding_mode_ == ::libaom_test::kOnePassGood ||
258 encoding_mode_ == ::libaom_test::kTwoPassGood) {
259 encoder->Control(AOME_SET_ENABLEAUTOALTREF, 1);
260 encoder->Control(AOME_SET_ARNR_MAXFRAMES, 5);
261 encoder->Control(AOME_SET_ARNR_STRENGTH, 5);
262 encoder->Control(AV1E_SET_FRAME_PARALLEL_DECODING, 0);
263 encoder->Control(AV1E_SET_MAX_GF_INTERVAL, 4);
264 // In row_mt_=0 case, the output of single thread (1 thread) will be
265 // compared with multi thread (4 thread) output (as per line no:340).
266 // Currently, Loop restoration stage is conditionally disabled for speed
267 // 5, 6 when num_workers > 1. Due to this, the match between single
268 // thread and multi thread output can not be achieved. Hence, testing
269 // this case alone with LR disabled.
270 // TODO(aomedia:3446): Remove the constraint on this test case once Loop
271 // restoration state is same in both single and multi thread path.
272 if (set_cpu_used_ >= 5 && row_mt_ == 0)
273 encoder->Control(AV1E_SET_ENABLE_RESTORATION, 0);
274 } else if (encoding_mode_ == ::libaom_test::kRealTime) {
275 encoder->Control(AOME_SET_ENABLEAUTOALTREF, 0);
276 encoder->Control(AV1E_SET_AQ_MODE, 3);
277 encoder->Control(AV1E_SET_COEFF_COST_UPD_FREQ, 2);
278 encoder->Control(AV1E_SET_MODE_COST_UPD_FREQ, 2);
279 encoder->Control(AV1E_SET_MV_COST_UPD_FREQ, 3);
280 encoder->Control(AV1E_SET_DV_COST_UPD_FREQ, 3);
281 } else {
282 encoder->Control(AOME_SET_CQ_LEVEL, kCqLevel);
283 }
284 encoder_initialized_ = true;
285 }
286 }
287
SetTileSize(libaom_test::Encoder * encoder)288 virtual void SetTileSize(libaom_test::Encoder *encoder) {
289 encoder->Control(AV1E_SET_TILE_COLUMNS, tile_cols_);
290 encoder->Control(AV1E_SET_TILE_ROWS, tile_rows_);
291 }
292
FramePktHook(const aom_codec_cx_pkt_t * pkt)293 void FramePktHook(const aom_codec_cx_pkt_t *pkt) override {
294 size_enc_.push_back(pkt->data.frame.sz);
295
296 ::libaom_test::MD5 md5_enc;
297 md5_enc.Add(reinterpret_cast<uint8_t *>(pkt->data.frame.buf),
298 pkt->data.frame.sz);
299 md5_enc_.push_back(md5_enc.Get());
300
301 const aom_codec_err_t res = decoder_->DecodeFrame(
302 reinterpret_cast<uint8_t *>(pkt->data.frame.buf), pkt->data.frame.sz);
303 if (res != AOM_CODEC_OK) {
304 abort_ = true;
305 ASSERT_EQ(AOM_CODEC_OK, res);
306 }
307 const aom_image_t *img = decoder_->GetDxData().Next();
308
309 if (img) {
310 ::libaom_test::MD5 md5_res;
311 md5_res.Add(img);
312 md5_dec_.push_back(md5_res.Get());
313 }
314 }
315
DoTest()316 void DoTest() {
317 ::libaom_test::YUVVideoSource video(
318 "niklas_640_480_30.yuv", AOM_IMG_FMT_I420, 640, 480, 30, 1, 15, 26);
319 cfg_.rc_target_bitrate = 1000;
320
321 if (row_mt_ == 0) {
322 // Encode using single thread.
323 cfg_.g_threads = 1;
324 init_flags_ = AOM_CODEC_USE_PSNR;
325 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
326 std::vector<size_t> single_thr_size_enc;
327 std::vector<std::string> single_thr_md5_enc;
328 std::vector<std::string> single_thr_md5_dec;
329 single_thr_size_enc = size_enc_;
330 single_thr_md5_enc = md5_enc_;
331 single_thr_md5_dec = md5_dec_;
332 size_enc_.clear();
333 md5_enc_.clear();
334 md5_dec_.clear();
335
336 // Encode using multiple threads.
337 cfg_.g_threads = 4;
338 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
339 std::vector<size_t> multi_thr_size_enc;
340 std::vector<std::string> multi_thr_md5_enc;
341 std::vector<std::string> multi_thr_md5_dec;
342 multi_thr_size_enc = size_enc_;
343 multi_thr_md5_enc = md5_enc_;
344 multi_thr_md5_dec = md5_dec_;
345 size_enc_.clear();
346 md5_enc_.clear();
347 md5_dec_.clear();
348
349 // Check that the vectors are equal.
350 ASSERT_EQ(single_thr_size_enc, multi_thr_size_enc);
351 ASSERT_EQ(single_thr_md5_enc, multi_thr_md5_enc);
352 ASSERT_EQ(single_thr_md5_dec, multi_thr_md5_dec);
353
354 DoTestMaxThreads(&video, single_thr_size_enc, single_thr_md5_enc,
355 single_thr_md5_dec);
356 } else if (row_mt_ == 1) {
357 // Encode using multiple threads row-mt enabled.
358 cfg_.g_threads = 2;
359 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
360 std::vector<size_t> multi_thr2_row_mt_size_enc;
361 std::vector<std::string> multi_thr2_row_mt_md5_enc;
362 std::vector<std::string> multi_thr2_row_mt_md5_dec;
363 multi_thr2_row_mt_size_enc = size_enc_;
364 multi_thr2_row_mt_md5_enc = md5_enc_;
365 multi_thr2_row_mt_md5_dec = md5_dec_;
366 size_enc_.clear();
367 md5_enc_.clear();
368 md5_dec_.clear();
369
370 // Disable threads=3 test for now to reduce the time so that the nightly
371 // test would not time out.
372 // cfg_.g_threads = 3;
373 // ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
374 // std::vector<size_t> multi_thr3_row_mt_size_enc;
375 // std::vector<std::string> multi_thr3_row_mt_md5_enc;
376 // std::vector<std::string> multi_thr3_row_mt_md5_dec;
377 // multi_thr3_row_mt_size_enc = size_enc_;
378 // multi_thr3_row_mt_md5_enc = md5_enc_;
379 // multi_thr3_row_mt_md5_dec = md5_dec_;
380 // size_enc_.clear();
381 // md5_enc_.clear();
382 // md5_dec_.clear();
383 // Check that the vectors are equal.
384 // ASSERT_EQ(multi_thr3_row_mt_size_enc, multi_thr2_row_mt_size_enc);
385 // ASSERT_EQ(multi_thr3_row_mt_md5_enc, multi_thr2_row_mt_md5_enc);
386 // ASSERT_EQ(multi_thr3_row_mt_md5_dec, multi_thr2_row_mt_md5_dec);
387
388 cfg_.g_threads = 4;
389 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
390 std::vector<size_t> multi_thr4_row_mt_size_enc;
391 std::vector<std::string> multi_thr4_row_mt_md5_enc;
392 std::vector<std::string> multi_thr4_row_mt_md5_dec;
393 multi_thr4_row_mt_size_enc = size_enc_;
394 multi_thr4_row_mt_md5_enc = md5_enc_;
395 multi_thr4_row_mt_md5_dec = md5_dec_;
396 size_enc_.clear();
397 md5_enc_.clear();
398 md5_dec_.clear();
399
400 // Check that the vectors are equal.
401 ASSERT_EQ(multi_thr4_row_mt_size_enc, multi_thr2_row_mt_size_enc);
402 ASSERT_EQ(multi_thr4_row_mt_md5_enc, multi_thr2_row_mt_md5_enc);
403 ASSERT_EQ(multi_thr4_row_mt_md5_dec, multi_thr2_row_mt_md5_dec);
404
405 DoTestMaxThreads(&video, multi_thr2_row_mt_size_enc,
406 multi_thr2_row_mt_md5_enc, multi_thr2_row_mt_md5_dec);
407 }
408 }
409
DoTestMaxThreads(::libaom_test::YUVVideoSource * video,const std::vector<size_t> ref_size_enc,const std::vector<std::string> ref_md5_enc,const std::vector<std::string> ref_md5_dec)410 virtual void DoTestMaxThreads(::libaom_test::YUVVideoSource *video,
411 const std::vector<size_t> ref_size_enc,
412 const std::vector<std::string> ref_md5_enc,
413 const std::vector<std::string> ref_md5_dec) {
414 // This value should be kept the same as MAX_NUM_THREADS
415 // in aom_thread.h
416 cfg_.g_threads = 64;
417 ASSERT_NO_FATAL_FAILURE(RunLoop(video));
418 std::vector<size_t> multi_thr_max_row_mt_size_enc;
419 std::vector<std::string> multi_thr_max_row_mt_md5_enc;
420 std::vector<std::string> multi_thr_max_row_mt_md5_dec;
421 multi_thr_max_row_mt_size_enc = size_enc_;
422 multi_thr_max_row_mt_md5_enc = md5_enc_;
423 multi_thr_max_row_mt_md5_dec = md5_dec_;
424 size_enc_.clear();
425 md5_enc_.clear();
426 md5_dec_.clear();
427
428 // Check that the vectors are equal.
429 ASSERT_EQ(ref_size_enc, multi_thr_max_row_mt_size_enc);
430 ASSERT_EQ(ref_md5_enc, multi_thr_max_row_mt_md5_enc);
431 ASSERT_EQ(ref_md5_dec, multi_thr_max_row_mt_md5_dec);
432 }
433
434 bool encoder_initialized_;
435 ::libaom_test::TestMode encoding_mode_;
436 int set_cpu_used_;
437 int tile_cols_;
438 int tile_rows_;
439 int row_mt_;
440 ::libaom_test::Decoder *decoder_;
441 std::vector<size_t> size_enc_;
442 std::vector<std::string> md5_enc_;
443 std::vector<std::string> md5_dec_;
444 };
445
446 class AVxEncoderThreadRTTest : public AVxEncoderThreadTest {};
447
TEST_P(AVxEncoderThreadRTTest,EncoderResultTest)448 TEST_P(AVxEncoderThreadRTTest, EncoderResultTest) {
449 cfg_.large_scale_tile = 0;
450 decoder_->Control(AV1_SET_TILE_MODE, 0);
451 DoTest();
452 }
453
454 // For real time mode, test speed 5, 6, 7, 8, 9, 10.
455 AV1_INSTANTIATE_TEST_SUITE(AVxEncoderThreadRTTest,
456 ::testing::Values(::libaom_test::kRealTime),
457 ::testing::Values(5, 6, 7, 8, 9, 10),
458 ::testing::Values(0, 2), ::testing::Values(0, 2),
459 ::testing::Values(0, 1));
460
461 #if !CONFIG_REALTIME_ONLY
462
463 // The AVxEncoderThreadTestLarge takes up ~14% of total run-time of the
464 // Valgrind long tests. Exclude it; the smaller tests are still run.
465 #if !AOM_VALGRIND_BUILD
466 class AVxEncoderThreadTestLarge : public AVxEncoderThreadTest {};
467
TEST_P(AVxEncoderThreadTestLarge,EncoderResultTest)468 TEST_P(AVxEncoderThreadTestLarge, EncoderResultTest) {
469 cfg_.large_scale_tile = 0;
470 decoder_->Control(AV1_SET_TILE_MODE, 0);
471 DoTest();
472 }
473
474 // Test cpu_used 0, 1, 3 and 5.
475 AV1_INSTANTIATE_TEST_SUITE(AVxEncoderThreadTestLarge,
476 ::testing::Values(::libaom_test::kTwoPassGood,
477 ::libaom_test::kOnePassGood),
478 ::testing::Values(0, 1, 3, 5),
479 ::testing::Values(1, 6), ::testing::Values(1, 6),
480 ::testing::Values(0, 1));
481 #endif // !AOM_VALGRIND_BUILD
482
TEST_P(AVxEncoderThreadTest,EncoderResultTest)483 TEST_P(AVxEncoderThreadTest, EncoderResultTest) {
484 cfg_.large_scale_tile = 0;
485 decoder_->Control(AV1_SET_TILE_MODE, 0);
486 DoTest();
487 }
488
489 class AVxEncoderThreadAllIntraTest : public AVxEncoderThreadTest {};
490
TEST_P(AVxEncoderThreadAllIntraTest,EncoderResultTest)491 TEST_P(AVxEncoderThreadAllIntraTest, EncoderResultTest) {
492 cfg_.large_scale_tile = 0;
493 decoder_->Control(AV1_SET_TILE_MODE, 0);
494 DoTest();
495 }
496
497 class AVxEncoderThreadAllIntraTestLarge : public AVxEncoderThreadTest {};
498
TEST_P(AVxEncoderThreadAllIntraTestLarge,EncoderResultTest)499 TEST_P(AVxEncoderThreadAllIntraTestLarge, EncoderResultTest) {
500 cfg_.large_scale_tile = 0;
501 decoder_->Control(AV1_SET_TILE_MODE, 0);
502 DoTest();
503 }
504
505 // first pass stats test
506 AV1_INSTANTIATE_TEST_SUITE(AVxFirstPassEncoderThreadTest,
507 ::testing::Values(::libaom_test::kTwoPassGood),
508 ::testing::Range(0, 6, 2), ::testing::Range(0, 2),
509 ::testing::Range(1, 3));
510
511 // For AV1, test speed 0, 1, 2, 3, 5.
512 // Only test cpu_used 2 here.
513 AV1_INSTANTIATE_TEST_SUITE(AVxEncoderThreadTest,
514 ::testing::Values(::libaom_test::kTwoPassGood),
515 ::testing::Values(2), ::testing::Values(0, 2),
516 ::testing::Values(0, 2), ::testing::Values(0, 1));
517
518 // For all intra mode, test speed 0, 2, 4, 6, 8.
519 // Only test cpu_used 6 here.
520 AV1_INSTANTIATE_TEST_SUITE(AVxEncoderThreadAllIntraTest,
521 ::testing::Values(::libaom_test::kAllIntra),
522 ::testing::Values(6), ::testing::Values(0, 2),
523 ::testing::Values(0, 2), ::testing::Values(0, 1));
524
525 // Test cpu_used 0, 2, 4 and 8.
526 AV1_INSTANTIATE_TEST_SUITE(AVxEncoderThreadAllIntraTestLarge,
527 ::testing::Values(::libaom_test::kAllIntra),
528 ::testing::Values(0, 2, 4, 8),
529 ::testing::Values(1, 6), ::testing::Values(1, 6),
530 ::testing::Values(0, 1));
531 #endif // !CONFIG_REALTIME_ONLY
532
533 class AVxEncoderThreadLSTest : public AVxEncoderThreadTest {
SetTileSize(libaom_test::Encoder * encoder)534 void SetTileSize(libaom_test::Encoder *encoder) override {
535 encoder->Control(AV1E_SET_TILE_COLUMNS, tile_cols_);
536 encoder->Control(AV1E_SET_TILE_ROWS, tile_rows_);
537 }
538
DoTestMaxThreads(::libaom_test::YUVVideoSource * video,const std::vector<size_t> ref_size_enc,const std::vector<std::string> ref_md5_enc,const std::vector<std::string> ref_md5_dec)539 void DoTestMaxThreads(::libaom_test::YUVVideoSource *video,
540 const std::vector<size_t> ref_size_enc,
541 const std::vector<std::string> ref_md5_enc,
542 const std::vector<std::string> ref_md5_dec) override {
543 (void)video;
544 (void)ref_size_enc;
545 (void)ref_md5_enc;
546 (void)ref_md5_dec;
547 }
548 };
549 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AVxEncoderThreadLSTest);
550
TEST_P(AVxEncoderThreadLSTest,EncoderResultTest)551 TEST_P(AVxEncoderThreadLSTest, EncoderResultTest) {
552 cfg_.large_scale_tile = 1;
553 decoder_->Control(AV1_SET_TILE_MODE, 1);
554 decoder_->Control(AV1D_EXT_TILE_DEBUG, 1);
555 DoTest();
556 }
557
558 // AVxEncoderThreadLSTestLarge takes up about 2% of total run-time of
559 // the Valgrind long tests. Since we already run AVxEncoderThreadLSTest,
560 // skip this one for Valgrind.
561 #if !CONFIG_REALTIME_ONLY && !AOM_VALGRIND_BUILD
562 class AVxEncoderThreadLSTestLarge : public AVxEncoderThreadLSTest {};
563
TEST_P(AVxEncoderThreadLSTestLarge,EncoderResultTest)564 TEST_P(AVxEncoderThreadLSTestLarge, EncoderResultTest) {
565 cfg_.large_scale_tile = 1;
566 decoder_->Control(AV1_SET_TILE_MODE, 1);
567 decoder_->Control(AV1D_EXT_TILE_DEBUG, 1);
568 DoTest();
569 }
570
571 AV1_INSTANTIATE_TEST_SUITE(AVxEncoderThreadLSTestLarge,
572 ::testing::Values(::libaom_test::kTwoPassGood,
573 ::libaom_test::kOnePassGood),
574 ::testing::Values(1, 3), ::testing::Values(0, 6),
575 ::testing::Values(0, 6), ::testing::Values(1));
576 #endif // !CONFIG_REALTIME_ONLY && !AOM_VALGRIND_BUILD
577 } // namespace
578