vp9_quantize_test.cc 22 KB

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