You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

483 lines
19KB

  1. /*
  2. * VP9 SIMD optimizations
  3. *
  4. * Copyright (c) 2013 Ronald S. Bultje <rsbultje gmail com>
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include "libavutil/attributes.h"
  23. #include "libavutil/cpu.h"
  24. #include "libavutil/mem.h"
  25. #include "libavutil/x86/asm.h"
  26. #include "libavutil/x86/cpu.h"
  27. #include "libavcodec/vp9dsp.h"
  28. #if HAVE_YASM
  29. #define fpel_func(avg, sz, opt) \
  30. void ff_vp9_##avg##sz##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  31. const uint8_t *src, ptrdiff_t src_stride, \
  32. int h, int mx, int my)
  33. fpel_func(put, 4, mmx);
  34. fpel_func(put, 8, mmx);
  35. fpel_func(put, 16, sse);
  36. fpel_func(put, 32, sse);
  37. fpel_func(put, 64, sse);
  38. fpel_func(avg, 4, mmxext);
  39. fpel_func(avg, 8, mmxext);
  40. fpel_func(avg, 16, sse2);
  41. fpel_func(avg, 32, sse2);
  42. fpel_func(avg, 64, sse2);
  43. fpel_func(put, 32, avx);
  44. fpel_func(put, 64, avx);
  45. fpel_func(avg, 32, avx2);
  46. fpel_func(avg, 64, avx2);
  47. #undef fpel_func
  48. #define mc_func(avg, sz, dir, opt, type, f_sz) \
  49. void ff_vp9_##avg##_8tap_1d_##dir##_##sz##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  50. const uint8_t *src, ptrdiff_t src_stride, \
  51. int h, const type (*filter)[f_sz])
  52. #define mc_funcs(sz, opt, type, fsz) \
  53. mc_func(put, sz, h, opt, type, fsz); \
  54. mc_func(avg, sz, h, opt, type, fsz); \
  55. mc_func(put, sz, v, opt, type, fsz); \
  56. mc_func(avg, sz, v, opt, type, fsz)
  57. mc_funcs(4, mmxext, int16_t, 8);
  58. mc_funcs(8, sse2, int16_t, 8);
  59. mc_funcs(4, ssse3, int8_t, 32);
  60. mc_funcs(8, ssse3, int8_t, 32);
  61. #if ARCH_X86_64
  62. mc_funcs(16, ssse3, int8_t, 32);
  63. mc_funcs(32, avx2, int8_t, 32);
  64. #endif
  65. #undef mc_funcs
  66. #undef mc_func
  67. #define mc_rep_func(avg, sz, hsz, dir, opt, type, f_sz) \
  68. static av_always_inline void \
  69. ff_vp9_##avg##_8tap_1d_##dir##_##sz##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  70. const uint8_t *src, ptrdiff_t src_stride, \
  71. int h, const type (*filter)[f_sz]) \
  72. { \
  73. ff_vp9_##avg##_8tap_1d_##dir##_##hsz##_##opt(dst, dst_stride, src, \
  74. src_stride, h, filter); \
  75. ff_vp9_##avg##_8tap_1d_##dir##_##hsz##_##opt(dst + hsz, dst_stride, src + hsz, \
  76. src_stride, h, filter); \
  77. }
  78. #define mc_rep_funcs(sz, hsz, opt, type, fsz) \
  79. mc_rep_func(put, sz, hsz, h, opt, type, fsz); \
  80. mc_rep_func(avg, sz, hsz, h, opt, type, fsz); \
  81. mc_rep_func(put, sz, hsz, v, opt, type, fsz); \
  82. mc_rep_func(avg, sz, hsz, v, opt, type, fsz)
  83. mc_rep_funcs(16, 8, sse2, int16_t, 8);
  84. #if ARCH_X86_32
  85. mc_rep_funcs(16, 8, ssse3, int8_t, 32);
  86. #endif
  87. mc_rep_funcs(32, 16, sse2, int16_t, 8);
  88. mc_rep_funcs(32, 16, ssse3, int8_t, 32);
  89. mc_rep_funcs(64, 32, sse2, int16_t, 8);
  90. mc_rep_funcs(64, 32, ssse3, int8_t, 32);
  91. #if ARCH_X86_64 && HAVE_AVX2_EXTERNAL
  92. mc_rep_funcs(64, 32, avx2, int8_t, 32);
  93. #endif
  94. #undef mc_rep_funcs
  95. #undef mc_rep_func
  96. extern const int8_t ff_filters_ssse3[3][15][4][32];
  97. extern const int16_t ff_filters_sse2[3][15][8][8];
  98. #define filter_8tap_2d_fn(op, sz, f, f_opt, fname, align, opt) \
  99. static void op##_8tap_##fname##_##sz##hv_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  100. const uint8_t *src, ptrdiff_t src_stride, \
  101. int h, int mx, int my) \
  102. { \
  103. LOCAL_ALIGNED_##align(uint8_t, temp, [71 * 64]); \
  104. ff_vp9_put_8tap_1d_h_##sz##_##opt(temp, 64, src - 3 * src_stride, src_stride, \
  105. h + 7, ff_filters_##f_opt[f][mx - 1]); \
  106. ff_vp9_##op##_8tap_1d_v_##sz##_##opt(dst, dst_stride, temp + 3 * 64, 64, \
  107. h, ff_filters_##f_opt[f][my - 1]); \
  108. }
  109. #define filters_8tap_2d_fn(op, sz, align, opt, f_opt) \
  110. filter_8tap_2d_fn(op, sz, FILTER_8TAP_REGULAR, f_opt, regular, align, opt) \
  111. filter_8tap_2d_fn(op, sz, FILTER_8TAP_SHARP, f_opt, sharp, align, opt) \
  112. filter_8tap_2d_fn(op, sz, FILTER_8TAP_SMOOTH, f_opt, smooth, align, opt)
  113. #define filters_8tap_2d_fn2(op, align, opt4, opt8, f_opt) \
  114. filters_8tap_2d_fn(op, 64, align, opt8, f_opt) \
  115. filters_8tap_2d_fn(op, 32, align, opt8, f_opt) \
  116. filters_8tap_2d_fn(op, 16, align, opt8, f_opt) \
  117. filters_8tap_2d_fn(op, 8, align, opt8, f_opt) \
  118. filters_8tap_2d_fn(op, 4, align, opt4, f_opt)
  119. filters_8tap_2d_fn2(put, 16, mmxext, sse2, sse2)
  120. filters_8tap_2d_fn2(avg, 16, mmxext, sse2, sse2)
  121. filters_8tap_2d_fn2(put, 16, ssse3, ssse3, ssse3)
  122. filters_8tap_2d_fn2(avg, 16, ssse3, ssse3, ssse3)
  123. #if ARCH_X86_64 && HAVE_AVX2_EXTERNAL
  124. filters_8tap_2d_fn(put, 64, 32, avx2, ssse3)
  125. filters_8tap_2d_fn(put, 32, 32, avx2, ssse3)
  126. filters_8tap_2d_fn(avg, 64, 32, avx2, ssse3)
  127. filters_8tap_2d_fn(avg, 32, 32, avx2, ssse3)
  128. #endif
  129. #undef filters_8tap_2d_fn2
  130. #undef filters_8tap_2d_fn
  131. #undef filter_8tap_2d_fn
  132. #define filter_8tap_1d_fn(op, sz, f, f_opt, fname, dir, dvar, opt) \
  133. static void op##_8tap_##fname##_##sz##dir##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  134. const uint8_t *src, ptrdiff_t src_stride, \
  135. int h, int mx, int my) \
  136. { \
  137. ff_vp9_##op##_8tap_1d_##dir##_##sz##_##opt(dst, dst_stride, src, src_stride, \
  138. h, ff_filters_##f_opt[f][dvar - 1]); \
  139. }
  140. #define filters_8tap_1d_fn(op, sz, dir, dvar, opt, f_opt) \
  141. filter_8tap_1d_fn(op, sz, FILTER_8TAP_REGULAR, f_opt, regular, dir, dvar, opt) \
  142. filter_8tap_1d_fn(op, sz, FILTER_8TAP_SHARP, f_opt, sharp, dir, dvar, opt) \
  143. filter_8tap_1d_fn(op, sz, FILTER_8TAP_SMOOTH, f_opt, smooth, dir, dvar, opt)
  144. #define filters_8tap_1d_fn2(op, sz, opt, f_opt) \
  145. filters_8tap_1d_fn(op, sz, h, mx, opt, f_opt) \
  146. filters_8tap_1d_fn(op, sz, v, my, opt, f_opt)
  147. #define filters_8tap_1d_fn3(op, opt4, opt8, f_opt) \
  148. filters_8tap_1d_fn2(op, 64, opt8, f_opt) \
  149. filters_8tap_1d_fn2(op, 32, opt8, f_opt) \
  150. filters_8tap_1d_fn2(op, 16, opt8, f_opt) \
  151. filters_8tap_1d_fn2(op, 8, opt8, f_opt) \
  152. filters_8tap_1d_fn2(op, 4, opt4, f_opt)
  153. filters_8tap_1d_fn3(put, mmxext, sse2, sse2)
  154. filters_8tap_1d_fn3(avg, mmxext, sse2, sse2)
  155. filters_8tap_1d_fn3(put, ssse3, ssse3, ssse3)
  156. filters_8tap_1d_fn3(avg, ssse3, ssse3, ssse3)
  157. #if ARCH_X86_64 && HAVE_AVX2_EXTERNAL
  158. filters_8tap_1d_fn2(put, 64, avx2, ssse3)
  159. filters_8tap_1d_fn2(put, 32, avx2, ssse3)
  160. filters_8tap_1d_fn2(avg, 64, avx2, ssse3)
  161. filters_8tap_1d_fn2(avg, 32, avx2, ssse3)
  162. #endif
  163. #undef filters_8tap_1d_fn
  164. #undef filters_8tap_1d_fn2
  165. #undef filters_8tap_1d_fn3
  166. #undef filter_8tap_1d_fn
  167. #define itxfm_func(typea, typeb, size, opt) \
  168. void ff_vp9_##typea##_##typeb##_##size##x##size##_add_##opt(uint8_t *dst, ptrdiff_t stride, \
  169. int16_t *block, int eob)
  170. #define itxfm_funcs(size, opt) \
  171. itxfm_func(idct, idct, size, opt); \
  172. itxfm_func(iadst, idct, size, opt); \
  173. itxfm_func(idct, iadst, size, opt); \
  174. itxfm_func(iadst, iadst, size, opt)
  175. itxfm_func(idct, idct, 4, mmxext);
  176. itxfm_func(idct, iadst, 4, sse2);
  177. itxfm_func(iadst, idct, 4, sse2);
  178. itxfm_func(iadst, iadst, 4, sse2);
  179. itxfm_funcs(4, ssse3);
  180. itxfm_funcs(8, sse2);
  181. itxfm_funcs(8, ssse3);
  182. itxfm_funcs(8, avx);
  183. itxfm_funcs(16, sse2);
  184. itxfm_funcs(16, ssse3);
  185. itxfm_funcs(16, avx);
  186. itxfm_func(idct, idct, 32, sse2);
  187. itxfm_func(idct, idct, 32, ssse3);
  188. itxfm_func(idct, idct, 32, avx);
  189. itxfm_func(iwht, iwht, 4, mmx);
  190. #undef itxfm_func
  191. #undef itxfm_funcs
  192. #define lpf_funcs(size1, size2, opt) \
  193. void ff_vp9_loop_filter_v_##size1##_##size2##_##opt(uint8_t *dst, ptrdiff_t stride, \
  194. int E, int I, int H); \
  195. void ff_vp9_loop_filter_h_##size1##_##size2##_##opt(uint8_t *dst, ptrdiff_t stride, \
  196. int E, int I, int H)
  197. lpf_funcs(16, 16, sse2);
  198. lpf_funcs(16, 16, ssse3);
  199. lpf_funcs(16, 16, avx);
  200. lpf_funcs(44, 16, sse2);
  201. lpf_funcs(44, 16, ssse3);
  202. lpf_funcs(44, 16, avx);
  203. lpf_funcs(84, 16, sse2);
  204. lpf_funcs(84, 16, ssse3);
  205. lpf_funcs(84, 16, avx);
  206. lpf_funcs(48, 16, sse2);
  207. lpf_funcs(48, 16, ssse3);
  208. lpf_funcs(48, 16, avx);
  209. lpf_funcs(88, 16, sse2);
  210. lpf_funcs(88, 16, ssse3);
  211. lpf_funcs(88, 16, avx);
  212. #undef lpf_funcs
  213. #define ipred_func(size, type, opt) \
  214. void ff_vp9_ipred_##type##_##size##x##size##_##opt(uint8_t *dst, ptrdiff_t stride, \
  215. const uint8_t *l, const uint8_t *a)
  216. #define ipred_funcs(type, opt) \
  217. ipred_func(4, type, opt); \
  218. ipred_func(8, type, opt); \
  219. ipred_func(16, type, opt); \
  220. ipred_func(32, type, opt)
  221. ipred_funcs(dc, ssse3);
  222. ipred_funcs(dc_left, ssse3);
  223. ipred_funcs(dc_top, ssse3);
  224. #undef ipred_funcs
  225. ipred_func(8, v, mmx);
  226. ipred_func(16, v, sse2);
  227. ipred_func(32, v, sse2);
  228. #define ipred_func_set(size, type, opt1, opt2) \
  229. ipred_func(size, type, opt1); \
  230. ipred_func(size, type, opt2)
  231. #define ipred_funcs(type, opt1, opt2) \
  232. ipred_func(4, type, opt1); \
  233. ipred_func_set(8, type, opt1, opt2); \
  234. ipred_func_set(16, type, opt1, opt2); \
  235. ipred_func_set(32, type, opt1, opt2)
  236. ipred_funcs(h, ssse3, avx);
  237. ipred_funcs(tm, ssse3, avx);
  238. ipred_funcs(dl, ssse3, avx);
  239. ipred_funcs(dr, ssse3, avx);
  240. ipred_funcs(hu, ssse3, avx);
  241. ipred_funcs(hd, ssse3, avx);
  242. ipred_funcs(vl, ssse3, avx);
  243. ipred_funcs(vr, ssse3, avx);
  244. ipred_func(32, dc, avx2);
  245. ipred_func(32, dc_left, avx2);
  246. ipred_func(32, dc_top, avx2);
  247. ipred_func(32, v, avx2);
  248. ipred_func(32, h, avx2);
  249. ipred_func(32, tm, avx2);
  250. #undef ipred_funcs
  251. #undef ipred_func_set
  252. #undef ipred_func
  253. #endif /* HAVE_YASM */
  254. av_cold void ff_vp9dsp_init_x86(VP9DSPContext *dsp)
  255. {
  256. #if HAVE_YASM
  257. int cpu_flags = av_get_cpu_flags();
  258. #define init_fpel(idx1, idx2, sz, type, opt) \
  259. dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][0][0] = \
  260. dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][0][0] = \
  261. dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][0][0] = \
  262. dsp->mc[idx1][FILTER_BILINEAR ][idx2][0][0] = ff_vp9_##type##sz##_##opt
  263. #define init_subpel1(idx1, idx2, idxh, idxv, sz, dir, type, opt) \
  264. dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][idxh][idxv] = type##_8tap_smooth_##sz##dir##_##opt; \
  265. dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][idxh][idxv] = type##_8tap_regular_##sz##dir##_##opt; \
  266. dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][idxh][idxv] = type##_8tap_sharp_##sz##dir##_##opt
  267. #define init_subpel2(idx1, idx2, sz, type, opt) \
  268. init_subpel1(idx1, idx2, 1, 1, sz, hv, type, opt); \
  269. init_subpel1(idx1, idx2, 0, 1, sz, v, type, opt); \
  270. init_subpel1(idx1, idx2, 1, 0, sz, h, type, opt)
  271. #define init_subpel3_32_64(idx, type, opt) \
  272. init_subpel2(0, idx, 64, type, opt); \
  273. init_subpel2(1, idx, 32, type, opt)
  274. #define init_subpel3_8to64(idx, type, opt) \
  275. init_subpel3_32_64(idx, type, opt); \
  276. init_subpel2(2, idx, 16, type, opt); \
  277. init_subpel2(3, idx, 8, type, opt)
  278. #define init_subpel3(idx, type, opt) \
  279. init_subpel3_8to64(idx, type, opt); \
  280. init_subpel2(4, idx, 4, type, opt)
  281. #define init_lpf(opt) do { \
  282. if (ARCH_X86_64) { \
  283. dsp->loop_filter_16[0] = ff_vp9_loop_filter_h_16_16_##opt; \
  284. dsp->loop_filter_16[1] = ff_vp9_loop_filter_v_16_16_##opt; \
  285. dsp->loop_filter_mix2[0][0][0] = ff_vp9_loop_filter_h_44_16_##opt; \
  286. dsp->loop_filter_mix2[0][0][1] = ff_vp9_loop_filter_v_44_16_##opt; \
  287. dsp->loop_filter_mix2[0][1][0] = ff_vp9_loop_filter_h_48_16_##opt; \
  288. dsp->loop_filter_mix2[0][1][1] = ff_vp9_loop_filter_v_48_16_##opt; \
  289. dsp->loop_filter_mix2[1][0][0] = ff_vp9_loop_filter_h_84_16_##opt; \
  290. dsp->loop_filter_mix2[1][0][1] = ff_vp9_loop_filter_v_84_16_##opt; \
  291. dsp->loop_filter_mix2[1][1][0] = ff_vp9_loop_filter_h_88_16_##opt; \
  292. dsp->loop_filter_mix2[1][1][1] = ff_vp9_loop_filter_v_88_16_##opt; \
  293. } \
  294. } while (0)
  295. #define init_ipred(tx, sz, opt) do { \
  296. dsp->intra_pred[tx][HOR_PRED] = ff_vp9_ipred_h_##sz##x##sz##_##opt; \
  297. dsp->intra_pred[tx][DIAG_DOWN_LEFT_PRED] = ff_vp9_ipred_dl_##sz##x##sz##_##opt; \
  298. dsp->intra_pred[tx][DIAG_DOWN_RIGHT_PRED] = ff_vp9_ipred_dr_##sz##x##sz##_##opt; \
  299. dsp->intra_pred[tx][HOR_DOWN_PRED] = ff_vp9_ipred_hd_##sz##x##sz##_##opt; \
  300. dsp->intra_pred[tx][VERT_LEFT_PRED] = ff_vp9_ipred_vl_##sz##x##sz##_##opt; \
  301. dsp->intra_pred[tx][HOR_UP_PRED] = ff_vp9_ipred_hu_##sz##x##sz##_##opt; \
  302. if (ARCH_X86_64 || tx != TX_32X32) { \
  303. dsp->intra_pred[tx][VERT_RIGHT_PRED] = ff_vp9_ipred_vr_##sz##x##sz##_##opt; \
  304. dsp->intra_pred[tx][TM_VP8_PRED] = ff_vp9_ipred_tm_##sz##x##sz##_##opt; \
  305. } \
  306. } while (0)
  307. #define init_dc_ipred(tx, sz, opt) do { \
  308. init_ipred(tx, sz, opt); \
  309. dsp->intra_pred[tx][DC_PRED] = ff_vp9_ipred_dc_##sz##x##sz##_##opt; \
  310. dsp->intra_pred[tx][LEFT_DC_PRED] = ff_vp9_ipred_dc_left_##sz##x##sz##_##opt; \
  311. dsp->intra_pred[tx][TOP_DC_PRED] = ff_vp9_ipred_dc_top_##sz##x##sz##_##opt; \
  312. } while (0)
  313. if (EXTERNAL_MMX(cpu_flags)) {
  314. init_fpel(4, 0, 4, put, mmx);
  315. init_fpel(3, 0, 8, put, mmx);
  316. dsp->itxfm_add[4 /* lossless */][DCT_DCT] =
  317. dsp->itxfm_add[4 /* lossless */][ADST_DCT] =
  318. dsp->itxfm_add[4 /* lossless */][DCT_ADST] =
  319. dsp->itxfm_add[4 /* lossless */][ADST_ADST] = ff_vp9_iwht_iwht_4x4_add_mmx;
  320. dsp->intra_pred[TX_8X8][VERT_PRED] = ff_vp9_ipred_v_8x8_mmx;
  321. }
  322. if (EXTERNAL_MMXEXT(cpu_flags)) {
  323. init_subpel2(4, 0, 4, put, mmxext);
  324. init_subpel2(4, 1, 4, avg, mmxext);
  325. init_fpel(4, 1, 4, avg, mmxext);
  326. init_fpel(3, 1, 8, avg, mmxext);
  327. dsp->itxfm_add[TX_4X4][DCT_DCT] = ff_vp9_idct_idct_4x4_add_mmxext;
  328. }
  329. if (EXTERNAL_SSE(cpu_flags)) {
  330. init_fpel(2, 0, 16, put, sse);
  331. init_fpel(1, 0, 32, put, sse);
  332. init_fpel(0, 0, 64, put, sse);
  333. }
  334. if (EXTERNAL_SSE2(cpu_flags)) {
  335. init_subpel3_8to64(0, put, sse2);
  336. init_subpel3_8to64(1, avg, sse2);
  337. init_fpel(2, 1, 16, avg, sse2);
  338. init_fpel(1, 1, 32, avg, sse2);
  339. init_fpel(0, 1, 64, avg, sse2);
  340. init_lpf(sse2);
  341. dsp->itxfm_add[TX_4X4][ADST_DCT] = ff_vp9_idct_iadst_4x4_add_sse2;
  342. dsp->itxfm_add[TX_4X4][DCT_ADST] = ff_vp9_iadst_idct_4x4_add_sse2;
  343. dsp->itxfm_add[TX_4X4][ADST_ADST] = ff_vp9_iadst_iadst_4x4_add_sse2;
  344. dsp->itxfm_add[TX_8X8][DCT_DCT] = ff_vp9_idct_idct_8x8_add_sse2;
  345. dsp->itxfm_add[TX_8X8][ADST_DCT] = ff_vp9_idct_iadst_8x8_add_sse2;
  346. dsp->itxfm_add[TX_8X8][DCT_ADST] = ff_vp9_iadst_idct_8x8_add_sse2;
  347. dsp->itxfm_add[TX_8X8][ADST_ADST] = ff_vp9_iadst_iadst_8x8_add_sse2;
  348. dsp->itxfm_add[TX_16X16][DCT_DCT] = ff_vp9_idct_idct_16x16_add_sse2;
  349. dsp->itxfm_add[TX_16X16][ADST_DCT] = ff_vp9_idct_iadst_16x16_add_sse2;
  350. dsp->itxfm_add[TX_16X16][DCT_ADST] = ff_vp9_iadst_idct_16x16_add_sse2;
  351. dsp->itxfm_add[TX_16X16][ADST_ADST] = ff_vp9_iadst_iadst_16x16_add_sse2;
  352. dsp->itxfm_add[TX_32X32][ADST_ADST] =
  353. dsp->itxfm_add[TX_32X32][ADST_DCT] =
  354. dsp->itxfm_add[TX_32X32][DCT_ADST] =
  355. dsp->itxfm_add[TX_32X32][DCT_DCT] = ff_vp9_idct_idct_32x32_add_sse2;
  356. dsp->intra_pred[TX_16X16][VERT_PRED] = ff_vp9_ipred_v_16x16_sse2;
  357. dsp->intra_pred[TX_32X32][VERT_PRED] = ff_vp9_ipred_v_32x32_sse2;
  358. }
  359. if (EXTERNAL_SSSE3(cpu_flags)) {
  360. init_subpel3(0, put, ssse3);
  361. init_subpel3(1, avg, ssse3);
  362. dsp->itxfm_add[TX_4X4][DCT_DCT] = ff_vp9_idct_idct_4x4_add_ssse3;
  363. dsp->itxfm_add[TX_4X4][ADST_DCT] = ff_vp9_idct_iadst_4x4_add_ssse3;
  364. dsp->itxfm_add[TX_4X4][DCT_ADST] = ff_vp9_iadst_idct_4x4_add_ssse3;
  365. dsp->itxfm_add[TX_4X4][ADST_ADST] = ff_vp9_iadst_iadst_4x4_add_ssse3;
  366. dsp->itxfm_add[TX_8X8][DCT_DCT] = ff_vp9_idct_idct_8x8_add_ssse3;
  367. dsp->itxfm_add[TX_8X8][ADST_DCT] = ff_vp9_idct_iadst_8x8_add_ssse3;
  368. dsp->itxfm_add[TX_8X8][DCT_ADST] = ff_vp9_iadst_idct_8x8_add_ssse3;
  369. dsp->itxfm_add[TX_8X8][ADST_ADST] = ff_vp9_iadst_iadst_8x8_add_ssse3;
  370. dsp->itxfm_add[TX_16X16][DCT_DCT] = ff_vp9_idct_idct_16x16_add_ssse3;
  371. dsp->itxfm_add[TX_16X16][ADST_DCT] = ff_vp9_idct_iadst_16x16_add_ssse3;
  372. dsp->itxfm_add[TX_16X16][DCT_ADST] = ff_vp9_iadst_idct_16x16_add_ssse3;
  373. dsp->itxfm_add[TX_16X16][ADST_ADST] = ff_vp9_iadst_iadst_16x16_add_ssse3;
  374. dsp->itxfm_add[TX_32X32][ADST_ADST] =
  375. dsp->itxfm_add[TX_32X32][ADST_DCT] =
  376. dsp->itxfm_add[TX_32X32][DCT_ADST] =
  377. dsp->itxfm_add[TX_32X32][DCT_DCT] = ff_vp9_idct_idct_32x32_add_ssse3;
  378. init_lpf(ssse3);
  379. init_dc_ipred(TX_4X4, 4, ssse3);
  380. init_dc_ipred(TX_8X8, 8, ssse3);
  381. init_dc_ipred(TX_16X16, 16, ssse3);
  382. init_dc_ipred(TX_32X32, 32, ssse3);
  383. }
  384. if (EXTERNAL_AVX(cpu_flags)) {
  385. dsp->itxfm_add[TX_8X8][DCT_DCT] = ff_vp9_idct_idct_8x8_add_avx;
  386. dsp->itxfm_add[TX_8X8][ADST_DCT] = ff_vp9_idct_iadst_8x8_add_avx;
  387. dsp->itxfm_add[TX_8X8][DCT_ADST] = ff_vp9_iadst_idct_8x8_add_avx;
  388. dsp->itxfm_add[TX_8X8][ADST_ADST] = ff_vp9_iadst_iadst_8x8_add_avx;
  389. dsp->itxfm_add[TX_16X16][DCT_DCT] = ff_vp9_idct_idct_16x16_add_avx;
  390. dsp->itxfm_add[TX_16X16][ADST_DCT] = ff_vp9_idct_iadst_16x16_add_avx;
  391. dsp->itxfm_add[TX_16X16][DCT_ADST] = ff_vp9_iadst_idct_16x16_add_avx;
  392. dsp->itxfm_add[TX_16X16][ADST_ADST] = ff_vp9_iadst_iadst_16x16_add_avx;
  393. dsp->itxfm_add[TX_32X32][ADST_ADST] =
  394. dsp->itxfm_add[TX_32X32][ADST_DCT] =
  395. dsp->itxfm_add[TX_32X32][DCT_ADST] =
  396. dsp->itxfm_add[TX_32X32][DCT_DCT] = ff_vp9_idct_idct_32x32_add_avx;
  397. init_fpel(1, 0, 32, put, avx);
  398. init_fpel(0, 0, 64, put, avx);
  399. init_lpf(avx);
  400. init_ipred(TX_8X8, 8, avx);
  401. init_ipred(TX_16X16, 16, avx);
  402. init_ipred(TX_32X32, 32, avx);
  403. }
  404. if (EXTERNAL_AVX2(cpu_flags)) {
  405. init_fpel(1, 1, 32, avg, avx2);
  406. init_fpel(0, 1, 64, avg, avx2);
  407. if (ARCH_X86_64) {
  408. #if ARCH_X86_64 && HAVE_AVX2_EXTERNAL
  409. init_subpel3_32_64(0, put, avx2);
  410. init_subpel3_32_64(1, avg, avx2);
  411. #endif
  412. }
  413. dsp->intra_pred[TX_32X32][DC_PRED] = ff_vp9_ipred_dc_32x32_avx2;
  414. dsp->intra_pred[TX_32X32][LEFT_DC_PRED] = ff_vp9_ipred_dc_left_32x32_avx2;
  415. dsp->intra_pred[TX_32X32][TOP_DC_PRED] = ff_vp9_ipred_dc_top_32x32_avx2;
  416. dsp->intra_pred[TX_32X32][VERT_PRED] = ff_vp9_ipred_v_32x32_avx2;
  417. dsp->intra_pred[TX_32X32][HOR_PRED] = ff_vp9_ipred_h_32x32_avx2;
  418. dsp->intra_pred[TX_32X32][TM_VP8_PRED] = ff_vp9_ipred_tm_32x32_avx2;
  419. }
  420. #undef init_fpel
  421. #undef init_subpel1
  422. #undef init_subpel2
  423. #undef init_subpel3
  424. #endif /* HAVE_YASM */
  425. }