convolve2_vert_dspr2.c 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * Copyright (c) 2013 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 <assert.h>
  11. #include <stdio.h>
  12. #include "./vpx_dsp_rtcd.h"
  13. #include "vpx_dsp/mips/convolve_common_dspr2.h"
  14. #include "vpx_dsp/vpx_convolve.h"
  15. #include "vpx_dsp/vpx_dsp_common.h"
  16. #include "vpx_ports/mem.h"
  17. #if HAVE_DSPR2
  18. static void convolve_bi_vert_4_dspr2(const uint8_t *src, int32_t src_stride,
  19. uint8_t *dst, int32_t dst_stride,
  20. const int16_t *filter_y, int32_t w,
  21. int32_t h) {
  22. int32_t x, y;
  23. const uint8_t *src_ptr;
  24. uint8_t *dst_ptr;
  25. uint8_t *cm = vpx_ff_cropTbl;
  26. uint32_t vector4a = 64;
  27. uint32_t load1, load2;
  28. uint32_t p1, p2;
  29. uint32_t scratch1;
  30. uint32_t store1, store2;
  31. int32_t Temp1, Temp2;
  32. const int16_t *filter = &filter_y[3];
  33. uint32_t filter45;
  34. filter45 = ((const int32_t *)filter)[0];
  35. for (y = h; y--;) {
  36. /* prefetch data to cache memory */
  37. prefetch_store(dst + dst_stride);
  38. for (x = 0; x < w; x += 4) {
  39. src_ptr = src + x;
  40. dst_ptr = dst + x;
  41. __asm__ __volatile__(
  42. "ulw %[load1], 0(%[src_ptr]) \n\t"
  43. "add %[src_ptr], %[src_ptr], %[src_stride] \n\t"
  44. "ulw %[load2], 0(%[src_ptr]) \n\t"
  45. "mtlo %[vector4a], $ac0 \n\t"
  46. "mtlo %[vector4a], $ac1 \n\t"
  47. "mtlo %[vector4a], $ac2 \n\t"
  48. "mtlo %[vector4a], $ac3 \n\t"
  49. "mthi $zero, $ac0 \n\t"
  50. "mthi $zero, $ac1 \n\t"
  51. "mthi $zero, $ac2 \n\t"
  52. "mthi $zero, $ac3 \n\t"
  53. "preceu.ph.qbr %[scratch1], %[load1] \n\t"
  54. "preceu.ph.qbr %[p1], %[load2] \n\t"
  55. "precrq.ph.w %[p2], %[p1], %[scratch1] \n\t" /* pixel 2 */
  56. "append %[p1], %[scratch1], 16 \n\t" /* pixel 1 */
  57. "dpa.w.ph $ac0, %[p1], %[filter45] \n\t"
  58. "dpa.w.ph $ac1, %[p2], %[filter45] \n\t"
  59. "preceu.ph.qbl %[scratch1], %[load1] \n\t"
  60. "preceu.ph.qbl %[p1], %[load2] \n\t"
  61. "precrq.ph.w %[p2], %[p1], %[scratch1] \n\t" /* pixel 2 */
  62. "append %[p1], %[scratch1], 16 \n\t" /* pixel 1 */
  63. "dpa.w.ph $ac2, %[p1], %[filter45] \n\t"
  64. "dpa.w.ph $ac3, %[p2], %[filter45] \n\t"
  65. "extp %[Temp1], $ac0, 31 \n\t"
  66. "extp %[Temp2], $ac1, 31 \n\t"
  67. "lbux %[store1], %[Temp1](%[cm]) \n\t"
  68. "extp %[Temp1], $ac2, 31 \n\t"
  69. "lbux %[store2], %[Temp2](%[cm]) \n\t"
  70. "extp %[Temp2], $ac3, 31 \n\t"
  71. "sb %[store1], 0(%[dst_ptr]) \n\t"
  72. "sb %[store2], 1(%[dst_ptr]) \n\t"
  73. "lbux %[store1], %[Temp1](%[cm]) \n\t"
  74. "lbux %[store2], %[Temp2](%[cm]) \n\t"
  75. "sb %[store1], 2(%[dst_ptr]) \n\t"
  76. "sb %[store2], 3(%[dst_ptr]) \n\t"
  77. : [load1] "=&r"(load1), [load2] "=&r"(load2), [p1] "=&r"(p1),
  78. [p2] "=&r"(p2), [scratch1] "=&r"(scratch1), [Temp1] "=&r"(Temp1),
  79. [Temp2] "=&r"(Temp2), [store1] "=&r"(store1),
  80. [store2] "=&r"(store2), [src_ptr] "+r"(src_ptr)
  81. : [filter45] "r"(filter45), [vector4a] "r"(vector4a),
  82. [src_stride] "r"(src_stride), [cm] "r"(cm), [dst_ptr] "r"(dst_ptr));
  83. }
  84. /* Next row... */
  85. src += src_stride;
  86. dst += dst_stride;
  87. }
  88. }
  89. static void convolve_bi_vert_64_dspr2(const uint8_t *src, int32_t src_stride,
  90. uint8_t *dst, int32_t dst_stride,
  91. const int16_t *filter_y, int32_t h) {
  92. int32_t x, y;
  93. const uint8_t *src_ptr;
  94. uint8_t *dst_ptr;
  95. uint8_t *cm = vpx_ff_cropTbl;
  96. uint32_t vector4a = 64;
  97. uint32_t load1, load2;
  98. uint32_t p1, p2;
  99. uint32_t scratch1;
  100. uint32_t store1, store2;
  101. int32_t Temp1, Temp2;
  102. const int16_t *filter = &filter_y[3];
  103. uint32_t filter45;
  104. filter45 = ((const int32_t *)filter)[0];
  105. for (y = h; y--;) {
  106. /* prefetch data to cache memory */
  107. prefetch_store(dst + dst_stride);
  108. for (x = 0; x < 64; x += 4) {
  109. src_ptr = src + x;
  110. dst_ptr = dst + x;
  111. __asm__ __volatile__(
  112. "ulw %[load1], 0(%[src_ptr]) \n\t"
  113. "add %[src_ptr], %[src_ptr], %[src_stride] \n\t"
  114. "ulw %[load2], 0(%[src_ptr]) \n\t"
  115. "mtlo %[vector4a], $ac0 \n\t"
  116. "mtlo %[vector4a], $ac1 \n\t"
  117. "mtlo %[vector4a], $ac2 \n\t"
  118. "mtlo %[vector4a], $ac3 \n\t"
  119. "mthi $zero, $ac0 \n\t"
  120. "mthi $zero, $ac1 \n\t"
  121. "mthi $zero, $ac2 \n\t"
  122. "mthi $zero, $ac3 \n\t"
  123. "preceu.ph.qbr %[scratch1], %[load1] \n\t"
  124. "preceu.ph.qbr %[p1], %[load2] \n\t"
  125. "precrq.ph.w %[p2], %[p1], %[scratch1] \n\t" /* pixel 2 */
  126. "append %[p1], %[scratch1], 16 \n\t" /* pixel 1 */
  127. "dpa.w.ph $ac0, %[p1], %[filter45] \n\t"
  128. "dpa.w.ph $ac1, %[p2], %[filter45] \n\t"
  129. "preceu.ph.qbl %[scratch1], %[load1] \n\t"
  130. "preceu.ph.qbl %[p1], %[load2] \n\t"
  131. "precrq.ph.w %[p2], %[p1], %[scratch1] \n\t" /* pixel 2 */
  132. "append %[p1], %[scratch1], 16 \n\t" /* pixel 1 */
  133. "dpa.w.ph $ac2, %[p1], %[filter45] \n\t"
  134. "dpa.w.ph $ac3, %[p2], %[filter45] \n\t"
  135. "extp %[Temp1], $ac0, 31 \n\t"
  136. "extp %[Temp2], $ac1, 31 \n\t"
  137. "lbux %[store1], %[Temp1](%[cm]) \n\t"
  138. "extp %[Temp1], $ac2, 31 \n\t"
  139. "lbux %[store2], %[Temp2](%[cm]) \n\t"
  140. "extp %[Temp2], $ac3, 31 \n\t"
  141. "sb %[store1], 0(%[dst_ptr]) \n\t"
  142. "sb %[store2], 1(%[dst_ptr]) \n\t"
  143. "lbux %[store1], %[Temp1](%[cm]) \n\t"
  144. "lbux %[store2], %[Temp2](%[cm]) \n\t"
  145. "sb %[store1], 2(%[dst_ptr]) \n\t"
  146. "sb %[store2], 3(%[dst_ptr]) \n\t"
  147. : [load1] "=&r"(load1), [load2] "=&r"(load2), [p1] "=&r"(p1),
  148. [p2] "=&r"(p2), [scratch1] "=&r"(scratch1), [Temp1] "=&r"(Temp1),
  149. [Temp2] "=&r"(Temp2), [store1] "=&r"(store1),
  150. [store2] "=&r"(store2), [src_ptr] "+r"(src_ptr)
  151. : [filter45] "r"(filter45), [vector4a] "r"(vector4a),
  152. [src_stride] "r"(src_stride), [cm] "r"(cm), [dst_ptr] "r"(dst_ptr));
  153. }
  154. /* Next row... */
  155. src += src_stride;
  156. dst += dst_stride;
  157. }
  158. }
  159. void vpx_convolve2_vert_dspr2(const uint8_t *src, ptrdiff_t src_stride,
  160. uint8_t *dst, ptrdiff_t dst_stride,
  161. const InterpKernel *filter, int x0_q4,
  162. int32_t x_step_q4, int y0_q4, int y_step_q4,
  163. int w, int h) {
  164. const int16_t *const filter_y = filter[y0_q4];
  165. uint32_t pos = 38;
  166. assert(y_step_q4 == 16);
  167. /* bit positon for extract from acc */
  168. __asm__ __volatile__("wrdsp %[pos], 1 \n\t"
  169. :
  170. : [pos] "r"(pos));
  171. prefetch_store(dst);
  172. switch (w) {
  173. case 4:
  174. case 8:
  175. case 16:
  176. case 32:
  177. convolve_bi_vert_4_dspr2(src, src_stride, dst, dst_stride, filter_y, w,
  178. h);
  179. break;
  180. case 64:
  181. prefetch_store(dst + 32);
  182. convolve_bi_vert_64_dspr2(src, src_stride, dst, dst_stride, filter_y, h);
  183. break;
  184. default:
  185. vpx_convolve8_vert_c(src, src_stride, dst, dst_stride, filter, x0_q4,
  186. x_step_q4, y0_q4, y_step_q4, w, h);
  187. break;
  188. }
  189. }
  190. #endif