convolve_test.cc 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247
  1. /*
  2. * Copyright (c) 2010 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 <string.h>
  11. #include "third_party/googletest/src/include/gtest/gtest.h"
  12. #include "./vp9_rtcd.h"
  13. #include "./vpx_config.h"
  14. #include "./vpx_dsp_rtcd.h"
  15. #include "test/acm_random.h"
  16. #include "test/clear_system_state.h"
  17. #include "test/register_state_check.h"
  18. #include "test/util.h"
  19. #include "vp9/common/vp9_common.h"
  20. #include "vp9/common/vp9_filter.h"
  21. #include "vpx_dsp/vpx_dsp_common.h"
  22. #include "vpx_dsp/vpx_filter.h"
  23. #include "vpx_mem/vpx_mem.h"
  24. #include "vpx_ports/mem.h"
  25. #include "vpx_ports/vpx_timer.h"
  26. namespace {
  27. static const unsigned int kMaxDimension = 64;
  28. typedef void (*ConvolveFunc)(const uint8_t *src, ptrdiff_t src_stride,
  29. uint8_t *dst, ptrdiff_t dst_stride,
  30. const InterpKernel *filter, int x0_q4,
  31. int x_step_q4, int y0_q4, int y_step_q4, int w,
  32. int h);
  33. typedef void (*WrapperFilterBlock2d8Func)(
  34. const uint8_t *src_ptr, const unsigned int src_stride,
  35. const int16_t *hfilter, const int16_t *vfilter, uint8_t *dst_ptr,
  36. unsigned int dst_stride, unsigned int output_width,
  37. unsigned int output_height, int use_highbd);
  38. struct ConvolveFunctions {
  39. ConvolveFunctions(ConvolveFunc copy, ConvolveFunc avg, ConvolveFunc h8,
  40. ConvolveFunc h8_avg, ConvolveFunc v8, ConvolveFunc v8_avg,
  41. ConvolveFunc hv8, ConvolveFunc hv8_avg, ConvolveFunc sh8,
  42. ConvolveFunc sh8_avg, ConvolveFunc sv8,
  43. ConvolveFunc sv8_avg, ConvolveFunc shv8,
  44. ConvolveFunc shv8_avg, int bd)
  45. : use_highbd_(bd) {
  46. copy_[0] = copy;
  47. copy_[1] = avg;
  48. h8_[0] = h8;
  49. h8_[1] = h8_avg;
  50. v8_[0] = v8;
  51. v8_[1] = v8_avg;
  52. hv8_[0] = hv8;
  53. hv8_[1] = hv8_avg;
  54. sh8_[0] = sh8;
  55. sh8_[1] = sh8_avg;
  56. sv8_[0] = sv8;
  57. sv8_[1] = sv8_avg;
  58. shv8_[0] = shv8;
  59. shv8_[1] = shv8_avg;
  60. }
  61. ConvolveFunc copy_[2];
  62. ConvolveFunc h8_[2];
  63. ConvolveFunc v8_[2];
  64. ConvolveFunc hv8_[2];
  65. ConvolveFunc sh8_[2]; // scaled horiz
  66. ConvolveFunc sv8_[2]; // scaled vert
  67. ConvolveFunc shv8_[2]; // scaled horiz/vert
  68. int use_highbd_; // 0 if high bitdepth not used, else the actual bit depth.
  69. };
  70. typedef std::tr1::tuple<int, int, const ConvolveFunctions *> ConvolveParam;
  71. #define ALL_SIZES(convolve_fn) \
  72. make_tuple(4, 4, &convolve_fn), make_tuple(8, 4, &convolve_fn), \
  73. make_tuple(4, 8, &convolve_fn), make_tuple(8, 8, &convolve_fn), \
  74. make_tuple(16, 8, &convolve_fn), make_tuple(8, 16, &convolve_fn), \
  75. make_tuple(16, 16, &convolve_fn), make_tuple(32, 16, &convolve_fn), \
  76. make_tuple(16, 32, &convolve_fn), make_tuple(32, 32, &convolve_fn), \
  77. make_tuple(64, 32, &convolve_fn), make_tuple(32, 64, &convolve_fn), \
  78. make_tuple(64, 64, &convolve_fn)
  79. // Reference 8-tap subpixel filter, slightly modified to fit into this test.
  80. #define VP9_FILTER_WEIGHT 128
  81. #define VP9_FILTER_SHIFT 7
  82. uint8_t clip_pixel(int x) { return x < 0 ? 0 : x > 255 ? 255 : x; }
  83. void filter_block2d_8_c(const uint8_t *src_ptr, const unsigned int src_stride,
  84. const int16_t *hfilter, const int16_t *vfilter,
  85. uint8_t *dst_ptr, unsigned int dst_stride,
  86. unsigned int output_width, unsigned int output_height) {
  87. // Between passes, we use an intermediate buffer whose height is extended to
  88. // have enough horizontally filtered values as input for the vertical pass.
  89. // This buffer is allocated to be big enough for the largest block type we
  90. // support.
  91. const int kInterp_Extend = 4;
  92. const unsigned int intermediate_height =
  93. (kInterp_Extend - 1) + output_height + kInterp_Extend;
  94. unsigned int i, j;
  95. // Size of intermediate_buffer is max_intermediate_height * filter_max_width,
  96. // where max_intermediate_height = (kInterp_Extend - 1) + filter_max_height
  97. // + kInterp_Extend
  98. // = 3 + 16 + 4
  99. // = 23
  100. // and filter_max_width = 16
  101. //
  102. uint8_t intermediate_buffer[71 * kMaxDimension];
  103. const int intermediate_next_stride =
  104. 1 - static_cast<int>(intermediate_height * output_width);
  105. // Horizontal pass (src -> transposed intermediate).
  106. uint8_t *output_ptr = intermediate_buffer;
  107. const int src_next_row_stride = src_stride - output_width;
  108. src_ptr -= (kInterp_Extend - 1) * src_stride + (kInterp_Extend - 1);
  109. for (i = 0; i < intermediate_height; ++i) {
  110. for (j = 0; j < output_width; ++j) {
  111. // Apply filter...
  112. const int temp = (src_ptr[0] * hfilter[0]) + (src_ptr[1] * hfilter[1]) +
  113. (src_ptr[2] * hfilter[2]) + (src_ptr[3] * hfilter[3]) +
  114. (src_ptr[4] * hfilter[4]) + (src_ptr[5] * hfilter[5]) +
  115. (src_ptr[6] * hfilter[6]) + (src_ptr[7] * hfilter[7]) +
  116. (VP9_FILTER_WEIGHT >> 1); // Rounding
  117. // Normalize back to 0-255...
  118. *output_ptr = clip_pixel(temp >> VP9_FILTER_SHIFT);
  119. ++src_ptr;
  120. output_ptr += intermediate_height;
  121. }
  122. src_ptr += src_next_row_stride;
  123. output_ptr += intermediate_next_stride;
  124. }
  125. // Vertical pass (transposed intermediate -> dst).
  126. src_ptr = intermediate_buffer;
  127. const int dst_next_row_stride = dst_stride - output_width;
  128. for (i = 0; i < output_height; ++i) {
  129. for (j = 0; j < output_width; ++j) {
  130. // Apply filter...
  131. const int temp = (src_ptr[0] * vfilter[0]) + (src_ptr[1] * vfilter[1]) +
  132. (src_ptr[2] * vfilter[2]) + (src_ptr[3] * vfilter[3]) +
  133. (src_ptr[4] * vfilter[4]) + (src_ptr[5] * vfilter[5]) +
  134. (src_ptr[6] * vfilter[6]) + (src_ptr[7] * vfilter[7]) +
  135. (VP9_FILTER_WEIGHT >> 1); // Rounding
  136. // Normalize back to 0-255...
  137. *dst_ptr++ = clip_pixel(temp >> VP9_FILTER_SHIFT);
  138. src_ptr += intermediate_height;
  139. }
  140. src_ptr += intermediate_next_stride;
  141. dst_ptr += dst_next_row_stride;
  142. }
  143. }
  144. void block2d_average_c(uint8_t *src, unsigned int src_stride,
  145. uint8_t *output_ptr, unsigned int output_stride,
  146. unsigned int output_width, unsigned int output_height) {
  147. unsigned int i, j;
  148. for (i = 0; i < output_height; ++i) {
  149. for (j = 0; j < output_width; ++j) {
  150. output_ptr[j] = (output_ptr[j] + src[i * src_stride + j] + 1) >> 1;
  151. }
  152. output_ptr += output_stride;
  153. }
  154. }
  155. void filter_average_block2d_8_c(const uint8_t *src_ptr,
  156. const unsigned int src_stride,
  157. const int16_t *hfilter, const int16_t *vfilter,
  158. uint8_t *dst_ptr, unsigned int dst_stride,
  159. unsigned int output_width,
  160. unsigned int output_height) {
  161. uint8_t tmp[kMaxDimension * kMaxDimension];
  162. assert(output_width <= kMaxDimension);
  163. assert(output_height <= kMaxDimension);
  164. filter_block2d_8_c(src_ptr, src_stride, hfilter, vfilter, tmp, 64,
  165. output_width, output_height);
  166. block2d_average_c(tmp, 64, dst_ptr, dst_stride, output_width, output_height);
  167. }
  168. #if CONFIG_VP9_HIGHBITDEPTH
  169. void highbd_filter_block2d_8_c(const uint16_t *src_ptr,
  170. const unsigned int src_stride,
  171. const int16_t *hfilter, const int16_t *vfilter,
  172. uint16_t *dst_ptr, unsigned int dst_stride,
  173. unsigned int output_width,
  174. unsigned int output_height, int bd) {
  175. // Between passes, we use an intermediate buffer whose height is extended to
  176. // have enough horizontally filtered values as input for the vertical pass.
  177. // This buffer is allocated to be big enough for the largest block type we
  178. // support.
  179. const int kInterp_Extend = 4;
  180. const unsigned int intermediate_height =
  181. (kInterp_Extend - 1) + output_height + kInterp_Extend;
  182. /* Size of intermediate_buffer is max_intermediate_height * filter_max_width,
  183. * where max_intermediate_height = (kInterp_Extend - 1) + filter_max_height
  184. * + kInterp_Extend
  185. * = 3 + 16 + 4
  186. * = 23
  187. * and filter_max_width = 16
  188. */
  189. uint16_t intermediate_buffer[71 * kMaxDimension];
  190. const int intermediate_next_stride =
  191. 1 - static_cast<int>(intermediate_height * output_width);
  192. // Horizontal pass (src -> transposed intermediate).
  193. {
  194. uint16_t *output_ptr = intermediate_buffer;
  195. const int src_next_row_stride = src_stride - output_width;
  196. unsigned int i, j;
  197. src_ptr -= (kInterp_Extend - 1) * src_stride + (kInterp_Extend - 1);
  198. for (i = 0; i < intermediate_height; ++i) {
  199. for (j = 0; j < output_width; ++j) {
  200. // Apply filter...
  201. const int temp = (src_ptr[0] * hfilter[0]) + (src_ptr[1] * hfilter[1]) +
  202. (src_ptr[2] * hfilter[2]) + (src_ptr[3] * hfilter[3]) +
  203. (src_ptr[4] * hfilter[4]) + (src_ptr[5] * hfilter[5]) +
  204. (src_ptr[6] * hfilter[6]) + (src_ptr[7] * hfilter[7]) +
  205. (VP9_FILTER_WEIGHT >> 1); // Rounding
  206. // Normalize back to 0-255...
  207. *output_ptr = clip_pixel_highbd(temp >> VP9_FILTER_SHIFT, bd);
  208. ++src_ptr;
  209. output_ptr += intermediate_height;
  210. }
  211. src_ptr += src_next_row_stride;
  212. output_ptr += intermediate_next_stride;
  213. }
  214. }
  215. // Vertical pass (transposed intermediate -> dst).
  216. {
  217. uint16_t *src_ptr = intermediate_buffer;
  218. const int dst_next_row_stride = dst_stride - output_width;
  219. unsigned int i, j;
  220. for (i = 0; i < output_height; ++i) {
  221. for (j = 0; j < output_width; ++j) {
  222. // Apply filter...
  223. const int temp = (src_ptr[0] * vfilter[0]) + (src_ptr[1] * vfilter[1]) +
  224. (src_ptr[2] * vfilter[2]) + (src_ptr[3] * vfilter[3]) +
  225. (src_ptr[4] * vfilter[4]) + (src_ptr[5] * vfilter[5]) +
  226. (src_ptr[6] * vfilter[6]) + (src_ptr[7] * vfilter[7]) +
  227. (VP9_FILTER_WEIGHT >> 1); // Rounding
  228. // Normalize back to 0-255...
  229. *dst_ptr++ = clip_pixel_highbd(temp >> VP9_FILTER_SHIFT, bd);
  230. src_ptr += intermediate_height;
  231. }
  232. src_ptr += intermediate_next_stride;
  233. dst_ptr += dst_next_row_stride;
  234. }
  235. }
  236. }
  237. void highbd_block2d_average_c(uint16_t *src, unsigned int src_stride,
  238. uint16_t *output_ptr, unsigned int output_stride,
  239. unsigned int output_width,
  240. unsigned int output_height) {
  241. unsigned int i, j;
  242. for (i = 0; i < output_height; ++i) {
  243. for (j = 0; j < output_width; ++j) {
  244. output_ptr[j] = (output_ptr[j] + src[i * src_stride + j] + 1) >> 1;
  245. }
  246. output_ptr += output_stride;
  247. }
  248. }
  249. void highbd_filter_average_block2d_8_c(
  250. const uint16_t *src_ptr, const unsigned int src_stride,
  251. const int16_t *hfilter, const int16_t *vfilter, uint16_t *dst_ptr,
  252. unsigned int dst_stride, unsigned int output_width,
  253. unsigned int output_height, int bd) {
  254. uint16_t tmp[kMaxDimension * kMaxDimension];
  255. assert(output_width <= kMaxDimension);
  256. assert(output_height <= kMaxDimension);
  257. highbd_filter_block2d_8_c(src_ptr, src_stride, hfilter, vfilter, tmp, 64,
  258. output_width, output_height, bd);
  259. highbd_block2d_average_c(tmp, 64, dst_ptr, dst_stride, output_width,
  260. output_height);
  261. }
  262. #endif // CONFIG_VP9_HIGHBITDEPTH
  263. void wrapper_filter_average_block2d_8_c(
  264. const uint8_t *src_ptr, const unsigned int src_stride,
  265. const int16_t *hfilter, const int16_t *vfilter, uint8_t *dst_ptr,
  266. unsigned int dst_stride, unsigned int output_width,
  267. unsigned int output_height, int use_highbd) {
  268. #if CONFIG_VP9_HIGHBITDEPTH
  269. if (use_highbd == 0) {
  270. filter_average_block2d_8_c(src_ptr, src_stride, hfilter, vfilter, dst_ptr,
  271. dst_stride, output_width, output_height);
  272. } else {
  273. highbd_filter_average_block2d_8_c(CAST_TO_SHORTPTR(src_ptr), src_stride,
  274. hfilter, vfilter,
  275. CAST_TO_SHORTPTR(dst_ptr), dst_stride,
  276. output_width, output_height, use_highbd);
  277. }
  278. #else
  279. ASSERT_EQ(0, use_highbd);
  280. filter_average_block2d_8_c(src_ptr, src_stride, hfilter, vfilter, dst_ptr,
  281. dst_stride, output_width, output_height);
  282. #endif
  283. }
  284. void wrapper_filter_block2d_8_c(const uint8_t *src_ptr,
  285. const unsigned int src_stride,
  286. const int16_t *hfilter, const int16_t *vfilter,
  287. uint8_t *dst_ptr, unsigned int dst_stride,
  288. unsigned int output_width,
  289. unsigned int output_height, int use_highbd) {
  290. #if CONFIG_VP9_HIGHBITDEPTH
  291. if (use_highbd == 0) {
  292. filter_block2d_8_c(src_ptr, src_stride, hfilter, vfilter, dst_ptr,
  293. dst_stride, output_width, output_height);
  294. } else {
  295. highbd_filter_block2d_8_c(CAST_TO_SHORTPTR(src_ptr), src_stride, hfilter,
  296. vfilter, CAST_TO_SHORTPTR(dst_ptr), dst_stride,
  297. output_width, output_height, use_highbd);
  298. }
  299. #else
  300. ASSERT_EQ(0, use_highbd);
  301. filter_block2d_8_c(src_ptr, src_stride, hfilter, vfilter, dst_ptr, dst_stride,
  302. output_width, output_height);
  303. #endif
  304. }
  305. class ConvolveTest : public ::testing::TestWithParam<ConvolveParam> {
  306. public:
  307. static void SetUpTestCase() {
  308. // Force input_ to be unaligned, output to be 16 byte aligned.
  309. input_ = reinterpret_cast<uint8_t *>(
  310. vpx_memalign(kDataAlignment, kInputBufferSize + 1)) +
  311. 1;
  312. output_ = reinterpret_cast<uint8_t *>(
  313. vpx_memalign(kDataAlignment, kOutputBufferSize));
  314. output_ref_ = reinterpret_cast<uint8_t *>(
  315. vpx_memalign(kDataAlignment, kOutputBufferSize));
  316. #if CONFIG_VP9_HIGHBITDEPTH
  317. input16_ = reinterpret_cast<uint16_t *>(vpx_memalign(
  318. kDataAlignment, (kInputBufferSize + 1) * sizeof(uint16_t))) +
  319. 1;
  320. output16_ = reinterpret_cast<uint16_t *>(
  321. vpx_memalign(kDataAlignment, (kOutputBufferSize) * sizeof(uint16_t)));
  322. output16_ref_ = reinterpret_cast<uint16_t *>(
  323. vpx_memalign(kDataAlignment, (kOutputBufferSize) * sizeof(uint16_t)));
  324. #endif
  325. }
  326. virtual void TearDown() { libvpx_test::ClearSystemState(); }
  327. static void TearDownTestCase() {
  328. vpx_free(input_ - 1);
  329. input_ = NULL;
  330. vpx_free(output_);
  331. output_ = NULL;
  332. vpx_free(output_ref_);
  333. output_ref_ = NULL;
  334. #if CONFIG_VP9_HIGHBITDEPTH
  335. vpx_free(input16_ - 1);
  336. input16_ = NULL;
  337. vpx_free(output16_);
  338. output16_ = NULL;
  339. vpx_free(output16_ref_);
  340. output16_ref_ = NULL;
  341. #endif
  342. }
  343. protected:
  344. static const int kDataAlignment = 16;
  345. static const int kOuterBlockSize = 256;
  346. static const int kInputStride = kOuterBlockSize;
  347. static const int kOutputStride = kOuterBlockSize;
  348. static const int kInputBufferSize = kOuterBlockSize * kOuterBlockSize;
  349. static const int kOutputBufferSize = kOuterBlockSize * kOuterBlockSize;
  350. int Width() const { return GET_PARAM(0); }
  351. int Height() const { return GET_PARAM(1); }
  352. int BorderLeft() const {
  353. const int center = (kOuterBlockSize - Width()) / 2;
  354. return (center + (kDataAlignment - 1)) & ~(kDataAlignment - 1);
  355. }
  356. int BorderTop() const { return (kOuterBlockSize - Height()) / 2; }
  357. bool IsIndexInBorder(int i) {
  358. return (i < BorderTop() * kOuterBlockSize ||
  359. i >= (BorderTop() + Height()) * kOuterBlockSize ||
  360. i % kOuterBlockSize < BorderLeft() ||
  361. i % kOuterBlockSize >= (BorderLeft() + Width()));
  362. }
  363. virtual void SetUp() {
  364. UUT_ = GET_PARAM(2);
  365. #if CONFIG_VP9_HIGHBITDEPTH
  366. if (UUT_->use_highbd_ != 0) {
  367. mask_ = (1 << UUT_->use_highbd_) - 1;
  368. } else {
  369. mask_ = 255;
  370. }
  371. #endif
  372. /* Set up guard blocks for an inner block centered in the outer block */
  373. for (int i = 0; i < kOutputBufferSize; ++i) {
  374. if (IsIndexInBorder(i)) {
  375. output_[i] = 255;
  376. } else {
  377. output_[i] = 0;
  378. }
  379. }
  380. ::libvpx_test::ACMRandom prng;
  381. for (int i = 0; i < kInputBufferSize; ++i) {
  382. if (i & 1) {
  383. input_[i] = 255;
  384. #if CONFIG_VP9_HIGHBITDEPTH
  385. input16_[i] = mask_;
  386. #endif
  387. } else {
  388. input_[i] = prng.Rand8Extremes();
  389. #if CONFIG_VP9_HIGHBITDEPTH
  390. input16_[i] = prng.Rand16() & mask_;
  391. #endif
  392. }
  393. }
  394. }
  395. void SetConstantInput(int value) {
  396. memset(input_, value, kInputBufferSize);
  397. #if CONFIG_VP9_HIGHBITDEPTH
  398. vpx_memset16(input16_, value, kInputBufferSize);
  399. #endif
  400. }
  401. void CopyOutputToRef() {
  402. memcpy(output_ref_, output_, kOutputBufferSize);
  403. #if CONFIG_VP9_HIGHBITDEPTH
  404. memcpy(output16_ref_, output16_,
  405. kOutputBufferSize * sizeof(output16_ref_[0]));
  406. #endif
  407. }
  408. void CheckGuardBlocks() {
  409. for (int i = 0; i < kOutputBufferSize; ++i) {
  410. if (IsIndexInBorder(i)) EXPECT_EQ(255, output_[i]);
  411. }
  412. }
  413. uint8_t *input() const {
  414. const int offset = BorderTop() * kOuterBlockSize + BorderLeft();
  415. #if CONFIG_VP9_HIGHBITDEPTH
  416. if (UUT_->use_highbd_ == 0) {
  417. return input_ + offset;
  418. } else {
  419. return CAST_TO_BYTEPTR(input16_ + offset);
  420. }
  421. #else
  422. return input_ + offset;
  423. #endif
  424. }
  425. uint8_t *output() const {
  426. const int offset = BorderTop() * kOuterBlockSize + BorderLeft();
  427. #if CONFIG_VP9_HIGHBITDEPTH
  428. if (UUT_->use_highbd_ == 0) {
  429. return output_ + offset;
  430. } else {
  431. return CAST_TO_BYTEPTR(output16_ + offset);
  432. }
  433. #else
  434. return output_ + offset;
  435. #endif
  436. }
  437. uint8_t *output_ref() const {
  438. const int offset = BorderTop() * kOuterBlockSize + BorderLeft();
  439. #if CONFIG_VP9_HIGHBITDEPTH
  440. if (UUT_->use_highbd_ == 0) {
  441. return output_ref_ + offset;
  442. } else {
  443. return CAST_TO_BYTEPTR(output16_ref_ + offset);
  444. }
  445. #else
  446. return output_ref_ + offset;
  447. #endif
  448. }
  449. uint16_t lookup(uint8_t *list, int index) const {
  450. #if CONFIG_VP9_HIGHBITDEPTH
  451. if (UUT_->use_highbd_ == 0) {
  452. return list[index];
  453. } else {
  454. return CAST_TO_SHORTPTR(list)[index];
  455. }
  456. #else
  457. return list[index];
  458. #endif
  459. }
  460. void assign_val(uint8_t *list, int index, uint16_t val) const {
  461. #if CONFIG_VP9_HIGHBITDEPTH
  462. if (UUT_->use_highbd_ == 0) {
  463. list[index] = (uint8_t)val;
  464. } else {
  465. CAST_TO_SHORTPTR(list)[index] = val;
  466. }
  467. #else
  468. list[index] = (uint8_t)val;
  469. #endif
  470. }
  471. const ConvolveFunctions *UUT_;
  472. static uint8_t *input_;
  473. static uint8_t *output_;
  474. static uint8_t *output_ref_;
  475. #if CONFIG_VP9_HIGHBITDEPTH
  476. static uint16_t *input16_;
  477. static uint16_t *output16_;
  478. static uint16_t *output16_ref_;
  479. int mask_;
  480. #endif
  481. };
  482. uint8_t *ConvolveTest::input_ = NULL;
  483. uint8_t *ConvolveTest::output_ = NULL;
  484. uint8_t *ConvolveTest::output_ref_ = NULL;
  485. #if CONFIG_VP9_HIGHBITDEPTH
  486. uint16_t *ConvolveTest::input16_ = NULL;
  487. uint16_t *ConvolveTest::output16_ = NULL;
  488. uint16_t *ConvolveTest::output16_ref_ = NULL;
  489. #endif
  490. TEST_P(ConvolveTest, GuardBlocks) { CheckGuardBlocks(); }
  491. TEST_P(ConvolveTest, DISABLED_Copy_Speed) {
  492. const uint8_t *const in = input();
  493. uint8_t *const out = output();
  494. const int kNumTests = 5000000;
  495. const int width = Width();
  496. const int height = Height();
  497. vpx_usec_timer timer;
  498. vpx_usec_timer_start(&timer);
  499. for (int n = 0; n < kNumTests; ++n) {
  500. UUT_->copy_[0](in, kInputStride, out, kOutputStride, NULL, 0, 0, 0, 0,
  501. width, height);
  502. }
  503. vpx_usec_timer_mark(&timer);
  504. const int elapsed_time = static_cast<int>(vpx_usec_timer_elapsed(&timer));
  505. printf("convolve_copy_%dx%d_%d: %d us\n", width, height,
  506. UUT_->use_highbd_ ? UUT_->use_highbd_ : 8, elapsed_time);
  507. }
  508. TEST_P(ConvolveTest, DISABLED_Avg_Speed) {
  509. const uint8_t *const in = input();
  510. uint8_t *const out = output();
  511. const int kNumTests = 5000000;
  512. const int width = Width();
  513. const int height = Height();
  514. vpx_usec_timer timer;
  515. vpx_usec_timer_start(&timer);
  516. for (int n = 0; n < kNumTests; ++n) {
  517. UUT_->copy_[1](in, kInputStride, out, kOutputStride, NULL, 0, 0, 0, 0,
  518. width, height);
  519. }
  520. vpx_usec_timer_mark(&timer);
  521. const int elapsed_time = static_cast<int>(vpx_usec_timer_elapsed(&timer));
  522. printf("convolve_avg_%dx%d_%d: %d us\n", width, height,
  523. UUT_->use_highbd_ ? UUT_->use_highbd_ : 8, elapsed_time);
  524. }
  525. TEST_P(ConvolveTest, Copy) {
  526. uint8_t *const in = input();
  527. uint8_t *const out = output();
  528. ASM_REGISTER_STATE_CHECK(UUT_->copy_[0](in, kInputStride, out, kOutputStride,
  529. NULL, 0, 0, 0, 0, Width(), Height()));
  530. CheckGuardBlocks();
  531. for (int y = 0; y < Height(); ++y) {
  532. for (int x = 0; x < Width(); ++x)
  533. ASSERT_EQ(lookup(out, y * kOutputStride + x),
  534. lookup(in, y * kInputStride + x))
  535. << "(" << x << "," << y << ")";
  536. }
  537. }
  538. TEST_P(ConvolveTest, Avg) {
  539. uint8_t *const in = input();
  540. uint8_t *const out = output();
  541. uint8_t *const out_ref = output_ref();
  542. CopyOutputToRef();
  543. ASM_REGISTER_STATE_CHECK(UUT_->copy_[1](in, kInputStride, out, kOutputStride,
  544. NULL, 0, 0, 0, 0, Width(), Height()));
  545. CheckGuardBlocks();
  546. for (int y = 0; y < Height(); ++y) {
  547. for (int x = 0; x < Width(); ++x)
  548. ASSERT_EQ(lookup(out, y * kOutputStride + x),
  549. ROUND_POWER_OF_TWO(lookup(in, y * kInputStride + x) +
  550. lookup(out_ref, y * kOutputStride + x),
  551. 1))
  552. << "(" << x << "," << y << ")";
  553. }
  554. }
  555. TEST_P(ConvolveTest, CopyHoriz) {
  556. uint8_t *const in = input();
  557. uint8_t *const out = output();
  558. ASM_REGISTER_STATE_CHECK(UUT_->sh8_[0](in, kInputStride, out, kOutputStride,
  559. vp9_filter_kernels[0], 0, 16, 0, 16,
  560. Width(), Height()));
  561. CheckGuardBlocks();
  562. for (int y = 0; y < Height(); ++y) {
  563. for (int x = 0; x < Width(); ++x)
  564. ASSERT_EQ(lookup(out, y * kOutputStride + x),
  565. lookup(in, y * kInputStride + x))
  566. << "(" << x << "," << y << ")";
  567. }
  568. }
  569. TEST_P(ConvolveTest, CopyVert) {
  570. uint8_t *const in = input();
  571. uint8_t *const out = output();
  572. ASM_REGISTER_STATE_CHECK(UUT_->sv8_[0](in, kInputStride, out, kOutputStride,
  573. vp9_filter_kernels[0], 0, 16, 0, 16,
  574. Width(), Height()));
  575. CheckGuardBlocks();
  576. for (int y = 0; y < Height(); ++y) {
  577. for (int x = 0; x < Width(); ++x)
  578. ASSERT_EQ(lookup(out, y * kOutputStride + x),
  579. lookup(in, y * kInputStride + x))
  580. << "(" << x << "," << y << ")";
  581. }
  582. }
  583. TEST_P(ConvolveTest, Copy2D) {
  584. uint8_t *const in = input();
  585. uint8_t *const out = output();
  586. ASM_REGISTER_STATE_CHECK(UUT_->shv8_[0](in, kInputStride, out, kOutputStride,
  587. vp9_filter_kernels[0], 0, 16, 0, 16,
  588. Width(), Height()));
  589. CheckGuardBlocks();
  590. for (int y = 0; y < Height(); ++y) {
  591. for (int x = 0; x < Width(); ++x)
  592. ASSERT_EQ(lookup(out, y * kOutputStride + x),
  593. lookup(in, y * kInputStride + x))
  594. << "(" << x << "," << y << ")";
  595. }
  596. }
  597. const int kNumFilterBanks = 4;
  598. const int kNumFilters = 16;
  599. TEST(ConvolveTest, FiltersWontSaturateWhenAddedPairwise) {
  600. for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) {
  601. const InterpKernel *filters =
  602. vp9_filter_kernels[static_cast<INTERP_FILTER>(filter_bank)];
  603. for (int i = 0; i < kNumFilters; i++) {
  604. const int p0 = filters[i][0] + filters[i][1];
  605. const int p1 = filters[i][2] + filters[i][3];
  606. const int p2 = filters[i][4] + filters[i][5];
  607. const int p3 = filters[i][6] + filters[i][7];
  608. EXPECT_LE(p0, 128);
  609. EXPECT_LE(p1, 128);
  610. EXPECT_LE(p2, 128);
  611. EXPECT_LE(p3, 128);
  612. EXPECT_LE(p0 + p3, 128);
  613. EXPECT_LE(p0 + p3 + p1, 128);
  614. EXPECT_LE(p0 + p3 + p1 + p2, 128);
  615. EXPECT_EQ(p0 + p1 + p2 + p3, 128);
  616. }
  617. }
  618. }
  619. const WrapperFilterBlock2d8Func wrapper_filter_block2d_8[2] = {
  620. wrapper_filter_block2d_8_c, wrapper_filter_average_block2d_8_c
  621. };
  622. TEST_P(ConvolveTest, MatchesReferenceSubpixelFilter) {
  623. for (int i = 0; i < 2; ++i) {
  624. uint8_t *const in = input();
  625. uint8_t *const out = output();
  626. #if CONFIG_VP9_HIGHBITDEPTH
  627. uint8_t ref8[kOutputStride * kMaxDimension];
  628. uint16_t ref16[kOutputStride * kMaxDimension];
  629. uint8_t *ref;
  630. if (UUT_->use_highbd_ == 0) {
  631. ref = ref8;
  632. } else {
  633. ref = CAST_TO_BYTEPTR(ref16);
  634. }
  635. #else
  636. uint8_t ref[kOutputStride * kMaxDimension];
  637. #endif
  638. // Populate ref and out with some random data
  639. ::libvpx_test::ACMRandom prng;
  640. for (int y = 0; y < Height(); ++y) {
  641. for (int x = 0; x < Width(); ++x) {
  642. uint16_t r;
  643. #if CONFIG_VP9_HIGHBITDEPTH
  644. if (UUT_->use_highbd_ == 0 || UUT_->use_highbd_ == 8) {
  645. r = prng.Rand8Extremes();
  646. } else {
  647. r = prng.Rand16() & mask_;
  648. }
  649. #else
  650. r = prng.Rand8Extremes();
  651. #endif
  652. assign_val(out, y * kOutputStride + x, r);
  653. assign_val(ref, y * kOutputStride + x, r);
  654. }
  655. }
  656. for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) {
  657. const InterpKernel *filters =
  658. vp9_filter_kernels[static_cast<INTERP_FILTER>(filter_bank)];
  659. for (int filter_x = 0; filter_x < kNumFilters; ++filter_x) {
  660. for (int filter_y = 0; filter_y < kNumFilters; ++filter_y) {
  661. wrapper_filter_block2d_8[i](in, kInputStride, filters[filter_x],
  662. filters[filter_y], ref, kOutputStride,
  663. Width(), Height(), UUT_->use_highbd_);
  664. if (filter_x && filter_y)
  665. ASM_REGISTER_STATE_CHECK(
  666. UUT_->hv8_[i](in, kInputStride, out, kOutputStride, filters,
  667. filter_x, 16, filter_y, 16, Width(), Height()));
  668. else if (filter_y)
  669. ASM_REGISTER_STATE_CHECK(
  670. UUT_->v8_[i](in, kInputStride, out, kOutputStride, filters, 0,
  671. 16, filter_y, 16, Width(), Height()));
  672. else if (filter_x)
  673. ASM_REGISTER_STATE_CHECK(
  674. UUT_->h8_[i](in, kInputStride, out, kOutputStride, filters,
  675. filter_x, 16, 0, 16, Width(), Height()));
  676. else
  677. ASM_REGISTER_STATE_CHECK(UUT_->copy_[i](in, kInputStride, out,
  678. kOutputStride, NULL, 0, 0,
  679. 0, 0, Width(), Height()));
  680. CheckGuardBlocks();
  681. for (int y = 0; y < Height(); ++y) {
  682. for (int x = 0; x < Width(); ++x)
  683. ASSERT_EQ(lookup(ref, y * kOutputStride + x),
  684. lookup(out, y * kOutputStride + x))
  685. << "mismatch at (" << x << "," << y << "), "
  686. << "filters (" << filter_bank << "," << filter_x << ","
  687. << filter_y << ")";
  688. }
  689. }
  690. }
  691. }
  692. }
  693. }
  694. TEST_P(ConvolveTest, FilterExtremes) {
  695. uint8_t *const in = input();
  696. uint8_t *const out = output();
  697. #if CONFIG_VP9_HIGHBITDEPTH
  698. uint8_t ref8[kOutputStride * kMaxDimension];
  699. uint16_t ref16[kOutputStride * kMaxDimension];
  700. uint8_t *ref;
  701. if (UUT_->use_highbd_ == 0) {
  702. ref = ref8;
  703. } else {
  704. ref = CAST_TO_BYTEPTR(ref16);
  705. }
  706. #else
  707. uint8_t ref[kOutputStride * kMaxDimension];
  708. #endif
  709. // Populate ref and out with some random data
  710. ::libvpx_test::ACMRandom prng;
  711. for (int y = 0; y < Height(); ++y) {
  712. for (int x = 0; x < Width(); ++x) {
  713. uint16_t r;
  714. #if CONFIG_VP9_HIGHBITDEPTH
  715. if (UUT_->use_highbd_ == 0 || UUT_->use_highbd_ == 8) {
  716. r = prng.Rand8Extremes();
  717. } else {
  718. r = prng.Rand16() & mask_;
  719. }
  720. #else
  721. r = prng.Rand8Extremes();
  722. #endif
  723. assign_val(out, y * kOutputStride + x, r);
  724. assign_val(ref, y * kOutputStride + x, r);
  725. }
  726. }
  727. for (int axis = 0; axis < 2; axis++) {
  728. int seed_val = 0;
  729. while (seed_val < 256) {
  730. for (int y = 0; y < 8; ++y) {
  731. for (int x = 0; x < 8; ++x) {
  732. #if CONFIG_VP9_HIGHBITDEPTH
  733. assign_val(in, y * kOutputStride + x - SUBPEL_TAPS / 2 + 1,
  734. ((seed_val >> (axis ? y : x)) & 1) * mask_);
  735. #else
  736. assign_val(in, y * kOutputStride + x - SUBPEL_TAPS / 2 + 1,
  737. ((seed_val >> (axis ? y : x)) & 1) * 255);
  738. #endif
  739. if (axis) seed_val++;
  740. }
  741. if (axis) {
  742. seed_val -= 8;
  743. } else {
  744. seed_val++;
  745. }
  746. }
  747. if (axis) seed_val += 8;
  748. for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) {
  749. const InterpKernel *filters =
  750. vp9_filter_kernels[static_cast<INTERP_FILTER>(filter_bank)];
  751. for (int filter_x = 0; filter_x < kNumFilters; ++filter_x) {
  752. for (int filter_y = 0; filter_y < kNumFilters; ++filter_y) {
  753. wrapper_filter_block2d_8_c(in, kInputStride, filters[filter_x],
  754. filters[filter_y], ref, kOutputStride,
  755. Width(), Height(), UUT_->use_highbd_);
  756. if (filter_x && filter_y)
  757. ASM_REGISTER_STATE_CHECK(
  758. UUT_->hv8_[0](in, kInputStride, out, kOutputStride, filters,
  759. filter_x, 16, filter_y, 16, Width(), Height()));
  760. else if (filter_y)
  761. ASM_REGISTER_STATE_CHECK(
  762. UUT_->v8_[0](in, kInputStride, out, kOutputStride, filters, 0,
  763. 16, filter_y, 16, Width(), Height()));
  764. else if (filter_x)
  765. ASM_REGISTER_STATE_CHECK(
  766. UUT_->h8_[0](in, kInputStride, out, kOutputStride, filters,
  767. filter_x, 16, 0, 16, Width(), Height()));
  768. else
  769. ASM_REGISTER_STATE_CHECK(UUT_->copy_[0](in, kInputStride, out,
  770. kOutputStride, NULL, 0, 0,
  771. 0, 0, Width(), Height()));
  772. for (int y = 0; y < Height(); ++y) {
  773. for (int x = 0; x < Width(); ++x)
  774. ASSERT_EQ(lookup(ref, y * kOutputStride + x),
  775. lookup(out, y * kOutputStride + x))
  776. << "mismatch at (" << x << "," << y << "), "
  777. << "filters (" << filter_bank << "," << filter_x << ","
  778. << filter_y << ")";
  779. }
  780. }
  781. }
  782. }
  783. }
  784. }
  785. }
  786. /* This test exercises that enough rows and columns are filtered with every
  787. possible initial fractional positions and scaling steps. */
  788. TEST_P(ConvolveTest, CheckScalingFiltering) {
  789. uint8_t *const in = input();
  790. uint8_t *const out = output();
  791. const InterpKernel *const eighttap = vp9_filter_kernels[EIGHTTAP];
  792. SetConstantInput(127);
  793. for (int frac = 0; frac < 16; ++frac) {
  794. for (int step = 1; step <= 32; ++step) {
  795. /* Test the horizontal and vertical filters in combination. */
  796. ASM_REGISTER_STATE_CHECK(
  797. UUT_->shv8_[0](in, kInputStride, out, kOutputStride, eighttap, frac,
  798. step, frac, step, Width(), Height()));
  799. CheckGuardBlocks();
  800. for (int y = 0; y < Height(); ++y) {
  801. for (int x = 0; x < Width(); ++x) {
  802. ASSERT_EQ(lookup(in, y * kInputStride + x),
  803. lookup(out, y * kOutputStride + x))
  804. << "x == " << x << ", y == " << y << ", frac == " << frac
  805. << ", step == " << step;
  806. }
  807. }
  808. }
  809. }
  810. }
  811. using std::tr1::make_tuple;
  812. #if CONFIG_VP9_HIGHBITDEPTH
  813. #define WRAP(func, bd) \
  814. void wrap_##func##_##bd( \
  815. const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, \
  816. ptrdiff_t dst_stride, const InterpKernel *filter, int x0_q4, \
  817. int x_step_q4, int y0_q4, int y_step_q4, int w, int h) { \
  818. vpx_highbd_##func(reinterpret_cast<const uint16_t *>(src), src_stride, \
  819. reinterpret_cast<uint16_t *>(dst), dst_stride, filter, \
  820. x0_q4, x_step_q4, y0_q4, y_step_q4, w, h, bd); \
  821. }
  822. #if HAVE_SSE2 && ARCH_X86_64
  823. WRAP(convolve_copy_sse2, 8)
  824. WRAP(convolve_avg_sse2, 8)
  825. WRAP(convolve_copy_sse2, 10)
  826. WRAP(convolve_avg_sse2, 10)
  827. WRAP(convolve_copy_sse2, 12)
  828. WRAP(convolve_avg_sse2, 12)
  829. WRAP(convolve8_horiz_sse2, 8)
  830. WRAP(convolve8_avg_horiz_sse2, 8)
  831. WRAP(convolve8_vert_sse2, 8)
  832. WRAP(convolve8_avg_vert_sse2, 8)
  833. WRAP(convolve8_sse2, 8)
  834. WRAP(convolve8_avg_sse2, 8)
  835. WRAP(convolve8_horiz_sse2, 10)
  836. WRAP(convolve8_avg_horiz_sse2, 10)
  837. WRAP(convolve8_vert_sse2, 10)
  838. WRAP(convolve8_avg_vert_sse2, 10)
  839. WRAP(convolve8_sse2, 10)
  840. WRAP(convolve8_avg_sse2, 10)
  841. WRAP(convolve8_horiz_sse2, 12)
  842. WRAP(convolve8_avg_horiz_sse2, 12)
  843. WRAP(convolve8_vert_sse2, 12)
  844. WRAP(convolve8_avg_vert_sse2, 12)
  845. WRAP(convolve8_sse2, 12)
  846. WRAP(convolve8_avg_sse2, 12)
  847. #endif // HAVE_SSE2 && ARCH_X86_64
  848. #if HAVE_AVX2
  849. WRAP(convolve_copy_avx2, 8)
  850. WRAP(convolve_avg_avx2, 8)
  851. WRAP(convolve8_horiz_avx2, 8)
  852. WRAP(convolve8_avg_horiz_avx2, 8)
  853. WRAP(convolve8_vert_avx2, 8)
  854. WRAP(convolve8_avg_vert_avx2, 8)
  855. WRAP(convolve8_avx2, 8)
  856. WRAP(convolve8_avg_avx2, 8)
  857. WRAP(convolve_copy_avx2, 10)
  858. WRAP(convolve_avg_avx2, 10)
  859. WRAP(convolve8_avx2, 10)
  860. WRAP(convolve8_horiz_avx2, 10)
  861. WRAP(convolve8_vert_avx2, 10)
  862. WRAP(convolve8_avg_avx2, 10)
  863. WRAP(convolve8_avg_horiz_avx2, 10)
  864. WRAP(convolve8_avg_vert_avx2, 10)
  865. WRAP(convolve_copy_avx2, 12)
  866. WRAP(convolve_avg_avx2, 12)
  867. WRAP(convolve8_avx2, 12)
  868. WRAP(convolve8_horiz_avx2, 12)
  869. WRAP(convolve8_vert_avx2, 12)
  870. WRAP(convolve8_avg_avx2, 12)
  871. WRAP(convolve8_avg_horiz_avx2, 12)
  872. WRAP(convolve8_avg_vert_avx2, 12)
  873. #endif // HAVE_AVX2
  874. #if HAVE_NEON
  875. WRAP(convolve_copy_neon, 8)
  876. WRAP(convolve_avg_neon, 8)
  877. WRAP(convolve_copy_neon, 10)
  878. WRAP(convolve_avg_neon, 10)
  879. WRAP(convolve_copy_neon, 12)
  880. WRAP(convolve_avg_neon, 12)
  881. WRAP(convolve8_horiz_neon, 8)
  882. WRAP(convolve8_avg_horiz_neon, 8)
  883. WRAP(convolve8_vert_neon, 8)
  884. WRAP(convolve8_avg_vert_neon, 8)
  885. WRAP(convolve8_neon, 8)
  886. WRAP(convolve8_avg_neon, 8)
  887. WRAP(convolve8_horiz_neon, 10)
  888. WRAP(convolve8_avg_horiz_neon, 10)
  889. WRAP(convolve8_vert_neon, 10)
  890. WRAP(convolve8_avg_vert_neon, 10)
  891. WRAP(convolve8_neon, 10)
  892. WRAP(convolve8_avg_neon, 10)
  893. WRAP(convolve8_horiz_neon, 12)
  894. WRAP(convolve8_avg_horiz_neon, 12)
  895. WRAP(convolve8_vert_neon, 12)
  896. WRAP(convolve8_avg_vert_neon, 12)
  897. WRAP(convolve8_neon, 12)
  898. WRAP(convolve8_avg_neon, 12)
  899. #endif // HAVE_NEON
  900. WRAP(convolve_copy_c, 8)
  901. WRAP(convolve_avg_c, 8)
  902. WRAP(convolve8_horiz_c, 8)
  903. WRAP(convolve8_avg_horiz_c, 8)
  904. WRAP(convolve8_vert_c, 8)
  905. WRAP(convolve8_avg_vert_c, 8)
  906. WRAP(convolve8_c, 8)
  907. WRAP(convolve8_avg_c, 8)
  908. WRAP(convolve_copy_c, 10)
  909. WRAP(convolve_avg_c, 10)
  910. WRAP(convolve8_horiz_c, 10)
  911. WRAP(convolve8_avg_horiz_c, 10)
  912. WRAP(convolve8_vert_c, 10)
  913. WRAP(convolve8_avg_vert_c, 10)
  914. WRAP(convolve8_c, 10)
  915. WRAP(convolve8_avg_c, 10)
  916. WRAP(convolve_copy_c, 12)
  917. WRAP(convolve_avg_c, 12)
  918. WRAP(convolve8_horiz_c, 12)
  919. WRAP(convolve8_avg_horiz_c, 12)
  920. WRAP(convolve8_vert_c, 12)
  921. WRAP(convolve8_avg_vert_c, 12)
  922. WRAP(convolve8_c, 12)
  923. WRAP(convolve8_avg_c, 12)
  924. #undef WRAP
  925. const ConvolveFunctions convolve8_c(
  926. wrap_convolve_copy_c_8, wrap_convolve_avg_c_8, wrap_convolve8_horiz_c_8,
  927. wrap_convolve8_avg_horiz_c_8, wrap_convolve8_vert_c_8,
  928. wrap_convolve8_avg_vert_c_8, wrap_convolve8_c_8, wrap_convolve8_avg_c_8,
  929. wrap_convolve8_horiz_c_8, wrap_convolve8_avg_horiz_c_8,
  930. wrap_convolve8_vert_c_8, wrap_convolve8_avg_vert_c_8, wrap_convolve8_c_8,
  931. wrap_convolve8_avg_c_8, 8);
  932. const ConvolveFunctions convolve10_c(
  933. wrap_convolve_copy_c_10, wrap_convolve_avg_c_10, wrap_convolve8_horiz_c_10,
  934. wrap_convolve8_avg_horiz_c_10, wrap_convolve8_vert_c_10,
  935. wrap_convolve8_avg_vert_c_10, wrap_convolve8_c_10, wrap_convolve8_avg_c_10,
  936. wrap_convolve8_horiz_c_10, wrap_convolve8_avg_horiz_c_10,
  937. wrap_convolve8_vert_c_10, wrap_convolve8_avg_vert_c_10, wrap_convolve8_c_10,
  938. wrap_convolve8_avg_c_10, 10);
  939. const ConvolveFunctions convolve12_c(
  940. wrap_convolve_copy_c_12, wrap_convolve_avg_c_12, wrap_convolve8_horiz_c_12,
  941. wrap_convolve8_avg_horiz_c_12, wrap_convolve8_vert_c_12,
  942. wrap_convolve8_avg_vert_c_12, wrap_convolve8_c_12, wrap_convolve8_avg_c_12,
  943. wrap_convolve8_horiz_c_12, wrap_convolve8_avg_horiz_c_12,
  944. wrap_convolve8_vert_c_12, wrap_convolve8_avg_vert_c_12, wrap_convolve8_c_12,
  945. wrap_convolve8_avg_c_12, 12);
  946. const ConvolveParam kArrayConvolve_c[] = {
  947. ALL_SIZES(convolve8_c), ALL_SIZES(convolve10_c), ALL_SIZES(convolve12_c)
  948. };
  949. #else
  950. const ConvolveFunctions convolve8_c(
  951. vpx_convolve_copy_c, vpx_convolve_avg_c, vpx_convolve8_horiz_c,
  952. vpx_convolve8_avg_horiz_c, vpx_convolve8_vert_c, vpx_convolve8_avg_vert_c,
  953. vpx_convolve8_c, vpx_convolve8_avg_c, vpx_scaled_horiz_c,
  954. vpx_scaled_avg_horiz_c, vpx_scaled_vert_c, vpx_scaled_avg_vert_c,
  955. vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
  956. const ConvolveParam kArrayConvolve_c[] = { ALL_SIZES(convolve8_c) };
  957. #endif
  958. INSTANTIATE_TEST_CASE_P(C, ConvolveTest, ::testing::ValuesIn(kArrayConvolve_c));
  959. #if HAVE_SSE2 && ARCH_X86_64
  960. #if CONFIG_VP9_HIGHBITDEPTH
  961. const ConvolveFunctions convolve8_sse2(
  962. wrap_convolve_copy_sse2_8, wrap_convolve_avg_sse2_8,
  963. wrap_convolve8_horiz_sse2_8, wrap_convolve8_avg_horiz_sse2_8,
  964. wrap_convolve8_vert_sse2_8, wrap_convolve8_avg_vert_sse2_8,
  965. wrap_convolve8_sse2_8, wrap_convolve8_avg_sse2_8,
  966. wrap_convolve8_horiz_sse2_8, wrap_convolve8_avg_horiz_sse2_8,
  967. wrap_convolve8_vert_sse2_8, wrap_convolve8_avg_vert_sse2_8,
  968. wrap_convolve8_sse2_8, wrap_convolve8_avg_sse2_8, 8);
  969. const ConvolveFunctions convolve10_sse2(
  970. wrap_convolve_copy_sse2_10, wrap_convolve_avg_sse2_10,
  971. wrap_convolve8_horiz_sse2_10, wrap_convolve8_avg_horiz_sse2_10,
  972. wrap_convolve8_vert_sse2_10, wrap_convolve8_avg_vert_sse2_10,
  973. wrap_convolve8_sse2_10, wrap_convolve8_avg_sse2_10,
  974. wrap_convolve8_horiz_sse2_10, wrap_convolve8_avg_horiz_sse2_10,
  975. wrap_convolve8_vert_sse2_10, wrap_convolve8_avg_vert_sse2_10,
  976. wrap_convolve8_sse2_10, wrap_convolve8_avg_sse2_10, 10);
  977. const ConvolveFunctions convolve12_sse2(
  978. wrap_convolve_copy_sse2_12, wrap_convolve_avg_sse2_12,
  979. wrap_convolve8_horiz_sse2_12, wrap_convolve8_avg_horiz_sse2_12,
  980. wrap_convolve8_vert_sse2_12, wrap_convolve8_avg_vert_sse2_12,
  981. wrap_convolve8_sse2_12, wrap_convolve8_avg_sse2_12,
  982. wrap_convolve8_horiz_sse2_12, wrap_convolve8_avg_horiz_sse2_12,
  983. wrap_convolve8_vert_sse2_12, wrap_convolve8_avg_vert_sse2_12,
  984. wrap_convolve8_sse2_12, wrap_convolve8_avg_sse2_12, 12);
  985. const ConvolveParam kArrayConvolve_sse2[] = { ALL_SIZES(convolve8_sse2),
  986. ALL_SIZES(convolve10_sse2),
  987. ALL_SIZES(convolve12_sse2) };
  988. #else
  989. const ConvolveFunctions convolve8_sse2(
  990. vpx_convolve_copy_sse2, vpx_convolve_avg_sse2, vpx_convolve8_horiz_sse2,
  991. vpx_convolve8_avg_horiz_sse2, vpx_convolve8_vert_sse2,
  992. vpx_convolve8_avg_vert_sse2, vpx_convolve8_sse2, vpx_convolve8_avg_sse2,
  993. vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c, vpx_scaled_vert_c,
  994. vpx_scaled_avg_vert_c, vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
  995. const ConvolveParam kArrayConvolve_sse2[] = { ALL_SIZES(convolve8_sse2) };
  996. #endif // CONFIG_VP9_HIGHBITDEPTH
  997. INSTANTIATE_TEST_CASE_P(SSE2, ConvolveTest,
  998. ::testing::ValuesIn(kArrayConvolve_sse2));
  999. #endif
  1000. #if HAVE_SSSE3
  1001. const ConvolveFunctions convolve8_ssse3(
  1002. vpx_convolve_copy_c, vpx_convolve_avg_c, vpx_convolve8_horiz_ssse3,
  1003. vpx_convolve8_avg_horiz_ssse3, vpx_convolve8_vert_ssse3,
  1004. vpx_convolve8_avg_vert_ssse3, vpx_convolve8_ssse3, vpx_convolve8_avg_ssse3,
  1005. vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c, vpx_scaled_vert_c,
  1006. vpx_scaled_avg_vert_c, vpx_scaled_2d_ssse3, vpx_scaled_avg_2d_c, 0);
  1007. const ConvolveParam kArrayConvolve8_ssse3[] = { ALL_SIZES(convolve8_ssse3) };
  1008. INSTANTIATE_TEST_CASE_P(SSSE3, ConvolveTest,
  1009. ::testing::ValuesIn(kArrayConvolve8_ssse3));
  1010. #endif
  1011. #if HAVE_AVX2
  1012. #if CONFIG_VP9_HIGHBITDEPTH
  1013. const ConvolveFunctions convolve8_avx2(
  1014. wrap_convolve_copy_avx2_8, wrap_convolve_avg_avx2_8,
  1015. wrap_convolve8_horiz_avx2_8, wrap_convolve8_avg_horiz_avx2_8,
  1016. wrap_convolve8_vert_avx2_8, wrap_convolve8_avg_vert_avx2_8,
  1017. wrap_convolve8_avx2_8, wrap_convolve8_avg_avx2_8, wrap_convolve8_horiz_c_8,
  1018. wrap_convolve8_avg_horiz_c_8, wrap_convolve8_vert_c_8,
  1019. wrap_convolve8_avg_vert_c_8, wrap_convolve8_c_8, wrap_convolve8_avg_c_8, 8);
  1020. const ConvolveFunctions convolve10_avx2(
  1021. wrap_convolve_copy_avx2_10, wrap_convolve_avg_avx2_10,
  1022. wrap_convolve8_horiz_avx2_10, wrap_convolve8_avg_horiz_avx2_10,
  1023. wrap_convolve8_vert_avx2_10, wrap_convolve8_avg_vert_avx2_10,
  1024. wrap_convolve8_avx2_10, wrap_convolve8_avg_avx2_10,
  1025. wrap_convolve8_horiz_c_10, wrap_convolve8_avg_horiz_c_10,
  1026. wrap_convolve8_vert_c_10, wrap_convolve8_avg_vert_c_10, wrap_convolve8_c_10,
  1027. wrap_convolve8_avg_c_10, 10);
  1028. const ConvolveFunctions convolve12_avx2(
  1029. wrap_convolve_copy_avx2_12, wrap_convolve_avg_avx2_12,
  1030. wrap_convolve8_horiz_avx2_12, wrap_convolve8_avg_horiz_avx2_12,
  1031. wrap_convolve8_vert_avx2_12, wrap_convolve8_avg_vert_avx2_12,
  1032. wrap_convolve8_avx2_12, wrap_convolve8_avg_avx2_12,
  1033. wrap_convolve8_horiz_c_12, wrap_convolve8_avg_horiz_c_12,
  1034. wrap_convolve8_vert_c_12, wrap_convolve8_avg_vert_c_12, wrap_convolve8_c_12,
  1035. wrap_convolve8_avg_c_12, 12);
  1036. const ConvolveParam kArrayConvolve8_avx2[] = { ALL_SIZES(convolve8_avx2),
  1037. ALL_SIZES(convolve10_avx2),
  1038. ALL_SIZES(convolve12_avx2) };
  1039. INSTANTIATE_TEST_CASE_P(AVX2, ConvolveTest,
  1040. ::testing::ValuesIn(kArrayConvolve8_avx2));
  1041. #else // !CONFIG_VP9_HIGHBITDEPTH
  1042. const ConvolveFunctions convolve8_avx2(
  1043. vpx_convolve_copy_c, vpx_convolve_avg_c, vpx_convolve8_horiz_avx2,
  1044. vpx_convolve8_avg_horiz_ssse3, vpx_convolve8_vert_avx2,
  1045. vpx_convolve8_avg_vert_ssse3, vpx_convolve8_avx2, vpx_convolve8_avg_ssse3,
  1046. vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c, vpx_scaled_vert_c,
  1047. vpx_scaled_avg_vert_c, vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
  1048. const ConvolveParam kArrayConvolve8_avx2[] = { ALL_SIZES(convolve8_avx2) };
  1049. INSTANTIATE_TEST_CASE_P(AVX2, ConvolveTest,
  1050. ::testing::ValuesIn(kArrayConvolve8_avx2));
  1051. #endif // CONFIG_VP9_HIGHBITDEPTH
  1052. #endif // HAVE_AVX2
  1053. #if HAVE_NEON
  1054. #if CONFIG_VP9_HIGHBITDEPTH
  1055. const ConvolveFunctions convolve8_neon(
  1056. wrap_convolve_copy_neon_8, wrap_convolve_avg_neon_8,
  1057. wrap_convolve8_horiz_neon_8, wrap_convolve8_avg_horiz_neon_8,
  1058. wrap_convolve8_vert_neon_8, wrap_convolve8_avg_vert_neon_8,
  1059. wrap_convolve8_neon_8, wrap_convolve8_avg_neon_8,
  1060. wrap_convolve8_horiz_neon_8, wrap_convolve8_avg_horiz_neon_8,
  1061. wrap_convolve8_vert_neon_8, wrap_convolve8_avg_vert_neon_8,
  1062. wrap_convolve8_neon_8, wrap_convolve8_avg_neon_8, 8);
  1063. const ConvolveFunctions convolve10_neon(
  1064. wrap_convolve_copy_neon_10, wrap_convolve_avg_neon_10,
  1065. wrap_convolve8_horiz_neon_10, wrap_convolve8_avg_horiz_neon_10,
  1066. wrap_convolve8_vert_neon_10, wrap_convolve8_avg_vert_neon_10,
  1067. wrap_convolve8_neon_10, wrap_convolve8_avg_neon_10,
  1068. wrap_convolve8_horiz_neon_10, wrap_convolve8_avg_horiz_neon_10,
  1069. wrap_convolve8_vert_neon_10, wrap_convolve8_avg_vert_neon_10,
  1070. wrap_convolve8_neon_10, wrap_convolve8_avg_neon_10, 10);
  1071. const ConvolveFunctions convolve12_neon(
  1072. wrap_convolve_copy_neon_12, wrap_convolve_avg_neon_12,
  1073. wrap_convolve8_horiz_neon_12, wrap_convolve8_avg_horiz_neon_12,
  1074. wrap_convolve8_vert_neon_12, wrap_convolve8_avg_vert_neon_12,
  1075. wrap_convolve8_neon_12, wrap_convolve8_avg_neon_12,
  1076. wrap_convolve8_horiz_neon_12, wrap_convolve8_avg_horiz_neon_12,
  1077. wrap_convolve8_vert_neon_12, wrap_convolve8_avg_vert_neon_12,
  1078. wrap_convolve8_neon_12, wrap_convolve8_avg_neon_12, 12);
  1079. const ConvolveParam kArrayConvolve_neon[] = { ALL_SIZES(convolve8_neon),
  1080. ALL_SIZES(convolve10_neon),
  1081. ALL_SIZES(convolve12_neon) };
  1082. #else
  1083. const ConvolveFunctions convolve8_neon(
  1084. vpx_convolve_copy_neon, vpx_convolve_avg_neon, vpx_convolve8_horiz_neon,
  1085. vpx_convolve8_avg_horiz_neon, vpx_convolve8_vert_neon,
  1086. vpx_convolve8_avg_vert_neon, vpx_convolve8_neon, vpx_convolve8_avg_neon,
  1087. vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c, vpx_scaled_vert_c,
  1088. vpx_scaled_avg_vert_c, vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
  1089. const ConvolveParam kArrayConvolve_neon[] = { ALL_SIZES(convolve8_neon) };
  1090. #endif // CONFIG_VP9_HIGHBITDEPTH
  1091. INSTANTIATE_TEST_CASE_P(NEON, ConvolveTest,
  1092. ::testing::ValuesIn(kArrayConvolve_neon));
  1093. #endif // HAVE_NEON
  1094. #if HAVE_DSPR2
  1095. const ConvolveFunctions convolve8_dspr2(
  1096. vpx_convolve_copy_dspr2, vpx_convolve_avg_dspr2, vpx_convolve8_horiz_dspr2,
  1097. vpx_convolve8_avg_horiz_dspr2, vpx_convolve8_vert_dspr2,
  1098. vpx_convolve8_avg_vert_dspr2, vpx_convolve8_dspr2, vpx_convolve8_avg_dspr2,
  1099. vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c, vpx_scaled_vert_c,
  1100. vpx_scaled_avg_vert_c, vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
  1101. const ConvolveParam kArrayConvolve8_dspr2[] = { ALL_SIZES(convolve8_dspr2) };
  1102. INSTANTIATE_TEST_CASE_P(DSPR2, ConvolveTest,
  1103. ::testing::ValuesIn(kArrayConvolve8_dspr2));
  1104. #endif // HAVE_DSPR2
  1105. #if HAVE_MSA
  1106. const ConvolveFunctions convolve8_msa(
  1107. vpx_convolve_copy_msa, vpx_convolve_avg_msa, vpx_convolve8_horiz_msa,
  1108. vpx_convolve8_avg_horiz_msa, vpx_convolve8_vert_msa,
  1109. vpx_convolve8_avg_vert_msa, vpx_convolve8_msa, vpx_convolve8_avg_msa,
  1110. vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c, vpx_scaled_vert_c,
  1111. vpx_scaled_avg_vert_c, vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
  1112. const ConvolveParam kArrayConvolve8_msa[] = { ALL_SIZES(convolve8_msa) };
  1113. INSTANTIATE_TEST_CASE_P(MSA, ConvolveTest,
  1114. ::testing::ValuesIn(kArrayConvolve8_msa));
  1115. #endif // HAVE_MSA
  1116. #if HAVE_VSX
  1117. const ConvolveFunctions convolve8_vsx(
  1118. vpx_convolve_copy_vsx, vpx_convolve_avg_vsx, vpx_convolve8_horiz_vsx,
  1119. vpx_convolve8_avg_horiz_vsx, vpx_convolve8_vert_vsx,
  1120. vpx_convolve8_avg_vert_vsx, vpx_convolve8_vsx, vpx_convolve8_avg_vsx,
  1121. vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c, vpx_scaled_vert_c,
  1122. vpx_scaled_avg_vert_c, vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
  1123. const ConvolveParam kArrayConvolve_vsx[] = { ALL_SIZES(convolve8_vsx) };
  1124. INSTANTIATE_TEST_CASE_P(VSX, ConvolveTest,
  1125. ::testing::ValuesIn(kArrayConvolve_vsx));
  1126. #endif // HAVE_VSX
  1127. } // namespace