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