avg_msa.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  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 <stdlib.h>
  11. #include "./vpx_config.h"
  12. #include "./vpx_dsp_rtcd.h"
  13. #include "vpx_dsp/mips/macros_msa.h"
  14. uint32_t vpx_avg_8x8_msa(const uint8_t *src, int32_t src_stride) {
  15. uint32_t sum_out;
  16. v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
  17. v8u16 sum0, sum1, sum2, sum3, sum4, sum5, sum6, sum7;
  18. v4u32 sum = { 0 };
  19. LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
  20. HADD_UB4_UH(src0, src1, src2, src3, sum0, sum1, sum2, sum3);
  21. HADD_UB4_UH(src4, src5, src6, src7, sum4, sum5, sum6, sum7);
  22. ADD4(sum0, sum1, sum2, sum3, sum4, sum5, sum6, sum7, sum0, sum2, sum4, sum6);
  23. ADD2(sum0, sum2, sum4, sum6, sum0, sum4);
  24. sum0 += sum4;
  25. sum = __msa_hadd_u_w(sum0, sum0);
  26. sum0 = (v8u16)__msa_pckev_h((v8i16)sum, (v8i16)sum);
  27. sum = __msa_hadd_u_w(sum0, sum0);
  28. sum = (v4u32)__msa_srari_w((v4i32)sum, 6);
  29. sum_out = __msa_copy_u_w((v4i32)sum, 0);
  30. return sum_out;
  31. }
  32. uint32_t vpx_avg_4x4_msa(const uint8_t *src, int32_t src_stride) {
  33. uint32_t sum_out;
  34. uint32_t src0, src1, src2, src3;
  35. v16u8 vec = { 0 };
  36. v8u16 sum0;
  37. v4u32 sum1;
  38. v2u64 sum2;
  39. LW4(src, src_stride, src0, src1, src2, src3);
  40. INSERT_W4_UB(src0, src1, src2, src3, vec);
  41. sum0 = __msa_hadd_u_h(vec, vec);
  42. sum1 = __msa_hadd_u_w(sum0, sum0);
  43. sum0 = (v8u16)__msa_pckev_h((v8i16)sum1, (v8i16)sum1);
  44. sum1 = __msa_hadd_u_w(sum0, sum0);
  45. sum2 = __msa_hadd_u_d(sum1, sum1);
  46. sum1 = (v4u32)__msa_srari_w((v4i32)sum2, 4);
  47. sum_out = __msa_copy_u_w((v4i32)sum1, 0);
  48. return sum_out;
  49. }
  50. #if !CONFIG_VP9_HIGHBITDEPTH
  51. void vpx_hadamard_8x8_msa(const int16_t *src, ptrdiff_t src_stride,
  52. int16_t *dst) {
  53. v8i16 src0, src1, src2, src3, src4, src5, src6, src7;
  54. v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
  55. LD_SH8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
  56. BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
  57. tmp6, tmp7, tmp5, tmp3, tmp1);
  58. BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
  59. src5, src7, src6, src3, src2);
  60. BUTTERFLY_8(src0, src1, src2, src3, src7, src6, src5, src4, tmp0, tmp7, tmp3,
  61. tmp4, tmp5, tmp1, tmp6, tmp2);
  62. TRANSPOSE8x8_SH_SH(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, src0, src1,
  63. src2, src3, src4, src5, src6, src7);
  64. BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
  65. tmp6, tmp7, tmp5, tmp3, tmp1);
  66. BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
  67. src5, src7, src6, src3, src2);
  68. BUTTERFLY_8(src0, src1, src2, src3, src7, src6, src5, src4, tmp0, tmp7, tmp3,
  69. tmp4, tmp5, tmp1, tmp6, tmp2);
  70. TRANSPOSE8x8_SH_SH(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, src0, src1,
  71. src2, src3, src4, src5, src6, src7);
  72. ST_SH8(src0, src1, src2, src3, src4, src5, src6, src7, dst, 8);
  73. }
  74. void vpx_hadamard_16x16_msa(const int16_t *src, ptrdiff_t src_stride,
  75. int16_t *dst) {
  76. v8i16 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
  77. v8i16 src11, src12, src13, src14, src15, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
  78. v8i16 tmp6, tmp7, tmp8, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15;
  79. v8i16 res0, res1, res2, res3, res4, res5, res6, res7;
  80. LD_SH2(src, 8, src0, src8);
  81. src += src_stride;
  82. LD_SH2(src, 8, src1, src9);
  83. src += src_stride;
  84. LD_SH2(src, 8, src2, src10);
  85. src += src_stride;
  86. LD_SH2(src, 8, src3, src11);
  87. src += src_stride;
  88. LD_SH2(src, 8, src4, src12);
  89. src += src_stride;
  90. LD_SH2(src, 8, src5, src13);
  91. src += src_stride;
  92. LD_SH2(src, 8, src6, src14);
  93. src += src_stride;
  94. LD_SH2(src, 8, src7, src15);
  95. src += src_stride;
  96. BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
  97. tmp6, tmp7, tmp5, tmp3, tmp1);
  98. BUTTERFLY_8(src8, src10, src12, src14, src15, src13, src11, src9, tmp8, tmp10,
  99. tmp12, tmp14, tmp15, tmp13, tmp11, tmp9);
  100. BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
  101. src5, src7, src6, src3, src2);
  102. BUTTERFLY_8(src0, src1, src2, src3, src7, src6, src5, src4, tmp0, tmp7, tmp3,
  103. tmp4, tmp5, tmp1, tmp6, tmp2);
  104. TRANSPOSE8x8_SH_SH(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, src0, src1,
  105. src2, src3, src4, src5, src6, src7);
  106. BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
  107. tmp6, tmp7, tmp5, tmp3, tmp1);
  108. BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
  109. src5, src7, src6, src3, src2);
  110. BUTTERFLY_8(src0, src1, src2, src3, src7, src6, src5, src4, tmp0, tmp7, tmp3,
  111. tmp4, tmp5, tmp1, tmp6, tmp2);
  112. TRANSPOSE8x8_SH_SH(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, src0, src1,
  113. src2, src11, src4, src5, src6, src7);
  114. ST_SH8(src0, src1, src2, src11, src4, src5, src6, src7, dst, 8);
  115. BUTTERFLY_8(tmp8, tmp9, tmp12, tmp13, tmp15, tmp14, tmp11, tmp10, src8, src9,
  116. src12, src13, src15, src14, src11, src10);
  117. BUTTERFLY_8(src8, src9, src10, src11, src15, src14, src13, src12, tmp8, tmp15,
  118. tmp11, tmp12, tmp13, tmp9, tmp14, tmp10);
  119. TRANSPOSE8x8_SH_SH(tmp8, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, src8,
  120. src9, src10, src11, src12, src13, src14, src15);
  121. BUTTERFLY_8(src8, src10, src12, src14, src15, src13, src11, src9, tmp8, tmp10,
  122. tmp12, tmp14, tmp15, tmp13, tmp11, tmp9);
  123. BUTTERFLY_8(tmp8, tmp9, tmp12, tmp13, tmp15, tmp14, tmp11, tmp10, src8, src9,
  124. src12, src13, src15, src14, src11, src10);
  125. BUTTERFLY_8(src8, src9, src10, src11, src15, src14, src13, src12, tmp8, tmp15,
  126. tmp11, tmp12, tmp13, tmp9, tmp14, tmp10);
  127. TRANSPOSE8x8_SH_SH(tmp8, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, res0,
  128. res1, res2, res3, res4, res5, res6, res7);
  129. LD_SH2(src, 8, src0, src8);
  130. src += src_stride;
  131. LD_SH2(src, 8, src1, src9);
  132. src += src_stride;
  133. LD_SH2(src, 8, src2, src10);
  134. src += src_stride;
  135. LD_SH2(src, 8, src3, src11);
  136. src += src_stride;
  137. ST_SH8(res0, res1, res2, res3, res4, res5, res6, res7, dst + 64, 8);
  138. LD_SH2(src, 8, src4, src12);
  139. src += src_stride;
  140. LD_SH2(src, 8, src5, src13);
  141. src += src_stride;
  142. LD_SH2(src, 8, src6, src14);
  143. src += src_stride;
  144. LD_SH2(src, 8, src7, src15);
  145. src += src_stride;
  146. BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
  147. tmp6, tmp7, tmp5, tmp3, tmp1);
  148. BUTTERFLY_8(src8, src10, src12, src14, src15, src13, src11, src9, tmp8, tmp10,
  149. tmp12, tmp14, tmp15, tmp13, tmp11, tmp9);
  150. BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
  151. src5, src7, src6, src3, src2);
  152. BUTTERFLY_8(src0, src1, src2, src3, src7, src6, src5, src4, tmp0, tmp7, tmp3,
  153. tmp4, tmp5, tmp1, tmp6, tmp2);
  154. TRANSPOSE8x8_SH_SH(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, src0, src1,
  155. src2, src3, src4, src5, src6, src7);
  156. BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
  157. tmp6, tmp7, tmp5, tmp3, tmp1);
  158. BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
  159. src5, src7, src6, src3, src2);
  160. BUTTERFLY_8(src0, src1, src2, src3, src7, src6, src5, src4, tmp0, tmp7, tmp3,
  161. tmp4, tmp5, tmp1, tmp6, tmp2);
  162. TRANSPOSE8x8_SH_SH(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, src0, src1,
  163. src2, src3, src4, src5, src6, src7);
  164. ST_SH8(src0, src1, src2, src3, src4, src5, src6, src7, dst + 2 * 64, 8);
  165. BUTTERFLY_8(tmp8, tmp9, tmp12, tmp13, tmp15, tmp14, tmp11, tmp10, src8, src9,
  166. src12, src13, src15, src14, src11, src10);
  167. BUTTERFLY_8(src8, src9, src10, src11, src15, src14, src13, src12, tmp8, tmp15,
  168. tmp11, tmp12, tmp13, tmp9, tmp14, tmp10);
  169. TRANSPOSE8x8_SH_SH(tmp8, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, src8,
  170. src9, src10, src11, src12, src13, src14, src15);
  171. BUTTERFLY_8(src8, src10, src12, src14, src15, src13, src11, src9, tmp8, tmp10,
  172. tmp12, tmp14, tmp15, tmp13, tmp11, tmp9);
  173. BUTTERFLY_8(tmp8, tmp9, tmp12, tmp13, tmp15, tmp14, tmp11, tmp10, src8, src9,
  174. src12, src13, src15, src14, src11, src10);
  175. BUTTERFLY_8(src8, src9, src10, src11, src15, src14, src13, src12, tmp8, tmp15,
  176. tmp11, tmp12, tmp13, tmp9, tmp14, tmp10);
  177. TRANSPOSE8x8_SH_SH(tmp8, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, res0,
  178. res1, res2, res3, res4, res5, res6, res7);
  179. ST_SH8(res0, res1, res2, res3, res4, res5, res6, res7, dst + 3 * 64, 8);
  180. LD_SH4(dst, 64, src0, src1, src2, src3);
  181. LD_SH4(dst + 8, 64, src4, src5, src6, src7);
  182. BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
  183. tmp6, tmp7, tmp5, tmp3, tmp1);
  184. SRA_4V(tmp0, tmp1, tmp2, tmp3, 1);
  185. SRA_4V(tmp4, tmp5, tmp6, tmp7, 1);
  186. BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
  187. src5, src7, src6, src3, src2);
  188. ST_SH4(src0, src1, src2, src3, dst, 64);
  189. ST_SH4(src4, src5, src6, src7, dst + 8, 64);
  190. dst += 16;
  191. LD_SH4(dst, 64, src0, src1, src2, src3);
  192. LD_SH4(dst + 8, 64, src4, src5, src6, src7);
  193. BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
  194. tmp6, tmp7, tmp5, tmp3, tmp1);
  195. SRA_4V(tmp0, tmp1, tmp2, tmp3, 1);
  196. SRA_4V(tmp4, tmp5, tmp6, tmp7, 1);
  197. BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
  198. src5, src7, src6, src3, src2);
  199. ST_SH4(src0, src1, src2, src3, dst, 64);
  200. ST_SH4(src4, src5, src6, src7, dst + 8, 64);
  201. dst += 16;
  202. LD_SH4(dst, 64, src0, src1, src2, src3);
  203. LD_SH4(dst + 8, 64, src4, src5, src6, src7);
  204. BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
  205. tmp6, tmp7, tmp5, tmp3, tmp1);
  206. SRA_4V(tmp0, tmp1, tmp2, tmp3, 1);
  207. SRA_4V(tmp4, tmp5, tmp6, tmp7, 1);
  208. BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
  209. src5, src7, src6, src3, src2);
  210. ST_SH4(src0, src1, src2, src3, dst, 64);
  211. ST_SH4(src4, src5, src6, src7, dst + 8, 64);
  212. dst += 16;
  213. LD_SH4(dst, 64, src0, src1, src2, src3);
  214. LD_SH4(dst + 8, 64, src4, src5, src6, src7);
  215. BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
  216. tmp6, tmp7, tmp5, tmp3, tmp1);
  217. SRA_4V(tmp0, tmp1, tmp2, tmp3, 1);
  218. SRA_4V(tmp4, tmp5, tmp6, tmp7, 1);
  219. BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
  220. src5, src7, src6, src3, src2);
  221. ST_SH4(src0, src1, src2, src3, dst, 64);
  222. ST_SH4(src4, src5, src6, src7, dst + 8, 64);
  223. }
  224. int vpx_satd_msa(const int16_t *data, int length) {
  225. int i, satd;
  226. v8i16 src0, src1, src2, src3, src4, src5, src6, src7;
  227. v8i16 src8, src9, src10, src11, src12, src13, src14, src15;
  228. v8i16 zero = { 0 };
  229. v8u16 tmp0_h, tmp1_h, tmp2_h, tmp3_h, tmp4_h, tmp5_h, tmp6_h, tmp7_h;
  230. v4u32 tmp0_w = { 0 };
  231. if (16 == length) {
  232. LD_SH2(data, 8, src0, src1);
  233. tmp0_h = (v8u16)__msa_asub_s_h(src0, zero);
  234. tmp1_h = (v8u16)__msa_asub_s_h(src1, zero);
  235. tmp0_w = __msa_hadd_u_w(tmp0_h, tmp0_h);
  236. tmp0_w += __msa_hadd_u_w(tmp1_h, tmp1_h);
  237. satd = HADD_UW_U32(tmp0_w);
  238. } else if (64 == length) {
  239. LD_SH8(data, 8, src0, src1, src2, src3, src4, src5, src6, src7);
  240. tmp0_h = (v8u16)__msa_asub_s_h(src0, zero);
  241. tmp1_h = (v8u16)__msa_asub_s_h(src1, zero);
  242. tmp2_h = (v8u16)__msa_asub_s_h(src2, zero);
  243. tmp3_h = (v8u16)__msa_asub_s_h(src3, zero);
  244. tmp4_h = (v8u16)__msa_asub_s_h(src4, zero);
  245. tmp5_h = (v8u16)__msa_asub_s_h(src5, zero);
  246. tmp6_h = (v8u16)__msa_asub_s_h(src6, zero);
  247. tmp7_h = (v8u16)__msa_asub_s_h(src7, zero);
  248. tmp0_w = __msa_hadd_u_w(tmp0_h, tmp0_h);
  249. tmp0_w += __msa_hadd_u_w(tmp1_h, tmp1_h);
  250. tmp0_w += __msa_hadd_u_w(tmp2_h, tmp2_h);
  251. tmp0_w += __msa_hadd_u_w(tmp3_h, tmp3_h);
  252. tmp0_w += __msa_hadd_u_w(tmp4_h, tmp4_h);
  253. tmp0_w += __msa_hadd_u_w(tmp5_h, tmp5_h);
  254. tmp0_w += __msa_hadd_u_w(tmp6_h, tmp6_h);
  255. tmp0_w += __msa_hadd_u_w(tmp7_h, tmp7_h);
  256. satd = HADD_UW_U32(tmp0_w);
  257. } else if (256 == length) {
  258. for (i = 0; i < 2; ++i) {
  259. LD_SH8(data, 8, src0, src1, src2, src3, src4, src5, src6, src7);
  260. data += 8 * 8;
  261. LD_SH8(data, 8, src8, src9, src10, src11, src12, src13, src14, src15);
  262. data += 8 * 8;
  263. tmp0_h = (v8u16)__msa_asub_s_h(src0, zero);
  264. tmp1_h = (v8u16)__msa_asub_s_h(src1, zero);
  265. tmp2_h = (v8u16)__msa_asub_s_h(src2, zero);
  266. tmp3_h = (v8u16)__msa_asub_s_h(src3, zero);
  267. tmp4_h = (v8u16)__msa_asub_s_h(src4, zero);
  268. tmp5_h = (v8u16)__msa_asub_s_h(src5, zero);
  269. tmp6_h = (v8u16)__msa_asub_s_h(src6, zero);
  270. tmp7_h = (v8u16)__msa_asub_s_h(src7, zero);
  271. tmp0_w += __msa_hadd_u_w(tmp0_h, tmp0_h);
  272. tmp0_w += __msa_hadd_u_w(tmp1_h, tmp1_h);
  273. tmp0_w += __msa_hadd_u_w(tmp2_h, tmp2_h);
  274. tmp0_w += __msa_hadd_u_w(tmp3_h, tmp3_h);
  275. tmp0_w += __msa_hadd_u_w(tmp4_h, tmp4_h);
  276. tmp0_w += __msa_hadd_u_w(tmp5_h, tmp5_h);
  277. tmp0_w += __msa_hadd_u_w(tmp6_h, tmp6_h);
  278. tmp0_w += __msa_hadd_u_w(tmp7_h, tmp7_h);
  279. tmp0_h = (v8u16)__msa_asub_s_h(src8, zero);
  280. tmp1_h = (v8u16)__msa_asub_s_h(src9, zero);
  281. tmp2_h = (v8u16)__msa_asub_s_h(src10, zero);
  282. tmp3_h = (v8u16)__msa_asub_s_h(src11, zero);
  283. tmp4_h = (v8u16)__msa_asub_s_h(src12, zero);
  284. tmp5_h = (v8u16)__msa_asub_s_h(src13, zero);
  285. tmp6_h = (v8u16)__msa_asub_s_h(src14, zero);
  286. tmp7_h = (v8u16)__msa_asub_s_h(src15, zero);
  287. tmp0_w += __msa_hadd_u_w(tmp0_h, tmp0_h);
  288. tmp0_w += __msa_hadd_u_w(tmp1_h, tmp1_h);
  289. tmp0_w += __msa_hadd_u_w(tmp2_h, tmp2_h);
  290. tmp0_w += __msa_hadd_u_w(tmp3_h, tmp3_h);
  291. tmp0_w += __msa_hadd_u_w(tmp4_h, tmp4_h);
  292. tmp0_w += __msa_hadd_u_w(tmp5_h, tmp5_h);
  293. tmp0_w += __msa_hadd_u_w(tmp6_h, tmp6_h);
  294. tmp0_w += __msa_hadd_u_w(tmp7_h, tmp7_h);
  295. }
  296. satd = HADD_UW_U32(tmp0_w);
  297. } else if (1024 == length) {
  298. for (i = 0; i < 8; ++i) {
  299. LD_SH8(data, 8, src0, src1, src2, src3, src4, src5, src6, src7);
  300. data += 8 * 8;
  301. LD_SH8(data, 8, src8, src9, src10, src11, src12, src13, src14, src15);
  302. data += 8 * 8;
  303. tmp0_h = (v8u16)__msa_asub_s_h(src0, zero);
  304. tmp1_h = (v8u16)__msa_asub_s_h(src1, zero);
  305. tmp2_h = (v8u16)__msa_asub_s_h(src2, zero);
  306. tmp3_h = (v8u16)__msa_asub_s_h(src3, zero);
  307. tmp4_h = (v8u16)__msa_asub_s_h(src4, zero);
  308. tmp5_h = (v8u16)__msa_asub_s_h(src5, zero);
  309. tmp6_h = (v8u16)__msa_asub_s_h(src6, zero);
  310. tmp7_h = (v8u16)__msa_asub_s_h(src7, zero);
  311. tmp0_w += __msa_hadd_u_w(tmp0_h, tmp0_h);
  312. tmp0_w += __msa_hadd_u_w(tmp1_h, tmp1_h);
  313. tmp0_w += __msa_hadd_u_w(tmp2_h, tmp2_h);
  314. tmp0_w += __msa_hadd_u_w(tmp3_h, tmp3_h);
  315. tmp0_w += __msa_hadd_u_w(tmp4_h, tmp4_h);
  316. tmp0_w += __msa_hadd_u_w(tmp5_h, tmp5_h);
  317. tmp0_w += __msa_hadd_u_w(tmp6_h, tmp6_h);
  318. tmp0_w += __msa_hadd_u_w(tmp7_h, tmp7_h);
  319. tmp0_h = (v8u16)__msa_asub_s_h(src8, zero);
  320. tmp1_h = (v8u16)__msa_asub_s_h(src9, zero);
  321. tmp2_h = (v8u16)__msa_asub_s_h(src10, zero);
  322. tmp3_h = (v8u16)__msa_asub_s_h(src11, zero);
  323. tmp4_h = (v8u16)__msa_asub_s_h(src12, zero);
  324. tmp5_h = (v8u16)__msa_asub_s_h(src13, zero);
  325. tmp6_h = (v8u16)__msa_asub_s_h(src14, zero);
  326. tmp7_h = (v8u16)__msa_asub_s_h(src15, zero);
  327. tmp0_w += __msa_hadd_u_w(tmp0_h, tmp0_h);
  328. tmp0_w += __msa_hadd_u_w(tmp1_h, tmp1_h);
  329. tmp0_w += __msa_hadd_u_w(tmp2_h, tmp2_h);
  330. tmp0_w += __msa_hadd_u_w(tmp3_h, tmp3_h);
  331. tmp0_w += __msa_hadd_u_w(tmp4_h, tmp4_h);
  332. tmp0_w += __msa_hadd_u_w(tmp5_h, tmp5_h);
  333. tmp0_w += __msa_hadd_u_w(tmp6_h, tmp6_h);
  334. tmp0_w += __msa_hadd_u_w(tmp7_h, tmp7_h);
  335. }
  336. satd = HADD_UW_U32(tmp0_w);
  337. } else {
  338. satd = 0;
  339. for (i = 0; i < length; ++i) {
  340. satd += abs(data[i]);
  341. }
  342. }
  343. return satd;
  344. }
  345. #endif // !CONFIG_VP9_HIGHBITDEPTH
  346. void vpx_int_pro_row_msa(int16_t hbuf[16], const uint8_t *ref,
  347. const int ref_stride, const int height) {
  348. int i;
  349. v16u8 ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
  350. v8i16 hbuf_r = { 0 };
  351. v8i16 hbuf_l = { 0 };
  352. v8i16 ref0_r, ref0_l, ref1_r, ref1_l, ref2_r, ref2_l, ref3_r, ref3_l;
  353. v8i16 ref4_r, ref4_l, ref5_r, ref5_l, ref6_r, ref6_l, ref7_r, ref7_l;
  354. if (16 == height) {
  355. for (i = 2; i--;) {
  356. LD_UB8(ref, ref_stride, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
  357. ref += 8 * ref_stride;
  358. UNPCK_UB_SH(ref0, ref0_r, ref0_l);
  359. UNPCK_UB_SH(ref1, ref1_r, ref1_l);
  360. UNPCK_UB_SH(ref2, ref2_r, ref2_l);
  361. UNPCK_UB_SH(ref3, ref3_r, ref3_l);
  362. UNPCK_UB_SH(ref4, ref4_r, ref4_l);
  363. UNPCK_UB_SH(ref5, ref5_r, ref5_l);
  364. UNPCK_UB_SH(ref6, ref6_r, ref6_l);
  365. UNPCK_UB_SH(ref7, ref7_r, ref7_l);
  366. ADD4(hbuf_r, ref0_r, hbuf_l, ref0_l, hbuf_r, ref1_r, hbuf_l, ref1_l,
  367. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  368. ADD4(hbuf_r, ref2_r, hbuf_l, ref2_l, hbuf_r, ref3_r, hbuf_l, ref3_l,
  369. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  370. ADD4(hbuf_r, ref4_r, hbuf_l, ref4_l, hbuf_r, ref5_r, hbuf_l, ref5_l,
  371. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  372. ADD4(hbuf_r, ref6_r, hbuf_l, ref6_l, hbuf_r, ref7_r, hbuf_l, ref7_l,
  373. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  374. }
  375. SRA_2V(hbuf_r, hbuf_l, 3);
  376. ST_SH2(hbuf_r, hbuf_l, hbuf, 8);
  377. } else if (32 == height) {
  378. for (i = 2; i--;) {
  379. LD_UB8(ref, ref_stride, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
  380. ref += 8 * ref_stride;
  381. UNPCK_UB_SH(ref0, ref0_r, ref0_l);
  382. UNPCK_UB_SH(ref1, ref1_r, ref1_l);
  383. UNPCK_UB_SH(ref2, ref2_r, ref2_l);
  384. UNPCK_UB_SH(ref3, ref3_r, ref3_l);
  385. UNPCK_UB_SH(ref4, ref4_r, ref4_l);
  386. UNPCK_UB_SH(ref5, ref5_r, ref5_l);
  387. UNPCK_UB_SH(ref6, ref6_r, ref6_l);
  388. UNPCK_UB_SH(ref7, ref7_r, ref7_l);
  389. ADD4(hbuf_r, ref0_r, hbuf_l, ref0_l, hbuf_r, ref1_r, hbuf_l, ref1_l,
  390. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  391. ADD4(hbuf_r, ref2_r, hbuf_l, ref2_l, hbuf_r, ref3_r, hbuf_l, ref3_l,
  392. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  393. ADD4(hbuf_r, ref4_r, hbuf_l, ref4_l, hbuf_r, ref5_r, hbuf_l, ref5_l,
  394. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  395. ADD4(hbuf_r, ref6_r, hbuf_l, ref6_l, hbuf_r, ref7_r, hbuf_l, ref7_l,
  396. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  397. LD_UB8(ref, ref_stride, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
  398. ref += 8 * ref_stride;
  399. UNPCK_UB_SH(ref0, ref0_r, ref0_l);
  400. UNPCK_UB_SH(ref1, ref1_r, ref1_l);
  401. UNPCK_UB_SH(ref2, ref2_r, ref2_l);
  402. UNPCK_UB_SH(ref3, ref3_r, ref3_l);
  403. UNPCK_UB_SH(ref4, ref4_r, ref4_l);
  404. UNPCK_UB_SH(ref5, ref5_r, ref5_l);
  405. UNPCK_UB_SH(ref6, ref6_r, ref6_l);
  406. UNPCK_UB_SH(ref7, ref7_r, ref7_l);
  407. ADD4(hbuf_r, ref0_r, hbuf_l, ref0_l, hbuf_r, ref1_r, hbuf_l, ref1_l,
  408. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  409. ADD4(hbuf_r, ref2_r, hbuf_l, ref2_l, hbuf_r, ref3_r, hbuf_l, ref3_l,
  410. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  411. ADD4(hbuf_r, ref4_r, hbuf_l, ref4_l, hbuf_r, ref5_r, hbuf_l, ref5_l,
  412. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  413. ADD4(hbuf_r, ref6_r, hbuf_l, ref6_l, hbuf_r, ref7_r, hbuf_l, ref7_l,
  414. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  415. }
  416. SRA_2V(hbuf_r, hbuf_l, 4);
  417. ST_SH2(hbuf_r, hbuf_l, hbuf, 8);
  418. } else if (64 == height) {
  419. for (i = 4; i--;) {
  420. LD_UB8(ref, ref_stride, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
  421. ref += 8 * ref_stride;
  422. UNPCK_UB_SH(ref0, ref0_r, ref0_l);
  423. UNPCK_UB_SH(ref1, ref1_r, ref1_l);
  424. UNPCK_UB_SH(ref2, ref2_r, ref2_l);
  425. UNPCK_UB_SH(ref3, ref3_r, ref3_l);
  426. UNPCK_UB_SH(ref4, ref4_r, ref4_l);
  427. UNPCK_UB_SH(ref5, ref5_r, ref5_l);
  428. UNPCK_UB_SH(ref6, ref6_r, ref6_l);
  429. UNPCK_UB_SH(ref7, ref7_r, ref7_l);
  430. ADD4(hbuf_r, ref0_r, hbuf_l, ref0_l, hbuf_r, ref1_r, hbuf_l, ref1_l,
  431. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  432. ADD4(hbuf_r, ref2_r, hbuf_l, ref2_l, hbuf_r, ref3_r, hbuf_l, ref3_l,
  433. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  434. ADD4(hbuf_r, ref4_r, hbuf_l, ref4_l, hbuf_r, ref5_r, hbuf_l, ref5_l,
  435. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  436. ADD4(hbuf_r, ref6_r, hbuf_l, ref6_l, hbuf_r, ref7_r, hbuf_l, ref7_l,
  437. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  438. LD_UB8(ref, ref_stride, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
  439. ref += 8 * ref_stride;
  440. UNPCK_UB_SH(ref0, ref0_r, ref0_l);
  441. UNPCK_UB_SH(ref1, ref1_r, ref1_l);
  442. UNPCK_UB_SH(ref2, ref2_r, ref2_l);
  443. UNPCK_UB_SH(ref3, ref3_r, ref3_l);
  444. UNPCK_UB_SH(ref4, ref4_r, ref4_l);
  445. UNPCK_UB_SH(ref5, ref5_r, ref5_l);
  446. UNPCK_UB_SH(ref6, ref6_r, ref6_l);
  447. UNPCK_UB_SH(ref7, ref7_r, ref7_l);
  448. ADD4(hbuf_r, ref0_r, hbuf_l, ref0_l, hbuf_r, ref1_r, hbuf_l, ref1_l,
  449. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  450. ADD4(hbuf_r, ref2_r, hbuf_l, ref2_l, hbuf_r, ref3_r, hbuf_l, ref3_l,
  451. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  452. ADD4(hbuf_r, ref4_r, hbuf_l, ref4_l, hbuf_r, ref5_r, hbuf_l, ref5_l,
  453. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  454. ADD4(hbuf_r, ref6_r, hbuf_l, ref6_l, hbuf_r, ref7_r, hbuf_l, ref7_l,
  455. hbuf_r, hbuf_l, hbuf_r, hbuf_l);
  456. }
  457. SRA_2V(hbuf_r, hbuf_l, 5);
  458. ST_SH2(hbuf_r, hbuf_l, hbuf, 8);
  459. } else {
  460. const int norm_factor = height >> 1;
  461. int cnt;
  462. for (cnt = 0; cnt < 16; cnt++) {
  463. hbuf[cnt] = 0;
  464. }
  465. for (i = 0; i < height; ++i) {
  466. for (cnt = 0; cnt < 16; cnt++) {
  467. hbuf[cnt] += ref[cnt];
  468. }
  469. ref += ref_stride;
  470. }
  471. for (cnt = 0; cnt < 16; cnt++) {
  472. hbuf[cnt] /= norm_factor;
  473. }
  474. }
  475. }
  476. int16_t vpx_int_pro_col_msa(const uint8_t *ref, const int width) {
  477. int16_t sum;
  478. v16u8 ref0, ref1, ref2, ref3;
  479. v8u16 ref0_h;
  480. if (16 == width) {
  481. ref0 = LD_UB(ref);
  482. ref0_h = __msa_hadd_u_h(ref0, ref0);
  483. sum = HADD_UH_U32(ref0_h);
  484. } else if (32 == width) {
  485. LD_UB2(ref, 16, ref0, ref1);
  486. ref0_h = __msa_hadd_u_h(ref0, ref0);
  487. ref0_h += __msa_hadd_u_h(ref1, ref1);
  488. sum = HADD_UH_U32(ref0_h);
  489. } else if (64 == width) {
  490. LD_UB4(ref, 16, ref0, ref1, ref2, ref3);
  491. ref0_h = __msa_hadd_u_h(ref0, ref0);
  492. ref0_h += __msa_hadd_u_h(ref1, ref1);
  493. ref0_h += __msa_hadd_u_h(ref2, ref2);
  494. ref0_h += __msa_hadd_u_h(ref3, ref3);
  495. sum = HADD_UH_U32(ref0_h);
  496. } else {
  497. int idx;
  498. sum = 0;
  499. for (idx = 0; idx < width; ++idx) {
  500. sum += ref[idx];
  501. }
  502. }
  503. return sum;
  504. }
  505. int vpx_vector_var_msa(const int16_t *ref, const int16_t *src, const int bwl) {
  506. int sse, mean, var;
  507. v8i16 src0, src1, src2, src3, src4, src5, src6, src7, ref0, ref1, ref2;
  508. v8i16 ref3, ref4, ref5, ref6, ref7, src_l0_m, src_l1_m, src_l2_m, src_l3_m;
  509. v8i16 src_l4_m, src_l5_m, src_l6_m, src_l7_m;
  510. v4i32 res_l0_m, res_l1_m, res_l2_m, res_l3_m, res_l4_m, res_l5_m, res_l6_m;
  511. v4i32 res_l7_m, mean_v;
  512. v2i64 sse_v;
  513. if (2 == bwl) {
  514. LD_SH2(src, 8, src0, src1);
  515. LD_SH2(ref, 8, ref0, ref1);
  516. ILVRL_H2_SH(src0, ref0, src_l0_m, src_l1_m);
  517. ILVRL_H2_SH(src1, ref1, src_l2_m, src_l3_m);
  518. HSUB_UH2_SW(src_l0_m, src_l1_m, res_l0_m, res_l1_m);
  519. HSUB_UH2_SW(src_l2_m, src_l3_m, res_l2_m, res_l3_m);
  520. sse_v = __msa_dotp_s_d(res_l0_m, res_l0_m);
  521. sse_v = __msa_dpadd_s_d(sse_v, res_l1_m, res_l1_m);
  522. DPADD_SD2_SD(res_l2_m, res_l3_m, sse_v, sse_v);
  523. mean_v = res_l0_m + res_l1_m;
  524. mean_v += res_l2_m + res_l3_m;
  525. sse_v += __msa_splati_d(sse_v, 1);
  526. sse = __msa_copy_s_w((v4i32)sse_v, 0);
  527. mean = HADD_SW_S32(mean_v);
  528. } else if (3 == bwl) {
  529. LD_SH4(src, 8, src0, src1, src2, src3);
  530. LD_SH4(ref, 8, ref0, ref1, ref2, ref3);
  531. ILVRL_H2_SH(src0, ref0, src_l0_m, src_l1_m);
  532. ILVRL_H2_SH(src1, ref1, src_l2_m, src_l3_m);
  533. ILVRL_H2_SH(src2, ref2, src_l4_m, src_l5_m);
  534. ILVRL_H2_SH(src3, ref3, src_l6_m, src_l7_m);
  535. HSUB_UH2_SW(src_l0_m, src_l1_m, res_l0_m, res_l1_m);
  536. HSUB_UH2_SW(src_l2_m, src_l3_m, res_l2_m, res_l3_m);
  537. HSUB_UH2_SW(src_l4_m, src_l5_m, res_l4_m, res_l5_m);
  538. HSUB_UH2_SW(src_l6_m, src_l7_m, res_l6_m, res_l7_m);
  539. sse_v = __msa_dotp_s_d(res_l0_m, res_l0_m);
  540. sse_v = __msa_dpadd_s_d(sse_v, res_l1_m, res_l1_m);
  541. DPADD_SD2_SD(res_l2_m, res_l3_m, sse_v, sse_v);
  542. DPADD_SD2_SD(res_l4_m, res_l5_m, sse_v, sse_v);
  543. DPADD_SD2_SD(res_l6_m, res_l7_m, sse_v, sse_v);
  544. mean_v = res_l0_m + res_l1_m;
  545. mean_v += res_l2_m + res_l3_m;
  546. mean_v += res_l4_m + res_l5_m;
  547. mean_v += res_l6_m + res_l7_m;
  548. sse_v += __msa_splati_d(sse_v, 1);
  549. sse = __msa_copy_s_w((v4i32)sse_v, 0);
  550. mean = HADD_SW_S32(mean_v);
  551. } else if (4 == bwl) {
  552. LD_SH8(src, 8, src0, src1, src2, src3, src4, src5, src6, src7);
  553. LD_SH8(ref, 8, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
  554. ILVRL_H2_SH(src0, ref0, src_l0_m, src_l1_m);
  555. ILVRL_H2_SH(src1, ref1, src_l2_m, src_l3_m);
  556. ILVRL_H2_SH(src2, ref2, src_l4_m, src_l5_m);
  557. ILVRL_H2_SH(src3, ref3, src_l6_m, src_l7_m);
  558. HSUB_UH2_SW(src_l0_m, src_l1_m, res_l0_m, res_l1_m);
  559. HSUB_UH2_SW(src_l2_m, src_l3_m, res_l2_m, res_l3_m);
  560. HSUB_UH2_SW(src_l4_m, src_l5_m, res_l4_m, res_l5_m);
  561. HSUB_UH2_SW(src_l6_m, src_l7_m, res_l6_m, res_l7_m);
  562. sse_v = __msa_dotp_s_d(res_l0_m, res_l0_m);
  563. sse_v = __msa_dpadd_s_d(sse_v, res_l1_m, res_l1_m);
  564. DPADD_SD2_SD(res_l2_m, res_l3_m, sse_v, sse_v);
  565. DPADD_SD2_SD(res_l4_m, res_l5_m, sse_v, sse_v);
  566. DPADD_SD2_SD(res_l6_m, res_l7_m, sse_v, sse_v);
  567. mean_v = res_l0_m + res_l1_m;
  568. mean_v += res_l2_m + res_l3_m;
  569. mean_v += res_l4_m + res_l5_m;
  570. mean_v += res_l6_m + res_l7_m;
  571. ILVRL_H2_SH(src4, ref4, src_l0_m, src_l1_m);
  572. ILVRL_H2_SH(src5, ref5, src_l2_m, src_l3_m);
  573. ILVRL_H2_SH(src6, ref6, src_l4_m, src_l5_m);
  574. ILVRL_H2_SH(src7, ref7, src_l6_m, src_l7_m);
  575. HSUB_UH2_SW(src_l0_m, src_l1_m, res_l0_m, res_l1_m);
  576. HSUB_UH2_SW(src_l2_m, src_l3_m, res_l2_m, res_l3_m);
  577. HSUB_UH2_SW(src_l4_m, src_l5_m, res_l4_m, res_l5_m);
  578. HSUB_UH2_SW(src_l6_m, src_l7_m, res_l6_m, res_l7_m);
  579. DPADD_SD2_SD(res_l0_m, res_l1_m, sse_v, sse_v);
  580. DPADD_SD2_SD(res_l2_m, res_l3_m, sse_v, sse_v);
  581. DPADD_SD2_SD(res_l4_m, res_l5_m, sse_v, sse_v);
  582. DPADD_SD2_SD(res_l6_m, res_l7_m, sse_v, sse_v);
  583. mean_v += res_l0_m + res_l1_m;
  584. mean_v += res_l2_m + res_l3_m;
  585. mean_v += res_l4_m + res_l5_m;
  586. mean_v += res_l6_m + res_l7_m;
  587. sse_v += __msa_splati_d(sse_v, 1);
  588. sse = __msa_copy_s_w((v4i32)sse_v, 0);
  589. mean = HADD_SW_S32(mean_v);
  590. } else {
  591. int i;
  592. const int width = 4 << bwl;
  593. sse = 0;
  594. mean = 0;
  595. for (i = 0; i < width; ++i) {
  596. const int diff = ref[i] - src[i];
  597. mean += diff;
  598. sse += diff * diff;
  599. }
  600. }
  601. var = sse - ((mean * mean) >> (bwl + 2));
  602. return var;
  603. }
  604. void vpx_minmax_8x8_msa(const uint8_t *s, int p, const uint8_t *d, int dp,
  605. int *min, int *max) {
  606. v16u8 s0, s1, s2, s3, s4, s5, s6, s7, d0, d1, d2, d3, d4, d5, d6, d7;
  607. v16u8 diff0, diff1, diff2, diff3, min0, min1, max0, max1;
  608. LD_UB8(s, p, s0, s1, s2, s3, s4, s5, s6, s7);
  609. LD_UB8(d, dp, d0, d1, d2, d3, d4, d5, d6, d7);
  610. PCKEV_D4_UB(s1, s0, s3, s2, s5, s4, s7, s6, s0, s1, s2, s3);
  611. PCKEV_D4_UB(d1, d0, d3, d2, d5, d4, d7, d6, d0, d1, d2, d3);
  612. diff0 = __msa_asub_u_b(s0, d0);
  613. diff1 = __msa_asub_u_b(s1, d1);
  614. diff2 = __msa_asub_u_b(s2, d2);
  615. diff3 = __msa_asub_u_b(s3, d3);
  616. min0 = __msa_min_u_b(diff0, diff1);
  617. min1 = __msa_min_u_b(diff2, diff3);
  618. min0 = __msa_min_u_b(min0, min1);
  619. max0 = __msa_max_u_b(diff0, diff1);
  620. max1 = __msa_max_u_b(diff2, diff3);
  621. max0 = __msa_max_u_b(max0, max1);
  622. min1 = (v16u8)__msa_sldi_b((v16i8)min1, (v16i8)min0, 8);
  623. min0 = __msa_min_u_b(min0, min1);
  624. max1 = (v16u8)__msa_sldi_b((v16i8)max1, (v16i8)max0, 8);
  625. max0 = __msa_max_u_b(max0, max1);
  626. min1 = (v16u8)__msa_sldi_b((v16i8)min1, (v16i8)min0, 4);
  627. min0 = __msa_min_u_b(min0, min1);
  628. max1 = (v16u8)__msa_sldi_b((v16i8)max1, (v16i8)max0, 4);
  629. max0 = __msa_max_u_b(max0, max1);
  630. min1 = (v16u8)__msa_sldi_b((v16i8)min1, (v16i8)min0, 2);
  631. min0 = __msa_min_u_b(min0, min1);
  632. max1 = (v16u8)__msa_sldi_b((v16i8)max1, (v16i8)max0, 2);
  633. max0 = __msa_max_u_b(max0, max1);
  634. min1 = (v16u8)__msa_sldi_b((v16i8)min1, (v16i8)min0, 1);
  635. min0 = __msa_min_u_b(min0, min1);
  636. max1 = (v16u8)__msa_sldi_b((v16i8)max1, (v16i8)max0, 1);
  637. max0 = __msa_max_u_b(max0, max1);
  638. *min = min0[0];
  639. *max = max0[0];
  640. }