intrapred4_dspr2.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * Copyright (c) 2015 The WebM project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include "vpx_dsp/mips/common_dspr2.h"
  11. #if HAVE_DSPR2
  12. void vpx_h_predictor_4x4_dspr2(uint8_t *dst, ptrdiff_t stride,
  13. const uint8_t *above, const uint8_t *left) {
  14. int32_t tmp1, tmp2, tmp3, tmp4;
  15. (void)above;
  16. __asm__ __volatile__(
  17. "lb %[tmp1], (%[left]) \n\t"
  18. "lb %[tmp2], 1(%[left]) \n\t"
  19. "lb %[tmp3], 2(%[left]) \n\t"
  20. "lb %[tmp4], 3(%[left]) \n\t"
  21. "replv.qb %[tmp1], %[tmp1] \n\t"
  22. "replv.qb %[tmp2], %[tmp2] \n\t"
  23. "replv.qb %[tmp3], %[tmp3] \n\t"
  24. "replv.qb %[tmp4], %[tmp4] \n\t"
  25. "sw %[tmp1], (%[dst]) \n\t"
  26. "add %[dst], %[dst], %[stride] \n\t"
  27. "sw %[tmp2], (%[dst]) \n\t"
  28. "add %[dst], %[dst], %[stride] \n\t"
  29. "sw %[tmp3], (%[dst]) \n\t"
  30. "add %[dst], %[dst], %[stride] \n\t"
  31. "sw %[tmp4], (%[dst]) \n\t"
  32. : [tmp1] "=&r"(tmp1), [tmp2] "=&r"(tmp2), [tmp3] "=&r"(tmp3),
  33. [tmp4] "=&r"(tmp4)
  34. : [left] "r"(left), [dst] "r"(dst), [stride] "r"(stride));
  35. }
  36. void vpx_dc_predictor_4x4_dspr2(uint8_t *dst, ptrdiff_t stride,
  37. const uint8_t *above, const uint8_t *left) {
  38. int32_t expected_dc;
  39. int32_t average;
  40. int32_t tmp, above_c, above_l, above_r, left_c, left_r, left_l;
  41. __asm__ __volatile__(
  42. "lw %[above_c], (%[above]) \n\t"
  43. "lw %[left_c], (%[left]) \n\t"
  44. "preceu.ph.qbl %[above_l], %[above_c] \n\t"
  45. "preceu.ph.qbr %[above_r], %[above_c] \n\t"
  46. "preceu.ph.qbl %[left_l], %[left_c] \n\t"
  47. "preceu.ph.qbr %[left_r], %[left_c] \n\t"
  48. "addu.ph %[average], %[above_r], %[above_l] \n\t"
  49. "addu.ph %[average], %[average], %[left_l] \n\t"
  50. "addu.ph %[average], %[average], %[left_r] \n\t"
  51. "addiu %[average], %[average], 4 \n\t"
  52. "srl %[tmp], %[average], 16 \n\t"
  53. "addu.ph %[average], %[tmp], %[average] \n\t"
  54. "srl %[expected_dc], %[average], 3 \n\t"
  55. "replv.qb %[expected_dc], %[expected_dc] \n\t"
  56. "sw %[expected_dc], (%[dst]) \n\t"
  57. "add %[dst], %[dst], %[stride] \n\t"
  58. "sw %[expected_dc], (%[dst]) \n\t"
  59. "add %[dst], %[dst], %[stride] \n\t"
  60. "sw %[expected_dc], (%[dst]) \n\t"
  61. "add %[dst], %[dst], %[stride] \n\t"
  62. "sw %[expected_dc], (%[dst]) \n\t"
  63. : [above_c] "=&r"(above_c), [above_l] "=&r"(above_l),
  64. [above_r] "=&r"(above_r), [left_c] "=&r"(left_c),
  65. [left_l] "=&r"(left_l), [left_r] "=&r"(left_r),
  66. [average] "=&r"(average), [tmp] "=&r"(tmp),
  67. [expected_dc] "=&r"(expected_dc)
  68. : [above] "r"(above), [left] "r"(left), [dst] "r"(dst),
  69. [stride] "r"(stride));
  70. }
  71. void vpx_tm_predictor_4x4_dspr2(uint8_t *dst, ptrdiff_t stride,
  72. const uint8_t *above, const uint8_t *left) {
  73. int32_t abovel, abover;
  74. int32_t left0, left1, left2, left3;
  75. int32_t res0, res1;
  76. int32_t resl;
  77. int32_t resr;
  78. int32_t top_left;
  79. uint8_t *cm = vpx_ff_cropTbl;
  80. __asm__ __volatile__(
  81. "ulw %[resl], (%[above]) \n\t"
  82. "lbu %[left0], (%[left]) \n\t"
  83. "lbu %[left1], 1(%[left]) \n\t"
  84. "lbu %[left2], 2(%[left]) \n\t"
  85. "lbu %[left3], 3(%[left]) \n\t"
  86. "lbu %[top_left], -1(%[above]) \n\t"
  87. "preceu.ph.qbl %[abovel], %[resl] \n\t"
  88. "preceu.ph.qbr %[abover], %[resl] \n\t"
  89. "replv.ph %[left0], %[left0] \n\t"
  90. "replv.ph %[left1], %[left1] \n\t"
  91. "replv.ph %[left2], %[left2] \n\t"
  92. "replv.ph %[left3], %[left3] \n\t"
  93. "replv.ph %[top_left], %[top_left] \n\t"
  94. "addu.ph %[resl], %[abovel], %[left0] \n\t"
  95. "subu.ph %[resl], %[resl], %[top_left] \n\t"
  96. "addu.ph %[resr], %[abover], %[left0] \n\t"
  97. "subu.ph %[resr], %[resr], %[top_left] \n\t"
  98. "sll %[res0], %[resr], 16 \n\t"
  99. "sra %[res0], %[res0], 16 \n\t"
  100. "lbux %[res0], %[res0](%[cm]) \n\t"
  101. "sra %[res1], %[resr], 16 \n\t"
  102. "lbux %[res1], %[res1](%[cm]) \n\t"
  103. "sb %[res0], (%[dst]) \n\t"
  104. "sll %[res0], %[resl], 16 \n\t"
  105. "sra %[res0], %[res0], 16 \n\t"
  106. "lbux %[res0], %[res0](%[cm]) \n\t"
  107. "sb %[res1], 1(%[dst]) \n\t"
  108. "sra %[res1], %[resl], 16 \n\t"
  109. "lbux %[res1], %[res1](%[cm]) \n\t"
  110. "addu.ph %[resl], %[abovel], %[left1] \n\t"
  111. "subu.ph %[resl], %[resl], %[top_left] \n\t"
  112. "addu.ph %[resr], %[abover], %[left1] \n\t"
  113. "subu.ph %[resr], %[resr], %[top_left] \n\t"
  114. "sb %[res0], 2(%[dst]) \n\t"
  115. "sb %[res1], 3(%[dst]) \n\t"
  116. "add %[dst], %[dst], %[stride] \n\t"
  117. "sll %[res0], %[resr], 16 \n\t"
  118. "sra %[res0], %[res0], 16 \n\t"
  119. "lbux %[res0], %[res0](%[cm]) \n\t"
  120. "sra %[res1], %[resr], 16 \n\t"
  121. "lbux %[res1], %[res1](%[cm]) \n\t"
  122. "sb %[res0], (%[dst]) \n\t"
  123. "sll %[res0], %[resl], 16 \n\t"
  124. "sra %[res0], %[res0], 16 \n\t"
  125. "lbux %[res0], %[res0](%[cm]) \n\t"
  126. "sb %[res1], 1(%[dst]) \n\t"
  127. "sra %[res1], %[resl], 16 \n\t"
  128. "lbux %[res1], %[res1](%[cm]) \n\t"
  129. "addu.ph %[resl], %[abovel], %[left2] \n\t"
  130. "subu.ph %[resl], %[resl], %[top_left] \n\t"
  131. "addu.ph %[resr], %[abover], %[left2] \n\t"
  132. "subu.ph %[resr], %[resr], %[top_left] \n\t"
  133. "sb %[res0], 2(%[dst]) \n\t"
  134. "sb %[res1], 3(%[dst]) \n\t"
  135. "add %[dst], %[dst], %[stride] \n\t"
  136. "sll %[res0], %[resr], 16 \n\t"
  137. "sra %[res0], %[res0], 16 \n\t"
  138. "lbux %[res0], %[res0](%[cm]) \n\t"
  139. "sra %[res1], %[resr], 16 \n\t"
  140. "lbux %[res1], %[res1](%[cm]) \n\t"
  141. "sb %[res0], (%[dst]) \n\t"
  142. "sll %[res0], %[resl], 16 \n\t"
  143. "sra %[res0], %[res0], 16 \n\t"
  144. "lbux %[res0], %[res0](%[cm]) \n\t"
  145. "sb %[res1], 1(%[dst]) \n\t"
  146. "sra %[res1], %[resl], 16 \n\t"
  147. "lbux %[res1], %[res1](%[cm]) \n\t"
  148. "addu.ph %[resl], %[abovel], %[left3] \n\t"
  149. "subu.ph %[resl], %[resl], %[top_left] \n\t"
  150. "addu.ph %[resr], %[abover], %[left3] \n\t"
  151. "subu.ph %[resr], %[resr], %[top_left] \n\t"
  152. "sb %[res0], 2(%[dst]) \n\t"
  153. "sb %[res1], 3(%[dst]) \n\t"
  154. "add %[dst], %[dst], %[stride] \n\t"
  155. "sll %[res0], %[resr], 16 \n\t"
  156. "sra %[res0], %[res0], 16 \n\t"
  157. "lbux %[res0], %[res0](%[cm]) \n\t"
  158. "sra %[res1], %[resr], 16 \n\t"
  159. "lbux %[res1], %[res1](%[cm]) \n\t"
  160. "sb %[res0], (%[dst]) \n\t"
  161. "sll %[res0], %[resl], 16 \n\t"
  162. "sra %[res0], %[res0], 16 \n\t"
  163. "lbux %[res0], %[res0](%[cm]) \n\t"
  164. "sb %[res1], 1(%[dst]) \n\t"
  165. "sra %[res1], %[resl], 16 \n\t"
  166. "lbux %[res1], %[res1](%[cm]) \n\t"
  167. "sb %[res0], 2(%[dst]) \n\t"
  168. "sb %[res1], 3(%[dst]) \n\t"
  169. : [abovel] "=&r"(abovel), [abover] "=&r"(abover), [left0] "=&r"(left0),
  170. [left1] "=&r"(left1), [left2] "=&r"(left2), [res0] "=&r"(res0),
  171. [res1] "=&r"(res1), [left3] "=&r"(left3), [resl] "=&r"(resl),
  172. [resr] "=&r"(resr), [top_left] "=&r"(top_left)
  173. : [above] "r"(above), [left] "r"(left), [dst] "r"(dst),
  174. [stride] "r"(stride), [cm] "r"(cm));
  175. }
  176. #endif // #if HAVE_DSPR2