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.

150 lines
7.2KB

  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. #ifndef AVCODEC_X86_VP9DSP_INIT_H
  23. #define AVCODEC_X86_VP9DSP_INIT_H
  24. #include <libavcodec/vp9dsp.h>
  25. #define decl_fpel_func(avg, sz, bpp, opt) \
  26. void ff_vp9_##avg##sz##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  27. const uint8_t *src, ptrdiff_t src_stride, \
  28. int h, int mx, int my)
  29. #define decl_mc_func(avg, sz, dir, opt, type, f_sz, bpp) \
  30. void ff_vp9_##avg##_8tap_1d_##dir##_##sz##_##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  31. const uint8_t *src, ptrdiff_t src_stride, \
  32. int h, const type (*filter)[f_sz])
  33. #define decl_mc_funcs(sz, opt, type, fsz, bpp) \
  34. decl_mc_func(put, sz, h, opt, type, fsz, bpp); \
  35. decl_mc_func(avg, sz, h, opt, type, fsz, bpp); \
  36. decl_mc_func(put, sz, v, opt, type, fsz, bpp); \
  37. decl_mc_func(avg, sz, v, opt, type, fsz, bpp)
  38. #define mc_rep_func(avg, sz, hsz, hszb, dir, opt, type, f_sz, bpp) \
  39. static av_always_inline void \
  40. ff_vp9_##avg##_8tap_1d_##dir##_##sz##_##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  41. const uint8_t *src, ptrdiff_t src_stride, \
  42. int h, const type (*filter)[f_sz]) \
  43. { \
  44. ff_vp9_##avg##_8tap_1d_##dir##_##hsz##_##bpp##_##opt(dst, dst_stride, src, \
  45. src_stride, h, filter); \
  46. ff_vp9_##avg##_8tap_1d_##dir##_##hsz##_##bpp##_##opt(dst + hszb, dst_stride, src + hszb, \
  47. src_stride, h, filter); \
  48. }
  49. #define mc_rep_funcs(sz, hsz, hszb, opt, type, fsz, bpp) \
  50. mc_rep_func(put, sz, hsz, hszb, h, opt, type, fsz, bpp); \
  51. mc_rep_func(avg, sz, hsz, hszb, h, opt, type, fsz, bpp); \
  52. mc_rep_func(put, sz, hsz, hszb, v, opt, type, fsz, bpp); \
  53. mc_rep_func(avg, sz, hsz, hszb, v, opt, type, fsz, bpp)
  54. #define filter_8tap_1d_fn(op, sz, f, f_opt, fname, dir, dvar, bpp, opt) \
  55. static void op##_8tap_##fname##_##sz##dir##_##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  56. const uint8_t *src, ptrdiff_t src_stride, \
  57. int h, int mx, int my) \
  58. { \
  59. ff_vp9_##op##_8tap_1d_##dir##_##sz##_##bpp##_##opt(dst, dst_stride, src, src_stride, \
  60. h, ff_filters_##f_opt[f][dvar - 1]); \
  61. }
  62. #define filters_8tap_1d_fn(op, sz, dir, dvar, bpp, opt, f_opt) \
  63. filter_8tap_1d_fn(op, sz, FILTER_8TAP_REGULAR, f_opt, regular, dir, dvar, bpp, opt) \
  64. filter_8tap_1d_fn(op, sz, FILTER_8TAP_SHARP, f_opt, sharp, dir, dvar, bpp, opt) \
  65. filter_8tap_1d_fn(op, sz, FILTER_8TAP_SMOOTH, f_opt, smooth, dir, dvar, bpp, opt)
  66. #define filters_8tap_1d_fn2(op, sz, bpp, opt, f_opt) \
  67. filters_8tap_1d_fn(op, sz, h, mx, bpp, opt, f_opt) \
  68. filters_8tap_1d_fn(op, sz, v, my, bpp, opt, f_opt)
  69. #define filters_8tap_1d_fn3(op, bpp, opt4, opt8, f_opt) \
  70. filters_8tap_1d_fn2(op, 64, bpp, opt8, f_opt) \
  71. filters_8tap_1d_fn2(op, 32, bpp, opt8, f_opt) \
  72. filters_8tap_1d_fn2(op, 16, bpp, opt8, f_opt) \
  73. filters_8tap_1d_fn2(op, 8, bpp, opt8, f_opt) \
  74. filters_8tap_1d_fn2(op, 4, bpp, opt4, f_opt)
  75. #define filter_8tap_2d_fn(op, sz, f, f_opt, fname, align, bpp, bytes, opt) \
  76. static void op##_8tap_##fname##_##sz##hv_##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  77. const uint8_t *src, ptrdiff_t src_stride, \
  78. int h, int mx, int my) \
  79. { \
  80. LOCAL_ALIGNED_##align(uint8_t, temp, [71 * 64 * bytes]); \
  81. ff_vp9_put_8tap_1d_h_##sz##_##bpp##_##opt(temp, 64 * bytes, src - 3 * src_stride, \
  82. src_stride, h + 7, \
  83. ff_filters_##f_opt[f][mx - 1]); \
  84. ff_vp9_##op##_8tap_1d_v_##sz##_##bpp##_##opt(dst, dst_stride, temp + 3 * bytes * 64, \
  85. 64 * bytes, h, \
  86. ff_filters_##f_opt[f][my - 1]); \
  87. }
  88. #define filters_8tap_2d_fn(op, sz, align, bpp, bytes, opt, f_opt) \
  89. filter_8tap_2d_fn(op, sz, FILTER_8TAP_REGULAR, f_opt, regular, align, bpp, bytes, opt) \
  90. filter_8tap_2d_fn(op, sz, FILTER_8TAP_SHARP, f_opt, sharp, align, bpp, bytes, opt) \
  91. filter_8tap_2d_fn(op, sz, FILTER_8TAP_SMOOTH, f_opt, smooth, align, bpp, bytes, opt)
  92. #define filters_8tap_2d_fn2(op, align, bpp, bytes, opt4, opt8, f_opt) \
  93. filters_8tap_2d_fn(op, 64, align, bpp, bytes, opt8, f_opt) \
  94. filters_8tap_2d_fn(op, 32, align, bpp, bytes, opt8, f_opt) \
  95. filters_8tap_2d_fn(op, 16, align, bpp, bytes, opt8, f_opt) \
  96. filters_8tap_2d_fn(op, 8, align, bpp, bytes, opt8, f_opt) \
  97. filters_8tap_2d_fn(op, 4, align, bpp, bytes, opt4, f_opt)
  98. #define init_fpel_func(idx1, idx2, sz, type, bpp, opt) \
  99. dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][0][0] = \
  100. dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][0][0] = \
  101. dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][0][0] = \
  102. dsp->mc[idx1][FILTER_BILINEAR ][idx2][0][0] = ff_vp9_##type##sz##bpp##_##opt
  103. #define init_subpel1(idx1, idx2, idxh, idxv, sz, dir, type, bpp, opt) \
  104. dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][idxh][idxv] = \
  105. type##_8tap_smooth_##sz##dir##_##bpp##_##opt; \
  106. dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][idxh][idxv] = \
  107. type##_8tap_regular_##sz##dir##_##bpp##_##opt; \
  108. dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][idxh][idxv] = \
  109. type##_8tap_sharp_##sz##dir##_##bpp##_##opt
  110. #define init_subpel2(idx1, idx2, sz, type, bpp, opt) \
  111. init_subpel1(idx1, idx2, 1, 1, sz, hv, type, bpp, opt); \
  112. init_subpel1(idx1, idx2, 0, 1, sz, v, type, bpp, opt); \
  113. init_subpel1(idx1, idx2, 1, 0, sz, h, type, bpp, opt)
  114. #define init_subpel3_32_64(idx, type, bpp, opt) \
  115. init_subpel2(0, idx, 64, type, bpp, opt); \
  116. init_subpel2(1, idx, 32, type, bpp, opt)
  117. #define init_subpel3_8to64(idx, type, bpp, opt) \
  118. init_subpel3_32_64(idx, type, bpp, opt); \
  119. init_subpel2(2, idx, 16, type, bpp, opt); \
  120. init_subpel2(3, idx, 8, type, bpp, opt)
  121. #define init_subpel3(idx, type, bpp, opt) \
  122. init_subpel3_8to64(idx, type, bpp, opt); \
  123. init_subpel2(4, idx, 4, type, bpp, opt)
  124. void ff_vp9dsp_init_10bpp_x86(VP9DSPContext *dsp);
  125. void ff_vp9dsp_init_12bpp_x86(VP9DSPContext *dsp);
  126. void ff_vp9dsp_init_16bpp_x86(VP9DSPContext *dsp);
  127. #endif /* AVCODEC_X86_VP9DSP_INIT_H */