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.

144 lines
5.6KB

  1. /*
  2. * Copyright (c) 2016 Google Inc.
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <stdint.h>
  21. #include "libavutil/attributes.h"
  22. #include "libavutil/arm/cpu.h"
  23. #include "libavcodec/vp9dsp.h"
  24. #define declare_fpel(type, sz) \
  25. void ff_vp9_##type##sz##_neon(uint8_t *dst, ptrdiff_t dst_stride, \
  26. const uint8_t *src, ptrdiff_t src_stride, \
  27. int h, int mx, int my)
  28. #define declare_copy_avg(sz) \
  29. declare_fpel(copy, sz); \
  30. declare_fpel(avg , sz)
  31. #define decl_mc_func(op, filter, dir, sz) \
  32. void ff_vp9_##op##_##filter##sz##_##dir##_neon(uint8_t *dst, ptrdiff_t dst_stride, \
  33. const uint8_t *src, ptrdiff_t src_stride, \
  34. int h, int mx, int my)
  35. #define define_8tap_2d_fn(op, filter, sz) \
  36. static void op##_##filter##sz##_hv_neon(uint8_t *dst, ptrdiff_t dst_stride, \
  37. const uint8_t *src, ptrdiff_t src_stride, \
  38. int h, int mx, int my) \
  39. { \
  40. LOCAL_ALIGNED_16(uint8_t, temp, [((1 + (sz < 64)) * sz + 8) * sz]); \
  41. /* We only need h + 7 lines, but the horizontal filter assumes an \
  42. * even number of rows, so filter h + 8 lines here. */ \
  43. ff_vp9_put_##filter##sz##_h_neon(temp, sz, \
  44. src - 3 * src_stride, src_stride, \
  45. h + 8, mx, 0); \
  46. ff_vp9_##op##_##filter##sz##_v_neon(dst, dst_stride, \
  47. temp + 3 * sz, sz, \
  48. h, 0, my); \
  49. }
  50. #define decl_filter_funcs(op, dir, sz) \
  51. decl_mc_func(op, regular, dir, sz); \
  52. decl_mc_func(op, sharp, dir, sz); \
  53. decl_mc_func(op, smooth, dir, sz)
  54. #define decl_mc_funcs(sz) \
  55. decl_filter_funcs(put, h, sz); \
  56. decl_filter_funcs(avg, h, sz); \
  57. decl_filter_funcs(put, v, sz); \
  58. decl_filter_funcs(avg, v, sz); \
  59. decl_filter_funcs(put, hv, sz); \
  60. decl_filter_funcs(avg, hv, sz)
  61. declare_copy_avg(64);
  62. declare_copy_avg(32);
  63. declare_copy_avg(16);
  64. declare_copy_avg(8);
  65. declare_copy_avg(4);
  66. decl_mc_funcs(64);
  67. decl_mc_funcs(32);
  68. decl_mc_funcs(16);
  69. decl_mc_funcs(8);
  70. decl_mc_funcs(4);
  71. #define define_8tap_2d_funcs(sz) \
  72. define_8tap_2d_fn(put, regular, sz) \
  73. define_8tap_2d_fn(put, sharp, sz) \
  74. define_8tap_2d_fn(put, smooth, sz) \
  75. define_8tap_2d_fn(avg, regular, sz) \
  76. define_8tap_2d_fn(avg, sharp, sz) \
  77. define_8tap_2d_fn(avg, smooth, sz)
  78. define_8tap_2d_funcs(64)
  79. define_8tap_2d_funcs(32)
  80. define_8tap_2d_funcs(16)
  81. define_8tap_2d_funcs(8)
  82. define_8tap_2d_funcs(4)
  83. av_cold void ff_vp9dsp_init_arm(VP9DSPContext *dsp, int bpp)
  84. {
  85. int cpu_flags = av_get_cpu_flags();
  86. if (bpp != 8)
  87. return;
  88. if (have_neon(cpu_flags)) {
  89. #define init_fpel(idx1, idx2, sz, type) \
  90. dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][0][0] = \
  91. dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][0][0] = \
  92. dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][0][0] = \
  93. dsp->mc[idx1][FILTER_BILINEAR ][idx2][0][0] = ff_vp9_##type##sz##_neon
  94. #define init_copy_avg(idx, sz) \
  95. init_fpel(idx, 0, sz, copy); \
  96. init_fpel(idx, 1, sz, avg)
  97. #define init_mc_func(idx1, idx2, op, filter, fname, dir, mx, my, sz, pfx) \
  98. dsp->mc[idx1][filter][idx2][mx][my] = pfx##op##_##fname##sz##_##dir##_neon
  99. #define init_mc_funcs(idx, dir, mx, my, sz, pfx) \
  100. init_mc_func(idx, 0, put, FILTER_8TAP_REGULAR, regular, dir, mx, my, sz, pfx); \
  101. init_mc_func(idx, 0, put, FILTER_8TAP_SHARP, sharp, dir, mx, my, sz, pfx); \
  102. init_mc_func(idx, 0, put, FILTER_8TAP_SMOOTH, smooth, dir, mx, my, sz, pfx); \
  103. init_mc_func(idx, 1, avg, FILTER_8TAP_REGULAR, regular, dir, mx, my, sz, pfx); \
  104. init_mc_func(idx, 1, avg, FILTER_8TAP_SHARP, sharp, dir, mx, my, sz, pfx); \
  105. init_mc_func(idx, 1, avg, FILTER_8TAP_SMOOTH, smooth, dir, mx, my, sz, pfx)
  106. #define init_mc_funcs_dirs(idx, sz) \
  107. init_mc_funcs(idx, h, 1, 0, sz, ff_vp9_); \
  108. init_mc_funcs(idx, v, 0, 1, sz, ff_vp9_); \
  109. init_mc_funcs(idx, hv, 1, 1, sz,)
  110. init_copy_avg(0, 64);
  111. init_copy_avg(1, 32);
  112. init_copy_avg(2, 16);
  113. init_copy_avg(3, 8);
  114. init_copy_avg(4, 4);
  115. init_mc_funcs_dirs(0, 64);
  116. init_mc_funcs_dirs(1, 32);
  117. init_mc_funcs_dirs(2, 16);
  118. init_mc_funcs_dirs(3, 8);
  119. init_mc_funcs_dirs(4, 4);
  120. }
  121. }