xref: /aosp_15_r20/external/libaom/test/encodetxb_test.cc (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2017, 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 <stdint.h>
13*77c1e3ccSAndroid Build Coastguard Worker #include <stdio.h>
14*77c1e3ccSAndroid Build Coastguard Worker #include <string.h>
15*77c1e3ccSAndroid Build Coastguard Worker #include <tuple>
16*77c1e3ccSAndroid Build Coastguard Worker 
17*77c1e3ccSAndroid Build Coastguard Worker #include "gtest/gtest.h"
18*77c1e3ccSAndroid Build Coastguard Worker 
19*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_config.h"
20*77c1e3ccSAndroid Build Coastguard Worker #include "config/av1_rtcd.h"
21*77c1e3ccSAndroid Build Coastguard Worker 
22*77c1e3ccSAndroid Build Coastguard Worker #include "aom_ports/aom_timer.h"
23*77c1e3ccSAndroid Build Coastguard Worker #include "aom_ports/mem.h"
24*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/av1_common_int.h"
25*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/idct.h"
26*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/scan.h"
27*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/txb_common.h"
28*77c1e3ccSAndroid Build Coastguard Worker #include "test/acm_random.h"
29*77c1e3ccSAndroid Build Coastguard Worker #include "test/register_state_check.h"
30*77c1e3ccSAndroid Build Coastguard Worker #include "test/util.h"
31*77c1e3ccSAndroid Build Coastguard Worker 
32*77c1e3ccSAndroid Build Coastguard Worker namespace {
33*77c1e3ccSAndroid Build Coastguard Worker using libaom_test::ACMRandom;
34*77c1e3ccSAndroid Build Coastguard Worker 
35*77c1e3ccSAndroid Build Coastguard Worker typedef void (*GetNzMapContextsFunc)(const uint8_t *const levels,
36*77c1e3ccSAndroid Build Coastguard Worker                                      const int16_t *const scan,
37*77c1e3ccSAndroid Build Coastguard Worker                                      const uint16_t eob, const TX_SIZE tx_size,
38*77c1e3ccSAndroid Build Coastguard Worker                                      const TX_CLASS tx_class,
39*77c1e3ccSAndroid Build Coastguard Worker                                      int8_t *const coeff_contexts);
40*77c1e3ccSAndroid Build Coastguard Worker 
41*77c1e3ccSAndroid Build Coastguard Worker class EncodeTxbTest : public ::testing::TestWithParam<GetNzMapContextsFunc> {
42*77c1e3ccSAndroid Build Coastguard Worker  public:
EncodeTxbTest()43*77c1e3ccSAndroid Build Coastguard Worker   EncodeTxbTest() : get_nz_map_contexts_func_(GetParam()) {}
44*77c1e3ccSAndroid Build Coastguard Worker 
45*77c1e3ccSAndroid Build Coastguard Worker   ~EncodeTxbTest() override = default;
46*77c1e3ccSAndroid Build Coastguard Worker 
SetUp()47*77c1e3ccSAndroid Build Coastguard Worker   void SetUp() override {
48*77c1e3ccSAndroid Build Coastguard Worker     coeff_contexts_ref_ = reinterpret_cast<int8_t *>(
49*77c1e3ccSAndroid Build Coastguard Worker         aom_memalign(16, sizeof(*coeff_contexts_ref_) * MAX_TX_SQUARE));
50*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_NE(coeff_contexts_ref_, nullptr);
51*77c1e3ccSAndroid Build Coastguard Worker     coeff_contexts_ = reinterpret_cast<int8_t *>(
52*77c1e3ccSAndroid Build Coastguard Worker         aom_memalign(16, sizeof(*coeff_contexts_) * MAX_TX_SQUARE));
53*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_NE(coeff_contexts_, nullptr);
54*77c1e3ccSAndroid Build Coastguard Worker   }
55*77c1e3ccSAndroid Build Coastguard Worker 
TearDown()56*77c1e3ccSAndroid Build Coastguard Worker   void TearDown() override {
57*77c1e3ccSAndroid Build Coastguard Worker     aom_free(coeff_contexts_ref_);
58*77c1e3ccSAndroid Build Coastguard Worker     aom_free(coeff_contexts_);
59*77c1e3ccSAndroid Build Coastguard Worker   }
60*77c1e3ccSAndroid Build Coastguard Worker 
GetNzMapContextsRun()61*77c1e3ccSAndroid Build Coastguard Worker   void GetNzMapContextsRun() {
62*77c1e3ccSAndroid Build Coastguard Worker     const int kNumTests = 10;
63*77c1e3ccSAndroid Build Coastguard Worker     int result = 0;
64*77c1e3ccSAndroid Build Coastguard Worker 
65*77c1e3ccSAndroid Build Coastguard Worker     for (int is_inter = 0; is_inter < 2; ++is_inter) {
66*77c1e3ccSAndroid Build Coastguard Worker       for (int tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
67*77c1e3ccSAndroid Build Coastguard Worker         const TX_CLASS tx_class = tx_type_to_class[tx_type];
68*77c1e3ccSAndroid Build Coastguard Worker         for (int tx_size = TX_4X4; tx_size < TX_SIZES_ALL; ++tx_size) {
69*77c1e3ccSAndroid Build Coastguard Worker           const int bhl = get_txb_bhl((TX_SIZE)tx_size);
70*77c1e3ccSAndroid Build Coastguard Worker           const int width = get_txb_wide((TX_SIZE)tx_size);
71*77c1e3ccSAndroid Build Coastguard Worker           const int height = get_txb_high((TX_SIZE)tx_size);
72*77c1e3ccSAndroid Build Coastguard Worker           const int real_width = tx_size_wide[tx_size];
73*77c1e3ccSAndroid Build Coastguard Worker           const int real_height = tx_size_high[tx_size];
74*77c1e3ccSAndroid Build Coastguard Worker           const int16_t *const scan = av1_scan_orders[tx_size][tx_type].scan;
75*77c1e3ccSAndroid Build Coastguard Worker 
76*77c1e3ccSAndroid Build Coastguard Worker           levels_ = set_levels(levels_buf_, height);
77*77c1e3ccSAndroid Build Coastguard Worker           for (int i = 0; i < kNumTests && !result; ++i) {
78*77c1e3ccSAndroid Build Coastguard Worker             for (int eob = 1; eob <= width * height && !result; ++eob) {
79*77c1e3ccSAndroid Build Coastguard Worker               InitDataWithEob(scan, bhl, eob);
80*77c1e3ccSAndroid Build Coastguard Worker 
81*77c1e3ccSAndroid Build Coastguard Worker               av1_get_nz_map_contexts_c(levels_, scan, eob, (TX_SIZE)tx_size,
82*77c1e3ccSAndroid Build Coastguard Worker                                         tx_class, coeff_contexts_ref_);
83*77c1e3ccSAndroid Build Coastguard Worker               get_nz_map_contexts_func_(levels_, scan, eob, (TX_SIZE)tx_size,
84*77c1e3ccSAndroid Build Coastguard Worker                                         tx_class, coeff_contexts_);
85*77c1e3ccSAndroid Build Coastguard Worker 
86*77c1e3ccSAndroid Build Coastguard Worker               result = Compare(scan, eob);
87*77c1e3ccSAndroid Build Coastguard Worker 
88*77c1e3ccSAndroid Build Coastguard Worker               EXPECT_EQ(result, 0)
89*77c1e3ccSAndroid Build Coastguard Worker                   << " tx_class " << (int)tx_class << " width " << real_width
90*77c1e3ccSAndroid Build Coastguard Worker                   << " height " << real_height << " eob " << eob;
91*77c1e3ccSAndroid Build Coastguard Worker             }
92*77c1e3ccSAndroid Build Coastguard Worker           }
93*77c1e3ccSAndroid Build Coastguard Worker         }
94*77c1e3ccSAndroid Build Coastguard Worker       }
95*77c1e3ccSAndroid Build Coastguard Worker     }
96*77c1e3ccSAndroid Build Coastguard Worker   }
97*77c1e3ccSAndroid Build Coastguard Worker 
SpeedTestGetNzMapContextsRun()98*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTestGetNzMapContextsRun() {
99*77c1e3ccSAndroid Build Coastguard Worker     const int kNumTests = 2000000000;
100*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
101*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer_ref;
102*77c1e3ccSAndroid Build Coastguard Worker 
103*77c1e3ccSAndroid Build Coastguard Worker     printf("Note: Only test the largest possible eob case!\n");
104*77c1e3ccSAndroid Build Coastguard Worker     for (int tx_size = TX_4X4; tx_size < TX_SIZES_ALL; ++tx_size) {
105*77c1e3ccSAndroid Build Coastguard Worker       const int bhl = get_txb_bhl((TX_SIZE)tx_size);
106*77c1e3ccSAndroid Build Coastguard Worker       const int width = get_txb_wide((TX_SIZE)tx_size);
107*77c1e3ccSAndroid Build Coastguard Worker       const int height = get_txb_high((TX_SIZE)tx_size);
108*77c1e3ccSAndroid Build Coastguard Worker       const int real_width = tx_size_wide[tx_size];
109*77c1e3ccSAndroid Build Coastguard Worker       const int real_height = tx_size_high[tx_size];
110*77c1e3ccSAndroid Build Coastguard Worker       const TX_TYPE tx_type = DCT_DCT;
111*77c1e3ccSAndroid Build Coastguard Worker       const TX_CLASS tx_class = tx_type_to_class[tx_type];
112*77c1e3ccSAndroid Build Coastguard Worker       const int16_t *const scan = av1_scan_orders[tx_size][tx_type].scan;
113*77c1e3ccSAndroid Build Coastguard Worker       const int eob = width * height;
114*77c1e3ccSAndroid Build Coastguard Worker       const int numTests = kNumTests / (width * height);
115*77c1e3ccSAndroid Build Coastguard Worker 
116*77c1e3ccSAndroid Build Coastguard Worker       levels_ = set_levels(levels_buf_, height);
117*77c1e3ccSAndroid Build Coastguard Worker       InitDataWithEob(scan, bhl, eob);
118*77c1e3ccSAndroid Build Coastguard Worker 
119*77c1e3ccSAndroid Build Coastguard Worker       aom_usec_timer_start(&timer_ref);
120*77c1e3ccSAndroid Build Coastguard Worker       for (int i = 0; i < numTests; ++i) {
121*77c1e3ccSAndroid Build Coastguard Worker         av1_get_nz_map_contexts_c(levels_, scan, eob, (TX_SIZE)tx_size,
122*77c1e3ccSAndroid Build Coastguard Worker                                   tx_class, coeff_contexts_ref_);
123*77c1e3ccSAndroid Build Coastguard Worker       }
124*77c1e3ccSAndroid Build Coastguard Worker       aom_usec_timer_mark(&timer_ref);
125*77c1e3ccSAndroid Build Coastguard Worker 
126*77c1e3ccSAndroid Build Coastguard Worker       levels_ = set_levels(levels_buf_, height);
127*77c1e3ccSAndroid Build Coastguard Worker       InitDataWithEob(scan, bhl, eob);
128*77c1e3ccSAndroid Build Coastguard Worker 
129*77c1e3ccSAndroid Build Coastguard Worker       aom_usec_timer_start(&timer);
130*77c1e3ccSAndroid Build Coastguard Worker       for (int i = 0; i < numTests; ++i) {
131*77c1e3ccSAndroid Build Coastguard Worker         get_nz_map_contexts_func_(levels_, scan, eob, (TX_SIZE)tx_size,
132*77c1e3ccSAndroid Build Coastguard Worker                                   tx_class, coeff_contexts_);
133*77c1e3ccSAndroid Build Coastguard Worker       }
134*77c1e3ccSAndroid Build Coastguard Worker       aom_usec_timer_mark(&timer);
135*77c1e3ccSAndroid Build Coastguard Worker 
136*77c1e3ccSAndroid Build Coastguard Worker       const int elapsed_time_ref =
137*77c1e3ccSAndroid Build Coastguard Worker           static_cast<int>(aom_usec_timer_elapsed(&timer_ref));
138*77c1e3ccSAndroid Build Coastguard Worker       const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
139*77c1e3ccSAndroid Build Coastguard Worker 
140*77c1e3ccSAndroid Build Coastguard Worker       printf("get_nz_map_contexts_%2dx%2d: %7.1f ms ref %7.1f ms gain %4.2f\n",
141*77c1e3ccSAndroid Build Coastguard Worker              real_width, real_height, elapsed_time / 1000.0,
142*77c1e3ccSAndroid Build Coastguard Worker              elapsed_time_ref / 1000.0,
143*77c1e3ccSAndroid Build Coastguard Worker              (elapsed_time_ref * 1.0) / (elapsed_time * 1.0));
144*77c1e3ccSAndroid Build Coastguard Worker     }
145*77c1e3ccSAndroid Build Coastguard Worker   }
146*77c1e3ccSAndroid Build Coastguard Worker 
147*77c1e3ccSAndroid Build Coastguard Worker  private:
InitDataWithEob(const int16_t * const scan,const int bhl,const int eob)148*77c1e3ccSAndroid Build Coastguard Worker   void InitDataWithEob(const int16_t *const scan, const int bhl,
149*77c1e3ccSAndroid Build Coastguard Worker                        const int eob) {
150*77c1e3ccSAndroid Build Coastguard Worker     memset(levels_buf_, 0, sizeof(levels_buf_));
151*77c1e3ccSAndroid Build Coastguard Worker     memset(coeff_contexts_, 0, sizeof(*coeff_contexts_) * MAX_TX_SQUARE);
152*77c1e3ccSAndroid Build Coastguard Worker 
153*77c1e3ccSAndroid Build Coastguard Worker     for (int c = 0; c < eob; ++c) {
154*77c1e3ccSAndroid Build Coastguard Worker       levels_[get_padded_idx(scan[c], bhl)] =
155*77c1e3ccSAndroid Build Coastguard Worker           static_cast<uint8_t>(clamp(rnd_.Rand8(), 0, INT8_MAX));
156*77c1e3ccSAndroid Build Coastguard Worker       coeff_contexts_[scan[c]] = static_cast<int8_t>(rnd_.Rand16() >> 1);
157*77c1e3ccSAndroid Build Coastguard Worker     }
158*77c1e3ccSAndroid Build Coastguard Worker 
159*77c1e3ccSAndroid Build Coastguard Worker     memcpy(coeff_contexts_ref_, coeff_contexts_,
160*77c1e3ccSAndroid Build Coastguard Worker            sizeof(*coeff_contexts_) * MAX_TX_SQUARE);
161*77c1e3ccSAndroid Build Coastguard Worker   }
162*77c1e3ccSAndroid Build Coastguard Worker 
Compare(const int16_t * const scan,const int eob) const163*77c1e3ccSAndroid Build Coastguard Worker   bool Compare(const int16_t *const scan, const int eob) const {
164*77c1e3ccSAndroid Build Coastguard Worker     bool result = false;
165*77c1e3ccSAndroid Build Coastguard Worker     if (memcmp(coeff_contexts_, coeff_contexts_ref_,
166*77c1e3ccSAndroid Build Coastguard Worker                sizeof(*coeff_contexts_ref_) * MAX_TX_SQUARE)) {
167*77c1e3ccSAndroid Build Coastguard Worker       for (int i = 0; i < eob; i++) {
168*77c1e3ccSAndroid Build Coastguard Worker         const int pos = scan[i];
169*77c1e3ccSAndroid Build Coastguard Worker         if (coeff_contexts_ref_[pos] != coeff_contexts_[pos]) {
170*77c1e3ccSAndroid Build Coastguard Worker           printf("coeff_contexts_[%d] diff:%6d (ref),%6d (opt)\n", pos,
171*77c1e3ccSAndroid Build Coastguard Worker                  coeff_contexts_ref_[pos], coeff_contexts_[pos]);
172*77c1e3ccSAndroid Build Coastguard Worker           result = true;
173*77c1e3ccSAndroid Build Coastguard Worker           break;
174*77c1e3ccSAndroid Build Coastguard Worker         }
175*77c1e3ccSAndroid Build Coastguard Worker       }
176*77c1e3ccSAndroid Build Coastguard Worker     }
177*77c1e3ccSAndroid Build Coastguard Worker     return result;
178*77c1e3ccSAndroid Build Coastguard Worker   }
179*77c1e3ccSAndroid Build Coastguard Worker 
180*77c1e3ccSAndroid Build Coastguard Worker   GetNzMapContextsFunc get_nz_map_contexts_func_;
181*77c1e3ccSAndroid Build Coastguard Worker   ACMRandom rnd_;
182*77c1e3ccSAndroid Build Coastguard Worker   uint8_t levels_buf_[TX_PAD_2D];
183*77c1e3ccSAndroid Build Coastguard Worker   uint8_t *levels_;
184*77c1e3ccSAndroid Build Coastguard Worker   int8_t *coeff_contexts_ref_;
185*77c1e3ccSAndroid Build Coastguard Worker   int8_t *coeff_contexts_;
186*77c1e3ccSAndroid Build Coastguard Worker };
187*77c1e3ccSAndroid Build Coastguard Worker GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EncodeTxbTest);
188*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(EncodeTxbTest,GetNzMapContexts)189*77c1e3ccSAndroid Build Coastguard Worker TEST_P(EncodeTxbTest, GetNzMapContexts) { GetNzMapContextsRun(); }
190*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(EncodeTxbTest,DISABLED_SpeedTestGetNzMapContexts)191*77c1e3ccSAndroid Build Coastguard Worker TEST_P(EncodeTxbTest, DISABLED_SpeedTestGetNzMapContexts) {
192*77c1e3ccSAndroid Build Coastguard Worker   SpeedTestGetNzMapContextsRun();
193*77c1e3ccSAndroid Build Coastguard Worker }
194*77c1e3ccSAndroid Build Coastguard Worker 
195*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE2
196*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE2, EncodeTxbTest,
197*77c1e3ccSAndroid Build Coastguard Worker                          ::testing::Values(av1_get_nz_map_contexts_sse2));
198*77c1e3ccSAndroid Build Coastguard Worker #endif
199*77c1e3ccSAndroid Build Coastguard Worker 
200*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
201*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, EncodeTxbTest,
202*77c1e3ccSAndroid Build Coastguard Worker                          ::testing::Values(av1_get_nz_map_contexts_neon));
203*77c1e3ccSAndroid Build Coastguard Worker #endif
204*77c1e3ccSAndroid Build Coastguard Worker 
205*77c1e3ccSAndroid Build Coastguard Worker typedef void (*av1_txb_init_levels_func)(const tran_low_t *const coeff,
206*77c1e3ccSAndroid Build Coastguard Worker                                          const int width, const int height,
207*77c1e3ccSAndroid Build Coastguard Worker                                          uint8_t *const levels);
208*77c1e3ccSAndroid Build Coastguard Worker 
209*77c1e3ccSAndroid Build Coastguard Worker typedef std::tuple<av1_txb_init_levels_func, int> TxbInitLevelParam;
210*77c1e3ccSAndroid Build Coastguard Worker 
211*77c1e3ccSAndroid Build Coastguard Worker class EncodeTxbInitLevelTest
212*77c1e3ccSAndroid Build Coastguard Worker     : public ::testing::TestWithParam<TxbInitLevelParam> {
213*77c1e3ccSAndroid Build Coastguard Worker  public:
214*77c1e3ccSAndroid Build Coastguard Worker   ~EncodeTxbInitLevelTest() override = default;
215*77c1e3ccSAndroid Build Coastguard Worker   void RunTest(av1_txb_init_levels_func test_func, int tx_size, int is_speed);
216*77c1e3ccSAndroid Build Coastguard Worker };
217*77c1e3ccSAndroid Build Coastguard Worker GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EncodeTxbInitLevelTest);
218*77c1e3ccSAndroid Build Coastguard Worker 
RunTest(av1_txb_init_levels_func test_func,int tx_size,int is_speed)219*77c1e3ccSAndroid Build Coastguard Worker void EncodeTxbInitLevelTest::RunTest(av1_txb_init_levels_func test_func,
220*77c1e3ccSAndroid Build Coastguard Worker                                      int tx_size, int is_speed) {
221*77c1e3ccSAndroid Build Coastguard Worker   const int width = get_txb_wide((TX_SIZE)tx_size);
222*77c1e3ccSAndroid Build Coastguard Worker   const int height = get_txb_high((TX_SIZE)tx_size);
223*77c1e3ccSAndroid Build Coastguard Worker   tran_low_t coeff[MAX_TX_SQUARE];
224*77c1e3ccSAndroid Build Coastguard Worker 
225*77c1e3ccSAndroid Build Coastguard Worker   uint8_t levels_buf[2][TX_PAD_2D];
226*77c1e3ccSAndroid Build Coastguard Worker   uint8_t *const levels0 = set_levels(levels_buf[0], height);
227*77c1e3ccSAndroid Build Coastguard Worker   uint8_t *const levels1 = set_levels(levels_buf[1], height);
228*77c1e3ccSAndroid Build Coastguard Worker 
229*77c1e3ccSAndroid Build Coastguard Worker   ACMRandom rnd(ACMRandom::DeterministicSeed());
230*77c1e3ccSAndroid Build Coastguard Worker   for (int i = 0; i < width * height; i++) {
231*77c1e3ccSAndroid Build Coastguard Worker     coeff[i] = rnd.Rand16Signed();
232*77c1e3ccSAndroid Build Coastguard Worker   }
233*77c1e3ccSAndroid Build Coastguard Worker   for (int i = 0; i < TX_PAD_2D; i++) {
234*77c1e3ccSAndroid Build Coastguard Worker     levels_buf[0][i] = rnd.Rand8();
235*77c1e3ccSAndroid Build Coastguard Worker     levels_buf[1][i] = rnd.Rand8();
236*77c1e3ccSAndroid Build Coastguard Worker   }
237*77c1e3ccSAndroid Build Coastguard Worker   const int run_times = is_speed ? (width * height) * 10000 : 1;
238*77c1e3ccSAndroid Build Coastguard Worker   aom_usec_timer timer;
239*77c1e3ccSAndroid Build Coastguard Worker   aom_usec_timer_start(&timer);
240*77c1e3ccSAndroid Build Coastguard Worker   for (int i = 0; i < run_times; ++i) {
241*77c1e3ccSAndroid Build Coastguard Worker     av1_txb_init_levels_c(coeff, width, height, levels0);
242*77c1e3ccSAndroid Build Coastguard Worker   }
243*77c1e3ccSAndroid Build Coastguard Worker   const double t1 = get_time_mark(&timer);
244*77c1e3ccSAndroid Build Coastguard Worker   aom_usec_timer_start(&timer);
245*77c1e3ccSAndroid Build Coastguard Worker   for (int i = 0; i < run_times; ++i) {
246*77c1e3ccSAndroid Build Coastguard Worker     test_func(coeff, width, height, levels1);
247*77c1e3ccSAndroid Build Coastguard Worker   }
248*77c1e3ccSAndroid Build Coastguard Worker   const double t2 = get_time_mark(&timer);
249*77c1e3ccSAndroid Build Coastguard Worker   if (is_speed) {
250*77c1e3ccSAndroid Build Coastguard Worker     printf("init %3dx%-3d:%7.2f/%7.2fns", width, height, t1, t2);
251*77c1e3ccSAndroid Build Coastguard Worker     printf("(%3.2f)\n", t1 / t2);
252*77c1e3ccSAndroid Build Coastguard Worker   }
253*77c1e3ccSAndroid Build Coastguard Worker   const int stride = width + TX_PAD_HOR;
254*77c1e3ccSAndroid Build Coastguard Worker   for (int r = 0; r < height + TX_PAD_VER; ++r) {
255*77c1e3ccSAndroid Build Coastguard Worker     for (int c = 0; c < stride; ++c) {
256*77c1e3ccSAndroid Build Coastguard Worker       ASSERT_EQ(levels_buf[0][c + r * stride], levels_buf[1][c + r * stride])
257*77c1e3ccSAndroid Build Coastguard Worker           << "[" << r << "," << c << "] " << run_times << width << "x"
258*77c1e3ccSAndroid Build Coastguard Worker           << height;
259*77c1e3ccSAndroid Build Coastguard Worker     }
260*77c1e3ccSAndroid Build Coastguard Worker   }
261*77c1e3ccSAndroid Build Coastguard Worker }
262*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(EncodeTxbInitLevelTest,match)263*77c1e3ccSAndroid Build Coastguard Worker TEST_P(EncodeTxbInitLevelTest, match) {
264*77c1e3ccSAndroid Build Coastguard Worker   RunTest(GET_PARAM(0), GET_PARAM(1), 0);
265*77c1e3ccSAndroid Build Coastguard Worker }
266*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(EncodeTxbInitLevelTest,DISABLED_Speed)267*77c1e3ccSAndroid Build Coastguard Worker TEST_P(EncodeTxbInitLevelTest, DISABLED_Speed) {
268*77c1e3ccSAndroid Build Coastguard Worker   RunTest(GET_PARAM(0), GET_PARAM(1), 1);
269*77c1e3ccSAndroid Build Coastguard Worker }
270*77c1e3ccSAndroid Build Coastguard Worker 
271*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
272*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
273*77c1e3ccSAndroid Build Coastguard Worker     SSE4_1, EncodeTxbInitLevelTest,
274*77c1e3ccSAndroid Build Coastguard Worker     ::testing::Combine(::testing::Values(&av1_txb_init_levels_sse4_1),
275*77c1e3ccSAndroid Build Coastguard Worker                        ::testing::Range(0, static_cast<int>(TX_SIZES_ALL), 1)));
276*77c1e3ccSAndroid Build Coastguard Worker #endif
277*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
278*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
279*77c1e3ccSAndroid Build Coastguard Worker     AVX2, EncodeTxbInitLevelTest,
280*77c1e3ccSAndroid Build Coastguard Worker     ::testing::Combine(::testing::Values(&av1_txb_init_levels_avx2),
281*77c1e3ccSAndroid Build Coastguard Worker                        ::testing::Range(0, static_cast<int>(TX_SIZES_ALL), 1)));
282*77c1e3ccSAndroid Build Coastguard Worker #endif
283*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
284*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
285*77c1e3ccSAndroid Build Coastguard Worker     NEON, EncodeTxbInitLevelTest,
286*77c1e3ccSAndroid Build Coastguard Worker     ::testing::Combine(::testing::Values(&av1_txb_init_levels_neon),
287*77c1e3ccSAndroid Build Coastguard Worker                        ::testing::Range(0, static_cast<int>(TX_SIZES_ALL), 1)));
288*77c1e3ccSAndroid Build Coastguard Worker #endif
289*77c1e3ccSAndroid Build Coastguard Worker }  // namespace
290