1 /*
2  *  Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include <math.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <tuple>
15 
16 #include "third_party/googletest/src/include/gtest/gtest.h"
17 
18 #include "./vp9_rtcd.h"
19 #include "./vpx_config.h"
20 #include "./vpx_dsp_rtcd.h"
21 #include "test/acm_random.h"
22 #include "test/bench.h"
23 #include "test/buffer.h"
24 #include "test/clear_system_state.h"
25 #include "test/register_state_check.h"
26 #include "test/util.h"
27 #include "vp9/common/vp9_entropy.h"
28 #include "vp9/common/vp9_scan.h"
29 #include "vpx/vpx_codec.h"
30 #include "vpx/vpx_integer.h"
31 #include "vpx_ports/msvc.h"
32 #include "vpx_ports/vpx_timer.h"
33 
34 using libvpx_test::ACMRandom;
35 using libvpx_test::Buffer;
36 
37 namespace {
38 const int number_of_iterations = 100;
39 
40 typedef void (*QuantizeFunc)(const tran_low_t *coeff, intptr_t count,
41                              int skip_block, const int16_t *zbin,
42                              const int16_t *round, const int16_t *quant,
43                              const int16_t *quant_shift, tran_low_t *qcoeff,
44                              tran_low_t *dqcoeff, const int16_t *dequant,
45                              uint16_t *eob, const int16_t *scan,
46                              const int16_t *iscan);
47 typedef std::tuple<QuantizeFunc, QuantizeFunc, vpx_bit_depth_t,
48                    int /*max_size*/, bool /*is_fp*/>
49     QuantizeParam;
50 
51 // Wrapper for FP version which does not use zbin or quant_shift.
52 typedef void (*QuantizeFPFunc)(const tran_low_t *coeff, intptr_t count,
53                                int skip_block, const int16_t *round,
54                                const int16_t *quant, tran_low_t *qcoeff,
55                                tran_low_t *dqcoeff, const int16_t *dequant,
56                                uint16_t *eob, const int16_t *scan,
57                                const int16_t *iscan);
58 
59 template <QuantizeFPFunc fn>
QuantFPWrapper(const tran_low_t * coeff,intptr_t count,int skip_block,const int16_t * zbin,const int16_t * round,const int16_t * quant,const int16_t * quant_shift,tran_low_t * qcoeff,tran_low_t * dqcoeff,const int16_t * dequant,uint16_t * eob,const int16_t * scan,const int16_t * iscan)60 void QuantFPWrapper(const tran_low_t *coeff, intptr_t count, int skip_block,
61                     const int16_t *zbin, const int16_t *round,
62                     const int16_t *quant, const int16_t *quant_shift,
63                     tran_low_t *qcoeff, tran_low_t *dqcoeff,
64                     const int16_t *dequant, uint16_t *eob, const int16_t *scan,
65                     const int16_t *iscan) {
66   (void)zbin;
67   (void)quant_shift;
68 
69   fn(coeff, count, skip_block, round, quant, qcoeff, dqcoeff, dequant, eob,
70      scan, iscan);
71 }
72 
73 class VP9QuantizeBase : public AbstractBench {
74  public:
VP9QuantizeBase(vpx_bit_depth_t bit_depth,int max_size,bool is_fp)75   VP9QuantizeBase(vpx_bit_depth_t bit_depth, int max_size, bool is_fp)
76       : bit_depth_(bit_depth), max_size_(max_size), is_fp_(is_fp),
77         coeff_(Buffer<tran_low_t>(max_size_, max_size_, 0, 16)),
78         qcoeff_(Buffer<tran_low_t>(max_size_, max_size_, 0, 32)),
79         dqcoeff_(Buffer<tran_low_t>(max_size_, max_size_, 0, 32)) {
80     // TODO(jianj): SSSE3 and AVX2 tests fail on extreme values.
81 #if HAVE_NEON
82     max_value_ = (1 << (7 + bit_depth_)) - 1;
83 #else
84     max_value_ = (1 << bit_depth_) - 1;
85 #endif
86     zbin_ptr_ =
87         reinterpret_cast<int16_t *>(vpx_memalign(16, 8 * sizeof(*zbin_ptr_)));
88     round_fp_ptr_ = reinterpret_cast<int16_t *>(
89         vpx_memalign(16, 8 * sizeof(*round_fp_ptr_)));
90     quant_fp_ptr_ = reinterpret_cast<int16_t *>(
91         vpx_memalign(16, 8 * sizeof(*quant_fp_ptr_)));
92     round_ptr_ =
93         reinterpret_cast<int16_t *>(vpx_memalign(16, 8 * sizeof(*round_ptr_)));
94     quant_ptr_ =
95         reinterpret_cast<int16_t *>(vpx_memalign(16, 8 * sizeof(*quant_ptr_)));
96     quant_shift_ptr_ = reinterpret_cast<int16_t *>(
97         vpx_memalign(16, 8 * sizeof(*quant_shift_ptr_)));
98     dequant_ptr_ = reinterpret_cast<int16_t *>(
99         vpx_memalign(16, 8 * sizeof(*dequant_ptr_)));
100 
101     r_ptr_ = (is_fp_) ? round_fp_ptr_ : round_ptr_;
102     q_ptr_ = (is_fp_) ? quant_fp_ptr_ : quant_ptr_;
103   }
104 
~VP9QuantizeBase()105   ~VP9QuantizeBase() {
106     vpx_free(zbin_ptr_);
107     vpx_free(round_fp_ptr_);
108     vpx_free(quant_fp_ptr_);
109     vpx_free(round_ptr_);
110     vpx_free(quant_ptr_);
111     vpx_free(quant_shift_ptr_);
112     vpx_free(dequant_ptr_);
113     zbin_ptr_ = nullptr;
114     round_fp_ptr_ = nullptr;
115     quant_fp_ptr_ = nullptr;
116     round_ptr_ = nullptr;
117     quant_ptr_ = nullptr;
118     quant_shift_ptr_ = nullptr;
119     dequant_ptr_ = nullptr;
120     libvpx_test::ClearSystemState();
121   }
122 
123  protected:
124   int16_t *zbin_ptr_;
125   int16_t *round_fp_ptr_;
126   int16_t *quant_fp_ptr_;
127   int16_t *round_ptr_;
128   int16_t *quant_ptr_;
129   int16_t *quant_shift_ptr_;
130   int16_t *dequant_ptr_;
131   const vpx_bit_depth_t bit_depth_;
132   int max_value_;
133   const int max_size_;
134   const bool is_fp_;
135   Buffer<tran_low_t> coeff_;
136   Buffer<tran_low_t> qcoeff_;
137   Buffer<tran_low_t> dqcoeff_;
138   int16_t *r_ptr_;
139   int16_t *q_ptr_;
140   int count_;
141   int skip_block_;
142   const scan_order *scan_;
143   uint16_t eob_;
144 };
145 
146 class VP9QuantizeTest : public VP9QuantizeBase,
147                         public ::testing::TestWithParam<QuantizeParam> {
148  public:
VP9QuantizeTest()149   VP9QuantizeTest()
150       : VP9QuantizeBase(GET_PARAM(2), GET_PARAM(3), GET_PARAM(4)),
151         quantize_op_(GET_PARAM(0)), ref_quantize_op_(GET_PARAM(1)) {}
152 
153  protected:
154   virtual void Run();
155   const QuantizeFunc quantize_op_;
156   const QuantizeFunc ref_quantize_op_;
157 };
158 
Run()159 void VP9QuantizeTest::Run() {
160   quantize_op_(coeff_.TopLeftPixel(), count_, skip_block_, zbin_ptr_, r_ptr_,
161                q_ptr_, quant_shift_ptr_, qcoeff_.TopLeftPixel(),
162                dqcoeff_.TopLeftPixel(), dequant_ptr_, &eob_, scan_->scan,
163                scan_->iscan);
164 }
165 
166 // This quantizer compares the AC coefficients to the quantization step size to
167 // determine if further multiplication operations are needed.
168 // Based on vp9_quantize_fp_sse2().
quant_fp_nz(const tran_low_t * coeff_ptr,intptr_t n_coeffs,int skip_block,const int16_t * round_ptr,const int16_t * quant_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan,int is_32x32)169 inline void quant_fp_nz(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
170                         int skip_block, const int16_t *round_ptr,
171                         const int16_t *quant_ptr, tran_low_t *qcoeff_ptr,
172                         tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr,
173                         uint16_t *eob_ptr, const int16_t *scan,
174                         const int16_t *iscan, int is_32x32) {
175   int i, eob = -1;
176   const int thr = dequant_ptr[1] >> (1 + is_32x32);
177   (void)iscan;
178   (void)skip_block;
179   assert(!skip_block);
180 
181   // Quantization pass: All coefficients with index >= zero_flag are
182   // skippable. Note: zero_flag can be zero.
183   for (i = 0; i < n_coeffs; i += 16) {
184     int y;
185     int nzflag_cnt = 0;
186     int abs_coeff[16];
187     int coeff_sign[16];
188 
189     // count nzflag for each row (16 tran_low_t)
190     for (y = 0; y < 16; ++y) {
191       const int rc = i + y;
192       const int coeff = coeff_ptr[rc];
193       coeff_sign[y] = (coeff >> 31);
194       abs_coeff[y] = (coeff ^ coeff_sign[y]) - coeff_sign[y];
195       // The first 16 are skipped in the sse2 code.  Do the same here to match.
196       if (i >= 16 && (abs_coeff[y] <= thr)) {
197         nzflag_cnt++;
198       }
199     }
200 
201     for (y = 0; y < 16; ++y) {
202       const int rc = i + y;
203       // If all of the AC coeffs in a row has magnitude less than the
204       // quantization step_size/2, quantize to zero.
205       if (nzflag_cnt < 16) {
206         int tmp;
207         int _round;
208 
209         if (is_32x32) {
210           _round = ROUND_POWER_OF_TWO(round_ptr[rc != 0], 1);
211         } else {
212           _round = round_ptr[rc != 0];
213         }
214         tmp = clamp(abs_coeff[y] + _round, INT16_MIN, INT16_MAX);
215         tmp = (tmp * quant_ptr[rc != 0]) >> (16 - is_32x32);
216         qcoeff_ptr[rc] = (tmp ^ coeff_sign[y]) - coeff_sign[y];
217         dqcoeff_ptr[rc] =
218             static_cast<tran_low_t>(qcoeff_ptr[rc] * dequant_ptr[rc != 0]);
219 
220         if (is_32x32) {
221           dqcoeff_ptr[rc] = static_cast<tran_low_t>(qcoeff_ptr[rc] *
222                                                     dequant_ptr[rc != 0] / 2);
223         } else {
224           dqcoeff_ptr[rc] =
225               static_cast<tran_low_t>(qcoeff_ptr[rc] * dequant_ptr[rc != 0]);
226         }
227       } else {
228         qcoeff_ptr[rc] = 0;
229         dqcoeff_ptr[rc] = 0;
230       }
231     }
232   }
233 
234   // Scan for eob.
235   for (i = 0; i < n_coeffs; i++) {
236     // Use the scan order to find the correct eob.
237     const int rc = scan[i];
238     if (qcoeff_ptr[rc]) {
239       eob = i;
240     }
241   }
242   *eob_ptr = eob + 1;
243 }
244 
quantize_fp_nz_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,int skip_block,const int16_t * round_ptr,const int16_t * quant_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)245 void quantize_fp_nz_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
246                       int skip_block, const int16_t *round_ptr,
247                       const int16_t *quant_ptr, tran_low_t *qcoeff_ptr,
248                       tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr,
249                       uint16_t *eob_ptr, const int16_t *scan,
250                       const int16_t *iscan) {
251   quant_fp_nz(coeff_ptr, n_coeffs, skip_block, round_ptr, quant_ptr, qcoeff_ptr,
252               dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan, 0);
253 }
254 
quantize_fp_32x32_nz_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,int skip_block,const int16_t * round_ptr,const int16_t * quant_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)255 void quantize_fp_32x32_nz_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
256                             int skip_block, const int16_t *round_ptr,
257                             const int16_t *quant_ptr, tran_low_t *qcoeff_ptr,
258                             tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr,
259                             uint16_t *eob_ptr, const int16_t *scan,
260                             const int16_t *iscan) {
261   quant_fp_nz(coeff_ptr, n_coeffs, skip_block, round_ptr, quant_ptr, qcoeff_ptr,
262               dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan, 1);
263 }
264 
GenerateHelperArrays(ACMRandom * rnd,int16_t * zbin,int16_t * round,int16_t * quant,int16_t * quant_shift,int16_t * dequant,int16_t * round_fp,int16_t * quant_fp)265 void GenerateHelperArrays(ACMRandom *rnd, int16_t *zbin, int16_t *round,
266                           int16_t *quant, int16_t *quant_shift,
267                           int16_t *dequant, int16_t *round_fp,
268                           int16_t *quant_fp) {
269   // Max when q == 0.  Otherwise, it is 48 for Y and 42 for U/V.
270   const int max_qrounding_factor_fp = 64;
271 
272   for (int j = 0; j < 2; j++) {
273     // The range is 4 to 1828 in the VP9 tables.
274     const int qlookup = rnd->RandRange(1825) + 4;
275     round_fp[j] = (max_qrounding_factor_fp * qlookup) >> 7;
276     quant_fp[j] = (1 << 16) / qlookup;
277 
278     // Values determined by deconstructing vp9_init_quantizer().
279     // zbin may be up to 1143 for 8 and 10 bit Y values, or 1200 for 12 bit Y
280     // values or U/V values of any bit depth. This is because y_delta is not
281     // factored into the vp9_ac_quant() call.
282     zbin[j] = rnd->RandRange(1200);
283 
284     // round may be up to 685 for Y values or 914 for U/V.
285     round[j] = rnd->RandRange(914);
286     // quant ranges from 1 to -32703
287     quant[j] = static_cast<int>(rnd->RandRange(32704)) - 32703;
288     // quant_shift goes up to 1 << 16.
289     quant_shift[j] = rnd->RandRange(16384);
290     // dequant maxes out at 1828 for all cases.
291     dequant[j] = rnd->RandRange(1828);
292   }
293   for (int j = 2; j < 8; j++) {
294     zbin[j] = zbin[1];
295     round_fp[j] = round_fp[1];
296     quant_fp[j] = quant_fp[1];
297     round[j] = round[1];
298     quant[j] = quant[1];
299     quant_shift[j] = quant_shift[1];
300     dequant[j] = dequant[1];
301   }
302 }
303 
TEST_P(VP9QuantizeTest,OperationCheck)304 TEST_P(VP9QuantizeTest, OperationCheck) {
305   ACMRandom rnd(ACMRandom::DeterministicSeed());
306   ASSERT_TRUE(coeff_.Init());
307   ASSERT_TRUE(qcoeff_.Init());
308   ASSERT_TRUE(dqcoeff_.Init());
309   Buffer<tran_low_t> ref_qcoeff =
310       Buffer<tran_low_t>(max_size_, max_size_, 0, 32);
311   ASSERT_TRUE(ref_qcoeff.Init());
312   Buffer<tran_low_t> ref_dqcoeff =
313       Buffer<tran_low_t>(max_size_, max_size_, 0, 32);
314   ASSERT_TRUE(ref_dqcoeff.Init());
315   uint16_t ref_eob = 0;
316   eob_ = 0;
317 
318   for (int i = 0; i < number_of_iterations; ++i) {
319     // Test skip block for the first three iterations to catch all the different
320     // sizes.
321     const int skip_block = 0;
322     TX_SIZE sz;
323     if (max_size_ == 16) {
324       sz = static_cast<TX_SIZE>(i % 3);  // TX_4X4, TX_8X8 TX_16X16
325     } else {
326       sz = TX_32X32;
327     }
328     const TX_TYPE tx_type = static_cast<TX_TYPE>((i >> 2) % 3);
329     scan_ = &vp9_scan_orders[sz][tx_type];
330     count_ = (4 << sz) * (4 << sz);
331     coeff_.Set(&rnd, -max_value_, max_value_);
332     GenerateHelperArrays(&rnd, zbin_ptr_, round_ptr_, quant_ptr_,
333                          quant_shift_ptr_, dequant_ptr_, round_fp_ptr_,
334                          quant_fp_ptr_);
335     ref_quantize_op_(coeff_.TopLeftPixel(), count_, skip_block, zbin_ptr_,
336                      r_ptr_, q_ptr_, quant_shift_ptr_,
337                      ref_qcoeff.TopLeftPixel(), ref_dqcoeff.TopLeftPixel(),
338                      dequant_ptr_, &ref_eob, scan_->scan, scan_->iscan);
339 
340     ASM_REGISTER_STATE_CHECK(quantize_op_(
341         coeff_.TopLeftPixel(), count_, skip_block, zbin_ptr_, r_ptr_, q_ptr_,
342         quant_shift_ptr_, qcoeff_.TopLeftPixel(), dqcoeff_.TopLeftPixel(),
343         dequant_ptr_, &eob_, scan_->scan, scan_->iscan));
344 
345     EXPECT_TRUE(qcoeff_.CheckValues(ref_qcoeff));
346     EXPECT_TRUE(dqcoeff_.CheckValues(ref_dqcoeff));
347 
348     EXPECT_EQ(eob_, ref_eob);
349 
350     if (HasFailure()) {
351       printf("Failure on iteration %d.\n", i);
352       qcoeff_.PrintDifference(ref_qcoeff);
353       dqcoeff_.PrintDifference(ref_dqcoeff);
354       return;
355     }
356   }
357 }
358 
TEST_P(VP9QuantizeTest,EOBCheck)359 TEST_P(VP9QuantizeTest, EOBCheck) {
360   ACMRandom rnd(ACMRandom::DeterministicSeed());
361   ASSERT_TRUE(coeff_.Init());
362   ASSERT_TRUE(qcoeff_.Init());
363   ASSERT_TRUE(dqcoeff_.Init());
364   Buffer<tran_low_t> ref_qcoeff =
365       Buffer<tran_low_t>(max_size_, max_size_, 0, 32);
366   ASSERT_TRUE(ref_qcoeff.Init());
367   Buffer<tran_low_t> ref_dqcoeff =
368       Buffer<tran_low_t>(max_size_, max_size_, 0, 32);
369   ASSERT_TRUE(ref_dqcoeff.Init());
370   uint16_t ref_eob = 0;
371   eob_ = 0;
372   const uint32_t max_index = max_size_ * max_size_ - 1;
373 
374   for (int i = 0; i < number_of_iterations; ++i) {
375     skip_block_ = 0;
376     TX_SIZE sz;
377     if (max_size_ == 16) {
378       sz = static_cast<TX_SIZE>(i % 3);  // TX_4X4, TX_8X8 TX_16X16
379     } else {
380       sz = TX_32X32;
381     }
382     const TX_TYPE tx_type = static_cast<TX_TYPE>((i >> 2) % 3);
383     scan_ = &vp9_scan_orders[sz][tx_type];
384     count_ = (4 << sz) * (4 << sz);
385     // Two random entries
386     coeff_.Set(0);
387     coeff_.TopLeftPixel()[rnd.RandRange(count_) & max_index] =
388         static_cast<int>(rnd.RandRange(max_value_ * 2)) - max_value_;
389     coeff_.TopLeftPixel()[rnd.RandRange(count_) & max_index] =
390         static_cast<int>(rnd.RandRange(max_value_ * 2)) - max_value_;
391     GenerateHelperArrays(&rnd, zbin_ptr_, round_ptr_, quant_ptr_,
392                          quant_shift_ptr_, dequant_ptr_, round_fp_ptr_,
393                          quant_fp_ptr_);
394     ref_quantize_op_(coeff_.TopLeftPixel(), count_, skip_block_, zbin_ptr_,
395                      r_ptr_, q_ptr_, quant_shift_ptr_,
396                      ref_qcoeff.TopLeftPixel(), ref_dqcoeff.TopLeftPixel(),
397                      dequant_ptr_, &ref_eob, scan_->scan, scan_->iscan);
398 
399     ASM_REGISTER_STATE_CHECK(quantize_op_(
400         coeff_.TopLeftPixel(), count_, skip_block_, zbin_ptr_, r_ptr_, q_ptr_,
401         quant_shift_ptr_, qcoeff_.TopLeftPixel(), dqcoeff_.TopLeftPixel(),
402         dequant_ptr_, &eob_, scan_->scan, scan_->iscan));
403 
404     EXPECT_TRUE(qcoeff_.CheckValues(ref_qcoeff));
405     EXPECT_TRUE(dqcoeff_.CheckValues(ref_dqcoeff));
406 
407     EXPECT_EQ(eob_, ref_eob);
408 
409     if (HasFailure()) {
410       printf("Failure on iteration %d.\n", i);
411       qcoeff_.PrintDifference(ref_qcoeff);
412       dqcoeff_.PrintDifference(ref_dqcoeff);
413       return;
414     }
415   }
416 }
417 
TEST_P(VP9QuantizeTest,DISABLED_Speed)418 TEST_P(VP9QuantizeTest, DISABLED_Speed) {
419   ACMRandom rnd(ACMRandom::DeterministicSeed());
420   ASSERT_TRUE(coeff_.Init());
421   ASSERT_TRUE(qcoeff_.Init());
422   ASSERT_TRUE(dqcoeff_.Init());
423   TX_SIZE starting_sz, ending_sz;
424 
425   if (max_size_ == 16) {
426     starting_sz = TX_4X4;
427     ending_sz = TX_16X16;
428   } else {
429     starting_sz = TX_32X32;
430     ending_sz = TX_32X32;
431   }
432 
433   for (TX_SIZE sz = starting_sz; sz <= ending_sz; ++sz) {
434     // zbin > coeff, zbin < coeff.
435     for (int i = 0; i < 2; ++i) {
436       skip_block_ = 0;
437       // TX_TYPE defines the scan order. That is not relevant to the speed test.
438       // Pick the first one.
439       const TX_TYPE tx_type = DCT_DCT;
440       count_ = (4 << sz) * (4 << sz);
441       scan_ = &vp9_scan_orders[sz][tx_type];
442 
443       GenerateHelperArrays(&rnd, zbin_ptr_, round_ptr_, quant_ptr_,
444                            quant_shift_ptr_, dequant_ptr_, round_fp_ptr_,
445                            quant_fp_ptr_);
446 
447       if (i == 0) {
448         // When |coeff values| are less than zbin the results are 0.
449         int threshold = 100;
450         if (max_size_ == 32) {
451           // For 32x32, the threshold is halved. Double it to keep the values
452           // from clearing it.
453           threshold = 200;
454         }
455         for (int j = 0; j < 8; ++j) zbin_ptr_[j] = threshold;
456         coeff_.Set(&rnd, -99, 99);
457       } else if (i == 1) {
458         for (int j = 0; j < 8; ++j) zbin_ptr_[j] = 50;
459         coeff_.Set(&rnd, -500, 500);
460       }
461 
462       RunNTimes(10000000 / count_);
463       const char *type =
464           (i == 0) ? "Bypass calculations " : "Full calculations ";
465       char block_size[16];
466       snprintf(block_size, sizeof(block_size), "%dx%d", 4 << sz, 4 << sz);
467       char title[100];
468       snprintf(title, sizeof(title), "%25s %8s ", type, block_size);
469       PrintMedian(title);
470     }
471   }
472 }
473 
474 using std::make_tuple;
475 
476 #if HAVE_SSE2
477 #if CONFIG_VP9_HIGHBITDEPTH
478 INSTANTIATE_TEST_SUITE_P(
479     SSE2, VP9QuantizeTest,
480     ::testing::Values(
481         make_tuple(&vpx_quantize_b_sse2, &vpx_quantize_b_c, VPX_BITS_8, 16,
482                    false),
483         make_tuple(&vpx_highbd_quantize_b_sse2, &vpx_highbd_quantize_b_c,
484                    VPX_BITS_8, 16, false),
485         make_tuple(&vpx_highbd_quantize_b_sse2, &vpx_highbd_quantize_b_c,
486                    VPX_BITS_10, 16, false),
487         make_tuple(&vpx_highbd_quantize_b_sse2, &vpx_highbd_quantize_b_c,
488                    VPX_BITS_12, 16, false),
489         make_tuple(&vpx_highbd_quantize_b_32x32_sse2,
490                    &vpx_highbd_quantize_b_32x32_c, VPX_BITS_8, 32, false),
491         make_tuple(&vpx_highbd_quantize_b_32x32_sse2,
492                    &vpx_highbd_quantize_b_32x32_c, VPX_BITS_10, 32, false),
493         make_tuple(&vpx_highbd_quantize_b_32x32_sse2,
494                    &vpx_highbd_quantize_b_32x32_c, VPX_BITS_12, 32, false)));
495 
496 #else
497 INSTANTIATE_TEST_SUITE_P(
498     SSE2, VP9QuantizeTest,
499     ::testing::Values(make_tuple(&vpx_quantize_b_sse2, &vpx_quantize_b_c,
500                                  VPX_BITS_8, 16, false),
501                       make_tuple(&QuantFPWrapper<vp9_quantize_fp_sse2>,
502                                  &QuantFPWrapper<quantize_fp_nz_c>, VPX_BITS_8,
503                                  16, true)));
504 #endif  // CONFIG_VP9_HIGHBITDEPTH
505 #endif  // HAVE_SSE2
506 
507 #if HAVE_SSSE3
508 #if VPX_ARCH_X86_64
509 INSTANTIATE_TEST_SUITE_P(
510     SSSE3, VP9QuantizeTest,
511     ::testing::Values(make_tuple(&vpx_quantize_b_ssse3, &vpx_quantize_b_c,
512                                  VPX_BITS_8, 16, false),
513                       make_tuple(&vpx_quantize_b_32x32_ssse3,
514                                  &vpx_quantize_b_32x32_c, VPX_BITS_8, 32,
515                                  false),
516                       make_tuple(&QuantFPWrapper<vp9_quantize_fp_ssse3>,
517                                  &QuantFPWrapper<quantize_fp_nz_c>, VPX_BITS_8,
518                                  16, true),
519                       make_tuple(&QuantFPWrapper<vp9_quantize_fp_32x32_ssse3>,
520                                  &QuantFPWrapper<quantize_fp_32x32_nz_c>,
521                                  VPX_BITS_8, 32, true)));
522 #else
523 INSTANTIATE_TEST_SUITE_P(
524     SSSE3, VP9QuantizeTest,
525     ::testing::Values(make_tuple(&vpx_quantize_b_ssse3, &vpx_quantize_b_c,
526                                  VPX_BITS_8, 16, false),
527                       make_tuple(&vpx_quantize_b_32x32_ssse3,
528                                  &vpx_quantize_b_32x32_c, VPX_BITS_8, 32,
529                                  false)));
530 
531 #endif  // VPX_ARCH_X86_64
532 #endif  // HAVE_SSSE3
533 
534 #if HAVE_AVX
535 INSTANTIATE_TEST_SUITE_P(AVX, VP9QuantizeTest,
536                          ::testing::Values(make_tuple(&vpx_quantize_b_avx,
537                                                       &vpx_quantize_b_c,
538                                                       VPX_BITS_8, 16, false),
539                                            make_tuple(&vpx_quantize_b_32x32_avx,
540                                                       &vpx_quantize_b_32x32_c,
541                                                       VPX_BITS_8, 32, false)));
542 #endif  // HAVE_AVX
543 
544 #if VPX_ARCH_X86_64 && HAVE_AVX2
545 INSTANTIATE_TEST_SUITE_P(
546     AVX2, VP9QuantizeTest,
547     ::testing::Values(make_tuple(&QuantFPWrapper<vp9_quantize_fp_avx2>,
548                                  &QuantFPWrapper<quantize_fp_nz_c>, VPX_BITS_8,
549                                  16, true)));
550 #endif  // HAVE_AVX2
551 
552 #if HAVE_NEON
553 INSTANTIATE_TEST_SUITE_P(
554     NEON, VP9QuantizeTest,
555     ::testing::Values(make_tuple(&vpx_quantize_b_neon, &vpx_quantize_b_c,
556                                  VPX_BITS_8, 16, false),
557                       make_tuple(&vpx_quantize_b_32x32_neon,
558                                  &vpx_quantize_b_32x32_c, VPX_BITS_8, 32,
559                                  false),
560                       make_tuple(&QuantFPWrapper<vp9_quantize_fp_neon>,
561                                  &QuantFPWrapper<vp9_quantize_fp_c>, VPX_BITS_8,
562                                  16, true),
563                       make_tuple(&QuantFPWrapper<vp9_quantize_fp_32x32_neon>,
564                                  &QuantFPWrapper<vp9_quantize_fp_32x32_c>,
565                                  VPX_BITS_8, 32, true)));
566 #endif  // HAVE_NEON
567 
568 #if HAVE_VSX && !CONFIG_VP9_HIGHBITDEPTH
569 INSTANTIATE_TEST_SUITE_P(
570     VSX, VP9QuantizeTest,
571     ::testing::Values(make_tuple(&vpx_quantize_b_vsx, &vpx_quantize_b_c,
572                                  VPX_BITS_8, 16, false),
573                       make_tuple(&vpx_quantize_b_32x32_vsx,
574                                  &vpx_quantize_b_32x32_c, VPX_BITS_8, 32,
575                                  false),
576                       make_tuple(&QuantFPWrapper<vp9_quantize_fp_vsx>,
577                                  &QuantFPWrapper<vp9_quantize_fp_c>, VPX_BITS_8,
578                                  16, true),
579                       make_tuple(&QuantFPWrapper<vp9_quantize_fp_32x32_vsx>,
580                                  &QuantFPWrapper<vp9_quantize_fp_32x32_c>,
581                                  VPX_BITS_8, 32, true)));
582 #endif  // HAVE_VSX && !CONFIG_VP9_HIGHBITDEPTH
583 
584 // Only useful to compare "Speed" test results.
585 INSTANTIATE_TEST_SUITE_P(
586     DISABLED_C, VP9QuantizeTest,
587     ::testing::Values(
588         make_tuple(&vpx_quantize_b_c, &vpx_quantize_b_c, VPX_BITS_8, 16, false),
589         make_tuple(&vpx_quantize_b_32x32_c, &vpx_quantize_b_32x32_c, VPX_BITS_8,
590                    32, false),
591         make_tuple(&QuantFPWrapper<vp9_quantize_fp_c>,
592                    &QuantFPWrapper<vp9_quantize_fp_c>, VPX_BITS_8, 16, true),
593         make_tuple(&QuantFPWrapper<quantize_fp_nz_c>,
594                    &QuantFPWrapper<quantize_fp_nz_c>, VPX_BITS_8, 16, true),
595         make_tuple(&QuantFPWrapper<quantize_fp_32x32_nz_c>,
596                    &QuantFPWrapper<quantize_fp_32x32_nz_c>, VPX_BITS_8, 32,
597                    true),
598         make_tuple(&QuantFPWrapper<vp9_quantize_fp_32x32_c>,
599                    &QuantFPWrapper<vp9_quantize_fp_32x32_c>, VPX_BITS_8, 32,
600                    true)));
601 }  // namespace
602