xref: /aosp_15_r20/external/libvpx/test/dct16x16_test.cc (revision fb1b10ab9aebc7c7068eedab379b749d7e3900be)
1 /*
2  *  Copyright (c) 2012 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 "gtest/gtest.h"
17 
18 #include "./vp9_rtcd.h"
19 #include "./vpx_dsp_rtcd.h"
20 #include "test/acm_random.h"
21 #include "test/clear_system_state.h"
22 #include "test/register_state_check.h"
23 #include "test/util.h"
24 #include "vp9/common/vp9_entropy.h"
25 #include "vp9/common/vp9_scan.h"
26 #include "vpx/vpx_codec.h"
27 #include "vpx/vpx_integer.h"
28 #include "vpx_config.h"
29 #include "vpx_ports/mem.h"
30 #include "vpx_ports/vpx_timer.h"
31 
32 using libvpx_test::ACMRandom;
33 
34 namespace {
35 
36 const int kNumCoeffs = 256;
37 const double C1 = 0.995184726672197;
38 const double C2 = 0.98078528040323;
39 const double C3 = 0.956940335732209;
40 const double C4 = 0.923879532511287;
41 const double C5 = 0.881921264348355;
42 const double C6 = 0.831469612302545;
43 const double C7 = 0.773010453362737;
44 const double C8 = 0.707106781186548;
45 const double C9 = 0.634393284163646;
46 const double C10 = 0.555570233019602;
47 const double C11 = 0.471396736825998;
48 const double C12 = 0.38268343236509;
49 const double C13 = 0.290284677254462;
50 const double C14 = 0.195090322016128;
51 const double C15 = 0.098017140329561;
52 
butterfly_16x16_dct_1d(double input[16],double output[16])53 void butterfly_16x16_dct_1d(double input[16], double output[16]) {
54   double step[16];
55   double intermediate[16];
56   double temp1, temp2;
57 
58   // step 1
59   step[0] = input[0] + input[15];
60   step[1] = input[1] + input[14];
61   step[2] = input[2] + input[13];
62   step[3] = input[3] + input[12];
63   step[4] = input[4] + input[11];
64   step[5] = input[5] + input[10];
65   step[6] = input[6] + input[9];
66   step[7] = input[7] + input[8];
67   step[8] = input[7] - input[8];
68   step[9] = input[6] - input[9];
69   step[10] = input[5] - input[10];
70   step[11] = input[4] - input[11];
71   step[12] = input[3] - input[12];
72   step[13] = input[2] - input[13];
73   step[14] = input[1] - input[14];
74   step[15] = input[0] - input[15];
75 
76   // step 2
77   output[0] = step[0] + step[7];
78   output[1] = step[1] + step[6];
79   output[2] = step[2] + step[5];
80   output[3] = step[3] + step[4];
81   output[4] = step[3] - step[4];
82   output[5] = step[2] - step[5];
83   output[6] = step[1] - step[6];
84   output[7] = step[0] - step[7];
85 
86   temp1 = step[8] * C7;
87   temp2 = step[15] * C9;
88   output[8] = temp1 + temp2;
89 
90   temp1 = step[9] * C11;
91   temp2 = step[14] * C5;
92   output[9] = temp1 - temp2;
93 
94   temp1 = step[10] * C3;
95   temp2 = step[13] * C13;
96   output[10] = temp1 + temp2;
97 
98   temp1 = step[11] * C15;
99   temp2 = step[12] * C1;
100   output[11] = temp1 - temp2;
101 
102   temp1 = step[11] * C1;
103   temp2 = step[12] * C15;
104   output[12] = temp2 + temp1;
105 
106   temp1 = step[10] * C13;
107   temp2 = step[13] * C3;
108   output[13] = temp2 - temp1;
109 
110   temp1 = step[9] * C5;
111   temp2 = step[14] * C11;
112   output[14] = temp2 + temp1;
113 
114   temp1 = step[8] * C9;
115   temp2 = step[15] * C7;
116   output[15] = temp2 - temp1;
117 
118   // step 3
119   step[0] = output[0] + output[3];
120   step[1] = output[1] + output[2];
121   step[2] = output[1] - output[2];
122   step[3] = output[0] - output[3];
123 
124   temp1 = output[4] * C14;
125   temp2 = output[7] * C2;
126   step[4] = temp1 + temp2;
127 
128   temp1 = output[5] * C10;
129   temp2 = output[6] * C6;
130   step[5] = temp1 + temp2;
131 
132   temp1 = output[5] * C6;
133   temp2 = output[6] * C10;
134   step[6] = temp2 - temp1;
135 
136   temp1 = output[4] * C2;
137   temp2 = output[7] * C14;
138   step[7] = temp2 - temp1;
139 
140   step[8] = output[8] + output[11];
141   step[9] = output[9] + output[10];
142   step[10] = output[9] - output[10];
143   step[11] = output[8] - output[11];
144 
145   step[12] = output[12] + output[15];
146   step[13] = output[13] + output[14];
147   step[14] = output[13] - output[14];
148   step[15] = output[12] - output[15];
149 
150   // step 4
151   output[0] = (step[0] + step[1]);
152   output[8] = (step[0] - step[1]);
153 
154   temp1 = step[2] * C12;
155   temp2 = step[3] * C4;
156   temp1 = temp1 + temp2;
157   output[4] = 2 * (temp1 * C8);
158 
159   temp1 = step[2] * C4;
160   temp2 = step[3] * C12;
161   temp1 = temp2 - temp1;
162   output[12] = 2 * (temp1 * C8);
163 
164   output[2] = 2 * ((step[4] + step[5]) * C8);
165   output[14] = 2 * ((step[7] - step[6]) * C8);
166 
167   temp1 = step[4] - step[5];
168   temp2 = step[6] + step[7];
169   output[6] = (temp1 + temp2);
170   output[10] = (temp1 - temp2);
171 
172   intermediate[8] = step[8] + step[14];
173   intermediate[9] = step[9] + step[15];
174 
175   temp1 = intermediate[8] * C12;
176   temp2 = intermediate[9] * C4;
177   temp1 = temp1 - temp2;
178   output[3] = 2 * (temp1 * C8);
179 
180   temp1 = intermediate[8] * C4;
181   temp2 = intermediate[9] * C12;
182   temp1 = temp2 + temp1;
183   output[13] = 2 * (temp1 * C8);
184 
185   output[9] = 2 * ((step[10] + step[11]) * C8);
186 
187   intermediate[11] = step[10] - step[11];
188   intermediate[12] = step[12] + step[13];
189   intermediate[13] = step[12] - step[13];
190   intermediate[14] = step[8] - step[14];
191   intermediate[15] = step[9] - step[15];
192 
193   output[15] = (intermediate[11] + intermediate[12]);
194   output[1] = -(intermediate[11] - intermediate[12]);
195 
196   output[7] = 2 * (intermediate[13] * C8);
197 
198   temp1 = intermediate[14] * C12;
199   temp2 = intermediate[15] * C4;
200   temp1 = temp1 - temp2;
201   output[11] = -2 * (temp1 * C8);
202 
203   temp1 = intermediate[14] * C4;
204   temp2 = intermediate[15] * C12;
205   temp1 = temp2 + temp1;
206   output[5] = 2 * (temp1 * C8);
207 }
208 
reference_16x16_dct_2d(int16_t input[256],double output[256])209 void reference_16x16_dct_2d(int16_t input[256], double output[256]) {
210   // First transform columns
211   for (int i = 0; i < 16; ++i) {
212     double temp_in[16], temp_out[16];
213     for (int j = 0; j < 16; ++j) temp_in[j] = input[j * 16 + i];
214     butterfly_16x16_dct_1d(temp_in, temp_out);
215     for (int j = 0; j < 16; ++j) output[j * 16 + i] = temp_out[j];
216   }
217   // Then transform rows
218   for (int i = 0; i < 16; ++i) {
219     double temp_in[16], temp_out[16];
220     for (int j = 0; j < 16; ++j) temp_in[j] = output[j + i * 16];
221     butterfly_16x16_dct_1d(temp_in, temp_out);
222     // Scale by some magic number
223     for (int j = 0; j < 16; ++j) output[j + i * 16] = temp_out[j] / 2;
224   }
225 }
226 
227 typedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride);
228 typedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride);
229 typedef void (*FhtFunc)(const int16_t *in, tran_low_t *out, int stride,
230                         int tx_type);
231 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
232                         int tx_type);
233 
234 typedef std::tuple<FdctFunc, IdctFunc, int, vpx_bit_depth_t> Dct16x16Param;
235 typedef std::tuple<FhtFunc, IhtFunc, int, vpx_bit_depth_t> Ht16x16Param;
236 typedef std::tuple<IdctFunc, IdctFunc, int, vpx_bit_depth_t> Idct16x16Param;
237 
fdct16x16_ref(const int16_t * in,tran_low_t * out,int stride,int)238 void fdct16x16_ref(const int16_t *in, tran_low_t *out, int stride,
239                    int /*tx_type*/) {
240   vpx_fdct16x16_c(in, out, stride);
241 }
242 
idct16x16_ref(const tran_low_t * in,uint8_t * dest,int stride,int)243 void idct16x16_ref(const tran_low_t *in, uint8_t *dest, int stride,
244                    int /*tx_type*/) {
245   vpx_idct16x16_256_add_c(in, dest, stride);
246 }
247 
fht16x16_ref(const int16_t * in,tran_low_t * out,int stride,int tx_type)248 void fht16x16_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
249   vp9_fht16x16_c(in, out, stride, tx_type);
250 }
251 
iht16x16_ref(const tran_low_t * in,uint8_t * dest,int stride,int tx_type)252 void iht16x16_ref(const tran_low_t *in, uint8_t *dest, int stride,
253                   int tx_type) {
254   vp9_iht16x16_256_add_c(in, dest, stride, tx_type);
255 }
256 
257 #if CONFIG_VP9_HIGHBITDEPTH
idct16x16_10(const tran_low_t * in,uint8_t * out,int stride)258 void idct16x16_10(const tran_low_t *in, uint8_t *out, int stride) {
259   vpx_highbd_idct16x16_256_add_c(in, CAST_TO_SHORTPTR(out), stride, 10);
260 }
261 
idct16x16_12(const tran_low_t * in,uint8_t * out,int stride)262 void idct16x16_12(const tran_low_t *in, uint8_t *out, int stride) {
263   vpx_highbd_idct16x16_256_add_c(in, CAST_TO_SHORTPTR(out), stride, 12);
264 }
265 
idct16x16_10_ref(const tran_low_t * in,uint8_t * out,int stride,int)266 void idct16x16_10_ref(const tran_low_t *in, uint8_t *out, int stride,
267                       int /*tx_type*/) {
268   idct16x16_10(in, out, stride);
269 }
270 
idct16x16_12_ref(const tran_low_t * in,uint8_t * out,int stride,int)271 void idct16x16_12_ref(const tran_low_t *in, uint8_t *out, int stride,
272                       int /*tx_type*/) {
273   idct16x16_12(in, out, stride);
274 }
275 
iht16x16_10(const tran_low_t * in,uint8_t * out,int stride,int tx_type)276 void iht16x16_10(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
277   vp9_highbd_iht16x16_256_add_c(in, CAST_TO_SHORTPTR(out), stride, tx_type, 10);
278 }
279 
iht16x16_12(const tran_low_t * in,uint8_t * out,int stride,int tx_type)280 void iht16x16_12(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
281   vp9_highbd_iht16x16_256_add_c(in, CAST_TO_SHORTPTR(out), stride, tx_type, 12);
282 }
283 
284 #if HAVE_SSE2
idct16x16_10_add_10_c(const tran_low_t * in,uint8_t * out,int stride)285 void idct16x16_10_add_10_c(const tran_low_t *in, uint8_t *out, int stride) {
286   vpx_highbd_idct16x16_10_add_c(in, CAST_TO_SHORTPTR(out), stride, 10);
287 }
288 
idct16x16_10_add_12_c(const tran_low_t * in,uint8_t * out,int stride)289 void idct16x16_10_add_12_c(const tran_low_t *in, uint8_t *out, int stride) {
290   vpx_highbd_idct16x16_10_add_c(in, CAST_TO_SHORTPTR(out), stride, 12);
291 }
292 
idct16x16_256_add_10_sse2(const tran_low_t * in,uint8_t * out,int stride)293 void idct16x16_256_add_10_sse2(const tran_low_t *in, uint8_t *out, int stride) {
294   vpx_highbd_idct16x16_256_add_sse2(in, CAST_TO_SHORTPTR(out), stride, 10);
295 }
296 
idct16x16_256_add_12_sse2(const tran_low_t * in,uint8_t * out,int stride)297 void idct16x16_256_add_12_sse2(const tran_low_t *in, uint8_t *out, int stride) {
298   vpx_highbd_idct16x16_256_add_sse2(in, CAST_TO_SHORTPTR(out), stride, 12);
299 }
300 
idct16x16_10_add_10_sse2(const tran_low_t * in,uint8_t * out,int stride)301 void idct16x16_10_add_10_sse2(const tran_low_t *in, uint8_t *out, int stride) {
302   vpx_highbd_idct16x16_10_add_sse2(in, CAST_TO_SHORTPTR(out), stride, 10);
303 }
304 
idct16x16_10_add_12_sse2(const tran_low_t * in,uint8_t * out,int stride)305 void idct16x16_10_add_12_sse2(const tran_low_t *in, uint8_t *out, int stride) {
306   vpx_highbd_idct16x16_10_add_sse2(in, CAST_TO_SHORTPTR(out), stride, 12);
307 }
308 #endif  // HAVE_SSE2
309 #endif  // CONFIG_VP9_HIGHBITDEPTH
310 
311 class Trans16x16TestBase {
312  public:
313   virtual ~Trans16x16TestBase() = default;
314 
315  protected:
316   virtual void RunFwdTxfm(int16_t *in, tran_low_t *out, int stride) = 0;
317 
318   virtual void RunInvTxfm(tran_low_t *out, uint8_t *dst, int stride) = 0;
319 
RunAccuracyCheck()320   void RunAccuracyCheck() {
321     ACMRandom rnd(ACMRandom::DeterministicSeed());
322     uint32_t max_error = 0;
323     int64_t total_error = 0;
324     const int count_test_block = 10000;
325     for (int i = 0; i < count_test_block; ++i) {
326       DECLARE_ALIGNED(16, int16_t, test_input_block[kNumCoeffs]);
327       DECLARE_ALIGNED(16, tran_low_t, test_temp_block[kNumCoeffs]);
328       DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]);
329       DECLARE_ALIGNED(16, uint8_t, src[kNumCoeffs]);
330 #if CONFIG_VP9_HIGHBITDEPTH
331       DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]);
332       DECLARE_ALIGNED(16, uint16_t, src16[kNumCoeffs]);
333 #endif
334 
335       // Initialize a test block with input range [-mask_, mask_].
336       for (int j = 0; j < kNumCoeffs; ++j) {
337         if (bit_depth_ == VPX_BITS_8) {
338           src[j] = rnd.Rand8();
339           dst[j] = rnd.Rand8();
340           test_input_block[j] = src[j] - dst[j];
341 #if CONFIG_VP9_HIGHBITDEPTH
342         } else {
343           src16[j] = rnd.Rand16() & mask_;
344           dst16[j] = rnd.Rand16() & mask_;
345           test_input_block[j] = src16[j] - dst16[j];
346 #endif
347         }
348       }
349 
350       ASM_REGISTER_STATE_CHECK(
351           RunFwdTxfm(test_input_block, test_temp_block, pitch_));
352       if (bit_depth_ == VPX_BITS_8) {
353         ASM_REGISTER_STATE_CHECK(RunInvTxfm(test_temp_block, dst, pitch_));
354 #if CONFIG_VP9_HIGHBITDEPTH
355       } else {
356         ASM_REGISTER_STATE_CHECK(
357             RunInvTxfm(test_temp_block, CAST_TO_BYTEPTR(dst16), pitch_));
358 #endif
359       }
360 
361       for (int j = 0; j < kNumCoeffs; ++j) {
362 #if CONFIG_VP9_HIGHBITDEPTH
363         const int32_t diff =
364             bit_depth_ == VPX_BITS_8 ? dst[j] - src[j] : dst16[j] - src16[j];
365 #else
366         const int32_t diff = dst[j] - src[j];
367 #endif
368         const uint32_t error = diff * diff;
369         if (max_error < error) max_error = error;
370         total_error += error;
371       }
372     }
373 
374     EXPECT_GE(1u << 2 * (bit_depth_ - 8), max_error)
375         << "Error: 16x16 FHT/IHT has an individual round trip error > 1";
376 
377     EXPECT_GE(count_test_block << 2 * (bit_depth_ - 8), total_error)
378         << "Error: 16x16 FHT/IHT has average round trip error > 1 per block";
379   }
380 
RunCoeffCheck()381   void RunCoeffCheck() {
382     ACMRandom rnd(ACMRandom::DeterministicSeed());
383     const int count_test_block = 1000;
384     DECLARE_ALIGNED(16, int16_t, input_block[kNumCoeffs]);
385     DECLARE_ALIGNED(16, tran_low_t, output_ref_block[kNumCoeffs]);
386     DECLARE_ALIGNED(16, tran_low_t, output_block[kNumCoeffs]);
387 
388     for (int i = 0; i < count_test_block; ++i) {
389       // Initialize a test block with input range [-mask_, mask_].
390       for (int j = 0; j < kNumCoeffs; ++j) {
391         input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
392       }
393 
394       fwd_txfm_ref(input_block, output_ref_block, pitch_, tx_type_);
395       ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_block, output_block, pitch_));
396 
397       // The minimum quant value is 4.
398       for (int j = 0; j < kNumCoeffs; ++j)
399         EXPECT_EQ(output_block[j], output_ref_block[j]);
400     }
401   }
402 
RunMemCheck()403   void RunMemCheck() {
404     ACMRandom rnd(ACMRandom::DeterministicSeed());
405     const int count_test_block = 1000;
406     DECLARE_ALIGNED(16, int16_t, input_extreme_block[kNumCoeffs]);
407     DECLARE_ALIGNED(16, tran_low_t, output_ref_block[kNumCoeffs]);
408     DECLARE_ALIGNED(16, tran_low_t, output_block[kNumCoeffs]);
409 
410     for (int i = 0; i < count_test_block; ++i) {
411       // Initialize a test block with input range [-mask_, mask_].
412       for (int j = 0; j < kNumCoeffs; ++j) {
413         input_extreme_block[j] = rnd.Rand8() % 2 ? mask_ : -mask_;
414       }
415       if (i == 0) {
416         for (int j = 0; j < kNumCoeffs; ++j) input_extreme_block[j] = mask_;
417       } else if (i == 1) {
418         for (int j = 0; j < kNumCoeffs; ++j) input_extreme_block[j] = -mask_;
419       }
420 
421       fwd_txfm_ref(input_extreme_block, output_ref_block, pitch_, tx_type_);
422       ASM_REGISTER_STATE_CHECK(
423           RunFwdTxfm(input_extreme_block, output_block, pitch_));
424 
425       // The minimum quant value is 4.
426       for (int j = 0; j < kNumCoeffs; ++j) {
427         EXPECT_EQ(output_block[j], output_ref_block[j]);
428         EXPECT_GE(4 * DCT_MAX_VALUE << (bit_depth_ - 8), abs(output_block[j]))
429             << "Error: 16x16 FDCT has coefficient larger than 4*DCT_MAX_VALUE";
430       }
431     }
432   }
433 
RunQuantCheck(int dc_thred,int ac_thred)434   void RunQuantCheck(int dc_thred, int ac_thred) {
435     ACMRandom rnd(ACMRandom::DeterministicSeed());
436     const int count_test_block = 100000;
437     DECLARE_ALIGNED(16, int16_t, input_extreme_block[kNumCoeffs]);
438     DECLARE_ALIGNED(16, tran_low_t, output_ref_block[kNumCoeffs]);
439 
440     DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]);
441     DECLARE_ALIGNED(16, uint8_t, ref[kNumCoeffs]);
442 #if CONFIG_VP9_HIGHBITDEPTH
443     DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]);
444     DECLARE_ALIGNED(16, uint16_t, ref16[kNumCoeffs]);
445 #endif
446 
447     for (int i = 0; i < count_test_block; ++i) {
448       // Initialize a test block with input range [-mask_, mask_].
449       for (int j = 0; j < kNumCoeffs; ++j) {
450         input_extreme_block[j] = rnd.Rand8() % 2 ? mask_ : -mask_;
451       }
452       if (i == 0) {
453         for (int j = 0; j < kNumCoeffs; ++j) input_extreme_block[j] = mask_;
454       }
455       if (i == 1) {
456         for (int j = 0; j < kNumCoeffs; ++j) input_extreme_block[j] = -mask_;
457       }
458 
459       fwd_txfm_ref(input_extreme_block, output_ref_block, pitch_, tx_type_);
460 
461       // clear reconstructed pixel buffers
462       memset(dst, 0, kNumCoeffs * sizeof(uint8_t));
463       memset(ref, 0, kNumCoeffs * sizeof(uint8_t));
464 #if CONFIG_VP9_HIGHBITDEPTH
465       memset(dst16, 0, kNumCoeffs * sizeof(uint16_t));
466       memset(ref16, 0, kNumCoeffs * sizeof(uint16_t));
467 #endif
468 
469       // quantization with maximum allowed step sizes
470       output_ref_block[0] = (output_ref_block[0] / dc_thred) * dc_thred;
471       for (int j = 1; j < kNumCoeffs; ++j) {
472         output_ref_block[j] = (output_ref_block[j] / ac_thred) * ac_thred;
473       }
474       if (bit_depth_ == VPX_BITS_8) {
475         inv_txfm_ref(output_ref_block, ref, pitch_, tx_type_);
476         ASM_REGISTER_STATE_CHECK(RunInvTxfm(output_ref_block, dst, pitch_));
477 #if CONFIG_VP9_HIGHBITDEPTH
478       } else {
479         inv_txfm_ref(output_ref_block, CAST_TO_BYTEPTR(ref16), pitch_,
480                      tx_type_);
481         ASM_REGISTER_STATE_CHECK(
482             RunInvTxfm(output_ref_block, CAST_TO_BYTEPTR(dst16), pitch_));
483 #endif
484       }
485       if (bit_depth_ == VPX_BITS_8) {
486         for (int j = 0; j < kNumCoeffs; ++j) EXPECT_EQ(ref[j], dst[j]);
487 #if CONFIG_VP9_HIGHBITDEPTH
488       } else {
489         for (int j = 0; j < kNumCoeffs; ++j) EXPECT_EQ(ref16[j], dst16[j]);
490 #endif
491       }
492     }
493   }
494 
RunInvAccuracyCheck()495   void RunInvAccuracyCheck() {
496     ACMRandom rnd(ACMRandom::DeterministicSeed());
497     const int count_test_block = 1000;
498     DECLARE_ALIGNED(16, int16_t, in[kNumCoeffs]);
499     DECLARE_ALIGNED(16, tran_low_t, coeff[kNumCoeffs]);
500     DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]);
501     DECLARE_ALIGNED(16, uint8_t, src[kNumCoeffs]);
502 #if CONFIG_VP9_HIGHBITDEPTH
503     DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]);
504     DECLARE_ALIGNED(16, uint16_t, src16[kNumCoeffs]);
505 #endif  // CONFIG_VP9_HIGHBITDEPTH
506 
507     for (int i = 0; i < count_test_block; ++i) {
508       double out_r[kNumCoeffs];
509 
510       // Initialize a test block with input range [-255, 255].
511       for (int j = 0; j < kNumCoeffs; ++j) {
512         if (bit_depth_ == VPX_BITS_8) {
513           src[j] = rnd.Rand8();
514           dst[j] = rnd.Rand8();
515           in[j] = src[j] - dst[j];
516 #if CONFIG_VP9_HIGHBITDEPTH
517         } else {
518           src16[j] = rnd.Rand16() & mask_;
519           dst16[j] = rnd.Rand16() & mask_;
520           in[j] = src16[j] - dst16[j];
521 #endif  // CONFIG_VP9_HIGHBITDEPTH
522         }
523       }
524 
525       reference_16x16_dct_2d(in, out_r);
526       for (int j = 0; j < kNumCoeffs; ++j) {
527         coeff[j] = static_cast<tran_low_t>(round(out_r[j]));
528       }
529 
530       if (bit_depth_ == VPX_BITS_8) {
531         ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, dst, 16));
532 #if CONFIG_VP9_HIGHBITDEPTH
533       } else {
534         ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, CAST_TO_BYTEPTR(dst16), 16));
535 #endif  // CONFIG_VP9_HIGHBITDEPTH
536       }
537 
538       for (int j = 0; j < kNumCoeffs; ++j) {
539 #if CONFIG_VP9_HIGHBITDEPTH
540         const uint32_t diff =
541             bit_depth_ == VPX_BITS_8 ? dst[j] - src[j] : dst16[j] - src16[j];
542 #else
543         const uint32_t diff = dst[j] - src[j];
544 #endif  // CONFIG_VP9_HIGHBITDEPTH
545         const uint32_t error = diff * diff;
546         EXPECT_GE(1u, error)
547             << "Error: 16x16 IDCT has error " << error << " at index " << j;
548       }
549     }
550   }
551 
RunSpeedTest()552   void RunSpeedTest() {
553     ACMRandom rnd(ACMRandom::DeterministicSeed());
554     const int count_test_block = 10000;
555     int c_sum_time = 0;
556     int simd_sum_time = 0;
557 
558     DECLARE_ALIGNED(32, int16_t, input_block[kNumCoeffs]);
559     DECLARE_ALIGNED(32, tran_low_t, output_ref_block[kNumCoeffs]);
560     DECLARE_ALIGNED(32, tran_low_t, output_block[kNumCoeffs]);
561 
562     // Initialize a test block with input range [-mask_, mask_].
563     for (int j = 0; j < kNumCoeffs; ++j) {
564       input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
565     }
566 
567     vpx_usec_timer timer_c;
568     vpx_usec_timer_start(&timer_c);
569     for (int i = 0; i < count_test_block; ++i) {
570       vpx_fdct16x16_c(input_block, output_ref_block, pitch_);
571     }
572     vpx_usec_timer_mark(&timer_c);
573     c_sum_time += static_cast<int>(vpx_usec_timer_elapsed(&timer_c));
574 
575     vpx_usec_timer timer_mod;
576     vpx_usec_timer_start(&timer_mod);
577     for (int i = 0; i < count_test_block; ++i) {
578       RunFwdTxfm(input_block, output_block, pitch_);
579     }
580 
581     vpx_usec_timer_mark(&timer_mod);
582     simd_sum_time += static_cast<int>(vpx_usec_timer_elapsed(&timer_mod));
583 
584     printf(
585         "c_time = %d \t simd_time = %d \t Gain = %4.2f \n", c_sum_time,
586         simd_sum_time,
587         (static_cast<float>(c_sum_time) / static_cast<float>(simd_sum_time)));
588   }
589 
CompareInvReference(IdctFunc ref_txfm,int thresh)590   void CompareInvReference(IdctFunc ref_txfm, int thresh) {
591     ACMRandom rnd(ACMRandom::DeterministicSeed());
592     const int count_test_block = 10000;
593     const int eob = 10;
594     const int16_t *scan = vp9_default_scan_orders[TX_16X16].scan;
595     DECLARE_ALIGNED(32, tran_low_t, coeff[kNumCoeffs]);
596     DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]);
597     DECLARE_ALIGNED(16, uint8_t, ref[kNumCoeffs]);
598 #if CONFIG_VP9_HIGHBITDEPTH
599     DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]);
600     DECLARE_ALIGNED(16, uint16_t, ref16[kNumCoeffs]);
601 #endif  // CONFIG_VP9_HIGHBITDEPTH
602 
603     for (int i = 0; i < count_test_block; ++i) {
604       for (int j = 0; j < kNumCoeffs; ++j) {
605         if (j < eob) {
606           // Random values less than the threshold, either positive or negative
607           coeff[scan[j]] = rnd(thresh) * (1 - 2 * (i % 2));
608         } else {
609           coeff[scan[j]] = 0;
610         }
611         if (bit_depth_ == VPX_BITS_8) {
612           dst[j] = 0;
613           ref[j] = 0;
614 #if CONFIG_VP9_HIGHBITDEPTH
615         } else {
616           dst16[j] = 0;
617           ref16[j] = 0;
618 #endif  // CONFIG_VP9_HIGHBITDEPTH
619         }
620       }
621       if (bit_depth_ == VPX_BITS_8) {
622         ref_txfm(coeff, ref, pitch_);
623         ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, dst, pitch_));
624       } else {
625 #if CONFIG_VP9_HIGHBITDEPTH
626         ref_txfm(coeff, CAST_TO_BYTEPTR(ref16), pitch_);
627         ASM_REGISTER_STATE_CHECK(
628             RunInvTxfm(coeff, CAST_TO_BYTEPTR(dst16), pitch_));
629 #endif  // CONFIG_VP9_HIGHBITDEPTH
630       }
631 
632       for (int j = 0; j < kNumCoeffs; ++j) {
633 #if CONFIG_VP9_HIGHBITDEPTH
634         const uint32_t diff =
635             bit_depth_ == VPX_BITS_8 ? dst[j] - ref[j] : dst16[j] - ref16[j];
636 #else
637         const uint32_t diff = dst[j] - ref[j];
638 #endif  // CONFIG_VP9_HIGHBITDEPTH
639         const uint32_t error = diff * diff;
640         EXPECT_EQ(0u, error) << "Error: 16x16 IDCT Comparison has error "
641                              << error << " at index " << j;
642       }
643     }
644   }
645 
RunInvTrans16x16SpeedTest(IdctFunc ref_txfm,int thresh)646   void RunInvTrans16x16SpeedTest(IdctFunc ref_txfm, int thresh) {
647     ACMRandom rnd(ACMRandom::DeterministicSeed());
648     const int count_test_block = 10000;
649     const int eob = 10;
650     const int16_t *scan = vp9_default_scan_orders[TX_16X16].scan;
651     int64_t c_sum_time = 0;
652     int64_t simd_sum_time = 0;
653     DECLARE_ALIGNED(32, tran_low_t, coeff[kNumCoeffs]);
654     DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]);
655     DECLARE_ALIGNED(16, uint8_t, ref[kNumCoeffs]);
656 #if CONFIG_VP9_HIGHBITDEPTH
657     DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]);
658     DECLARE_ALIGNED(16, uint16_t, ref16[kNumCoeffs]);
659 #endif  // CONFIG_VP9_HIGHBITDEPTH
660 
661     for (int j = 0; j < kNumCoeffs; ++j) {
662       if (j < eob) {
663         // Random values less than the threshold, either positive or negative
664         coeff[scan[j]] = rnd(thresh);
665       } else {
666         coeff[scan[j]] = 0;
667       }
668       if (bit_depth_ == VPX_BITS_8) {
669         dst[j] = 0;
670         ref[j] = 0;
671 #if CONFIG_VP9_HIGHBITDEPTH
672       } else {
673         dst16[j] = 0;
674         ref16[j] = 0;
675 #endif  // CONFIG_VP9_HIGHBITDEPTH
676       }
677     }
678 
679     if (bit_depth_ == VPX_BITS_8) {
680       vpx_usec_timer timer_c;
681       vpx_usec_timer_start(&timer_c);
682       for (int i = 0; i < count_test_block; ++i) {
683         ref_txfm(coeff, ref, pitch_);
684       }
685       vpx_usec_timer_mark(&timer_c);
686       c_sum_time += vpx_usec_timer_elapsed(&timer_c);
687 
688       vpx_usec_timer timer_mod;
689       vpx_usec_timer_start(&timer_mod);
690       for (int i = 0; i < count_test_block; ++i) {
691         RunInvTxfm(coeff, dst, pitch_);
692       }
693       vpx_usec_timer_mark(&timer_mod);
694       simd_sum_time += vpx_usec_timer_elapsed(&timer_mod);
695     } else {
696 #if CONFIG_VP9_HIGHBITDEPTH
697       vpx_usec_timer timer_c;
698       vpx_usec_timer_start(&timer_c);
699       for (int i = 0; i < count_test_block; ++i) {
700         ref_txfm(coeff, CAST_TO_BYTEPTR(ref16), pitch_);
701       }
702       vpx_usec_timer_mark(&timer_c);
703       c_sum_time += vpx_usec_timer_elapsed(&timer_c);
704 
705       vpx_usec_timer timer_mod;
706       vpx_usec_timer_start(&timer_mod);
707       for (int i = 0; i < count_test_block; ++i) {
708         RunInvTxfm(coeff, CAST_TO_BYTEPTR(dst16), pitch_);
709       }
710       vpx_usec_timer_mark(&timer_mod);
711       simd_sum_time += vpx_usec_timer_elapsed(&timer_mod);
712 #endif  // CONFIG_VP9_HIGHBITDEPTH
713     }
714     printf(
715         "c_time = %" PRId64 " \t simd_time = %" PRId64 " \t Gain = %4.2f \n",
716         c_sum_time, simd_sum_time,
717         (static_cast<float>(c_sum_time) / static_cast<float>(simd_sum_time)));
718   }
719 
720   int pitch_;
721   int tx_type_;
722   vpx_bit_depth_t bit_depth_;
723   int mask_;
724   FhtFunc fwd_txfm_ref;
725   IhtFunc inv_txfm_ref;
726 };
727 
728 class Trans16x16DCT : public Trans16x16TestBase,
729                       public ::testing::TestWithParam<Dct16x16Param> {
730  public:
731   ~Trans16x16DCT() override = default;
732 
SetUp()733   void SetUp() override {
734     fwd_txfm_ = GET_PARAM(0);
735     inv_txfm_ = GET_PARAM(1);
736     tx_type_ = GET_PARAM(2);
737     bit_depth_ = GET_PARAM(3);
738     pitch_ = 16;
739     fwd_txfm_ref = fdct16x16_ref;
740     inv_txfm_ref = idct16x16_ref;
741     mask_ = (1 << bit_depth_) - 1;
742 #if CONFIG_VP9_HIGHBITDEPTH
743     switch (bit_depth_) {
744       case VPX_BITS_10: inv_txfm_ref = idct16x16_10_ref; break;
745       case VPX_BITS_12: inv_txfm_ref = idct16x16_12_ref; break;
746       default: inv_txfm_ref = idct16x16_ref; break;
747     }
748 #else
749     inv_txfm_ref = idct16x16_ref;
750 #endif
751   }
TearDown()752   void TearDown() override { libvpx_test::ClearSystemState(); }
753 
754  protected:
RunFwdTxfm(int16_t * in,tran_low_t * out,int stride)755   void RunFwdTxfm(int16_t *in, tran_low_t *out, int stride) override {
756     fwd_txfm_(in, out, stride);
757   }
RunInvTxfm(tran_low_t * out,uint8_t * dst,int stride)758   void RunInvTxfm(tran_low_t *out, uint8_t *dst, int stride) override {
759     inv_txfm_(out, dst, stride);
760   }
761 
762   FdctFunc fwd_txfm_;
763   IdctFunc inv_txfm_;
764 };
765 
TEST_P(Trans16x16DCT,AccuracyCheck)766 TEST_P(Trans16x16DCT, AccuracyCheck) { RunAccuracyCheck(); }
767 
TEST_P(Trans16x16DCT,CoeffCheck)768 TEST_P(Trans16x16DCT, CoeffCheck) { RunCoeffCheck(); }
769 
TEST_P(Trans16x16DCT,MemCheck)770 TEST_P(Trans16x16DCT, MemCheck) { RunMemCheck(); }
771 
TEST_P(Trans16x16DCT,QuantCheck)772 TEST_P(Trans16x16DCT, QuantCheck) {
773   // Use maximally allowed quantization step sizes for DC and AC
774   // coefficients respectively.
775   RunQuantCheck(1336, 1828);
776 }
777 
TEST_P(Trans16x16DCT,InvAccuracyCheck)778 TEST_P(Trans16x16DCT, InvAccuracyCheck) { RunInvAccuracyCheck(); }
779 
TEST_P(Trans16x16DCT,DISABLED_Speed)780 TEST_P(Trans16x16DCT, DISABLED_Speed) { RunSpeedTest(); }
781 
782 class Trans16x16HT : public Trans16x16TestBase,
783                      public ::testing::TestWithParam<Ht16x16Param> {
784  public:
785   ~Trans16x16HT() override = default;
786 
SetUp()787   void SetUp() override {
788     fwd_txfm_ = GET_PARAM(0);
789     inv_txfm_ = GET_PARAM(1);
790     tx_type_ = GET_PARAM(2);
791     bit_depth_ = GET_PARAM(3);
792     pitch_ = 16;
793     fwd_txfm_ref = fht16x16_ref;
794     inv_txfm_ref = iht16x16_ref;
795     mask_ = (1 << bit_depth_) - 1;
796 #if CONFIG_VP9_HIGHBITDEPTH
797     switch (bit_depth_) {
798       case VPX_BITS_10: inv_txfm_ref = iht16x16_10; break;
799       case VPX_BITS_12: inv_txfm_ref = iht16x16_12; break;
800       default: inv_txfm_ref = iht16x16_ref; break;
801     }
802 #else
803     inv_txfm_ref = iht16x16_ref;
804 #endif
805   }
TearDown()806   void TearDown() override { libvpx_test::ClearSystemState(); }
807 
808  protected:
RunFwdTxfm(int16_t * in,tran_low_t * out,int stride)809   void RunFwdTxfm(int16_t *in, tran_low_t *out, int stride) override {
810     fwd_txfm_(in, out, stride, tx_type_);
811   }
RunInvTxfm(tran_low_t * out,uint8_t * dst,int stride)812   void RunInvTxfm(tran_low_t *out, uint8_t *dst, int stride) override {
813     inv_txfm_(out, dst, stride, tx_type_);
814   }
815 
816   FhtFunc fwd_txfm_;
817   IhtFunc inv_txfm_;
818 };
819 
TEST_P(Trans16x16HT,AccuracyCheck)820 TEST_P(Trans16x16HT, AccuracyCheck) { RunAccuracyCheck(); }
821 
TEST_P(Trans16x16HT,CoeffCheck)822 TEST_P(Trans16x16HT, CoeffCheck) { RunCoeffCheck(); }
823 
TEST_P(Trans16x16HT,MemCheck)824 TEST_P(Trans16x16HT, MemCheck) { RunMemCheck(); }
825 
TEST_P(Trans16x16HT,QuantCheck)826 TEST_P(Trans16x16HT, QuantCheck) {
827   // The encoder skips any non-DC intra prediction modes,
828   // when the quantization step size goes beyond 988.
829   RunQuantCheck(429, 729);
830 }
831 
832 class InvTrans16x16DCT : public Trans16x16TestBase,
833                          public ::testing::TestWithParam<Idct16x16Param> {
834  public:
835   ~InvTrans16x16DCT() override = default;
836 
SetUp()837   void SetUp() override {
838     ref_txfm_ = GET_PARAM(0);
839     inv_txfm_ = GET_PARAM(1);
840     thresh_ = GET_PARAM(2);
841     bit_depth_ = GET_PARAM(3);
842     pitch_ = 16;
843     mask_ = (1 << bit_depth_) - 1;
844   }
TearDown()845   void TearDown() override { libvpx_test::ClearSystemState(); }
846 
847  protected:
RunFwdTxfm(int16_t *,tran_low_t *,int)848   void RunFwdTxfm(int16_t * /*in*/, tran_low_t * /*out*/,
849                   int /*stride*/) override {}
RunInvTxfm(tran_low_t * out,uint8_t * dst,int stride)850   void RunInvTxfm(tran_low_t *out, uint8_t *dst, int stride) override {
851     inv_txfm_(out, dst, stride);
852   }
853 
854   IdctFunc ref_txfm_;
855   IdctFunc inv_txfm_;
856   int thresh_;
857 };
858 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(InvTrans16x16DCT);
859 
TEST_P(InvTrans16x16DCT,CompareReference)860 TEST_P(InvTrans16x16DCT, CompareReference) {
861   CompareInvReference(ref_txfm_, thresh_);
862 }
863 
TEST_P(InvTrans16x16DCT,DISABLED_Speed)864 TEST_P(InvTrans16x16DCT, DISABLED_Speed) {
865   RunInvTrans16x16SpeedTest(ref_txfm_, thresh_);
866 }
867 
868 using std::make_tuple;
869 
870 #if CONFIG_VP9_HIGHBITDEPTH
871 INSTANTIATE_TEST_SUITE_P(
872     C, Trans16x16DCT,
873     ::testing::Values(
874         make_tuple(&vpx_highbd_fdct16x16_c, &idct16x16_10, 0, VPX_BITS_10),
875         make_tuple(&vpx_highbd_fdct16x16_c, &idct16x16_12, 0, VPX_BITS_12),
876         make_tuple(&vpx_fdct16x16_c, &vpx_idct16x16_256_add_c, 0, VPX_BITS_8)));
877 #else
878 INSTANTIATE_TEST_SUITE_P(C, Trans16x16DCT,
879                          ::testing::Values(make_tuple(&vpx_fdct16x16_c,
880                                                       &vpx_idct16x16_256_add_c,
881                                                       0, VPX_BITS_8)));
882 #endif  // CONFIG_VP9_HIGHBITDEPTH
883 
884 #if CONFIG_VP9_HIGHBITDEPTH
885 INSTANTIATE_TEST_SUITE_P(
886     C, Trans16x16HT,
887     ::testing::Values(
888         make_tuple(&vp9_highbd_fht16x16_c, &iht16x16_10, 0, VPX_BITS_10),
889         make_tuple(&vp9_highbd_fht16x16_c, &iht16x16_10, 1, VPX_BITS_10),
890         make_tuple(&vp9_highbd_fht16x16_c, &iht16x16_10, 2, VPX_BITS_10),
891         make_tuple(&vp9_highbd_fht16x16_c, &iht16x16_10, 3, VPX_BITS_10),
892         make_tuple(&vp9_highbd_fht16x16_c, &iht16x16_12, 0, VPX_BITS_12),
893         make_tuple(&vp9_highbd_fht16x16_c, &iht16x16_12, 1, VPX_BITS_12),
894         make_tuple(&vp9_highbd_fht16x16_c, &iht16x16_12, 2, VPX_BITS_12),
895         make_tuple(&vp9_highbd_fht16x16_c, &iht16x16_12, 3, VPX_BITS_12),
896         make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 0, VPX_BITS_8),
897         make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 1, VPX_BITS_8),
898         make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 2, VPX_BITS_8),
899         make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 3, VPX_BITS_8)));
900 #else
901 INSTANTIATE_TEST_SUITE_P(
902     C, Trans16x16HT,
903     ::testing::Values(
904         make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 0, VPX_BITS_8),
905         make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 1, VPX_BITS_8),
906         make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 2, VPX_BITS_8),
907         make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 3, VPX_BITS_8)));
908 
909 INSTANTIATE_TEST_SUITE_P(C, InvTrans16x16DCT,
910                          ::testing::Values(make_tuple(&vpx_idct16x16_256_add_c,
911                                                       &vpx_idct16x16_256_add_c,
912                                                       6225, VPX_BITS_8)));
913 
914 #endif  // CONFIG_VP9_HIGHBITDEPTH
915 
916 #if HAVE_NEON && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
917 INSTANTIATE_TEST_SUITE_P(
918     NEON, Trans16x16DCT,
919     ::testing::Values(make_tuple(&vpx_fdct16x16_neon,
920                                  &vpx_idct16x16_256_add_neon, 0, VPX_BITS_8)));
921 #endif  // HAVE_NEON && !CONFIG_EMULATE_HARDWARE
922 
923 #if HAVE_NEON && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
924 INSTANTIATE_TEST_SUITE_P(
925     NEON, Trans16x16DCT,
926     ::testing::Values(
927         make_tuple(&vpx_highbd_fdct16x16_neon, &idct16x16_10, 0, VPX_BITS_10),
928         make_tuple(&vpx_highbd_fdct16x16_neon, &idct16x16_12, 0, VPX_BITS_12),
929         make_tuple(&vpx_fdct16x16_neon, &vpx_idct16x16_256_add_c, 0,
930                    VPX_BITS_8)));
931 #endif  // HAVE_NEON && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
932 
933 #if HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
934 INSTANTIATE_TEST_SUITE_P(
935     SSE2, Trans16x16DCT,
936     ::testing::Values(make_tuple(&vpx_fdct16x16_sse2,
937                                  &vpx_idct16x16_256_add_sse2, 0, VPX_BITS_8)));
938 INSTANTIATE_TEST_SUITE_P(
939     SSE2, Trans16x16HT,
940     ::testing::Values(make_tuple(&vp9_fht16x16_sse2, &vp9_iht16x16_256_add_sse2,
941                                  0, VPX_BITS_8),
942                       make_tuple(&vp9_fht16x16_sse2, &vp9_iht16x16_256_add_sse2,
943                                  1, VPX_BITS_8),
944                       make_tuple(&vp9_fht16x16_sse2, &vp9_iht16x16_256_add_sse2,
945                                  2, VPX_BITS_8),
946                       make_tuple(&vp9_fht16x16_sse2, &vp9_iht16x16_256_add_sse2,
947                                  3, VPX_BITS_8)));
948 
949 INSTANTIATE_TEST_SUITE_P(SSE2, InvTrans16x16DCT,
950                          ::testing::Values(make_tuple(
951                              &vpx_idct16x16_256_add_c,
952                              &vpx_idct16x16_256_add_sse2, 6225, VPX_BITS_8)));
953 #endif  // HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
954 
955 #if HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
956 INSTANTIATE_TEST_SUITE_P(
957     AVX2, Trans16x16DCT,
958     ::testing::Values(make_tuple(&vpx_fdct16x16_avx2,
959                                  &vpx_idct16x16_256_add_sse2, 0, VPX_BITS_8)));
960 
961 INSTANTIATE_TEST_SUITE_P(AVX2, InvTrans16x16DCT,
962                          ::testing::Values(make_tuple(
963                              &vpx_idct16x16_256_add_c,
964                              &vpx_idct16x16_256_add_avx2, 6225, VPX_BITS_8)));
965 #endif  // HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
966 
967 #if HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
968 INSTANTIATE_TEST_SUITE_P(
969     SSE2, Trans16x16DCT,
970     ::testing::Values(
971         make_tuple(&vpx_highbd_fdct16x16_sse2, &idct16x16_10, 0, VPX_BITS_10),
972         make_tuple(&vpx_highbd_fdct16x16_c, &idct16x16_256_add_10_sse2, 0,
973                    VPX_BITS_10),
974         make_tuple(&vpx_highbd_fdct16x16_sse2, &idct16x16_12, 0, VPX_BITS_12),
975         make_tuple(&vpx_highbd_fdct16x16_c, &idct16x16_256_add_12_sse2, 0,
976                    VPX_BITS_12),
977         make_tuple(&vpx_fdct16x16_sse2, &vpx_idct16x16_256_add_c, 0,
978                    VPX_BITS_8)));
979 INSTANTIATE_TEST_SUITE_P(
980     SSE2, Trans16x16HT,
981     ::testing::Values(
982         make_tuple(&vp9_fht16x16_sse2, &vp9_iht16x16_256_add_c, 0, VPX_BITS_8),
983         make_tuple(&vp9_fht16x16_sse2, &vp9_iht16x16_256_add_c, 1, VPX_BITS_8),
984         make_tuple(&vp9_fht16x16_sse2, &vp9_iht16x16_256_add_c, 2, VPX_BITS_8),
985         make_tuple(&vp9_fht16x16_sse2, &vp9_iht16x16_256_add_c, 3,
986                    VPX_BITS_8)));
987 // Optimizations take effect at a threshold of 3155, so we use a value close to
988 // that to test both branches.
989 INSTANTIATE_TEST_SUITE_P(
990     SSE2, InvTrans16x16DCT,
991     ::testing::Values(make_tuple(&idct16x16_10_add_10_c,
992                                  &idct16x16_10_add_10_sse2, 3167, VPX_BITS_10),
993                       make_tuple(&idct16x16_10, &idct16x16_256_add_10_sse2,
994                                  3167, VPX_BITS_10),
995                       make_tuple(&idct16x16_10_add_12_c,
996                                  &idct16x16_10_add_12_sse2, 3167, VPX_BITS_12),
997                       make_tuple(&idct16x16_12, &idct16x16_256_add_12_sse2,
998                                  3167, VPX_BITS_12)));
999 #endif  // HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
1000 
1001 #if HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
1002 INSTANTIATE_TEST_SUITE_P(
1003     MSA, Trans16x16DCT,
1004     ::testing::Values(make_tuple(&vpx_fdct16x16_msa, &vpx_idct16x16_256_add_msa,
1005                                  0, VPX_BITS_8)));
1006 INSTANTIATE_TEST_SUITE_P(
1007     MSA, Trans16x16HT,
1008     ::testing::Values(
1009         make_tuple(&vp9_fht16x16_msa, &vp9_iht16x16_256_add_msa, 0, VPX_BITS_8),
1010         make_tuple(&vp9_fht16x16_msa, &vp9_iht16x16_256_add_msa, 1, VPX_BITS_8),
1011         make_tuple(&vp9_fht16x16_msa, &vp9_iht16x16_256_add_msa, 2, VPX_BITS_8),
1012         make_tuple(&vp9_fht16x16_msa, &vp9_iht16x16_256_add_msa, 3,
1013                    VPX_BITS_8)));
1014 #endif  // HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
1015 
1016 #if HAVE_VSX && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
1017 INSTANTIATE_TEST_SUITE_P(
1018     VSX, Trans16x16DCT,
1019     ::testing::Values(make_tuple(&vpx_fdct16x16_c, &vpx_idct16x16_256_add_vsx,
1020                                  0, VPX_BITS_8)));
1021 #endif  // HAVE_VSX && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
1022 
1023 #if HAVE_LSX && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
1024 INSTANTIATE_TEST_SUITE_P(LSX, Trans16x16DCT,
1025                          ::testing::Values(make_tuple(&vpx_fdct16x16_lsx,
1026                                                       &vpx_idct16x16_256_add_c,
1027                                                       0, VPX_BITS_8)));
1028 #endif  // HAVE_LSX && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
1029 }  // namespace
1030