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.0KB

  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 "libavutil/mips/generic_macros_msa.h"
  21. #include "pixblockdsp_mips.h"
  22. static void diff_pixels_msa(int16_t *block, const uint8_t *src1,
  23. const uint8_t *src2, int32_t stride)
  24. {
  25. v16u8 in10, in11, in12, in13, in14, in15, in16, in17;
  26. v16u8 in20, in21, in22, in23, in24, in25, in26, in27;
  27. v8i16 out0, out1, out2, out3, out4, out5, out6, out7;
  28. LD_UB8(src1, stride, in10, in11, in12, in13, in14, in15, in16, in17);
  29. LD_UB8(src2, stride, in20, in21, in22, in23, in24, in25, in26, in27);
  30. ILVR_B4_SH(in10, in20, in11, in21, in12, in22, in13, in23,
  31. out0, out1, out2, out3);
  32. ILVR_B4_SH(in14, in24, in15, in25, in16, in26, in17, in27,
  33. out4, out5, out6, out7);
  34. HSUB_UB4_SH(out0, out1, out2, out3, out0, out1, out2, out3);
  35. HSUB_UB4_SH(out4, out5, out6, out7, out4, out5, out6, out7);
  36. ST_SH8(out0, out1, out2, out3, out4, out5, out6, out7, block, 8);
  37. }
  38. static void copy_8bit_to_16bit_width8_msa(const uint8_t *src, int32_t src_stride,
  39. int16_t *dst, int32_t dst_stride,
  40. int32_t height)
  41. {
  42. uint8_t *dst_ptr;
  43. int32_t cnt;
  44. v16u8 src0, src1, src2, src3;
  45. v16i8 zero = { 0 };
  46. dst_ptr = (uint8_t *) dst;
  47. for (cnt = (height >> 2); cnt--;) {
  48. LD_UB4(src, src_stride, src0, src1, src2, src3);
  49. src += (4 * src_stride);
  50. ILVR_B4_UB(zero, src0, zero, src1, zero, src2, zero, src3,
  51. src0, src1, src2, src3);
  52. ST_UB4(src0, src1, src2, src3, dst_ptr, (dst_stride * 2));
  53. dst_ptr += (4 * 2 * dst_stride);
  54. }
  55. }
  56. static void copy_16multx8mult_msa(const uint8_t *src, int32_t src_stride,
  57. uint8_t *dst, int32_t dst_stride,
  58. int32_t height, int32_t width)
  59. {
  60. int32_t cnt, loop_cnt;
  61. const uint8_t *src_tmp;
  62. uint8_t *dst_tmp;
  63. v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
  64. for (cnt = (width >> 4); cnt--;) {
  65. src_tmp = src;
  66. dst_tmp = dst;
  67. for (loop_cnt = (height >> 3); loop_cnt--;) {
  68. LD_UB8(src_tmp, src_stride,
  69. src0, src1, src2, src3, src4, src5, src6, src7);
  70. src_tmp += (8 * src_stride);
  71. ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7,
  72. dst_tmp, dst_stride);
  73. dst_tmp += (8 * dst_stride);
  74. }
  75. src += 16;
  76. dst += 16;
  77. }
  78. }
  79. static void copy_width16_msa(const uint8_t *src, int32_t src_stride,
  80. uint8_t *dst, int32_t dst_stride,
  81. int32_t height)
  82. {
  83. int32_t cnt;
  84. v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
  85. if (0 == height % 12) {
  86. for (cnt = (height / 12); cnt--;) {
  87. LD_UB8(src, src_stride,
  88. src0, src1, src2, src3, src4, src5, src6, src7);
  89. src += (8 * src_stride);
  90. ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7,
  91. dst, dst_stride);
  92. dst += (8 * dst_stride);
  93. LD_UB4(src, src_stride, src0, src1, src2, src3);
  94. src += (4 * src_stride);
  95. ST_UB4(src0, src1, src2, src3, dst, dst_stride);
  96. dst += (4 * dst_stride);
  97. }
  98. } else if (0 == height % 8) {
  99. copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 16);
  100. } else if (0 == height % 4) {
  101. for (cnt = (height >> 2); cnt--;) {
  102. LD_UB4(src, src_stride, src0, src1, src2, src3);
  103. src += (4 * src_stride);
  104. ST_UB4(src0, src1, src2, src3, dst, dst_stride);
  105. dst += (4 * dst_stride);
  106. }
  107. }
  108. }
  109. void ff_get_pixels_16_msa(int16_t *av_restrict dest, const uint8_t *src,
  110. ptrdiff_t stride)
  111. {
  112. copy_width16_msa(src, stride, (uint8_t *) dest, 16, 8);
  113. }
  114. void ff_get_pixels_8_msa(int16_t *av_restrict dest, const uint8_t *src,
  115. ptrdiff_t stride)
  116. {
  117. copy_8bit_to_16bit_width8_msa(src, stride, dest, 8, 8);
  118. }
  119. void ff_diff_pixels_msa(int16_t *av_restrict block, const uint8_t *src1,
  120. const uint8_t *src2, int stride)
  121. {
  122. diff_pixels_msa(block, src1, src2, stride);
  123. }