blob: bebf72fc3278210abfaced4690c9c0798e9f1927 [file] [log] [blame]
Yi Luoef39c842017-05-19 11:51:53 -07001/*
James Zernb7c05bd2024-06-11 19:15:10 -07002 * Copyright (c) 2017, Alliance for Open Media. All rights reserved.
Yi Luoef39c842017-05-19 11:51:53 -07003 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11
Scott LaVarnway61f1e352022-05-06 05:19:00 -070012#include <algorithm>
sarahparkera543df52018-11-02 16:02:05 -070013#include <tuple>
14
Yi Luoef39c842017-05-19 11:51:53 -070015#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
16
Tom Finegan60e653d2018-05-22 11:34:58 -070017#include "config/aom_config.h"
Tom Finegan44702c82018-05-22 13:00:39 -070018#include "config/aom_dsp_rtcd.h"
19#include "config/av1_rtcd.h"
Tom Finegan60e653d2018-05-22 11:34:58 -070020
Yi Luoef39c842017-05-19 11:51:53 -070021#include "aom/aom_codec.h"
Wan-Teh Chang87a1e9e2024-03-26 21:44:29 -070022#include "aom_dsp/txfm_common.h"
Yi Luo2d44b692017-06-07 16:41:51 -070023#include "aom_ports/aom_timer.h"
Yi Luoef39c842017-05-19 11:51:53 -070024#include "av1/encoder/encoder.h"
Peng Bin03ea5222018-04-12 15:59:54 +080025#include "av1/common/scan.h"
Yi Luoef39c842017-05-19 11:51:53 -070026#include "test/acm_random.h"
Yi Luoef39c842017-05-19 11:51:53 -070027#include "test/register_state_check.h"
28#include "test/util.h"
29
30namespace {
31using libaom_test::ACMRandom;
32
Peng Bin6b971982018-09-07 15:21:40 +080033#define QUAN_PARAM_LIST \
Peng Bin437cbae2018-04-19 20:39:22 +080034 const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr, \
35 const int16_t *round_ptr, const int16_t *quant_ptr, \
36 const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, \
37 tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, \
38 const int16_t *scan, const int16_t *iscan
39
Jerome Jiang3838b5c2020-09-01 18:28:52 -070040#define LP_QUANTIZE_PARAM_LIST \
41 const int16_t *coeff_ptr, intptr_t n_coeffs, const int16_t *round_ptr, \
42 const int16_t *quant_ptr, int16_t *qcoeff_ptr, int16_t *dqcoeff_ptr, \
43 const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, \
44 const int16_t *iscan
45
46typedef void (*LPQuantizeFunc)(LP_QUANTIZE_PARAM_LIST);
Yi Luo6faf3492017-06-15 16:56:08 -070047typedef void (*QuantizeFunc)(QUAN_PARAM_LIST);
Peng Bin6b971982018-09-07 15:21:40 +080048typedef void (*QuantizeFuncHbd)(QUAN_PARAM_LIST, int log_scale);
Yi Luo6faf3492017-06-15 16:56:08 -070049
Jerome Jiang3838b5c2020-09-01 18:28:52 -070050#undef LP_QUANTIZE_PARAM_LIST
51
Yi Luo6faf3492017-06-15 16:56:08 -070052#define HBD_QUAN_FUNC \
Peng Bin0dcd23c2018-04-19 21:42:30 +080053 fn(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr, quant_shift_ptr, \
54 qcoeff_ptr, dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan, log_scale)
Yi Luo6faf3492017-06-15 16:56:08 -070055
Peng Bin6b971982018-09-07 15:21:40 +080056#define LBD_QUAN_FUNC \
Peng Bin437cbae2018-04-19 20:39:22 +080057 fn(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr, quant_shift_ptr, \
58 qcoeff_ptr, dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan)
59
Yi Luo6faf3492017-06-15 16:56:08 -070060template <QuantizeFuncHbd fn>
61void highbd_quan16x16_wrapper(QUAN_PARAM_LIST) {
62 const int log_scale = 0;
63 HBD_QUAN_FUNC;
64}
65
66template <QuantizeFuncHbd fn>
67void highbd_quan32x32_wrapper(QUAN_PARAM_LIST) {
68 const int log_scale = 1;
69 HBD_QUAN_FUNC;
70}
71
72template <QuantizeFuncHbd fn>
73void highbd_quan64x64_wrapper(QUAN_PARAM_LIST) {
74 const int log_scale = 2;
75 HBD_QUAN_FUNC;
76}
Yi Luoef39c842017-05-19 11:51:53 -070077
Pascal Massiminoa6fe4322019-04-09 09:49:24 +020078enum QuantType { TYPE_B, TYPE_DC, TYPE_FP };
Yi Luo193422e2017-06-19 15:54:06 -070079
sarahparkera543df52018-11-02 16:02:05 -070080using std::tuple;
Jerome Jiang3838b5c2020-09-01 18:28:52 -070081
82template <typename FuncType>
83using QuantizeParam =
84 tuple<FuncType, FuncType, TX_SIZE, QuantType, aom_bit_depth_t>;
Yi Luoef39c842017-05-19 11:51:53 -070085
86typedef struct {
87 QUANTS quant;
88 Dequants dequant;
89} QuanTable;
90
91const int kTestNum = 1000;
92
Jerome Jiang3838b5c2020-09-01 18:28:52 -070093#define GET_TEMPLATE_PARAM(k) std::get<k>(this->GetParam())
94
95template <typename CoeffType, typename FuncType>
96class QuantizeTestBase
97 : public ::testing::TestWithParam<QuantizeParam<FuncType>> {
Yi Luoef39c842017-05-19 11:51:53 -070098 protected:
Jerome Jiange58af082020-08-28 14:53:14 -070099 QuantizeTestBase()
Jerome Jiang3838b5c2020-09-01 18:28:52 -0700100 : quant_ref_(GET_TEMPLATE_PARAM(0)), quant_(GET_TEMPLATE_PARAM(1)),
101 tx_size_(GET_TEMPLATE_PARAM(2)), type_(GET_TEMPLATE_PARAM(3)),
102 bd_(GET_TEMPLATE_PARAM(4)) {}
Yi Luoef39c842017-05-19 11:51:53 -0700103
James Zernf1fa1eb2023-07-25 15:34:13 -0700104 ~QuantizeTestBase() override = default;
Yi Luoef39c842017-05-19 11:51:53 -0700105
James Zernfaa2dcf2023-07-24 18:29:51 -0700106 void SetUp() override {
Yi Luo2d44b692017-06-07 16:41:51 -0700107 qtab_ = reinterpret_cast<QuanTable *>(aom_memalign(32, sizeof(*qtab_)));
James Zern1633b592021-11-22 15:48:34 -0800108 ASSERT_NE(qtab_, nullptr);
Yi Luo7e2dce02017-06-06 10:15:22 -0700109 const int n_coeffs = coeff_num();
Jerome Jiange58af082020-08-28 14:53:14 -0700110 coeff_ = reinterpret_cast<CoeffType *>(
111 aom_memalign(32, 6 * n_coeffs * sizeof(CoeffType)));
James Zern1633b592021-11-22 15:48:34 -0800112 ASSERT_NE(coeff_, nullptr);
Yi Luoef39c842017-05-19 11:51:53 -0700113 InitQuantizer();
114 }
115
James Zernfaa2dcf2023-07-24 18:29:51 -0700116 void TearDown() override {
Yi Luoef39c842017-05-19 11:51:53 -0700117 aom_free(qtab_);
James Zern664f04d2022-05-24 17:30:58 -0700118 qtab_ = nullptr;
Yi Luoef39c842017-05-19 11:51:53 -0700119 aom_free(coeff_);
James Zern664f04d2022-05-24 17:30:58 -0700120 coeff_ = nullptr;
Yi Luoef39c842017-05-19 11:51:53 -0700121 }
122
123 void InitQuantizer() {
Yaowu Xube42dc72017-11-08 17:38:24 -0800124 av1_build_quantizer(bd_, 0, 0, 0, 0, 0, &qtab_->quant, &qtab_->dequant);
Yi Luoef39c842017-05-19 11:51:53 -0700125 }
126
Jerome Jiange58af082020-08-28 14:53:14 -0700127 virtual void RunQuantizeFunc(
128 const CoeffType *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
129 const int16_t *round_ptr, const int16_t *quant_ptr,
130 const int16_t *quant_shift_ptr, CoeffType *qcoeff_ptr,
131 CoeffType *qcoeff_ref_ptr, CoeffType *dqcoeff_ptr,
132 CoeffType *dqcoeff_ref_ptr, const int16_t *dequant_ptr,
133 uint16_t *eob_ref_ptr, uint16_t *eob_ptr, const int16_t *scan,
134 const int16_t *iscan) = 0;
135
Yi Luo7e2dce02017-06-06 10:15:22 -0700136 void QuantizeRun(bool is_loop, int q = 0, int test_num = 1) {
Jerome Jiange58af082020-08-28 14:53:14 -0700137 CoeffType *coeff_ptr = coeff_;
Yi Luo7e2dce02017-06-06 10:15:22 -0700138 const intptr_t n_coeffs = coeff_num();
Yi Luoef39c842017-05-19 11:51:53 -0700139
Jerome Jiange58af082020-08-28 14:53:14 -0700140 CoeffType *qcoeff_ref = coeff_ptr + n_coeffs;
141 CoeffType *dqcoeff_ref = qcoeff_ref + n_coeffs;
Yi Luoef39c842017-05-19 11:51:53 -0700142
Jerome Jiange58af082020-08-28 14:53:14 -0700143 CoeffType *qcoeff = dqcoeff_ref + n_coeffs;
144 CoeffType *dqcoeff = qcoeff + n_coeffs;
Yi Luoef39c842017-05-19 11:51:53 -0700145 uint16_t *eob = (uint16_t *)(dqcoeff + n_coeffs);
146
147 // Testing uses 2-D DCT scan order table
Peng Bin03ea5222018-04-12 15:59:54 +0800148 const SCAN_ORDER *const sc = get_default_scan(tx_size_, DCT_DCT);
Yi Luoef39c842017-05-19 11:51:53 -0700149
150 // Testing uses luminance quantization table
151 const int16_t *zbin = qtab_->quant.y_zbin[q];
Yi Luo193422e2017-06-19 15:54:06 -0700152
James Zern65fca7c2023-07-25 15:39:01 -0700153 const int16_t *round = nullptr;
154 const int16_t *quant = nullptr;
Yi Luo193422e2017-06-19 15:54:06 -0700155 if (type_ == TYPE_B) {
156 round = qtab_->quant.y_round[q];
157 quant = qtab_->quant.y_quant[q];
158 } else if (type_ == TYPE_FP) {
159 round = qtab_->quant.y_round_fp[q];
160 quant = qtab_->quant.y_quant_fp[q];
161 }
162
Yi Luoef39c842017-05-19 11:51:53 -0700163 const int16_t *quant_shift = qtab_->quant.y_quant_shift[q];
Monty Montgomery125c0fc2017-10-26 00:44:35 -0400164 const int16_t *dequant = qtab_->dequant.y_dequant_QTX[q];
Yi Luoef39c842017-05-19 11:51:53 -0700165
Yi Luo7e2dce02017-06-06 10:15:22 -0700166 for (int i = 0; i < test_num; ++i) {
167 if (is_loop) FillCoeffRandom();
Yi Luoef39c842017-05-19 11:51:53 -0700168
169 memset(qcoeff_ref, 0, 5 * n_coeffs * sizeof(*qcoeff_ref));
170
Jerome Jiange58af082020-08-28 14:53:14 -0700171 RunQuantizeFunc(coeff_ptr, n_coeffs, zbin, round, quant, quant_shift,
172 qcoeff, qcoeff_ref, dqcoeff, dqcoeff_ref, dequant,
173 &eob[0], &eob[1], sc->scan, sc->iscan);
174
Yi Luo2d44b692017-06-07 16:41:51 -0700175 for (int j = 0; j < n_coeffs; ++j) {
176 ASSERT_EQ(qcoeff_ref[j], qcoeff[j])
177 << "Q mismatch on test: " << i << " at position: " << j
178 << " Q: " << q << " coeff: " << coeff_ptr[j];
179 }
180
181 for (int j = 0; j < n_coeffs; ++j) {
182 ASSERT_EQ(dqcoeff_ref[j], dqcoeff[j])
183 << "Dq mismatch on test: " << i << " at position: " << j
184 << " Q: " << q << " coeff: " << coeff_ptr[j];
185 }
186
clang-format4eafefe2017-09-04 12:51:20 -0700187 ASSERT_EQ(eob[0], eob[1])
188 << "eobs mismatch on test: " << i << " Q: " << q;
Yi Luoef39c842017-05-19 11:51:53 -0700189 }
190 }
191
Jerome Jiange58af082020-08-28 14:53:14 -0700192 void CompareResults(const CoeffType *buf_ref, const CoeffType *buf, int size,
193 const char *text, int q, int number) {
Yi Luoef39c842017-05-19 11:51:53 -0700194 int i;
195 for (i = 0; i < size; ++i) {
196 ASSERT_EQ(buf_ref[i], buf[i]) << text << " mismatch on test: " << number
197 << " at position: " << i << " Q: " << q;
198 }
199 }
200
Urvang Joshi80893152017-10-27 11:51:14 -0700201 int coeff_num() const { return av1_get_max_eob(tx_size_); }
Yi Luoef39c842017-05-19 11:51:53 -0700202
Jerome Jiange58af082020-08-28 14:53:14 -0700203 void FillCoeff(CoeffType c) {
Yi Luo7e2dce02017-06-06 10:15:22 -0700204 const int n_coeffs = coeff_num();
205 for (int i = 0; i < n_coeffs; ++i) {
206 coeff_[i] = c;
Yi Luoef39c842017-05-19 11:51:53 -0700207 }
208 }
209
Yi Luo7e2dce02017-06-06 10:15:22 -0700210 void FillCoeffRandom() {
211 const int n_coeffs = coeff_num();
212 FillCoeffZero();
Scott LaVarnway61f1e352022-05-06 05:19:00 -0700213 const int num = rnd_.Rand16() % n_coeffs;
214 // Randomize the first non zero coeff position.
215 const int start = rnd_.Rand16() % n_coeffs;
216 const int end = std::min(start + num, n_coeffs);
217 for (int i = start; i < end; ++i) {
Yi Luo7e2dce02017-06-06 10:15:22 -0700218 coeff_[i] = GetRandomCoeff();
219 }
220 }
221
Aniket Dhok64a5e402019-03-19 20:15:29 +0530222 void FillCoeffRandomRows(int num) {
223 FillCoeffZero();
224 for (int i = 0; i < num; ++i) {
225 coeff_[i] = GetRandomCoeff();
226 }
227 }
228
Yi Luo7e2dce02017-06-06 10:15:22 -0700229 void FillCoeffZero() { FillCoeff(0); }
Yi Luoef39c842017-05-19 11:51:53 -0700230
231 void FillCoeffConstant() {
Jerome Jiange58af082020-08-28 14:53:14 -0700232 CoeffType c = GetRandomCoeff();
Yi Luo7e2dce02017-06-06 10:15:22 -0700233 FillCoeff(c);
Yi Luoef39c842017-05-19 11:51:53 -0700234 }
235
236 void FillDcOnly() {
237 FillCoeffZero();
238 coeff_[0] = GetRandomCoeff();
239 }
240
241 void FillDcLargeNegative() {
242 FillCoeffZero();
243 // Generate a qcoeff which contains 512/-512 (0x0100/0xFE00) to catch issues
244 // like BUG=883 where the constant being compared was incorrectly
245 // initialized.
246 coeff_[0] = -8191;
247 }
248
Jerome Jiange58af082020-08-28 14:53:14 -0700249 CoeffType GetRandomCoeff() {
250 CoeffType coeff;
Yi Luo6faf3492017-06-15 16:56:08 -0700251 if (bd_ == AOM_BITS_8) {
252 coeff =
253 clamp(static_cast<int16_t>(rnd_.Rand16()), INT16_MIN + 1, INT16_MAX);
254 } else {
Jerome Jiange58af082020-08-28 14:53:14 -0700255 CoeffType min = -(1 << (7 + bd_));
256 CoeffType max = -min - 1;
257 coeff = clamp(static_cast<CoeffType>(rnd_.Rand31()), min, max);
Yi Luo6faf3492017-06-15 16:56:08 -0700258 }
259 return coeff;
Yi Luoef39c842017-05-19 11:51:53 -0700260 }
261
262 ACMRandom rnd_;
263 QuanTable *qtab_;
Jerome Jiange58af082020-08-28 14:53:14 -0700264 CoeffType *coeff_;
Jerome Jiang3838b5c2020-09-01 18:28:52 -0700265 FuncType quant_ref_;
266 FuncType quant_;
Yi Luoef39c842017-05-19 11:51:53 -0700267 TX_SIZE tx_size_;
Yi Luo193422e2017-06-19 15:54:06 -0700268 QuantType type_;
Yi Luoef39c842017-05-19 11:51:53 -0700269 aom_bit_depth_t bd_;
270};
271
Jerome Jiang3838b5c2020-09-01 18:28:52 -0700272class FullPrecisionQuantizeTest
273 : public QuantizeTestBase<tran_low_t, QuantizeFunc> {
Jerome Jiange58af082020-08-28 14:53:14 -0700274 void RunQuantizeFunc(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
275 const int16_t *zbin_ptr, const int16_t *round_ptr,
276 const int16_t *quant_ptr, const int16_t *quant_shift_ptr,
277 tran_low_t *qcoeff_ptr, tran_low_t *qcoeff_ref_ptr,
278 tran_low_t *dqcoeff_ptr, tran_low_t *dqcoeff_ref_ptr,
279 const int16_t *dequant_ptr, uint16_t *eob_ref_ptr,
280 uint16_t *eob_ptr, const int16_t *scan,
281 const int16_t *iscan) override {
282 quant_ref_(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
283 quant_shift_ptr, qcoeff_ref_ptr, dqcoeff_ref_ptr, dequant_ptr,
284 eob_ref_ptr, scan, iscan);
285
chiyotsaief261062021-07-01 14:01:45 -0700286 API_REGISTER_STATE_CHECK(quant_(
Jerome Jiange58af082020-08-28 14:53:14 -0700287 coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr, quant_shift_ptr,
288 qcoeff_ptr, dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan));
289 }
290};
291
Jerome Jiang3838b5c2020-09-01 18:28:52 -0700292class LowPrecisionQuantizeTest
293 : public QuantizeTestBase<int16_t, LPQuantizeFunc> {
294 void RunQuantizeFunc(const int16_t *coeff_ptr, intptr_t n_coeffs,
295 const int16_t * /*zbin_ptr*/, const int16_t *round_ptr,
296 const int16_t *quant_ptr,
297 const int16_t * /*quant_shift_ptr*/, int16_t *qcoeff_ptr,
298 int16_t *qcoeff_ref_ptr, int16_t *dqcoeff_ptr,
299 int16_t *dqcoeff_ref_ptr, const int16_t *dequant_ptr,
300 uint16_t *eob_ref_ptr, uint16_t *eob_ptr,
301 const int16_t *scan, const int16_t *iscan) override {
302 quant_ref_(coeff_ptr, n_coeffs, round_ptr, quant_ptr, qcoeff_ref_ptr,
303 dqcoeff_ref_ptr, dequant_ptr, eob_ref_ptr, scan, iscan);
304
305 API_REGISTER_STATE_CHECK(quant_(coeff_ptr, n_coeffs, round_ptr, quant_ptr,
306 qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
307 eob_ptr, scan, iscan));
308 }
309};
310
Jerome Jiange58af082020-08-28 14:53:14 -0700311TEST_P(FullPrecisionQuantizeTest, ZeroInput) {
Yi Luoef39c842017-05-19 11:51:53 -0700312 FillCoeffZero();
313 QuantizeRun(false);
314}
315
Jerome Jiange58af082020-08-28 14:53:14 -0700316TEST_P(FullPrecisionQuantizeTest, LargeNegativeInput) {
Yi Luoef39c842017-05-19 11:51:53 -0700317 FillDcLargeNegative();
Yi Luo2d44b692017-06-07 16:41:51 -0700318 QuantizeRun(false, 0, 1);
Yi Luoef39c842017-05-19 11:51:53 -0700319}
320
Jerome Jiange58af082020-08-28 14:53:14 -0700321TEST_P(FullPrecisionQuantizeTest, DcOnlyInput) {
Yi Luoef39c842017-05-19 11:51:53 -0700322 FillDcOnly();
Yi Luo2d44b692017-06-07 16:41:51 -0700323 QuantizeRun(false, 0, 1);
Yi Luoef39c842017-05-19 11:51:53 -0700324}
325
Jerome Jiange58af082020-08-28 14:53:14 -0700326TEST_P(FullPrecisionQuantizeTest, RandomInput) {
327 QuantizeRun(true, 0, kTestNum);
328}
Yi Luoef39c842017-05-19 11:51:53 -0700329
Jerome Jiange58af082020-08-28 14:53:14 -0700330TEST_P(FullPrecisionQuantizeTest, MultipleQ) {
Yi Luoef39c842017-05-19 11:51:53 -0700331 for (int q = 0; q < QINDEX_RANGE; ++q) {
332 QuantizeRun(true, q, kTestNum);
333 }
334}
335
Scott LaVarnway3e9e26f2018-05-02 12:51:16 -0700336// Force the coeff to be half the value of the dequant. This exposes a
337// mismatch found in av1_quantize_fp_sse2().
Jerome Jiange58af082020-08-28 14:53:14 -0700338TEST_P(FullPrecisionQuantizeTest, CoeffHalfDequant) {
Scott LaVarnway3e9e26f2018-05-02 12:51:16 -0700339 FillCoeff(16);
340 QuantizeRun(false, 25, 1);
341}
342
Jerome Jiange58af082020-08-28 14:53:14 -0700343TEST_P(FullPrecisionQuantizeTest, DISABLED_Speed) {
Yi Luo2d44b692017-06-07 16:41:51 -0700344 tran_low_t *coeff_ptr = coeff_;
345 const intptr_t n_coeffs = coeff_num();
Yi Luo2d44b692017-06-07 16:41:51 -0700346
347 tran_low_t *qcoeff_ref = coeff_ptr + n_coeffs;
348 tran_low_t *dqcoeff_ref = qcoeff_ref + n_coeffs;
349
350 tran_low_t *qcoeff = dqcoeff_ref + n_coeffs;
351 tran_low_t *dqcoeff = qcoeff + n_coeffs;
352 uint16_t *eob = (uint16_t *)(dqcoeff + n_coeffs);
353
354 // Testing uses 2-D DCT scan order table
Peng Bin03ea5222018-04-12 15:59:54 +0800355 const SCAN_ORDER *const sc = get_default_scan(tx_size_, DCT_DCT);
Yi Luo2d44b692017-06-07 16:41:51 -0700356
357 // Testing uses luminance quantization table
358 const int q = 22;
359 const int16_t *zbin = qtab_->quant.y_zbin[q];
360 const int16_t *round_fp = qtab_->quant.y_round_fp[q];
361 const int16_t *quant_fp = qtab_->quant.y_quant_fp[q];
362 const int16_t *quant_shift = qtab_->quant.y_quant_shift[q];
Monty Montgomery125c0fc2017-10-26 00:44:35 -0400363 const int16_t *dequant = qtab_->dequant.y_dequant_QTX[q];
Yi Luo2d44b692017-06-07 16:41:51 -0700364 const int kNumTests = 5000000;
Aniket Dhok90fc8d02018-11-21 18:28:32 +0530365 aom_usec_timer timer, simd_timer;
Aniket Dhok64a5e402019-03-19 20:15:29 +0530366 int rows = tx_size_high[tx_size_];
367 int cols = tx_size_wide[tx_size_];
Aniket Dhok29d8ce42019-03-29 19:44:02 +0530368 rows = AOMMIN(32, rows);
369 cols = AOMMIN(32, cols);
Aniket Dhok64a5e402019-03-19 20:15:29 +0530370 for (int cnt = 0; cnt <= rows; cnt++) {
371 FillCoeffRandomRows(cnt * cols);
Yi Luo2d44b692017-06-07 16:41:51 -0700372
Aniket Dhok64a5e402019-03-19 20:15:29 +0530373 aom_usec_timer_start(&timer);
374 for (int n = 0; n < kNumTests; ++n) {
375 quant_ref_(coeff_ptr, n_coeffs, zbin, round_fp, quant_fp, quant_shift,
376 qcoeff, dqcoeff, dequant, eob, sc->scan, sc->iscan);
377 }
378 aom_usec_timer_mark(&timer);
Yi Luo2d44b692017-06-07 16:41:51 -0700379
Aniket Dhok64a5e402019-03-19 20:15:29 +0530380 aom_usec_timer_start(&simd_timer);
381 for (int n = 0; n < kNumTests; ++n) {
382 quant_(coeff_ptr, n_coeffs, zbin, round_fp, quant_fp, quant_shift, qcoeff,
383 dqcoeff, dequant, eob, sc->scan, sc->iscan);
384 }
385 aom_usec_timer_mark(&simd_timer);
386
387 const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
388 const int simd_elapsed_time =
389 static_cast<int>(aom_usec_timer_elapsed(&simd_timer));
Scott LaVarnway85b7ce72022-04-26 05:56:34 -0700390 printf("c_time = %d \t simd_time = %d \t Gain = %f \n", elapsed_time,
391 simd_elapsed_time, ((float)elapsed_time / simd_elapsed_time));
Yi Luo2d44b692017-06-07 16:41:51 -0700392 }
Yi Luo2d44b692017-06-07 16:41:51 -0700393}
394
Jerome Jiang3838b5c2020-09-01 18:28:52 -0700395// TODO(crbug.com/aomedia/2796)
396TEST_P(LowPrecisionQuantizeTest, ZeroInput) {
397 FillCoeffZero();
398 QuantizeRun(false);
399}
400
401TEST_P(LowPrecisionQuantizeTest, LargeNegativeInput) {
402 FillDcLargeNegative();
403 QuantizeRun(false, 0, 1);
404}
405
406TEST_P(LowPrecisionQuantizeTest, DcOnlyInput) {
407 FillDcOnly();
408 QuantizeRun(false, 0, 1);
409}
410
411TEST_P(LowPrecisionQuantizeTest, RandomInput) {
412 QuantizeRun(true, 0, kTestNum);
413}
414
415TEST_P(LowPrecisionQuantizeTest, MultipleQ) {
416 for (int q = 0; q < QINDEX_RANGE; ++q) {
417 QuantizeRun(true, q, kTestNum);
418 }
419}
420
421// Force the coeff to be half the value of the dequant. This exposes a
422// mismatch found in av1_quantize_fp_sse2().
423TEST_P(LowPrecisionQuantizeTest, CoeffHalfDequant) {
424 FillCoeff(16);
425 QuantizeRun(false, 25, 1);
426}
427
428TEST_P(LowPrecisionQuantizeTest, DISABLED_Speed) {
429 int16_t *coeff_ptr = coeff_;
430 const intptr_t n_coeffs = coeff_num();
431
432 int16_t *qcoeff_ref = coeff_ptr + n_coeffs;
433 int16_t *dqcoeff_ref = qcoeff_ref + n_coeffs;
434
435 int16_t *qcoeff = dqcoeff_ref + n_coeffs;
436 int16_t *dqcoeff = qcoeff + n_coeffs;
437 uint16_t *eob = (uint16_t *)(dqcoeff + n_coeffs);
438
439 // Testing uses 2-D DCT scan order table
440 const SCAN_ORDER *const sc = get_default_scan(tx_size_, DCT_DCT);
441
442 // Testing uses luminance quantization table
443 const int q = 22;
444 const int16_t *round_fp = qtab_->quant.y_round_fp[q];
445 const int16_t *quant_fp = qtab_->quant.y_quant_fp[q];
446 const int16_t *dequant = qtab_->dequant.y_dequant_QTX[q];
447 const int kNumTests = 5000000;
448 aom_usec_timer timer, simd_timer;
449 int rows = tx_size_high[tx_size_];
450 int cols = tx_size_wide[tx_size_];
451 rows = AOMMIN(32, rows);
452 cols = AOMMIN(32, cols);
453 for (int cnt = 0; cnt <= rows; cnt++) {
454 FillCoeffRandomRows(cnt * cols);
455
456 aom_usec_timer_start(&timer);
457 for (int n = 0; n < kNumTests; ++n) {
458 quant_ref_(coeff_ptr, n_coeffs, round_fp, quant_fp, qcoeff, dqcoeff,
459 dequant, eob, sc->scan, sc->iscan);
460 }
461 aom_usec_timer_mark(&timer);
462
463 aom_usec_timer_start(&simd_timer);
464 for (int n = 0; n < kNumTests; ++n) {
465 quant_(coeff_ptr, n_coeffs, round_fp, quant_fp, qcoeff, dqcoeff, dequant,
466 eob, sc->scan, sc->iscan);
467 }
468 aom_usec_timer_mark(&simd_timer);
469
470 const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
471 const int simd_elapsed_time =
472 static_cast<int>(aom_usec_timer_elapsed(&simd_timer));
473 printf("c_time = %d \t simd_time = %d \t Gain = %f \n", elapsed_time,
474 simd_elapsed_time, ((float)elapsed_time / simd_elapsed_time));
475 }
476}
477
sarahparkera543df52018-11-02 16:02:05 -0700478using std::make_tuple;
Yi Luoef39c842017-05-19 11:51:53 -0700479
Yi Luo2d44b692017-06-07 16:41:51 -0700480#if HAVE_AVX2
Jerome Jiang3838b5c2020-09-01 18:28:52 -0700481
482const QuantizeParam<LPQuantizeFunc> kLPQParamArrayAvx2[] = {
483 make_tuple(&av1_quantize_lp_c, &av1_quantize_lp_avx2,
484 static_cast<TX_SIZE>(TX_16X16), TYPE_FP, AOM_BITS_8),
485 make_tuple(&av1_quantize_lp_c, &av1_quantize_lp_avx2,
Salome Thirot69975b12024-03-15 15:37:39 +0000486 static_cast<TX_SIZE>(TX_8X8), TYPE_FP, AOM_BITS_8),
Jerome Jiang3838b5c2020-09-01 18:28:52 -0700487 make_tuple(&av1_quantize_lp_c, &av1_quantize_lp_avx2,
Salome Thirot69975b12024-03-15 15:37:39 +0000488 static_cast<TX_SIZE>(TX_4X4), TYPE_FP, AOM_BITS_8)
Jerome Jiang3838b5c2020-09-01 18:28:52 -0700489};
490
491INSTANTIATE_TEST_SUITE_P(AVX2, LowPrecisionQuantizeTest,
492 ::testing::ValuesIn(kLPQParamArrayAvx2));
493
494const QuantizeParam<QuantizeFunc> kQParamArrayAvx2[] = {
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200495 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_avx2,
496 static_cast<TX_SIZE>(TX_16X16), TYPE_FP, AOM_BITS_8),
497 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_avx2,
498 static_cast<TX_SIZE>(TX_4X16), TYPE_FP, AOM_BITS_8),
499 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_avx2,
500 static_cast<TX_SIZE>(TX_16X4), TYPE_FP, AOM_BITS_8),
501 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_avx2,
502 static_cast<TX_SIZE>(TX_32X8), TYPE_FP, AOM_BITS_8),
503 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_avx2,
504 static_cast<TX_SIZE>(TX_8X32), TYPE_FP, AOM_BITS_8),
505 make_tuple(&av1_quantize_fp_32x32_c, &av1_quantize_fp_32x32_avx2,
506 static_cast<TX_SIZE>(TX_32X32), TYPE_FP, AOM_BITS_8),
507 make_tuple(&av1_quantize_fp_32x32_c, &av1_quantize_fp_32x32_avx2,
508 static_cast<TX_SIZE>(TX_16X64), TYPE_FP, AOM_BITS_8),
509 make_tuple(&av1_quantize_fp_32x32_c, &av1_quantize_fp_32x32_avx2,
510 static_cast<TX_SIZE>(TX_64X16), TYPE_FP, AOM_BITS_8),
511 make_tuple(&av1_quantize_fp_64x64_c, &av1_quantize_fp_64x64_avx2,
512 static_cast<TX_SIZE>(TX_64X64), TYPE_FP, AOM_BITS_8),
Jerome Jiangf8cc1c42019-08-02 16:34:32 -0700513#if CONFIG_AV1_HIGHBITDEPTH
Yi Luo6faf3492017-06-15 16:56:08 -0700514 make_tuple(&highbd_quan16x16_wrapper<av1_highbd_quantize_fp_c>,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200515 &highbd_quan16x16_wrapper<av1_highbd_quantize_fp_avx2>,
516 static_cast<TX_SIZE>(TX_16X16), TYPE_FP, AOM_BITS_8),
Yi Luo6faf3492017-06-15 16:56:08 -0700517 make_tuple(&highbd_quan16x16_wrapper<av1_highbd_quantize_fp_c>,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200518 &highbd_quan16x16_wrapper<av1_highbd_quantize_fp_avx2>,
519 static_cast<TX_SIZE>(TX_16X16), TYPE_FP, AOM_BITS_10),
Yi Luo6faf3492017-06-15 16:56:08 -0700520 make_tuple(&highbd_quan16x16_wrapper<av1_highbd_quantize_fp_c>,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200521 &highbd_quan16x16_wrapper<av1_highbd_quantize_fp_avx2>,
522 static_cast<TX_SIZE>(TX_16X16), TYPE_FP, AOM_BITS_12),
Yi Luo6faf3492017-06-15 16:56:08 -0700523 make_tuple(&highbd_quan32x32_wrapper<av1_highbd_quantize_fp_c>,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200524 &highbd_quan32x32_wrapper<av1_highbd_quantize_fp_avx2>,
525 static_cast<TX_SIZE>(TX_32X32), TYPE_FP, AOM_BITS_8),
Yi Luo6faf3492017-06-15 16:56:08 -0700526 make_tuple(&highbd_quan32x32_wrapper<av1_highbd_quantize_fp_c>,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200527 &highbd_quan32x32_wrapper<av1_highbd_quantize_fp_avx2>,
528 static_cast<TX_SIZE>(TX_32X32), TYPE_FP, AOM_BITS_10),
Yi Luo6faf3492017-06-15 16:56:08 -0700529 make_tuple(&highbd_quan32x32_wrapper<av1_highbd_quantize_fp_c>,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200530 &highbd_quan32x32_wrapper<av1_highbd_quantize_fp_avx2>,
531 static_cast<TX_SIZE>(TX_32X32), TYPE_FP, AOM_BITS_12),
Yi Luo6faf3492017-06-15 16:56:08 -0700532 make_tuple(&highbd_quan64x64_wrapper<av1_highbd_quantize_fp_c>,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200533 &highbd_quan64x64_wrapper<av1_highbd_quantize_fp_avx2>,
534 static_cast<TX_SIZE>(TX_64X64), TYPE_FP, AOM_BITS_8),
Yi Luo6faf3492017-06-15 16:56:08 -0700535 make_tuple(&highbd_quan64x64_wrapper<av1_highbd_quantize_fp_c>,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200536 &highbd_quan64x64_wrapper<av1_highbd_quantize_fp_avx2>,
537 static_cast<TX_SIZE>(TX_64X64), TYPE_FP, AOM_BITS_10),
Yi Luo6faf3492017-06-15 16:56:08 -0700538 make_tuple(&highbd_quan64x64_wrapper<av1_highbd_quantize_fp_c>,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200539 &highbd_quan64x64_wrapper<av1_highbd_quantize_fp_avx2>,
540 static_cast<TX_SIZE>(TX_64X64), TYPE_FP, AOM_BITS_12),
541 make_tuple(&aom_highbd_quantize_b_c, &aom_highbd_quantize_b_avx2,
542 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_8),
543 make_tuple(&aom_highbd_quantize_b_c, &aom_highbd_quantize_b_avx2,
544 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_10),
545 make_tuple(&aom_highbd_quantize_b_c, &aom_highbd_quantize_b_avx2,
546 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_12),
Scott LaVarnwaycfce5002022-06-13 10:18:00 -0700547 make_tuple(&aom_highbd_quantize_b_32x32_c, &aom_highbd_quantize_b_32x32_avx2,
548 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_12),
Scott LaVarnwaya62d5d72022-06-14 18:20:37 -0700549 make_tuple(&aom_highbd_quantize_b_64x64_c, &aom_highbd_quantize_b_64x64_avx2,
550 static_cast<TX_SIZE>(TX_64X64), TYPE_B, AOM_BITS_12),
James Zern7c6fd212022-06-09 13:41:52 -0700551#if !CONFIG_REALTIME_ONLY
Remya8a99f6b2019-05-27 18:36:12 +0530552 make_tuple(&aom_highbd_quantize_b_adaptive_c,
553 &aom_highbd_quantize_b_adaptive_avx2,
554 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_8),
555 make_tuple(&aom_highbd_quantize_b_adaptive_c,
556 &aom_highbd_quantize_b_adaptive_avx2,
557 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_10),
558 make_tuple(&aom_highbd_quantize_b_adaptive_c,
559 &aom_highbd_quantize_b_adaptive_avx2,
Remyaa7d48a62019-06-03 14:22:34 +0530560 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_12),
561 make_tuple(&aom_highbd_quantize_b_32x32_adaptive_c,
562 &aom_highbd_quantize_b_32x32_adaptive_avx2,
563 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_8),
564 make_tuple(&aom_highbd_quantize_b_32x32_adaptive_c,
565 &aom_highbd_quantize_b_32x32_adaptive_avx2,
566 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_10),
567 make_tuple(&aom_highbd_quantize_b_32x32_adaptive_c,
568 &aom_highbd_quantize_b_32x32_adaptive_avx2,
Jerome Jiangf8cc1c42019-08-02 16:34:32 -0700569 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_12),
James Zern7c6fd212022-06-09 13:41:52 -0700570#endif // !CONFIG_REALTIME_ONLY
571#endif // CONFIG_AV1_HIGHBITDEPTH
572#if !CONFIG_REALTIME_ONLY
Jerome Jiangf8cc1c42019-08-02 16:34:32 -0700573 make_tuple(&aom_quantize_b_adaptive_c, &aom_quantize_b_adaptive_avx2,
574 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_8),
575 make_tuple(&aom_quantize_b_adaptive_c, &aom_quantize_b_adaptive_avx2,
576 static_cast<TX_SIZE>(TX_8X8), TYPE_B, AOM_BITS_8),
577 make_tuple(&aom_quantize_b_adaptive_c, &aom_quantize_b_adaptive_avx2,
Scott LaVarnway93ae6152022-06-01 11:33:19 -0700578 static_cast<TX_SIZE>(TX_4X4), TYPE_B, AOM_BITS_8),
James Zern7c6fd212022-06-09 13:41:52 -0700579#endif // !CONFIG_REALTIME_ONLY
Scott LaVarnway93ae6152022-06-01 11:33:19 -0700580 make_tuple(&aom_quantize_b_c, &aom_quantize_b_avx2,
581 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_8),
Scott LaVarnwaydbd28672022-06-09 16:47:13 -0700582 make_tuple(&aom_quantize_b_32x32_c, &aom_quantize_b_32x32_avx2,
583 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_8),
Scott LaVarnway339fef72022-06-09 18:10:02 -0700584 make_tuple(&aom_quantize_b_64x64_c, &aom_quantize_b_64x64_avx2,
585 static_cast<TX_SIZE>(TX_64X64), TYPE_B, AOM_BITS_8),
Yi Luo2d44b692017-06-07 16:41:51 -0700586};
587
Jerome Jiange58af082020-08-28 14:53:14 -0700588INSTANTIATE_TEST_SUITE_P(AVX2, FullPrecisionQuantizeTest,
Cheng Chen96786fe2020-02-14 17:28:25 -0800589 ::testing::ValuesIn(kQParamArrayAvx2));
Yi Luo6faf3492017-06-15 16:56:08 -0700590#endif // HAVE_AVX2
Yi Luo2d44b692017-06-07 16:41:51 -0700591
Yi Luoef39c842017-05-19 11:51:53 -0700592#if HAVE_SSE2
Jerome Jiang3838b5c2020-09-01 18:28:52 -0700593
594const QuantizeParam<LPQuantizeFunc> kLPQParamArraySSE2[] = {
595 make_tuple(&av1_quantize_lp_c, &av1_quantize_lp_sse2,
596 static_cast<TX_SIZE>(TX_16X16), TYPE_FP, AOM_BITS_8),
597 make_tuple(&av1_quantize_lp_c, &av1_quantize_lp_sse2,
598 static_cast<TX_SIZE>(TX_8X8), TYPE_FP, AOM_BITS_8),
599 make_tuple(&av1_quantize_lp_c, &av1_quantize_lp_sse2,
600 static_cast<TX_SIZE>(TX_4X4), TYPE_FP, AOM_BITS_8)
601};
602
603INSTANTIATE_TEST_SUITE_P(SSE2, LowPrecisionQuantizeTest,
604 ::testing::ValuesIn(kLPQParamArraySSE2));
605
606const QuantizeParam<QuantizeFunc> kQParamArraySSE2[] = {
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200607 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_sse2,
608 static_cast<TX_SIZE>(TX_16X16), TYPE_FP, AOM_BITS_8),
609 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_sse2,
610 static_cast<TX_SIZE>(TX_4X16), TYPE_FP, AOM_BITS_8),
611 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_sse2,
612 static_cast<TX_SIZE>(TX_16X4), TYPE_FP, AOM_BITS_8),
613 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_sse2,
614 static_cast<TX_SIZE>(TX_8X32), TYPE_FP, AOM_BITS_8),
615 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_sse2,
616 static_cast<TX_SIZE>(TX_32X8), TYPE_FP, AOM_BITS_8),
617 make_tuple(&aom_quantize_b_c, &aom_quantize_b_sse2,
618 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_8),
Jerome Jiangf8cc1c42019-08-02 16:34:32 -0700619#if CONFIG_AV1_HIGHBITDEPTH
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200620 make_tuple(&aom_highbd_quantize_b_c, &aom_highbd_quantize_b_sse2,
621 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_8),
622 make_tuple(&aom_highbd_quantize_b_c, &aom_highbd_quantize_b_sse2,
623 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_10),
624 make_tuple(&aom_highbd_quantize_b_c, &aom_highbd_quantize_b_sse2,
625 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_12),
James Zern7c6fd212022-06-09 13:41:52 -0700626#if !CONFIG_REALTIME_ONLY
Remya7a3af0c2019-06-04 11:51:32 +0530627 make_tuple(&aom_highbd_quantize_b_adaptive_c,
628 &aom_highbd_quantize_b_adaptive_sse2,
629 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_8),
630 make_tuple(&aom_highbd_quantize_b_adaptive_c,
631 &aom_highbd_quantize_b_adaptive_sse2,
632 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_10),
633 make_tuple(&aom_highbd_quantize_b_adaptive_c,
634 &aom_highbd_quantize_b_adaptive_sse2,
635 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_12),
Yi Luo193422e2017-06-19 15:54:06 -0700636 make_tuple(&aom_highbd_quantize_b_32x32_c, &aom_highbd_quantize_b_32x32_sse2,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200637 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_8),
Yi Luo193422e2017-06-19 15:54:06 -0700638 make_tuple(&aom_highbd_quantize_b_32x32_c, &aom_highbd_quantize_b_32x32_sse2,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200639 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_10),
Yi Luo193422e2017-06-19 15:54:06 -0700640 make_tuple(&aom_highbd_quantize_b_32x32_c, &aom_highbd_quantize_b_32x32_sse2,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200641 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_12),
Remya014f91a2019-06-04 11:10:10 +0530642 make_tuple(&aom_highbd_quantize_b_32x32_adaptive_c,
643 &aom_highbd_quantize_b_32x32_adaptive_sse2,
644 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_8),
645 make_tuple(&aom_highbd_quantize_b_32x32_adaptive_c,
646 &aom_highbd_quantize_b_32x32_adaptive_sse2,
647 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_10),
648 make_tuple(&aom_highbd_quantize_b_32x32_adaptive_c,
649 &aom_highbd_quantize_b_32x32_adaptive_sse2,
650 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_12),
James Zern7c6fd212022-06-09 13:41:52 -0700651#endif // !CONFIG_REALTIME_ONLY
Aniket Dhok3ff6ff32019-02-06 22:03:22 +0530652 make_tuple(&aom_highbd_quantize_b_64x64_c, &aom_highbd_quantize_b_64x64_sse2,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200653 static_cast<TX_SIZE>(TX_64X64), TYPE_B, AOM_BITS_8),
Aniket Dhok3ff6ff32019-02-06 22:03:22 +0530654 make_tuple(&aom_highbd_quantize_b_64x64_c, &aom_highbd_quantize_b_64x64_sse2,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200655 static_cast<TX_SIZE>(TX_64X64), TYPE_B, AOM_BITS_10),
Aniket Dhok3ff6ff32019-02-06 22:03:22 +0530656 make_tuple(&aom_highbd_quantize_b_64x64_c, &aom_highbd_quantize_b_64x64_sse2,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200657 static_cast<TX_SIZE>(TX_64X64), TYPE_B, AOM_BITS_12),
James Zern7c6fd212022-06-09 13:41:52 -0700658#if !CONFIG_REALTIME_ONLY
Remyad9f35282019-06-03 10:52:34 +0530659 make_tuple(&aom_highbd_quantize_b_64x64_adaptive_c,
660 &aom_highbd_quantize_b_64x64_adaptive_sse2,
661 static_cast<TX_SIZE>(TX_64X64), TYPE_B, AOM_BITS_8),
662 make_tuple(&aom_highbd_quantize_b_64x64_adaptive_c,
663 &aom_highbd_quantize_b_64x64_adaptive_sse2,
664 static_cast<TX_SIZE>(TX_64X64), TYPE_B, AOM_BITS_10),
665 make_tuple(&aom_highbd_quantize_b_64x64_adaptive_c,
666 &aom_highbd_quantize_b_64x64_adaptive_sse2,
667 static_cast<TX_SIZE>(TX_64X64), TYPE_B, AOM_BITS_12),
James Zern7c6fd212022-06-09 13:41:52 -0700668#endif // !CONFIG_REALTIME_ONLY
669#endif // CONFIG_AV1_HIGHBITDEPTH
670#if !CONFIG_REALTIME_ONLY
Aniket Dhok64a5e402019-03-19 20:15:29 +0530671 make_tuple(&aom_quantize_b_adaptive_c, &aom_quantize_b_adaptive_sse2,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200672 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_8),
673 make_tuple(&aom_quantize_b_adaptive_c, &aom_quantize_b_adaptive_sse2,
674 static_cast<TX_SIZE>(TX_8X8), TYPE_B, AOM_BITS_8),
675 make_tuple(&aom_quantize_b_adaptive_c, &aom_quantize_b_adaptive_sse2,
676 static_cast<TX_SIZE>(TX_4X4), TYPE_B, AOM_BITS_8),
Aniket Dhokc615fd32019-03-22 19:42:05 +0530677 make_tuple(&aom_quantize_b_32x32_adaptive_c,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200678 &aom_quantize_b_32x32_adaptive_sse2,
679 static_cast<TX_SIZE>(TX_32X16), TYPE_B, AOM_BITS_8),
Aniket Dhokc615fd32019-03-22 19:42:05 +0530680 make_tuple(&aom_quantize_b_32x32_adaptive_c,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200681 &aom_quantize_b_32x32_adaptive_sse2,
682 static_cast<TX_SIZE>(TX_16X32), TYPE_B, AOM_BITS_8),
Aniket Dhokc615fd32019-03-22 19:42:05 +0530683 make_tuple(&aom_quantize_b_32x32_adaptive_c,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200684 &aom_quantize_b_32x32_adaptive_sse2,
685 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_8),
Aniket Dhok29d8ce42019-03-29 19:44:02 +0530686 make_tuple(&aom_quantize_b_64x64_adaptive_c,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200687 &aom_quantize_b_64x64_adaptive_sse2,
688 static_cast<TX_SIZE>(TX_32X64), TYPE_B, AOM_BITS_8),
Aniket Dhok29d8ce42019-03-29 19:44:02 +0530689 make_tuple(&aom_quantize_b_64x64_adaptive_c,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200690 &aom_quantize_b_64x64_adaptive_sse2,
691 static_cast<TX_SIZE>(TX_64X32), TYPE_B, AOM_BITS_8),
Aniket Dhok29d8ce42019-03-29 19:44:02 +0530692 make_tuple(&aom_quantize_b_64x64_adaptive_c,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200693 &aom_quantize_b_64x64_adaptive_sse2,
694 static_cast<TX_SIZE>(TX_64X64), TYPE_B, AOM_BITS_8)
James Zern7c6fd212022-06-09 13:41:52 -0700695#endif // !CONFIG_REALTIME_ONLY
Yi Luo193422e2017-06-19 15:54:06 -0700696};
Yi Luoef39c842017-05-19 11:51:53 -0700697
Jerome Jiange58af082020-08-28 14:53:14 -0700698INSTANTIATE_TEST_SUITE_P(SSE2, FullPrecisionQuantizeTest,
Cheng Chen96786fe2020-02-14 17:28:25 -0800699 ::testing::ValuesIn(kQParamArraySSE2));
Yi Luoef39c842017-05-19 11:51:53 -0700700#endif
701
Jerome Jiange604b4e2019-07-01 16:19:48 -0700702#if HAVE_NEON
Jerome Jiang3838b5c2020-09-01 18:28:52 -0700703
704const QuantizeParam<LPQuantizeFunc> kLPQParamArrayNEON[] = {
705 make_tuple(av1_quantize_lp_c, av1_quantize_lp_neon,
706 static_cast<TX_SIZE>(TX_16X16), TYPE_FP, AOM_BITS_8),
707 make_tuple(av1_quantize_lp_c, av1_quantize_lp_neon,
Salome Thirot69975b12024-03-15 15:37:39 +0000708 static_cast<TX_SIZE>(TX_8X8), TYPE_FP, AOM_BITS_8),
Jerome Jiang3838b5c2020-09-01 18:28:52 -0700709 make_tuple(av1_quantize_lp_c, av1_quantize_lp_neon,
Salome Thirot69975b12024-03-15 15:37:39 +0000710 static_cast<TX_SIZE>(TX_4X4), TYPE_FP, AOM_BITS_8)
Jerome Jiang3838b5c2020-09-01 18:28:52 -0700711};
712
713INSTANTIATE_TEST_SUITE_P(NEON, LowPrecisionQuantizeTest,
714 ::testing::ValuesIn(kLPQParamArrayNEON));
715
716const QuantizeParam<QuantizeFunc> kQParamArrayNEON[] = {
Jerome Jiange604b4e2019-07-01 16:19:48 -0700717 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_neon,
718 static_cast<TX_SIZE>(TX_16X16), TYPE_FP, AOM_BITS_8),
719 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_neon,
720 static_cast<TX_SIZE>(TX_4X16), TYPE_FP, AOM_BITS_8),
721 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_neon,
722 static_cast<TX_SIZE>(TX_16X4), TYPE_FP, AOM_BITS_8),
723 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_neon,
724 static_cast<TX_SIZE>(TX_8X32), TYPE_FP, AOM_BITS_8),
725 make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_neon,
Vitalii Dziumenko5951ee32020-03-30 19:56:54 +0300726 static_cast<TX_SIZE>(TX_32X8), TYPE_FP, AOM_BITS_8),
727 make_tuple(&av1_quantize_fp_32x32_c, &av1_quantize_fp_32x32_neon,
728 static_cast<TX_SIZE>(TX_32X32), TYPE_FP, AOM_BITS_8),
729 make_tuple(&av1_quantize_fp_64x64_c, &av1_quantize_fp_64x64_neon,
730 static_cast<TX_SIZE>(TX_64X64), TYPE_FP, AOM_BITS_8),
731 make_tuple(&aom_quantize_b_c, &aom_quantize_b_neon,
732 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_8),
733 make_tuple(&aom_quantize_b_32x32_c, &aom_quantize_b_32x32_neon,
734 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_8),
735 make_tuple(&aom_quantize_b_64x64_c, &aom_quantize_b_64x64_neon,
Scott LaVarnway85b7ce72022-04-26 05:56:34 -0700736 static_cast<TX_SIZE>(TX_64X64), TYPE_B, AOM_BITS_8),
Scott LaVarnwaycdbfa942022-04-22 07:19:25 -0700737
Scott LaVarnway85b7ce72022-04-26 05:56:34 -0700738#if CONFIG_AV1_HIGHBITDEPTH
739 make_tuple(&highbd_quan16x16_wrapper<av1_highbd_quantize_fp_c>,
740 &highbd_quan16x16_wrapper<av1_highbd_quantize_fp_neon>,
741 static_cast<TX_SIZE>(TX_16X16), TYPE_FP, AOM_BITS_12),
742 make_tuple(&highbd_quan32x32_wrapper<av1_highbd_quantize_fp_c>,
743 &highbd_quan32x32_wrapper<av1_highbd_quantize_fp_neon>,
744 static_cast<TX_SIZE>(TX_32X32), TYPE_FP, AOM_BITS_12),
745 make_tuple(&highbd_quan64x64_wrapper<av1_highbd_quantize_fp_c>,
746 &highbd_quan64x64_wrapper<av1_highbd_quantize_fp_neon>,
747 static_cast<TX_SIZE>(TX_64X64), TYPE_FP, AOM_BITS_12),
Scott LaVarnwaycdbfa942022-04-22 07:19:25 -0700748 make_tuple(&aom_highbd_quantize_b_c, &aom_highbd_quantize_b_neon,
749 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_12),
750 make_tuple(&aom_highbd_quantize_b_32x32_c, &aom_highbd_quantize_b_32x32_neon,
751 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_12),
752 make_tuple(&aom_highbd_quantize_b_64x64_c, &aom_highbd_quantize_b_64x64_neon,
753 static_cast<TX_SIZE>(TX_64X64), TYPE_B, AOM_BITS_12),
James Zern7c6fd212022-06-09 13:41:52 -0700754#if !CONFIG_REALTIME_ONLY
Scott LaVarnway2727d2d2022-05-03 07:20:51 -0700755 make_tuple(&aom_highbd_quantize_b_adaptive_c,
756 &aom_highbd_quantize_b_adaptive_neon,
757 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_12),
758 make_tuple(&aom_highbd_quantize_b_32x32_adaptive_c,
759 &aom_highbd_quantize_b_32x32_adaptive_neon,
760 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_12),
761 make_tuple(&aom_highbd_quantize_b_64x64_adaptive_c,
762 &aom_highbd_quantize_b_64x64_adaptive_neon,
763 static_cast<TX_SIZE>(TX_64X64), TYPE_B, AOM_BITS_12),
James Zern7c6fd212022-06-09 13:41:52 -0700764#endif // !CONFIG_REALTIME_ONLY
765#endif // CONFIG_AV1_HIGHBITDEPTH
Jerome Jiange604b4e2019-07-01 16:19:48 -0700766};
767
Jerome Jiange58af082020-08-28 14:53:14 -0700768INSTANTIATE_TEST_SUITE_P(NEON, FullPrecisionQuantizeTest,
Cheng Chen96786fe2020-02-14 17:28:25 -0800769 ::testing::ValuesIn(kQParamArrayNEON));
Jerome Jiange604b4e2019-07-01 16:19:48 -0700770#endif
771
James Zern1fbb25c2023-05-22 10:45:24 -0700772#if HAVE_SSSE3 && AOM_ARCH_X86_64
Cheng Chen96786fe2020-02-14 17:28:25 -0800773INSTANTIATE_TEST_SUITE_P(
Jerome Jiange58af082020-08-28 14:53:14 -0700774 SSSE3, FullPrecisionQuantizeTest,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200775 ::testing::Values(
776 make_tuple(&aom_quantize_b_c, &aom_quantize_b_ssse3,
777 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_8),
778 make_tuple(&aom_quantize_b_32x32_c, &aom_quantize_b_32x32_ssse3,
779 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_8),
780 make_tuple(&aom_quantize_b_64x64_c, &aom_quantize_b_64x64_ssse3,
781 static_cast<TX_SIZE>(TX_64X64), TYPE_B, AOM_BITS_8)));
Johann89b4c612018-09-13 15:43:29 -0700782
James Zern1fbb25c2023-05-22 10:45:24 -0700783#endif // HAVE_SSSE3 && AOM_ARCH_X86_64
Johann89b4c612018-09-13 15:43:29 -0700784
Jerome Jianga2817212020-04-29 10:37:51 -0700785#if HAVE_AVX
Cheng Chen96786fe2020-02-14 17:28:25 -0800786INSTANTIATE_TEST_SUITE_P(
Jerome Jiange58af082020-08-28 14:53:14 -0700787 AVX, FullPrecisionQuantizeTest,
Pascal Massiminoa6fe4322019-04-09 09:49:24 +0200788 ::testing::Values(
789 make_tuple(&aom_quantize_b_c, &aom_quantize_b_avx,
790 static_cast<TX_SIZE>(TX_16X16), TYPE_B, AOM_BITS_8),
791 make_tuple(&aom_quantize_b_32x32_c, &aom_quantize_b_32x32_avx,
792 static_cast<TX_SIZE>(TX_32X32), TYPE_B, AOM_BITS_8)));
Johann89b4c612018-09-13 15:43:29 -0700793
Jerome Jianga2817212020-04-29 10:37:51 -0700794#endif // HAVE_AVX
Angie Chiang4dd53d02021-04-27 17:04:44 -0700795
Yi Luoef39c842017-05-19 11:51:53 -0700796} // namespace