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.

310 lines
14KB

  1. /**
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include <stdint.h>
  19. #include "libavcodec/vp8dsp.h"
  20. void ff_vp8_luma_dc_wht_dc_armv6(DCTELEM block[4][4][16], DCTELEM dc[16]);
  21. #define idct_funcs(opt) \
  22. void ff_vp8_luma_dc_wht_ ## opt(DCTELEM block[4][4][16], DCTELEM dc[16]); \
  23. void ff_vp8_idct_add_ ## opt(uint8_t *dst, DCTELEM block[16], int stride); \
  24. void ff_vp8_idct_dc_add_ ## opt(uint8_t *dst, DCTELEM block[16], int stride); \
  25. void ff_vp8_idct_dc_add4y_ ## opt(uint8_t *dst, DCTELEM block[4][16], int stride); \
  26. void ff_vp8_idct_dc_add4uv_ ## opt(uint8_t *dst, DCTELEM block[4][16], int stride)
  27. idct_funcs(neon);
  28. idct_funcs(armv6);
  29. void ff_vp8_v_loop_filter16_neon(uint8_t *dst, int stride,
  30. int flim_E, int flim_I, int hev_thresh);
  31. void ff_vp8_h_loop_filter16_neon(uint8_t *dst, int stride,
  32. int flim_E, int flim_I, int hev_thresh);
  33. void ff_vp8_v_loop_filter8uv_neon(uint8_t *dstU, uint8_t *dstV, int stride,
  34. int flim_E, int flim_I, int hev_thresh);
  35. void ff_vp8_h_loop_filter8uv_neon(uint8_t *dstU, uint8_t *dstV, int stride,
  36. int flim_E, int flim_I, int hev_thresh);
  37. void ff_vp8_v_loop_filter16_inner_neon(uint8_t *dst, int stride,
  38. int flim_E, int flim_I, int hev_thresh);
  39. void ff_vp8_h_loop_filter16_inner_neon(uint8_t *dst, int stride,
  40. int flim_E, int flim_I, int hev_thresh);
  41. void ff_vp8_v_loop_filter8uv_inner_neon(uint8_t *dstU, uint8_t *dstV,
  42. int stride, int flim_E, int flim_I,
  43. int hev_thresh);
  44. void ff_vp8_h_loop_filter8uv_inner_neon(uint8_t *dstU, uint8_t *dstV,
  45. int stride, int flim_E, int flim_I,
  46. int hev_thresh);
  47. void ff_vp8_v_loop_filter_inner_armv6(uint8_t *dst, int stride,
  48. int flim_E, int flim_I,
  49. int hev_thresh, int count);
  50. void ff_vp8_h_loop_filter_inner_armv6(uint8_t *dst, int stride,
  51. int flim_E, int flim_I,
  52. int hev_thresh, int count);
  53. void ff_vp8_v_loop_filter_armv6(uint8_t *dst, int stride,
  54. int flim_E, int flim_I,
  55. int hev_thresh, int count);
  56. void ff_vp8_h_loop_filter_armv6(uint8_t *dst, int stride,
  57. int flim_E, int flim_I,
  58. int hev_thresh, int count);
  59. static void ff_vp8_v_loop_filter16_armv6(uint8_t *dst, int stride,
  60. int flim_E, int flim_I, int hev_thresh)
  61. {
  62. ff_vp8_v_loop_filter_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4);
  63. }
  64. static void ff_vp8_h_loop_filter16_armv6(uint8_t *dst, int stride,
  65. int flim_E, int flim_I, int hev_thresh)
  66. {
  67. ff_vp8_h_loop_filter_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4);
  68. }
  69. static void ff_vp8_v_loop_filter8uv_armv6(uint8_t *dstU, uint8_t *dstV, int stride,
  70. int flim_E, int flim_I, int hev_thresh)
  71. {
  72. ff_vp8_v_loop_filter_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2);
  73. ff_vp8_v_loop_filter_armv6(dstV, stride, flim_E, flim_I, hev_thresh, 2);
  74. }
  75. static void ff_vp8_h_loop_filter8uv_armv6(uint8_t *dstU, uint8_t *dstV, int stride,
  76. int flim_E, int flim_I, int hev_thresh)
  77. {
  78. ff_vp8_h_loop_filter_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2);
  79. ff_vp8_h_loop_filter_armv6(dstV, stride, flim_E, flim_I, hev_thresh, 2);
  80. }
  81. static void ff_vp8_v_loop_filter16_inner_armv6(uint8_t *dst, int stride,
  82. int flim_E, int flim_I, int hev_thresh)
  83. {
  84. ff_vp8_v_loop_filter_inner_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4);
  85. }
  86. static void ff_vp8_h_loop_filter16_inner_armv6(uint8_t *dst, int stride,
  87. int flim_E, int flim_I, int hev_thresh)
  88. {
  89. ff_vp8_h_loop_filter_inner_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4);
  90. }
  91. static void ff_vp8_v_loop_filter8uv_inner_armv6(uint8_t *dstU, uint8_t *dstV,
  92. int stride, int flim_E, int flim_I,
  93. int hev_thresh)
  94. {
  95. ff_vp8_v_loop_filter_inner_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2);
  96. ff_vp8_v_loop_filter_inner_armv6(dstV, stride, flim_E, flim_I, hev_thresh, 2);
  97. }
  98. static void ff_vp8_h_loop_filter8uv_inner_armv6(uint8_t *dstU, uint8_t *dstV,
  99. int stride, int flim_E, int flim_I,
  100. int hev_thresh)
  101. {
  102. ff_vp8_h_loop_filter_inner_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2);
  103. ff_vp8_h_loop_filter_inner_armv6(dstV, stride, flim_E, flim_I, hev_thresh, 2);
  104. }
  105. #define simple_lf_funcs(opt) \
  106. void ff_vp8_v_loop_filter16_simple_ ## opt(uint8_t *dst, int stride, int flim); \
  107. void ff_vp8_h_loop_filter16_simple_ ## opt(uint8_t *dst, int stride, int flim)
  108. simple_lf_funcs(neon);
  109. simple_lf_funcs(armv6);
  110. #define VP8_MC_OPT(n, opt) \
  111. void ff_put_vp8_##n##_##opt(uint8_t *dst, int dststride, \
  112. uint8_t *src, int srcstride, \
  113. int h, int x, int y)
  114. #define VP8_MC(n) \
  115. VP8_MC_OPT(n, neon)
  116. #define VP8_EPEL(w) \
  117. VP8_MC(epel ## w ## _h4); \
  118. VP8_MC(epel ## w ## _h6); \
  119. VP8_MC(epel ## w ## _h4v4); \
  120. VP8_MC(epel ## w ## _h6v4); \
  121. VP8_MC(epel ## w ## _v4); \
  122. VP8_MC(epel ## w ## _v6); \
  123. VP8_MC(epel ## w ## _h4v6); \
  124. VP8_MC(epel ## w ## _h6v6)
  125. VP8_EPEL(16);
  126. VP8_MC(pixels16);
  127. VP8_MC_OPT(pixels16, armv6);
  128. VP8_EPEL(8);
  129. VP8_MC(pixels8);
  130. VP8_MC_OPT(pixels8, armv6);
  131. VP8_EPEL(4);
  132. VP8_MC_OPT(pixels4, armv6);
  133. VP8_MC(bilin16_h);
  134. VP8_MC(bilin16_v);
  135. VP8_MC(bilin16_hv);
  136. VP8_MC(bilin8_h);
  137. VP8_MC(bilin8_v);
  138. VP8_MC(bilin8_hv);
  139. VP8_MC(bilin4_h);
  140. VP8_MC(bilin4_v);
  141. VP8_MC(bilin4_hv);
  142. #define VP8_V6_MC(n) \
  143. void ff_put_vp8_##n##_armv6(uint8_t *dst, int dststride, uint8_t *src, \
  144. int srcstride, int w, int h, int mxy)
  145. VP8_V6_MC(epel_v6);
  146. VP8_V6_MC(epel_h6);
  147. VP8_V6_MC(epel_v4);
  148. VP8_V6_MC(epel_h4);
  149. VP8_V6_MC(bilin_v);
  150. VP8_V6_MC(bilin_h);
  151. #define VP8_EPEL_HV(SIZE, TAPNUMX, TAPNUMY, NAME, HNAME, VNAME, MAXHEIGHT) \
  152. static void ff_put_vp8_##NAME##SIZE##_##HNAME##VNAME##_armv6( \
  153. uint8_t *dst, int dststride, uint8_t *src, \
  154. int srcstride, int h, int mx, int my) \
  155. { \
  156. DECLARE_ALIGNED(4, uint8_t, tmp)[SIZE * (MAXHEIGHT + TAPNUMY - 1)]; \
  157. uint8_t *tmpptr = tmp + SIZE * (TAPNUMY / 2 - 1); \
  158. src -= srcstride * (TAPNUMY / 2 - 1); \
  159. ff_put_vp8_ ## NAME ## _ ## HNAME ## _armv6(tmp, SIZE, src, srcstride, \
  160. SIZE, h + TAPNUMY - 1, mx); \
  161. ff_put_vp8_ ## NAME ## _ ## VNAME ## _armv6(dst, dststride, tmpptr, SIZE, \
  162. SIZE, h, my); \
  163. }
  164. VP8_EPEL_HV(16, 6, 6, epel, h6, v6, 16);
  165. VP8_EPEL_HV(16, 2, 2, bilin, h, v, 16);
  166. VP8_EPEL_HV(8, 6, 6, epel, h6, v6, 16);
  167. VP8_EPEL_HV(8, 4, 6, epel, h4, v6, 16);
  168. VP8_EPEL_HV(8, 6, 4, epel, h6, v4, 16);
  169. VP8_EPEL_HV(8, 4, 4, epel, h4, v4, 16);
  170. VP8_EPEL_HV(8, 2, 2, bilin, h, v, 16);
  171. VP8_EPEL_HV(4, 6, 6, epel, h6, v6, 8);
  172. VP8_EPEL_HV(4, 4, 6, epel, h4, v6, 8);
  173. VP8_EPEL_HV(4, 6, 4, epel, h6, v4, 8);
  174. VP8_EPEL_HV(4, 4, 4, epel, h4, v4, 8);
  175. VP8_EPEL_HV(4, 2, 2, bilin, h, v, 8);
  176. extern void put_vp8_epel4_v6_c(uint8_t *dst, int d, uint8_t *src, int s, int h, int mx, int my);
  177. #undef printf
  178. #define VP8_EPEL_H_OR_V(SIZE, NAME, HV) \
  179. static void ff_put_vp8_##NAME##SIZE##_##HV##_armv6( \
  180. uint8_t *dst, int dststride, uint8_t *src, \
  181. int srcstride, int h, int mx, int my) \
  182. { \
  183. ff_put_vp8_## NAME ## _ ## HV ## _armv6(dst, dststride, src, srcstride, \
  184. SIZE, h, mx | my); \
  185. }
  186. VP8_EPEL_H_OR_V(4, epel, h6);
  187. VP8_EPEL_H_OR_V(4, epel, h4);
  188. VP8_EPEL_H_OR_V(4, epel, v6);
  189. VP8_EPEL_H_OR_V(4, epel, v4);
  190. VP8_EPEL_H_OR_V(4, bilin, v);
  191. VP8_EPEL_H_OR_V(4, bilin, h);
  192. VP8_EPEL_H_OR_V(8, epel, h6);
  193. VP8_EPEL_H_OR_V(8, epel, h4);
  194. VP8_EPEL_H_OR_V(8, epel, v6);
  195. VP8_EPEL_H_OR_V(8, epel, v4);
  196. VP8_EPEL_H_OR_V(8, bilin, v);
  197. VP8_EPEL_H_OR_V(8, bilin, h);
  198. VP8_EPEL_H_OR_V(16, epel, h6);
  199. VP8_EPEL_H_OR_V(16, epel, v6);
  200. VP8_EPEL_H_OR_V(16, bilin, v);
  201. VP8_EPEL_H_OR_V(16, bilin, h);
  202. av_cold void ff_vp8dsp_init_arm(VP8DSPContext *dsp)
  203. {
  204. #define set_func_ptrs(opt) \
  205. dsp->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_##opt; \
  206. dsp->vp8_luma_dc_wht_dc = ff_vp8_luma_dc_wht_dc_armv6; \
  207. \
  208. dsp->vp8_idct_add = ff_vp8_idct_add_##opt; \
  209. dsp->vp8_idct_dc_add = ff_vp8_idct_dc_add_##opt; \
  210. dsp->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_##opt; \
  211. dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_##opt; \
  212. \
  213. dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_##opt; \
  214. dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_##opt; \
  215. dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_##opt; \
  216. dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_##opt; \
  217. \
  218. dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_##opt; \
  219. dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_##opt; \
  220. dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_##opt; \
  221. dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_##opt; \
  222. \
  223. dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter16_simple_##opt; \
  224. dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter16_simple_##opt; \
  225. \
  226. dsp->put_vp8_epel_pixels_tab[0][0][0] = ff_put_vp8_pixels16_##opt; \
  227. dsp->put_vp8_epel_pixels_tab[0][0][2] = ff_put_vp8_epel16_h6_##opt; \
  228. dsp->put_vp8_epel_pixels_tab[0][2][0] = ff_put_vp8_epel16_v6_##opt; \
  229. dsp->put_vp8_epel_pixels_tab[0][2][2] = ff_put_vp8_epel16_h6v6_##opt; \
  230. \
  231. dsp->put_vp8_epel_pixels_tab[1][0][0] = ff_put_vp8_pixels8_##opt; \
  232. dsp->put_vp8_epel_pixels_tab[1][0][1] = ff_put_vp8_epel8_h4_##opt; \
  233. dsp->put_vp8_epel_pixels_tab[1][0][2] = ff_put_vp8_epel8_h6_##opt; \
  234. dsp->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_##opt; \
  235. dsp->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_##opt; \
  236. dsp->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_##opt; \
  237. dsp->put_vp8_epel_pixels_tab[1][2][0] = ff_put_vp8_epel8_v6_##opt; \
  238. dsp->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_##opt; \
  239. dsp->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_##opt; \
  240. \
  241. dsp->put_vp8_epel_pixels_tab[2][0][0] = ff_put_vp8_pixels4_armv6; \
  242. dsp->put_vp8_epel_pixels_tab[2][0][1] = ff_put_vp8_epel4_h4_##opt; \
  243. dsp->put_vp8_epel_pixels_tab[2][0][2] = ff_put_vp8_epel4_h6_##opt; \
  244. dsp->put_vp8_epel_pixels_tab[2][1][0] = ff_put_vp8_epel4_v4_##opt; \
  245. dsp->put_vp8_epel_pixels_tab[2][1][1] = ff_put_vp8_epel4_h4v4_##opt; \
  246. dsp->put_vp8_epel_pixels_tab[2][1][2] = ff_put_vp8_epel4_h6v4_##opt; \
  247. dsp->put_vp8_epel_pixels_tab[2][2][0] = ff_put_vp8_epel4_v6_##opt; \
  248. dsp->put_vp8_epel_pixels_tab[2][2][1] = ff_put_vp8_epel4_h4v6_##opt; \
  249. dsp->put_vp8_epel_pixels_tab[2][2][2] = ff_put_vp8_epel4_h6v6_##opt; \
  250. \
  251. dsp->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_##opt; \
  252. dsp->put_vp8_bilinear_pixels_tab[0][0][2] = ff_put_vp8_bilin16_h_##opt; \
  253. dsp->put_vp8_bilinear_pixels_tab[0][2][0] = ff_put_vp8_bilin16_v_##opt; \
  254. dsp->put_vp8_bilinear_pixels_tab[0][2][2] = ff_put_vp8_bilin16_hv_##opt; \
  255. \
  256. dsp->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_##opt; \
  257. dsp->put_vp8_bilinear_pixels_tab[1][0][1] = ff_put_vp8_bilin8_h_##opt; \
  258. dsp->put_vp8_bilinear_pixels_tab[1][0][2] = ff_put_vp8_bilin8_h_##opt; \
  259. dsp->put_vp8_bilinear_pixels_tab[1][1][0] = ff_put_vp8_bilin8_v_##opt; \
  260. dsp->put_vp8_bilinear_pixels_tab[1][1][1] = ff_put_vp8_bilin8_hv_##opt; \
  261. dsp->put_vp8_bilinear_pixels_tab[1][1][2] = ff_put_vp8_bilin8_hv_##opt; \
  262. dsp->put_vp8_bilinear_pixels_tab[1][2][0] = ff_put_vp8_bilin8_v_##opt; \
  263. dsp->put_vp8_bilinear_pixels_tab[1][2][1] = ff_put_vp8_bilin8_hv_##opt; \
  264. dsp->put_vp8_bilinear_pixels_tab[1][2][2] = ff_put_vp8_bilin8_hv_##opt; \
  265. \
  266. dsp->put_vp8_bilinear_pixels_tab[2][0][0] = ff_put_vp8_pixels4_armv6; \
  267. dsp->put_vp8_bilinear_pixels_tab[2][0][1] = ff_put_vp8_bilin4_h_##opt; \
  268. dsp->put_vp8_bilinear_pixels_tab[2][0][2] = ff_put_vp8_bilin4_h_##opt; \
  269. dsp->put_vp8_bilinear_pixels_tab[2][1][0] = ff_put_vp8_bilin4_v_##opt; \
  270. dsp->put_vp8_bilinear_pixels_tab[2][1][1] = ff_put_vp8_bilin4_hv_##opt; \
  271. dsp->put_vp8_bilinear_pixels_tab[2][1][2] = ff_put_vp8_bilin4_hv_##opt; \
  272. dsp->put_vp8_bilinear_pixels_tab[2][2][0] = ff_put_vp8_bilin4_v_##opt; \
  273. dsp->put_vp8_bilinear_pixels_tab[2][2][1] = ff_put_vp8_bilin4_hv_##opt; \
  274. dsp->put_vp8_bilinear_pixels_tab[2][2][2] = ff_put_vp8_bilin4_hv_##opt
  275. if (HAVE_NEON) {
  276. set_func_ptrs(neon);
  277. } else if (HAVE_ARMV6) {
  278. set_func_ptrs(armv6);
  279. }
  280. }