2
0

vpx_convolve.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. /*
  2. * Copyright (c) 2013 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 <assert.h>
  11. #include <string.h>
  12. #include "./vpx_config.h"
  13. #include "./vpx_dsp_rtcd.h"
  14. #include "vpx/vpx_integer.h"
  15. #include "vpx_dsp/vpx_convolve.h"
  16. #include "vpx_dsp/vpx_dsp_common.h"
  17. #include "vpx_dsp/vpx_filter.h"
  18. #include "vpx_ports/mem.h"
  19. static void convolve_horiz(const uint8_t *src, ptrdiff_t src_stride,
  20. uint8_t *dst, ptrdiff_t dst_stride,
  21. const InterpKernel *x_filters, int x0_q4,
  22. int x_step_q4, int w, int h) {
  23. int x, y;
  24. src -= SUBPEL_TAPS / 2 - 1;
  25. for (y = 0; y < h; ++y) {
  26. int x_q4 = x0_q4;
  27. for (x = 0; x < w; ++x) {
  28. const uint8_t *const src_x = &src[x_q4 >> SUBPEL_BITS];
  29. const int16_t *const x_filter = x_filters[x_q4 & SUBPEL_MASK];
  30. int k, sum = 0;
  31. for (k = 0; k < SUBPEL_TAPS; ++k) sum += src_x[k] * x_filter[k];
  32. dst[x] = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
  33. x_q4 += x_step_q4;
  34. }
  35. src += src_stride;
  36. dst += dst_stride;
  37. }
  38. }
  39. static void convolve_avg_horiz(const uint8_t *src, ptrdiff_t src_stride,
  40. uint8_t *dst, ptrdiff_t dst_stride,
  41. const InterpKernel *x_filters, int x0_q4,
  42. int x_step_q4, int w, int h) {
  43. int x, y;
  44. src -= SUBPEL_TAPS / 2 - 1;
  45. for (y = 0; y < h; ++y) {
  46. int x_q4 = x0_q4;
  47. for (x = 0; x < w; ++x) {
  48. const uint8_t *const src_x = &src[x_q4 >> SUBPEL_BITS];
  49. const int16_t *const x_filter = x_filters[x_q4 & SUBPEL_MASK];
  50. int k, sum = 0;
  51. for (k = 0; k < SUBPEL_TAPS; ++k) sum += src_x[k] * x_filter[k];
  52. dst[x] = ROUND_POWER_OF_TWO(
  53. dst[x] + clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS)), 1);
  54. x_q4 += x_step_q4;
  55. }
  56. src += src_stride;
  57. dst += dst_stride;
  58. }
  59. }
  60. static void convolve_vert(const uint8_t *src, ptrdiff_t src_stride,
  61. uint8_t *dst, ptrdiff_t dst_stride,
  62. const InterpKernel *y_filters, int y0_q4,
  63. int y_step_q4, int w, int h) {
  64. int x, y;
  65. src -= src_stride * (SUBPEL_TAPS / 2 - 1);
  66. for (x = 0; x < w; ++x) {
  67. int y_q4 = y0_q4;
  68. for (y = 0; y < h; ++y) {
  69. const uint8_t *src_y = &src[(y_q4 >> SUBPEL_BITS) * src_stride];
  70. const int16_t *const y_filter = y_filters[y_q4 & SUBPEL_MASK];
  71. int k, sum = 0;
  72. for (k = 0; k < SUBPEL_TAPS; ++k)
  73. sum += src_y[k * src_stride] * y_filter[k];
  74. dst[y * dst_stride] = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
  75. y_q4 += y_step_q4;
  76. }
  77. ++src;
  78. ++dst;
  79. }
  80. }
  81. static void convolve_avg_vert(const uint8_t *src, ptrdiff_t src_stride,
  82. uint8_t *dst, ptrdiff_t dst_stride,
  83. const InterpKernel *y_filters, int y0_q4,
  84. int y_step_q4, int w, int h) {
  85. int x, y;
  86. src -= src_stride * (SUBPEL_TAPS / 2 - 1);
  87. for (x = 0; x < w; ++x) {
  88. int y_q4 = y0_q4;
  89. for (y = 0; y < h; ++y) {
  90. const uint8_t *src_y = &src[(y_q4 >> SUBPEL_BITS) * src_stride];
  91. const int16_t *const y_filter = y_filters[y_q4 & SUBPEL_MASK];
  92. int k, sum = 0;
  93. for (k = 0; k < SUBPEL_TAPS; ++k)
  94. sum += src_y[k * src_stride] * y_filter[k];
  95. dst[y * dst_stride] = ROUND_POWER_OF_TWO(
  96. dst[y * dst_stride] +
  97. clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS)),
  98. 1);
  99. y_q4 += y_step_q4;
  100. }
  101. ++src;
  102. ++dst;
  103. }
  104. }
  105. void vpx_convolve8_horiz_c(const uint8_t *src, ptrdiff_t src_stride,
  106. uint8_t *dst, ptrdiff_t dst_stride,
  107. const InterpKernel *filter, int x0_q4, int x_step_q4,
  108. int y0_q4, int y_step_q4, int w, int h) {
  109. (void)y0_q4;
  110. (void)y_step_q4;
  111. convolve_horiz(src, src_stride, dst, dst_stride, filter, x0_q4, x_step_q4, w,
  112. h);
  113. }
  114. void vpx_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride,
  115. uint8_t *dst, ptrdiff_t dst_stride,
  116. const InterpKernel *filter, int x0_q4,
  117. int x_step_q4, int y0_q4, int y_step_q4, int w,
  118. int h) {
  119. (void)y0_q4;
  120. (void)y_step_q4;
  121. convolve_avg_horiz(src, src_stride, dst, dst_stride, filter, x0_q4, x_step_q4,
  122. w, h);
  123. }
  124. void vpx_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride,
  125. uint8_t *dst, ptrdiff_t dst_stride,
  126. const InterpKernel *filter, int x0_q4, int x_step_q4,
  127. int y0_q4, int y_step_q4, int w, int h) {
  128. (void)x0_q4;
  129. (void)x_step_q4;
  130. convolve_vert(src, src_stride, dst, dst_stride, filter, y0_q4, y_step_q4, w,
  131. h);
  132. }
  133. void vpx_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride,
  134. uint8_t *dst, ptrdiff_t dst_stride,
  135. const InterpKernel *filter, int x0_q4,
  136. int x_step_q4, int y0_q4, int y_step_q4, int w,
  137. int h) {
  138. (void)x0_q4;
  139. (void)x_step_q4;
  140. convolve_avg_vert(src, src_stride, dst, dst_stride, filter, y0_q4, y_step_q4,
  141. w, h);
  142. }
  143. void vpx_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
  144. ptrdiff_t dst_stride, const InterpKernel *filter,
  145. int x0_q4, int x_step_q4, int y0_q4, int y_step_q4, int w,
  146. int h) {
  147. // Note: Fixed size intermediate buffer, temp, places limits on parameters.
  148. // 2d filtering proceeds in 2 steps:
  149. // (1) Interpolate horizontally into an intermediate buffer, temp.
  150. // (2) Interpolate temp vertically to derive the sub-pixel result.
  151. // Deriving the maximum number of rows in the temp buffer (135):
  152. // --Smallest scaling factor is x1/2 ==> y_step_q4 = 32 (Normative).
  153. // --Largest block size is 64x64 pixels.
  154. // --64 rows in the downscaled frame span a distance of (64 - 1) * 32 in the
  155. // original frame (in 1/16th pixel units).
  156. // --Must round-up because block may be located at sub-pixel position.
  157. // --Require an additional SUBPEL_TAPS rows for the 8-tap filter tails.
  158. // --((64 - 1) * 32 + 15) >> 4 + 8 = 135.
  159. // When calling in frame scaling function, the smallest scaling factor is x1/4
  160. // ==> y_step_q4 = 64. Since w and h are at most 16, the temp buffer is still
  161. // big enough.
  162. uint8_t temp[64 * 135];
  163. const int intermediate_height =
  164. (((h - 1) * y_step_q4 + y0_q4) >> SUBPEL_BITS) + SUBPEL_TAPS;
  165. assert(w <= 64);
  166. assert(h <= 64);
  167. assert(y_step_q4 <= 32 || (y_step_q4 <= 64 && h <= 32));
  168. assert(x_step_q4 <= 64);
  169. convolve_horiz(src - src_stride * (SUBPEL_TAPS / 2 - 1), src_stride, temp, 64,
  170. filter, x0_q4, x_step_q4, w, intermediate_height);
  171. convolve_vert(temp + 64 * (SUBPEL_TAPS / 2 - 1), 64, dst, dst_stride, filter,
  172. y0_q4, y_step_q4, w, h);
  173. }
  174. void vpx_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
  175. ptrdiff_t dst_stride, const InterpKernel *filter,
  176. int x0_q4, int x_step_q4, int y0_q4, int y_step_q4,
  177. int w, int h) {
  178. // Fixed size intermediate buffer places limits on parameters.
  179. DECLARE_ALIGNED(16, uint8_t, temp[64 * 64]);
  180. assert(w <= 64);
  181. assert(h <= 64);
  182. vpx_convolve8_c(src, src_stride, temp, 64, filter, x0_q4, x_step_q4, y0_q4,
  183. y_step_q4, w, h);
  184. vpx_convolve_avg_c(temp, 64, dst, dst_stride, NULL, 0, 0, 0, 0, w, h);
  185. }
  186. void vpx_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
  187. ptrdiff_t dst_stride, const InterpKernel *filter,
  188. int x0_q4, int x_step_q4, int y0_q4, int y_step_q4,
  189. int w, int h) {
  190. int r;
  191. (void)filter;
  192. (void)x0_q4;
  193. (void)x_step_q4;
  194. (void)y0_q4;
  195. (void)y_step_q4;
  196. for (r = h; r > 0; --r) {
  197. memcpy(dst, src, w);
  198. src += src_stride;
  199. dst += dst_stride;
  200. }
  201. }
  202. void vpx_convolve_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
  203. ptrdiff_t dst_stride, const InterpKernel *filter,
  204. int x0_q4, int x_step_q4, int y0_q4, int y_step_q4,
  205. int w, int h) {
  206. int x, y;
  207. (void)filter;
  208. (void)x0_q4;
  209. (void)x_step_q4;
  210. (void)y0_q4;
  211. (void)y_step_q4;
  212. for (y = 0; y < h; ++y) {
  213. for (x = 0; x < w; ++x) dst[x] = ROUND_POWER_OF_TWO(dst[x] + src[x], 1);
  214. src += src_stride;
  215. dst += dst_stride;
  216. }
  217. }
  218. void vpx_scaled_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
  219. ptrdiff_t dst_stride, const InterpKernel *filter,
  220. int x0_q4, int x_step_q4, int y0_q4, int y_step_q4,
  221. int w, int h) {
  222. vpx_convolve8_horiz_c(src, src_stride, dst, dst_stride, filter, x0_q4,
  223. x_step_q4, y0_q4, y_step_q4, w, h);
  224. }
  225. void vpx_scaled_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
  226. ptrdiff_t dst_stride, const InterpKernel *filter,
  227. int x0_q4, int x_step_q4, int y0_q4, int y_step_q4,
  228. int w, int h) {
  229. vpx_convolve8_vert_c(src, src_stride, dst, dst_stride, filter, x0_q4,
  230. x_step_q4, y0_q4, y_step_q4, w, h);
  231. }
  232. void vpx_scaled_2d_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
  233. ptrdiff_t dst_stride, const InterpKernel *filter,
  234. int x0_q4, int x_step_q4, int y0_q4, int y_step_q4, int w,
  235. int h) {
  236. vpx_convolve8_c(src, src_stride, dst, dst_stride, filter, x0_q4, x_step_q4,
  237. y0_q4, y_step_q4, w, h);
  238. }
  239. void vpx_scaled_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride,
  240. uint8_t *dst, ptrdiff_t dst_stride,
  241. const InterpKernel *filter, int x0_q4,
  242. int x_step_q4, int y0_q4, int y_step_q4, int w,
  243. int h) {
  244. vpx_convolve8_avg_horiz_c(src, src_stride, dst, dst_stride, filter, x0_q4,
  245. x_step_q4, y0_q4, y_step_q4, w, h);
  246. }
  247. void vpx_scaled_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride,
  248. uint8_t *dst, ptrdiff_t dst_stride,
  249. const InterpKernel *filter, int x0_q4, int x_step_q4,
  250. int y0_q4, int y_step_q4, int w, int h) {
  251. vpx_convolve8_avg_vert_c(src, src_stride, dst, dst_stride, filter, x0_q4,
  252. x_step_q4, y0_q4, y_step_q4, w, h);
  253. }
  254. void vpx_scaled_avg_2d_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
  255. ptrdiff_t dst_stride, const InterpKernel *filter,
  256. int x0_q4, int x_step_q4, int y0_q4, int y_step_q4,
  257. int w, int h) {
  258. vpx_convolve8_avg_c(src, src_stride, dst, dst_stride, filter, x0_q4,
  259. x_step_q4, y0_q4, y_step_q4, w, h);
  260. }
  261. #if CONFIG_VP9_HIGHBITDEPTH
  262. static void highbd_convolve_horiz(const uint16_t *src, ptrdiff_t src_stride,
  263. uint16_t *dst, ptrdiff_t dst_stride,
  264. const InterpKernel *x_filters, int x0_q4,
  265. int x_step_q4, int w, int h, int bd) {
  266. int x, y;
  267. src -= SUBPEL_TAPS / 2 - 1;
  268. for (y = 0; y < h; ++y) {
  269. int x_q4 = x0_q4;
  270. for (x = 0; x < w; ++x) {
  271. const uint16_t *const src_x = &src[x_q4 >> SUBPEL_BITS];
  272. const int16_t *const x_filter = x_filters[x_q4 & SUBPEL_MASK];
  273. int k, sum = 0;
  274. for (k = 0; k < SUBPEL_TAPS; ++k) sum += src_x[k] * x_filter[k];
  275. dst[x] = clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd);
  276. x_q4 += x_step_q4;
  277. }
  278. src += src_stride;
  279. dst += dst_stride;
  280. }
  281. }
  282. static void highbd_convolve_avg_horiz(const uint16_t *src, ptrdiff_t src_stride,
  283. uint16_t *dst, ptrdiff_t dst_stride,
  284. const InterpKernel *x_filters, int x0_q4,
  285. int x_step_q4, int w, int h, int bd) {
  286. int x, y;
  287. src -= SUBPEL_TAPS / 2 - 1;
  288. for (y = 0; y < h; ++y) {
  289. int x_q4 = x0_q4;
  290. for (x = 0; x < w; ++x) {
  291. const uint16_t *const src_x = &src[x_q4 >> SUBPEL_BITS];
  292. const int16_t *const x_filter = x_filters[x_q4 & SUBPEL_MASK];
  293. int k, sum = 0;
  294. for (k = 0; k < SUBPEL_TAPS; ++k) sum += src_x[k] * x_filter[k];
  295. dst[x] = ROUND_POWER_OF_TWO(
  296. dst[x] + clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd),
  297. 1);
  298. x_q4 += x_step_q4;
  299. }
  300. src += src_stride;
  301. dst += dst_stride;
  302. }
  303. }
  304. static void highbd_convolve_vert(const uint16_t *src, ptrdiff_t src_stride,
  305. uint16_t *dst, ptrdiff_t dst_stride,
  306. const InterpKernel *y_filters, int y0_q4,
  307. int y_step_q4, int w, int h, int bd) {
  308. int x, y;
  309. src -= src_stride * (SUBPEL_TAPS / 2 - 1);
  310. for (x = 0; x < w; ++x) {
  311. int y_q4 = y0_q4;
  312. for (y = 0; y < h; ++y) {
  313. const uint16_t *src_y = &src[(y_q4 >> SUBPEL_BITS) * src_stride];
  314. const int16_t *const y_filter = y_filters[y_q4 & SUBPEL_MASK];
  315. int k, sum = 0;
  316. for (k = 0; k < SUBPEL_TAPS; ++k)
  317. sum += src_y[k * src_stride] * y_filter[k];
  318. dst[y * dst_stride] =
  319. clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd);
  320. y_q4 += y_step_q4;
  321. }
  322. ++src;
  323. ++dst;
  324. }
  325. }
  326. static void highbd_convolve_avg_vert(const uint16_t *src, ptrdiff_t src_stride,
  327. uint16_t *dst, ptrdiff_t dst_stride,
  328. const InterpKernel *y_filters, int y0_q4,
  329. int y_step_q4, int w, int h, int bd) {
  330. int x, y;
  331. src -= src_stride * (SUBPEL_TAPS / 2 - 1);
  332. for (x = 0; x < w; ++x) {
  333. int y_q4 = y0_q4;
  334. for (y = 0; y < h; ++y) {
  335. const uint16_t *src_y = &src[(y_q4 >> SUBPEL_BITS) * src_stride];
  336. const int16_t *const y_filter = y_filters[y_q4 & SUBPEL_MASK];
  337. int k, sum = 0;
  338. for (k = 0; k < SUBPEL_TAPS; ++k)
  339. sum += src_y[k * src_stride] * y_filter[k];
  340. dst[y * dst_stride] = ROUND_POWER_OF_TWO(
  341. dst[y * dst_stride] +
  342. clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd),
  343. 1);
  344. y_q4 += y_step_q4;
  345. }
  346. ++src;
  347. ++dst;
  348. }
  349. }
  350. static void highbd_convolve(const uint16_t *src, ptrdiff_t src_stride,
  351. uint16_t *dst, ptrdiff_t dst_stride,
  352. const InterpKernel *filter, int x0_q4,
  353. int x_step_q4, int y0_q4, int y_step_q4, int w,
  354. int h, int bd) {
  355. // Note: Fixed size intermediate buffer, temp, places limits on parameters.
  356. // 2d filtering proceeds in 2 steps:
  357. // (1) Interpolate horizontally into an intermediate buffer, temp.
  358. // (2) Interpolate temp vertically to derive the sub-pixel result.
  359. // Deriving the maximum number of rows in the temp buffer (135):
  360. // --Smallest scaling factor is x1/2 ==> y_step_q4 = 32 (Normative).
  361. // --Largest block size is 64x64 pixels.
  362. // --64 rows in the downscaled frame span a distance of (64 - 1) * 32 in the
  363. // original frame (in 1/16th pixel units).
  364. // --Must round-up because block may be located at sub-pixel position.
  365. // --Require an additional SUBPEL_TAPS rows for the 8-tap filter tails.
  366. // --((64 - 1) * 32 + 15) >> 4 + 8 = 135.
  367. uint16_t temp[64 * 135];
  368. const int intermediate_height =
  369. (((h - 1) * y_step_q4 + y0_q4) >> SUBPEL_BITS) + SUBPEL_TAPS;
  370. assert(w <= 64);
  371. assert(h <= 64);
  372. assert(y_step_q4 <= 32);
  373. assert(x_step_q4 <= 32);
  374. highbd_convolve_horiz(src - src_stride * (SUBPEL_TAPS / 2 - 1), src_stride,
  375. temp, 64, filter, x0_q4, x_step_q4, w,
  376. intermediate_height, bd);
  377. highbd_convolve_vert(temp + 64 * (SUBPEL_TAPS / 2 - 1), 64, dst, dst_stride,
  378. filter, y0_q4, y_step_q4, w, h, bd);
  379. }
  380. void vpx_highbd_convolve8_horiz_c(const uint16_t *src, ptrdiff_t src_stride,
  381. uint16_t *dst, ptrdiff_t dst_stride,
  382. const InterpKernel *filter, int x0_q4,
  383. int x_step_q4, int y0_q4, int y_step_q4,
  384. int w, int h, int bd) {
  385. (void)y0_q4;
  386. (void)y_step_q4;
  387. highbd_convolve_horiz(src, src_stride, dst, dst_stride, filter, x0_q4,
  388. x_step_q4, w, h, bd);
  389. }
  390. void vpx_highbd_convolve8_avg_horiz_c(const uint16_t *src, ptrdiff_t src_stride,
  391. uint16_t *dst, ptrdiff_t dst_stride,
  392. const InterpKernel *filter, int x0_q4,
  393. int x_step_q4, int y0_q4, int y_step_q4,
  394. int w, int h, int bd) {
  395. (void)y0_q4;
  396. (void)y_step_q4;
  397. highbd_convolve_avg_horiz(src, src_stride, dst, dst_stride, filter, x0_q4,
  398. x_step_q4, w, h, bd);
  399. }
  400. void vpx_highbd_convolve8_vert_c(const uint16_t *src, ptrdiff_t src_stride,
  401. uint16_t *dst, ptrdiff_t dst_stride,
  402. const InterpKernel *filter, int x0_q4,
  403. int x_step_q4, int y0_q4, int y_step_q4, int w,
  404. int h, int bd) {
  405. (void)x0_q4;
  406. (void)x_step_q4;
  407. highbd_convolve_vert(src, src_stride, dst, dst_stride, filter, y0_q4,
  408. y_step_q4, w, h, bd);
  409. }
  410. void vpx_highbd_convolve8_avg_vert_c(const uint16_t *src, ptrdiff_t src_stride,
  411. uint16_t *dst, ptrdiff_t dst_stride,
  412. const InterpKernel *filter, int x0_q4,
  413. int x_step_q4, int y0_q4, int y_step_q4,
  414. int w, int h, int bd) {
  415. (void)x0_q4;
  416. (void)x_step_q4;
  417. highbd_convolve_avg_vert(src, src_stride, dst, dst_stride, filter, y0_q4,
  418. y_step_q4, w, h, bd);
  419. }
  420. void vpx_highbd_convolve8_c(const uint16_t *src, ptrdiff_t src_stride,
  421. uint16_t *dst, ptrdiff_t dst_stride,
  422. const InterpKernel *filter, int x0_q4,
  423. int x_step_q4, int y0_q4, int y_step_q4, int w,
  424. int h, int bd) {
  425. highbd_convolve(src, src_stride, dst, dst_stride, filter, x0_q4, x_step_q4,
  426. y0_q4, y_step_q4, w, h, bd);
  427. }
  428. void vpx_highbd_convolve8_avg_c(const uint16_t *src, ptrdiff_t src_stride,
  429. uint16_t *dst, ptrdiff_t dst_stride,
  430. const InterpKernel *filter, int x0_q4,
  431. int x_step_q4, int y0_q4, int y_step_q4, int w,
  432. int h, int bd) {
  433. // Fixed size intermediate buffer places limits on parameters.
  434. DECLARE_ALIGNED(16, uint16_t, temp[64 * 64]);
  435. assert(w <= 64);
  436. assert(h <= 64);
  437. vpx_highbd_convolve8_c(src, src_stride, temp, 64, filter, x0_q4, x_step_q4,
  438. y0_q4, y_step_q4, w, h, bd);
  439. vpx_highbd_convolve_avg_c(temp, 64, dst, dst_stride, NULL, 0, 0, 0, 0, w, h,
  440. bd);
  441. }
  442. void vpx_highbd_convolve_copy_c(const uint16_t *src, ptrdiff_t src_stride,
  443. uint16_t *dst, ptrdiff_t dst_stride,
  444. const InterpKernel *filter, int x0_q4,
  445. int x_step_q4, int y0_q4, int y_step_q4, int w,
  446. int h, int bd) {
  447. int r;
  448. (void)filter;
  449. (void)x0_q4;
  450. (void)x_step_q4;
  451. (void)y0_q4;
  452. (void)y_step_q4;
  453. (void)bd;
  454. for (r = h; r > 0; --r) {
  455. memcpy(dst, src, w * sizeof(uint16_t));
  456. src += src_stride;
  457. dst += dst_stride;
  458. }
  459. }
  460. void vpx_highbd_convolve_avg_c(const uint16_t *src, ptrdiff_t src_stride,
  461. uint16_t *dst, ptrdiff_t dst_stride,
  462. const InterpKernel *filter, int x0_q4,
  463. int x_step_q4, int y0_q4, int y_step_q4, int w,
  464. int h, int bd) {
  465. int x, y;
  466. (void)filter;
  467. (void)x0_q4;
  468. (void)x_step_q4;
  469. (void)y0_q4;
  470. (void)y_step_q4;
  471. (void)bd;
  472. for (y = 0; y < h; ++y) {
  473. for (x = 0; x < w; ++x) dst[x] = ROUND_POWER_OF_TWO(dst[x] + src[x], 1);
  474. src += src_stride;
  475. dst += dst_stride;
  476. }
  477. }
  478. #endif