xref: /aosp_15_r20/external/libaom/test/av1_quantize_test.cc (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
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 #include <stdlib.h>
12*77c1e3ccSAndroid Build Coastguard Worker 
13*77c1e3ccSAndroid Build Coastguard Worker #include "gtest/gtest.h"
14*77c1e3ccSAndroid Build Coastguard Worker 
15*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_config.h"
16*77c1e3ccSAndroid Build Coastguard Worker #include "config/av1_rtcd.h"
17*77c1e3ccSAndroid Build Coastguard Worker 
18*77c1e3ccSAndroid Build Coastguard Worker #include "test/acm_random.h"
19*77c1e3ccSAndroid Build Coastguard Worker #include "test/register_state_check.h"
20*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/scan.h"
21*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/av1_quantize.h"
22*77c1e3ccSAndroid Build Coastguard Worker 
23*77c1e3ccSAndroid Build Coastguard Worker namespace {
24*77c1e3ccSAndroid Build Coastguard Worker 
25*77c1e3ccSAndroid Build Coastguard Worker typedef void (*QuantizeFpFunc)(
26*77c1e3ccSAndroid Build Coastguard Worker     const tran_low_t *coeff_ptr, intptr_t count, const int16_t *zbin_ptr,
27*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *round_ptr, const int16_t *quant_ptr,
28*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
29*77c1e3ccSAndroid Build Coastguard Worker     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
30*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *scan, const int16_t *iscan, int log_scale);
31*77c1e3ccSAndroid Build Coastguard Worker 
32*77c1e3ccSAndroid Build Coastguard Worker struct QuantizeFuncParams {
QuantizeFuncParams__anoneab749040111::QuantizeFuncParams33*77c1e3ccSAndroid Build Coastguard Worker   QuantizeFuncParams(QuantizeFpFunc qF = nullptr,
34*77c1e3ccSAndroid Build Coastguard Worker                      QuantizeFpFunc qRefF = nullptr, int count = 16)
35*77c1e3ccSAndroid Build Coastguard Worker       : qFunc(qF), qFuncRef(qRefF), coeffCount(count) {}
36*77c1e3ccSAndroid Build Coastguard Worker   QuantizeFpFunc qFunc;
37*77c1e3ccSAndroid Build Coastguard Worker   QuantizeFpFunc qFuncRef;
38*77c1e3ccSAndroid Build Coastguard Worker   int coeffCount;
39*77c1e3ccSAndroid Build Coastguard Worker };
40*77c1e3ccSAndroid Build Coastguard Worker 
41*77c1e3ccSAndroid Build Coastguard Worker using libaom_test::ACMRandom;
42*77c1e3ccSAndroid Build Coastguard Worker 
43*77c1e3ccSAndroid Build Coastguard Worker const int numTests = 1000;
44*77c1e3ccSAndroid Build Coastguard Worker const int maxSize = 1024;
45*77c1e3ccSAndroid Build Coastguard Worker const int roundFactorRange = 127;
46*77c1e3ccSAndroid Build Coastguard Worker const int dequantRange = 32768;
47*77c1e3ccSAndroid Build Coastguard Worker const int coeffRange = (1 << 20) - 1;
48*77c1e3ccSAndroid Build Coastguard Worker 
49*77c1e3ccSAndroid Build Coastguard Worker class AV1QuantizeTest : public ::testing::TestWithParam<QuantizeFuncParams> {
50*77c1e3ccSAndroid Build Coastguard Worker  public:
RunQuantizeTest()51*77c1e3ccSAndroid Build Coastguard Worker   void RunQuantizeTest() {
52*77c1e3ccSAndroid Build Coastguard Worker     ACMRandom rnd(ACMRandom::DeterministicSeed());
53*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, tran_low_t, coeff_ptr[maxSize]);
54*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, int16_t, zbin_ptr[8]);
55*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, int16_t, round_ptr[8]);
56*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, int16_t, quant_ptr[8]);
57*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, int16_t, quant_shift_ptr[8]);
58*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, tran_low_t, qcoeff_ptr[maxSize]);
59*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, tran_low_t, dqcoeff_ptr[maxSize]);
60*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, tran_low_t, ref_qcoeff_ptr[maxSize]);
61*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, tran_low_t, ref_dqcoeff_ptr[maxSize]);
62*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, int16_t, dequant_ptr[8]);
63*77c1e3ccSAndroid Build Coastguard Worker     uint16_t eob;
64*77c1e3ccSAndroid Build Coastguard Worker     uint16_t ref_eob;
65*77c1e3ccSAndroid Build Coastguard Worker     int err_count_total = 0;
66*77c1e3ccSAndroid Build Coastguard Worker     int first_failure = -1;
67*77c1e3ccSAndroid Build Coastguard Worker     int count = params_.coeffCount;
68*77c1e3ccSAndroid Build Coastguard Worker     const TX_SIZE txSize = getTxSize(count);
69*77c1e3ccSAndroid Build Coastguard Worker     int log_scale = (txSize == TX_32X32);
70*77c1e3ccSAndroid Build Coastguard Worker     QuantizeFpFunc quanFunc = params_.qFunc;
71*77c1e3ccSAndroid Build Coastguard Worker     QuantizeFpFunc quanFuncRef = params_.qFuncRef;
72*77c1e3ccSAndroid Build Coastguard Worker 
73*77c1e3ccSAndroid Build Coastguard Worker     const SCAN_ORDER scanOrder = av1_scan_orders[txSize][DCT_DCT];
74*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < numTests; i++) {
75*77c1e3ccSAndroid Build Coastguard Worker       int err_count = 0;
76*77c1e3ccSAndroid Build Coastguard Worker       ref_eob = eob = UINT16_MAX;
77*77c1e3ccSAndroid Build Coastguard Worker       for (int j = 0; j < count; j++) {
78*77c1e3ccSAndroid Build Coastguard Worker         coeff_ptr[j] = rnd(coeffRange);
79*77c1e3ccSAndroid Build Coastguard Worker       }
80*77c1e3ccSAndroid Build Coastguard Worker 
81*77c1e3ccSAndroid Build Coastguard Worker       for (int j = 0; j < 2; j++) {
82*77c1e3ccSAndroid Build Coastguard Worker         zbin_ptr[j] = rnd.Rand16Signed();
83*77c1e3ccSAndroid Build Coastguard Worker         quant_shift_ptr[j] = rnd.Rand16Signed();
84*77c1e3ccSAndroid Build Coastguard Worker         // int16_t positive
85*77c1e3ccSAndroid Build Coastguard Worker         dequant_ptr[j] = abs(rnd(dequantRange));
86*77c1e3ccSAndroid Build Coastguard Worker         quant_ptr[j] = static_cast<int16_t>((1 << 16) / dequant_ptr[j]);
87*77c1e3ccSAndroid Build Coastguard Worker         round_ptr[j] = (abs(rnd(roundFactorRange)) * dequant_ptr[j]) >> 7;
88*77c1e3ccSAndroid Build Coastguard Worker       }
89*77c1e3ccSAndroid Build Coastguard Worker       for (int j = 2; j < 8; ++j) {
90*77c1e3ccSAndroid Build Coastguard Worker         zbin_ptr[j] = zbin_ptr[1];
91*77c1e3ccSAndroid Build Coastguard Worker         quant_shift_ptr[j] = quant_shift_ptr[1];
92*77c1e3ccSAndroid Build Coastguard Worker         dequant_ptr[j] = dequant_ptr[1];
93*77c1e3ccSAndroid Build Coastguard Worker         quant_ptr[j] = quant_ptr[1];
94*77c1e3ccSAndroid Build Coastguard Worker         round_ptr[j] = round_ptr[1];
95*77c1e3ccSAndroid Build Coastguard Worker       }
96*77c1e3ccSAndroid Build Coastguard Worker       quanFuncRef(coeff_ptr, count, zbin_ptr, round_ptr, quant_ptr,
97*77c1e3ccSAndroid Build Coastguard Worker                   quant_shift_ptr, ref_qcoeff_ptr, ref_dqcoeff_ptr, dequant_ptr,
98*77c1e3ccSAndroid Build Coastguard Worker                   &ref_eob, scanOrder.scan, scanOrder.iscan, log_scale);
99*77c1e3ccSAndroid Build Coastguard Worker 
100*77c1e3ccSAndroid Build Coastguard Worker       API_REGISTER_STATE_CHECK(
101*77c1e3ccSAndroid Build Coastguard Worker           quanFunc(coeff_ptr, count, zbin_ptr, round_ptr, quant_ptr,
102*77c1e3ccSAndroid Build Coastguard Worker                    quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr, &eob,
103*77c1e3ccSAndroid Build Coastguard Worker                    scanOrder.scan, scanOrder.iscan, log_scale));
104*77c1e3ccSAndroid Build Coastguard Worker 
105*77c1e3ccSAndroid Build Coastguard Worker       for (int j = 0; j < count; ++j) {
106*77c1e3ccSAndroid Build Coastguard Worker         err_count += (ref_qcoeff_ptr[j] != qcoeff_ptr[j]) |
107*77c1e3ccSAndroid Build Coastguard Worker                      (ref_dqcoeff_ptr[j] != dqcoeff_ptr[j]);
108*77c1e3ccSAndroid Build Coastguard Worker         ASSERT_EQ(ref_qcoeff_ptr[j], qcoeff_ptr[j])
109*77c1e3ccSAndroid Build Coastguard Worker             << "qcoeff error: i = " << i << " j = " << j << "\n";
110*77c1e3ccSAndroid Build Coastguard Worker         EXPECT_EQ(ref_dqcoeff_ptr[j], dqcoeff_ptr[j])
111*77c1e3ccSAndroid Build Coastguard Worker             << "dqcoeff error: i = " << i << " j = " << j << "\n";
112*77c1e3ccSAndroid Build Coastguard Worker       }
113*77c1e3ccSAndroid Build Coastguard Worker       EXPECT_EQ(ref_eob, eob) << "eob error: "
114*77c1e3ccSAndroid Build Coastguard Worker                               << "i = " << i << "\n";
115*77c1e3ccSAndroid Build Coastguard Worker       err_count += (ref_eob != eob);
116*77c1e3ccSAndroid Build Coastguard Worker       if (err_count && !err_count_total) {
117*77c1e3ccSAndroid Build Coastguard Worker         first_failure = i;
118*77c1e3ccSAndroid Build Coastguard Worker       }
119*77c1e3ccSAndroid Build Coastguard Worker       err_count_total += err_count;
120*77c1e3ccSAndroid Build Coastguard Worker     }
121*77c1e3ccSAndroid Build Coastguard Worker     EXPECT_EQ(0, err_count_total)
122*77c1e3ccSAndroid Build Coastguard Worker         << "Error: Quantization Test, C output doesn't match SSE2 output. "
123*77c1e3ccSAndroid Build Coastguard Worker         << "First failed at test case " << first_failure;
124*77c1e3ccSAndroid Build Coastguard Worker   }
125*77c1e3ccSAndroid Build Coastguard Worker 
RunEobTest()126*77c1e3ccSAndroid Build Coastguard Worker   void RunEobTest() {
127*77c1e3ccSAndroid Build Coastguard Worker     ACMRandom rnd(ACMRandom::DeterministicSeed());
128*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, tran_low_t, coeff_ptr[maxSize]);
129*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, int16_t, zbin_ptr[8]);
130*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, int16_t, round_ptr[8]);
131*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, int16_t, quant_ptr[8]);
132*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, int16_t, quant_shift_ptr[8]);
133*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, tran_low_t, qcoeff_ptr[maxSize]);
134*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, tran_low_t, dqcoeff_ptr[maxSize]);
135*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, tran_low_t, ref_qcoeff_ptr[maxSize]);
136*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, tran_low_t, ref_dqcoeff_ptr[maxSize]);
137*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, int16_t, dequant_ptr[8]);
138*77c1e3ccSAndroid Build Coastguard Worker     uint16_t eob;
139*77c1e3ccSAndroid Build Coastguard Worker     uint16_t ref_eob;
140*77c1e3ccSAndroid Build Coastguard Worker     int count = params_.coeffCount;
141*77c1e3ccSAndroid Build Coastguard Worker     const TX_SIZE txSize = getTxSize(count);
142*77c1e3ccSAndroid Build Coastguard Worker     int log_scale = (txSize == TX_32X32);
143*77c1e3ccSAndroid Build Coastguard Worker     QuantizeFpFunc quanFunc = params_.qFunc;
144*77c1e3ccSAndroid Build Coastguard Worker     QuantizeFpFunc quanFuncRef = params_.qFuncRef;
145*77c1e3ccSAndroid Build Coastguard Worker     const SCAN_ORDER scanOrder = av1_scan_orders[txSize][DCT_DCT];
146*77c1e3ccSAndroid Build Coastguard Worker 
147*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < numTests; i++) {
148*77c1e3ccSAndroid Build Coastguard Worker       ref_eob = eob = UINT16_MAX;
149*77c1e3ccSAndroid Build Coastguard Worker       for (int j = 0; j < count; j++) {
150*77c1e3ccSAndroid Build Coastguard Worker         coeff_ptr[j] = 0;
151*77c1e3ccSAndroid Build Coastguard Worker       }
152*77c1e3ccSAndroid Build Coastguard Worker 
153*77c1e3ccSAndroid Build Coastguard Worker       coeff_ptr[rnd(count)] = rnd(coeffRange);
154*77c1e3ccSAndroid Build Coastguard Worker       coeff_ptr[rnd(count)] = rnd(coeffRange);
155*77c1e3ccSAndroid Build Coastguard Worker       coeff_ptr[rnd(count)] = rnd(coeffRange);
156*77c1e3ccSAndroid Build Coastguard Worker 
157*77c1e3ccSAndroid Build Coastguard Worker       for (int j = 0; j < 2; j++) {
158*77c1e3ccSAndroid Build Coastguard Worker         zbin_ptr[j] = rnd.Rand16Signed();
159*77c1e3ccSAndroid Build Coastguard Worker         quant_shift_ptr[j] = rnd.Rand16Signed();
160*77c1e3ccSAndroid Build Coastguard Worker         // int16_t positive
161*77c1e3ccSAndroid Build Coastguard Worker         dequant_ptr[j] = abs(rnd(dequantRange));
162*77c1e3ccSAndroid Build Coastguard Worker         quant_ptr[j] = (1 << 16) / dequant_ptr[j];
163*77c1e3ccSAndroid Build Coastguard Worker         round_ptr[j] = (abs(rnd(roundFactorRange)) * dequant_ptr[j]) >> 7;
164*77c1e3ccSAndroid Build Coastguard Worker       }
165*77c1e3ccSAndroid Build Coastguard Worker       for (int j = 2; j < 8; ++j) {
166*77c1e3ccSAndroid Build Coastguard Worker         zbin_ptr[j] = zbin_ptr[1];
167*77c1e3ccSAndroid Build Coastguard Worker         quant_shift_ptr[j] = quant_shift_ptr[1];
168*77c1e3ccSAndroid Build Coastguard Worker         dequant_ptr[j] = dequant_ptr[1];
169*77c1e3ccSAndroid Build Coastguard Worker         quant_ptr[j] = quant_ptr[1];
170*77c1e3ccSAndroid Build Coastguard Worker         round_ptr[j] = round_ptr[1];
171*77c1e3ccSAndroid Build Coastguard Worker       }
172*77c1e3ccSAndroid Build Coastguard Worker 
173*77c1e3ccSAndroid Build Coastguard Worker       quanFuncRef(coeff_ptr, count, zbin_ptr, round_ptr, quant_ptr,
174*77c1e3ccSAndroid Build Coastguard Worker                   quant_shift_ptr, ref_qcoeff_ptr, ref_dqcoeff_ptr, dequant_ptr,
175*77c1e3ccSAndroid Build Coastguard Worker                   &ref_eob, scanOrder.scan, scanOrder.iscan, log_scale);
176*77c1e3ccSAndroid Build Coastguard Worker 
177*77c1e3ccSAndroid Build Coastguard Worker       API_REGISTER_STATE_CHECK(
178*77c1e3ccSAndroid Build Coastguard Worker           quanFunc(coeff_ptr, count, zbin_ptr, round_ptr, quant_ptr,
179*77c1e3ccSAndroid Build Coastguard Worker                    quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr, &eob,
180*77c1e3ccSAndroid Build Coastguard Worker                    scanOrder.scan, scanOrder.iscan, log_scale));
181*77c1e3ccSAndroid Build Coastguard Worker       EXPECT_EQ(ref_eob, eob) << "eob error: "
182*77c1e3ccSAndroid Build Coastguard Worker                               << "i = " << i << "\n";
183*77c1e3ccSAndroid Build Coastguard Worker     }
184*77c1e3ccSAndroid Build Coastguard Worker   }
185*77c1e3ccSAndroid Build Coastguard Worker 
SetUp()186*77c1e3ccSAndroid Build Coastguard Worker   void SetUp() override { params_ = GetParam(); }
187*77c1e3ccSAndroid Build Coastguard Worker 
188*77c1e3ccSAndroid Build Coastguard Worker   ~AV1QuantizeTest() override = default;
189*77c1e3ccSAndroid Build Coastguard Worker 
190*77c1e3ccSAndroid Build Coastguard Worker  private:
getTxSize(int count)191*77c1e3ccSAndroid Build Coastguard Worker   TX_SIZE getTxSize(int count) {
192*77c1e3ccSAndroid Build Coastguard Worker     switch (count) {
193*77c1e3ccSAndroid Build Coastguard Worker       case 16: return TX_4X4;
194*77c1e3ccSAndroid Build Coastguard Worker       case 64: return TX_8X8;
195*77c1e3ccSAndroid Build Coastguard Worker       case 256: return TX_16X16;
196*77c1e3ccSAndroid Build Coastguard Worker       case 1024: return TX_32X32;
197*77c1e3ccSAndroid Build Coastguard Worker       default: return TX_4X4;
198*77c1e3ccSAndroid Build Coastguard Worker     }
199*77c1e3ccSAndroid Build Coastguard Worker   }
200*77c1e3ccSAndroid Build Coastguard Worker 
201*77c1e3ccSAndroid Build Coastguard Worker   QuantizeFuncParams params_;
202*77c1e3ccSAndroid Build Coastguard Worker };
203*77c1e3ccSAndroid Build Coastguard Worker GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AV1QuantizeTest);
204*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1QuantizeTest,BitExactCheck)205*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1QuantizeTest, BitExactCheck) { RunQuantizeTest(); }
TEST_P(AV1QuantizeTest,EobVerify)206*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1QuantizeTest, EobVerify) { RunEobTest(); }
207*77c1e3ccSAndroid Build Coastguard Worker 
TEST(AV1QuantizeTest,QuantizeFpNoQmatrix)208*77c1e3ccSAndroid Build Coastguard Worker TEST(AV1QuantizeTest, QuantizeFpNoQmatrix) {
209*77c1e3ccSAndroid Build Coastguard Worker   // Here we use a uniform quantizer as an example
210*77c1e3ccSAndroid Build Coastguard Worker   const int16_t dequant_ptr[2] = { 78, 93 };  // quantize step
211*77c1e3ccSAndroid Build Coastguard Worker   const int16_t round_ptr[2] = { 39, 46 };    // round ~= dequant / 2
212*77c1e3ccSAndroid Build Coastguard Worker 
213*77c1e3ccSAndroid Build Coastguard Worker   // quant ~= 2^16 / dequant. This is a 16-bit fixed point representation of the
214*77c1e3ccSAndroid Build Coastguard Worker   // inverse of quantize step.
215*77c1e3ccSAndroid Build Coastguard Worker   const int16_t quant_ptr[2] = { 840, 704 };
216*77c1e3ccSAndroid Build Coastguard Worker   int log_scale = 0;
217*77c1e3ccSAndroid Build Coastguard Worker   int coeff_count = 4;
218*77c1e3ccSAndroid Build Coastguard Worker   const tran_low_t coeff_ptr[4] = { -449, 624, -14, 24 };
219*77c1e3ccSAndroid Build Coastguard Worker   const tran_low_t ref_qcoeff_ptr[4] = { -6, 7, 0, 0 };
220*77c1e3ccSAndroid Build Coastguard Worker   const tran_low_t ref_dqcoeff_ptr[4] = { -468, 651, 0, 0 };
221*77c1e3ccSAndroid Build Coastguard Worker   const int16_t scan[4] = { 0, 1, 2, 3 };
222*77c1e3ccSAndroid Build Coastguard Worker   tran_low_t qcoeff_ptr[4];
223*77c1e3ccSAndroid Build Coastguard Worker   tran_low_t dqcoeff_ptr[4];
224*77c1e3ccSAndroid Build Coastguard Worker   int eob = av1_quantize_fp_no_qmatrix(quant_ptr, dequant_ptr, round_ptr,
225*77c1e3ccSAndroid Build Coastguard Worker                                        log_scale, scan, coeff_count, coeff_ptr,
226*77c1e3ccSAndroid Build Coastguard Worker                                        qcoeff_ptr, dqcoeff_ptr);
227*77c1e3ccSAndroid Build Coastguard Worker   EXPECT_EQ(eob, 2);
228*77c1e3ccSAndroid Build Coastguard Worker   for (int i = 0; i < coeff_count; ++i) {
229*77c1e3ccSAndroid Build Coastguard Worker     EXPECT_EQ(qcoeff_ptr[i], ref_qcoeff_ptr[i]);
230*77c1e3ccSAndroid Build Coastguard Worker     EXPECT_EQ(dqcoeff_ptr[i], ref_dqcoeff_ptr[i]);
231*77c1e3ccSAndroid Build Coastguard Worker   }
232*77c1e3ccSAndroid Build Coastguard Worker }
233*77c1e3ccSAndroid Build Coastguard Worker 
234*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
235*77c1e3ccSAndroid Build Coastguard Worker const QuantizeFuncParams qfps[4] = {
236*77c1e3ccSAndroid Build Coastguard Worker   QuantizeFuncParams(&av1_highbd_quantize_fp_sse4_1, &av1_highbd_quantize_fp_c,
237*77c1e3ccSAndroid Build Coastguard Worker                      16),
238*77c1e3ccSAndroid Build Coastguard Worker   QuantizeFuncParams(&av1_highbd_quantize_fp_sse4_1, &av1_highbd_quantize_fp_c,
239*77c1e3ccSAndroid Build Coastguard Worker                      64),
240*77c1e3ccSAndroid Build Coastguard Worker   QuantizeFuncParams(&av1_highbd_quantize_fp_sse4_1, &av1_highbd_quantize_fp_c,
241*77c1e3ccSAndroid Build Coastguard Worker                      256),
242*77c1e3ccSAndroid Build Coastguard Worker   QuantizeFuncParams(&av1_highbd_quantize_fp_sse4_1, &av1_highbd_quantize_fp_c,
243*77c1e3ccSAndroid Build Coastguard Worker                      1024),
244*77c1e3ccSAndroid Build Coastguard Worker };
245*77c1e3ccSAndroid Build Coastguard Worker 
246*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE4_1, AV1QuantizeTest, ::testing::ValuesIn(qfps));
247*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_SSE4_1
248*77c1e3ccSAndroid Build Coastguard Worker 
249*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
250*77c1e3ccSAndroid Build Coastguard Worker const QuantizeFuncParams qfps_avx2[4] = {
251*77c1e3ccSAndroid Build Coastguard Worker   QuantizeFuncParams(&av1_highbd_quantize_fp_avx2, &av1_highbd_quantize_fp_c,
252*77c1e3ccSAndroid Build Coastguard Worker                      16),
253*77c1e3ccSAndroid Build Coastguard Worker   QuantizeFuncParams(&av1_highbd_quantize_fp_avx2, &av1_highbd_quantize_fp_c,
254*77c1e3ccSAndroid Build Coastguard Worker                      64),
255*77c1e3ccSAndroid Build Coastguard Worker   QuantizeFuncParams(&av1_highbd_quantize_fp_avx2, &av1_highbd_quantize_fp_c,
256*77c1e3ccSAndroid Build Coastguard Worker                      256),
257*77c1e3ccSAndroid Build Coastguard Worker   QuantizeFuncParams(&av1_highbd_quantize_fp_avx2, &av1_highbd_quantize_fp_c,
258*77c1e3ccSAndroid Build Coastguard Worker                      1024),
259*77c1e3ccSAndroid Build Coastguard Worker };
260*77c1e3ccSAndroid Build Coastguard Worker 
261*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, AV1QuantizeTest, ::testing::ValuesIn(qfps_avx2));
262*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_AVX2
263*77c1e3ccSAndroid Build Coastguard Worker 
264*77c1e3ccSAndroid Build Coastguard Worker }  // namespace
265