2
0

vp9dsp_init.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. // hack to force-expand BPC
  26. #define cat(a, bpp, b) a##bpp##b
  27. #define decl_fpel_func(avg, sz, bpp, opt) \
  28. void ff_vp9_##avg##sz##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  29. const uint8_t *src, ptrdiff_t src_stride, \
  30. int h, int mx, int my)
  31. #define decl_mc_func(avg, sz, dir, opt, type, f_sz, bpp) \
  32. void ff_vp9_##avg##_8tap_1d_##dir##_##sz##_##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  33. const uint8_t *src, ptrdiff_t src_stride, \
  34. int h, const type (*filter)[f_sz])
  35. #define decl_mc_funcs(sz, opt, type, fsz, bpp) \
  36. decl_mc_func(put, sz, h, opt, type, fsz, bpp); \
  37. decl_mc_func(avg, sz, h, opt, type, fsz, bpp); \
  38. decl_mc_func(put, sz, v, opt, type, fsz, bpp); \
  39. decl_mc_func(avg, sz, v, opt, type, fsz, bpp)
  40. #define decl_ipred_fn(type, sz, bpp, opt) \
  41. void ff_vp9_ipred_##type##_##sz##x##sz##_##bpp##_##opt(uint8_t *dst, \
  42. ptrdiff_t stride, \
  43. const uint8_t *l, \
  44. const uint8_t *a)
  45. #define decl_ipred_fns(type, bpp, opt4, opt8_16_32) \
  46. decl_ipred_fn(type, 4, bpp, opt4); \
  47. decl_ipred_fn(type, 8, bpp, opt8_16_32); \
  48. decl_ipred_fn(type, 16, bpp, opt8_16_32); \
  49. decl_ipred_fn(type, 32, bpp, opt8_16_32)
  50. #define decl_itxfm_func(typea, typeb, size, bpp, opt) \
  51. void cat(ff_vp9_##typea##_##typeb##_##size##x##size##_add_, bpp, _##opt)(uint8_t *dst, \
  52. ptrdiff_t stride, \
  53. int16_t *block, \
  54. int eob)
  55. #define decl_itxfm_funcs(size, bpp, opt) \
  56. decl_itxfm_func(idct, idct, size, bpp, opt); \
  57. decl_itxfm_func(iadst, idct, size, bpp, opt); \
  58. decl_itxfm_func(idct, iadst, size, bpp, opt); \
  59. decl_itxfm_func(iadst, iadst, size, bpp, opt)
  60. #define mc_rep_func(avg, sz, hsz, hszb, dir, opt, type, f_sz, bpp) \
  61. static av_always_inline void \
  62. ff_vp9_##avg##_8tap_1d_##dir##_##sz##_##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  63. const uint8_t *src, ptrdiff_t src_stride, \
  64. int h, const type (*filter)[f_sz]) \
  65. { \
  66. ff_vp9_##avg##_8tap_1d_##dir##_##hsz##_##bpp##_##opt(dst, dst_stride, src, \
  67. src_stride, h, filter); \
  68. ff_vp9_##avg##_8tap_1d_##dir##_##hsz##_##bpp##_##opt(dst + hszb, dst_stride, src + hszb, \
  69. src_stride, h, filter); \
  70. }
  71. #define mc_rep_funcs(sz, hsz, hszb, opt, type, fsz, bpp) \
  72. mc_rep_func(put, sz, hsz, hszb, h, opt, type, fsz, bpp) \
  73. mc_rep_func(avg, sz, hsz, hszb, h, opt, type, fsz, bpp) \
  74. mc_rep_func(put, sz, hsz, hszb, v, opt, type, fsz, bpp) \
  75. mc_rep_func(avg, sz, hsz, hszb, v, opt, type, fsz, bpp)
  76. #define filter_8tap_1d_fn(op, sz, f, f_opt, fname, dir, dvar, bpp, opt) \
  77. static void op##_8tap_##fname##_##sz##dir##_##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  78. const uint8_t *src, ptrdiff_t src_stride, \
  79. int h, int mx, int my) \
  80. { \
  81. ff_vp9_##op##_8tap_1d_##dir##_##sz##_##bpp##_##opt(dst, dst_stride, src, src_stride, \
  82. h, ff_filters_##f_opt[f][dvar - 1]); \
  83. }
  84. #define filters_8tap_1d_fn(op, sz, dir, dvar, bpp, opt, f_opt) \
  85. filter_8tap_1d_fn(op, sz, FILTER_8TAP_REGULAR, f_opt, regular, dir, dvar, bpp, opt) \
  86. filter_8tap_1d_fn(op, sz, FILTER_8TAP_SHARP, f_opt, sharp, dir, dvar, bpp, opt) \
  87. filter_8tap_1d_fn(op, sz, FILTER_8TAP_SMOOTH, f_opt, smooth, dir, dvar, bpp, opt)
  88. #define filters_8tap_1d_fn2(op, sz, bpp, opt, f_opt) \
  89. filters_8tap_1d_fn(op, sz, h, mx, bpp, opt, f_opt) \
  90. filters_8tap_1d_fn(op, sz, v, my, bpp, opt, f_opt)
  91. #define filters_8tap_1d_fn3(op, bpp, opt4, opt8, f_opt) \
  92. filters_8tap_1d_fn2(op, 64, bpp, opt8, f_opt) \
  93. filters_8tap_1d_fn2(op, 32, bpp, opt8, f_opt) \
  94. filters_8tap_1d_fn2(op, 16, bpp, opt8, f_opt) \
  95. filters_8tap_1d_fn2(op, 8, bpp, opt8, f_opt) \
  96. filters_8tap_1d_fn2(op, 4, bpp, opt4, f_opt)
  97. #define filter_8tap_2d_fn(op, sz, f, f_opt, fname, align, bpp, bytes, opt) \
  98. static void op##_8tap_##fname##_##sz##hv_##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
  99. const uint8_t *src, ptrdiff_t src_stride, \
  100. int h, int mx, int my) \
  101. { \
  102. LOCAL_ALIGNED_##align(uint8_t, temp, [71 * 64 * bytes]); \
  103. ff_vp9_put_8tap_1d_h_##sz##_##bpp##_##opt(temp, 64 * bytes, src - 3 * src_stride, \
  104. src_stride, h + 7, \
  105. ff_filters_##f_opt[f][mx - 1]); \
  106. ff_vp9_##op##_8tap_1d_v_##sz##_##bpp##_##opt(dst, dst_stride, temp + 3 * bytes * 64, \
  107. 64 * bytes, h, \
  108. ff_filters_##f_opt[f][my - 1]); \
  109. }
  110. #define filters_8tap_2d_fn(op, sz, align, bpp, bytes, opt, f_opt) \
  111. filter_8tap_2d_fn(op, sz, FILTER_8TAP_REGULAR, f_opt, regular, align, bpp, bytes, opt) \
  112. filter_8tap_2d_fn(op, sz, FILTER_8TAP_SHARP, f_opt, sharp, align, bpp, bytes, opt) \
  113. filter_8tap_2d_fn(op, sz, FILTER_8TAP_SMOOTH, f_opt, smooth, align, bpp, bytes, opt)
  114. #define filters_8tap_2d_fn2(op, align, bpp, bytes, opt4, opt8, f_opt) \
  115. filters_8tap_2d_fn(op, 64, align, bpp, bytes, opt8, f_opt) \
  116. filters_8tap_2d_fn(op, 32, align, bpp, bytes, opt8, f_opt) \
  117. filters_8tap_2d_fn(op, 16, align, bpp, bytes, opt8, f_opt) \
  118. filters_8tap_2d_fn(op, 8, align, bpp, bytes, opt8, f_opt) \
  119. filters_8tap_2d_fn(op, 4, align, bpp, bytes, opt4, f_opt)
  120. #define init_fpel_func(idx1, idx2, sz, type, bpp, opt) \
  121. dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][0][0] = \
  122. dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][0][0] = \
  123. dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][0][0] = \
  124. dsp->mc[idx1][FILTER_BILINEAR ][idx2][0][0] = ff_vp9_##type##sz##bpp##_##opt
  125. #define init_subpel1(idx1, idx2, idxh, idxv, sz, dir, type, bpp, opt) \
  126. dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][idxh][idxv] = \
  127. type##_8tap_smooth_##sz##dir##_##bpp##_##opt; \
  128. dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][idxh][idxv] = \
  129. type##_8tap_regular_##sz##dir##_##bpp##_##opt; \
  130. dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][idxh][idxv] = \
  131. type##_8tap_sharp_##sz##dir##_##bpp##_##opt
  132. #define init_subpel2(idx1, idx2, sz, type, bpp, opt) \
  133. init_subpel1(idx1, idx2, 1, 1, sz, hv, type, bpp, opt); \
  134. init_subpel1(idx1, idx2, 0, 1, sz, v, type, bpp, opt); \
  135. init_subpel1(idx1, idx2, 1, 0, sz, h, type, bpp, opt)
  136. #define init_subpel3_32_64(idx, type, bpp, opt) \
  137. init_subpel2(0, idx, 64, type, bpp, opt); \
  138. init_subpel2(1, idx, 32, type, bpp, opt)
  139. #define init_subpel3_8to64(idx, type, bpp, opt) \
  140. init_subpel3_32_64(idx, type, bpp, opt); \
  141. init_subpel2(2, idx, 16, type, bpp, opt); \
  142. init_subpel2(3, idx, 8, type, bpp, opt)
  143. #define init_subpel3(idx, type, bpp, opt) \
  144. init_subpel3_8to64(idx, type, bpp, opt); \
  145. init_subpel2(4, idx, 4, type, bpp, opt)
  146. #define init_ipred_func(type, enum, sz, bpp, opt) \
  147. dsp->intra_pred[TX_##sz##X##sz][enum##_PRED] = \
  148. cat(ff_vp9_ipred_##type##_##sz##x##sz##_, bpp, _##opt)
  149. #define init_8_16_32_ipred_funcs(type, enum, bpp, opt) \
  150. init_ipred_func(type, enum, 8, bpp, opt); \
  151. init_ipred_func(type, enum, 16, bpp, opt); \
  152. init_ipred_func(type, enum, 32, bpp, opt)
  153. #define init_ipred_funcs(type, enum, bpp, opt) \
  154. init_ipred_func(type, enum, 4, bpp, opt); \
  155. init_8_16_32_ipred_funcs(type, enum, bpp, opt)
  156. void ff_vp9dsp_init_10bpp_x86(VP9DSPContext *dsp, int bitexact);
  157. void ff_vp9dsp_init_12bpp_x86(VP9DSPContext *dsp, int bitexact);
  158. void ff_vp9dsp_init_16bpp_x86(VP9DSPContext *dsp);
  159. #endif /* AVCODEC_X86_VP9DSP_INIT_H */