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.

120 lines
4.2KB

  1. /*
  2. * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com)
  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 "config.h"
  21. #include "libavutil/common.h"
  22. #include "libavcodec/vp9dsp.h"
  23. #include "vp9dsp_mips.h"
  24. #if HAVE_MSA
  25. static av_cold void vp9dsp_mc_init_msa(VP9DSPContext *dsp, int bpp)
  26. {
  27. if (bpp == 8) {
  28. #define init_fpel(idx1, idx2, sz, type) \
  29. dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][0][0] = ff_##type##sz##_msa; \
  30. dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][0][0] = ff_##type##sz##_msa; \
  31. dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][0][0] = ff_##type##sz##_msa; \
  32. dsp->mc[idx1][FILTER_BILINEAR ][idx2][0][0] = ff_##type##sz##_msa
  33. #define init_copy_avg(idx, sz) \
  34. init_fpel(idx, 0, sz, copy); \
  35. init_fpel(idx, 1, sz, avg)
  36. #define init_avg(idx, sz) \
  37. init_fpel(idx, 1, sz, avg)
  38. init_copy_avg(0, 64);
  39. init_copy_avg(1, 32);
  40. init_copy_avg(2, 16);
  41. init_copy_avg(3, 8);
  42. init_avg(4, 4);
  43. #undef init_copy_avg
  44. #undef init_avg
  45. #undef init_fpel
  46. #define init_subpel1(idx1, idx2, idxh, idxv, sz, dir, type) \
  47. dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][idxh][idxv] = \
  48. ff_##type##_8tap_smooth_##sz##dir##_msa; \
  49. dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][idxh][idxv] = \
  50. ff_##type##_8tap_regular_##sz##dir##_msa; \
  51. dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][idxh][idxv] = \
  52. ff_##type##_8tap_sharp_##sz##dir##_msa;
  53. #define init_subpel2(idx, idxh, idxv, dir, type) \
  54. init_subpel1(0, idx, idxh, idxv, 64, dir, type); \
  55. init_subpel1(1, idx, idxh, idxv, 32, dir, type); \
  56. init_subpel1(2, idx, idxh, idxv, 16, dir, type); \
  57. init_subpel1(3, idx, idxh, idxv, 8, dir, type); \
  58. init_subpel1(4, idx, idxh, idxv, 4, dir, type)
  59. #define init_subpel3(idx, type) \
  60. init_subpel2(idx, 1, 1, hv, type); \
  61. init_subpel2(idx, 0, 1, v, type); \
  62. init_subpel2(idx, 1, 0, h, type)
  63. init_subpel3(0, put);
  64. init_subpel3(1, avg);
  65. #undef init_subpel1
  66. #undef init_subpel2
  67. #undef init_subpel3
  68. }
  69. }
  70. static av_cold void vp9dsp_loopfilter_init_msa(VP9DSPContext *dsp, int bpp)
  71. {
  72. if (bpp == 8) {
  73. dsp->loop_filter_8[0][0] = ff_loop_filter_h_4_8_msa;
  74. dsp->loop_filter_8[0][1] = ff_loop_filter_v_4_8_msa;
  75. dsp->loop_filter_8[1][0] = ff_loop_filter_h_8_8_msa;
  76. dsp->loop_filter_8[1][1] = ff_loop_filter_v_8_8_msa;
  77. dsp->loop_filter_8[2][0] = ff_loop_filter_h_16_8_msa;
  78. dsp->loop_filter_8[2][1] = ff_loop_filter_v_16_8_msa;
  79. dsp->loop_filter_16[0] = ff_loop_filter_h_16_16_msa;
  80. dsp->loop_filter_16[1] = ff_loop_filter_v_16_16_msa;
  81. dsp->loop_filter_mix2[0][0][0] = ff_loop_filter_h_44_16_msa;
  82. dsp->loop_filter_mix2[0][0][1] = ff_loop_filter_v_44_16_msa;
  83. dsp->loop_filter_mix2[0][1][0] = ff_loop_filter_h_48_16_msa;
  84. dsp->loop_filter_mix2[0][1][1] = ff_loop_filter_v_48_16_msa;
  85. dsp->loop_filter_mix2[1][0][0] = ff_loop_filter_h_84_16_msa;
  86. dsp->loop_filter_mix2[1][0][1] = ff_loop_filter_v_84_16_msa;
  87. dsp->loop_filter_mix2[1][1][0] = ff_loop_filter_h_88_16_msa;
  88. dsp->loop_filter_mix2[1][1][1] = ff_loop_filter_v_88_16_msa;
  89. }
  90. }
  91. static av_cold void vp9dsp_init_msa(VP9DSPContext *dsp, int bpp)
  92. {
  93. vp9dsp_mc_init_msa(dsp, bpp);
  94. vp9dsp_loopfilter_init_msa(dsp, bpp);
  95. }
  96. #endif // #if HAVE_MSA
  97. av_cold void ff_vp9dsp_init_mips(VP9DSPContext *dsp, int bpp)
  98. {
  99. #if HAVE_MSA
  100. vp9dsp_init_msa(dsp, bpp);
  101. #endif // #if HAVE_MSA
  102. }