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