dec_mips32.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. // Copyright 2014 Google Inc. All Rights Reserved.
  2. //
  3. // Use of this source code is governed by a BSD-style license
  4. // that can be found in the COPYING file in the root of the source
  5. // tree. An additional intellectual property rights grant can be found
  6. // in the file PATENTS. All contributing project authors may
  7. // be found in the AUTHORS file in the root of the source tree.
  8. // -----------------------------------------------------------------------------
  9. //
  10. // MIPS version of dsp functions
  11. //
  12. // Author(s): Djordje Pesut (djordje.pesut@imgtec.com)
  13. // Jovan Zelincevic (jovan.zelincevic@imgtec.com)
  14. #include "./dsp.h"
  15. #if defined(WEBP_USE_MIPS32)
  16. #include "./mips_macro.h"
  17. static const int kC1 = 20091 + (1 << 16);
  18. static const int kC2 = 35468;
  19. static WEBP_INLINE int abs_mips32(int x) {
  20. const int sign = x >> 31;
  21. return (x ^ sign) - sign;
  22. }
  23. // 4 pixels in, 2 pixels out
  24. static WEBP_INLINE void do_filter2(uint8_t* p, int step) {
  25. const int p1 = p[-2 * step], p0 = p[-step], q0 = p[0], q1 = p[step];
  26. const int a = 3 * (q0 - p0) + VP8ksclip1[p1 - q1];
  27. const int a1 = VP8ksclip2[(a + 4) >> 3];
  28. const int a2 = VP8ksclip2[(a + 3) >> 3];
  29. p[-step] = VP8kclip1[p0 + a2];
  30. p[ 0] = VP8kclip1[q0 - a1];
  31. }
  32. // 4 pixels in, 4 pixels out
  33. static WEBP_INLINE void do_filter4(uint8_t* p, int step) {
  34. const int p1 = p[-2 * step], p0 = p[-step], q0 = p[0], q1 = p[step];
  35. const int a = 3 * (q0 - p0);
  36. const int a1 = VP8ksclip2[(a + 4) >> 3];
  37. const int a2 = VP8ksclip2[(a + 3) >> 3];
  38. const int a3 = (a1 + 1) >> 1;
  39. p[-2 * step] = VP8kclip1[p1 + a3];
  40. p[- step] = VP8kclip1[p0 + a2];
  41. p[ 0] = VP8kclip1[q0 - a1];
  42. p[ step] = VP8kclip1[q1 - a3];
  43. }
  44. // 6 pixels in, 6 pixels out
  45. static WEBP_INLINE void do_filter6(uint8_t* p, int step) {
  46. const int p2 = p[-3 * step], p1 = p[-2 * step], p0 = p[-step];
  47. const int q0 = p[0], q1 = p[step], q2 = p[2 * step];
  48. const int a = VP8ksclip1[3 * (q0 - p0) + VP8ksclip1[p1 - q1]];
  49. // a is in [-128,127], a1 in [-27,27], a2 in [-18,18] and a3 in [-9,9]
  50. const int a1 = (27 * a + 63) >> 7; // eq. to ((3 * a + 7) * 9) >> 7
  51. const int a2 = (18 * a + 63) >> 7; // eq. to ((2 * a + 7) * 9) >> 7
  52. const int a3 = (9 * a + 63) >> 7; // eq. to ((1 * a + 7) * 9) >> 7
  53. p[-3 * step] = VP8kclip1[p2 + a3];
  54. p[-2 * step] = VP8kclip1[p1 + a2];
  55. p[- step] = VP8kclip1[p0 + a1];
  56. p[ 0] = VP8kclip1[q0 - a1];
  57. p[ step] = VP8kclip1[q1 - a2];
  58. p[ 2 * step] = VP8kclip1[q2 - a3];
  59. }
  60. static WEBP_INLINE int hev(const uint8_t* p, int step, int thresh) {
  61. const int p1 = p[-2 * step], p0 = p[-step], q0 = p[0], q1 = p[step];
  62. return (abs_mips32(p1 - p0) > thresh) || (abs_mips32(q1 - q0) > thresh);
  63. }
  64. static WEBP_INLINE int needs_filter(const uint8_t* p, int step, int t) {
  65. const int p1 = p[-2 * step], p0 = p[-step], q0 = p[0], q1 = p[step];
  66. return ((4 * abs_mips32(p0 - q0) + abs_mips32(p1 - q1)) <= t);
  67. }
  68. static WEBP_INLINE int needs_filter2(const uint8_t* p,
  69. int step, int t, int it) {
  70. const int p3 = p[-4 * step], p2 = p[-3 * step];
  71. const int p1 = p[-2 * step], p0 = p[-step];
  72. const int q0 = p[0], q1 = p[step], q2 = p[2 * step], q3 = p[3 * step];
  73. if ((4 * abs_mips32(p0 - q0) + abs_mips32(p1 - q1)) > t) {
  74. return 0;
  75. }
  76. return abs_mips32(p3 - p2) <= it && abs_mips32(p2 - p1) <= it &&
  77. abs_mips32(p1 - p0) <= it && abs_mips32(q3 - q2) <= it &&
  78. abs_mips32(q2 - q1) <= it && abs_mips32(q1 - q0) <= it;
  79. }
  80. static WEBP_INLINE void FilterLoop26(uint8_t* p,
  81. int hstride, int vstride, int size,
  82. int thresh, int ithresh, int hev_thresh) {
  83. const int thresh2 = 2 * thresh + 1;
  84. while (size-- > 0) {
  85. if (needs_filter2(p, hstride, thresh2, ithresh)) {
  86. if (hev(p, hstride, hev_thresh)) {
  87. do_filter2(p, hstride);
  88. } else {
  89. do_filter6(p, hstride);
  90. }
  91. }
  92. p += vstride;
  93. }
  94. }
  95. static WEBP_INLINE void FilterLoop24(uint8_t* p,
  96. int hstride, int vstride, int size,
  97. int thresh, int ithresh, int hev_thresh) {
  98. const int thresh2 = 2 * thresh + 1;
  99. while (size-- > 0) {
  100. if (needs_filter2(p, hstride, thresh2, ithresh)) {
  101. if (hev(p, hstride, hev_thresh)) {
  102. do_filter2(p, hstride);
  103. } else {
  104. do_filter4(p, hstride);
  105. }
  106. }
  107. p += vstride;
  108. }
  109. }
  110. // on macroblock edges
  111. static void VFilter16(uint8_t* p, int stride,
  112. int thresh, int ithresh, int hev_thresh) {
  113. FilterLoop26(p, stride, 1, 16, thresh, ithresh, hev_thresh);
  114. }
  115. static void HFilter16(uint8_t* p, int stride,
  116. int thresh, int ithresh, int hev_thresh) {
  117. FilterLoop26(p, 1, stride, 16, thresh, ithresh, hev_thresh);
  118. }
  119. // 8-pixels wide variant, for chroma filtering
  120. static void VFilter8(uint8_t* u, uint8_t* v, int stride,
  121. int thresh, int ithresh, int hev_thresh) {
  122. FilterLoop26(u, stride, 1, 8, thresh, ithresh, hev_thresh);
  123. FilterLoop26(v, stride, 1, 8, thresh, ithresh, hev_thresh);
  124. }
  125. static void HFilter8(uint8_t* u, uint8_t* v, int stride,
  126. int thresh, int ithresh, int hev_thresh) {
  127. FilterLoop26(u, 1, stride, 8, thresh, ithresh, hev_thresh);
  128. FilterLoop26(v, 1, stride, 8, thresh, ithresh, hev_thresh);
  129. }
  130. static void VFilter8i(uint8_t* u, uint8_t* v, int stride,
  131. int thresh, int ithresh, int hev_thresh) {
  132. FilterLoop24(u + 4 * stride, stride, 1, 8, thresh, ithresh, hev_thresh);
  133. FilterLoop24(v + 4 * stride, stride, 1, 8, thresh, ithresh, hev_thresh);
  134. }
  135. static void HFilter8i(uint8_t* u, uint8_t* v, int stride,
  136. int thresh, int ithresh, int hev_thresh) {
  137. FilterLoop24(u + 4, 1, stride, 8, thresh, ithresh, hev_thresh);
  138. FilterLoop24(v + 4, 1, stride, 8, thresh, ithresh, hev_thresh);
  139. }
  140. // on three inner edges
  141. static void VFilter16i(uint8_t* p, int stride,
  142. int thresh, int ithresh, int hev_thresh) {
  143. int k;
  144. for (k = 3; k > 0; --k) {
  145. p += 4 * stride;
  146. FilterLoop24(p, stride, 1, 16, thresh, ithresh, hev_thresh);
  147. }
  148. }
  149. static void HFilter16i(uint8_t* p, int stride,
  150. int thresh, int ithresh, int hev_thresh) {
  151. int k;
  152. for (k = 3; k > 0; --k) {
  153. p += 4;
  154. FilterLoop24(p, 1, stride, 16, thresh, ithresh, hev_thresh);
  155. }
  156. }
  157. //------------------------------------------------------------------------------
  158. // Simple In-loop filtering (Paragraph 15.2)
  159. static void SimpleVFilter16(uint8_t* p, int stride, int thresh) {
  160. int i;
  161. const int thresh2 = 2 * thresh + 1;
  162. for (i = 0; i < 16; ++i) {
  163. if (needs_filter(p + i, stride, thresh2)) {
  164. do_filter2(p + i, stride);
  165. }
  166. }
  167. }
  168. static void SimpleHFilter16(uint8_t* p, int stride, int thresh) {
  169. int i;
  170. const int thresh2 = 2 * thresh + 1;
  171. for (i = 0; i < 16; ++i) {
  172. if (needs_filter(p + i * stride, 1, thresh2)) {
  173. do_filter2(p + i * stride, 1);
  174. }
  175. }
  176. }
  177. static void SimpleVFilter16i(uint8_t* p, int stride, int thresh) {
  178. int k;
  179. for (k = 3; k > 0; --k) {
  180. p += 4 * stride;
  181. SimpleVFilter16(p, stride, thresh);
  182. }
  183. }
  184. static void SimpleHFilter16i(uint8_t* p, int stride, int thresh) {
  185. int k;
  186. for (k = 3; k > 0; --k) {
  187. p += 4;
  188. SimpleHFilter16(p, stride, thresh);
  189. }
  190. }
  191. static void TransformOne(const int16_t* in, uint8_t* dst) {
  192. int temp0, temp1, temp2, temp3, temp4;
  193. int temp5, temp6, temp7, temp8, temp9;
  194. int temp10, temp11, temp12, temp13, temp14;
  195. int temp15, temp16, temp17, temp18;
  196. int16_t* p_in = (int16_t*)in;
  197. // loops unrolled and merged to avoid usage of tmp buffer
  198. // and to reduce number of stalls. MUL macro is written
  199. // in assembler and inlined
  200. __asm__ volatile(
  201. "lh %[temp0], 0(%[in]) \n\t"
  202. "lh %[temp8], 16(%[in]) \n\t"
  203. "lh %[temp4], 8(%[in]) \n\t"
  204. "lh %[temp12], 24(%[in]) \n\t"
  205. "addu %[temp16], %[temp0], %[temp8] \n\t"
  206. "subu %[temp0], %[temp0], %[temp8] \n\t"
  207. "mul %[temp8], %[temp4], %[kC2] \n\t"
  208. "mul %[temp17], %[temp12], %[kC1] \n\t"
  209. "mul %[temp4], %[temp4], %[kC1] \n\t"
  210. "mul %[temp12], %[temp12], %[kC2] \n\t"
  211. "lh %[temp1], 2(%[in]) \n\t"
  212. "lh %[temp5], 10(%[in]) \n\t"
  213. "lh %[temp9], 18(%[in]) \n\t"
  214. "lh %[temp13], 26(%[in]) \n\t"
  215. "sra %[temp8], %[temp8], 16 \n\t"
  216. "sra %[temp17], %[temp17], 16 \n\t"
  217. "sra %[temp4], %[temp4], 16 \n\t"
  218. "sra %[temp12], %[temp12], 16 \n\t"
  219. "lh %[temp2], 4(%[in]) \n\t"
  220. "lh %[temp6], 12(%[in]) \n\t"
  221. "lh %[temp10], 20(%[in]) \n\t"
  222. "lh %[temp14], 28(%[in]) \n\t"
  223. "subu %[temp17], %[temp8], %[temp17] \n\t"
  224. "addu %[temp4], %[temp4], %[temp12] \n\t"
  225. "addu %[temp8], %[temp16], %[temp4] \n\t"
  226. "subu %[temp4], %[temp16], %[temp4] \n\t"
  227. "addu %[temp16], %[temp1], %[temp9] \n\t"
  228. "subu %[temp1], %[temp1], %[temp9] \n\t"
  229. "lh %[temp3], 6(%[in]) \n\t"
  230. "lh %[temp7], 14(%[in]) \n\t"
  231. "lh %[temp11], 22(%[in]) \n\t"
  232. "lh %[temp15], 30(%[in]) \n\t"
  233. "addu %[temp12], %[temp0], %[temp17] \n\t"
  234. "subu %[temp0], %[temp0], %[temp17] \n\t"
  235. "mul %[temp9], %[temp5], %[kC2] \n\t"
  236. "mul %[temp17], %[temp13], %[kC1] \n\t"
  237. "mul %[temp5], %[temp5], %[kC1] \n\t"
  238. "mul %[temp13], %[temp13], %[kC2] \n\t"
  239. "sra %[temp9], %[temp9], 16 \n\t"
  240. "sra %[temp17], %[temp17], 16 \n\t"
  241. "subu %[temp17], %[temp9], %[temp17] \n\t"
  242. "sra %[temp5], %[temp5], 16 \n\t"
  243. "sra %[temp13], %[temp13], 16 \n\t"
  244. "addu %[temp5], %[temp5], %[temp13] \n\t"
  245. "addu %[temp13], %[temp1], %[temp17] \n\t"
  246. "subu %[temp1], %[temp1], %[temp17] \n\t"
  247. "mul %[temp17], %[temp14], %[kC1] \n\t"
  248. "mul %[temp14], %[temp14], %[kC2] \n\t"
  249. "addu %[temp9], %[temp16], %[temp5] \n\t"
  250. "subu %[temp5], %[temp16], %[temp5] \n\t"
  251. "addu %[temp16], %[temp2], %[temp10] \n\t"
  252. "subu %[temp2], %[temp2], %[temp10] \n\t"
  253. "mul %[temp10], %[temp6], %[kC2] \n\t"
  254. "mul %[temp6], %[temp6], %[kC1] \n\t"
  255. "sra %[temp17], %[temp17], 16 \n\t"
  256. "sra %[temp14], %[temp14], 16 \n\t"
  257. "sra %[temp10], %[temp10], 16 \n\t"
  258. "sra %[temp6], %[temp6], 16 \n\t"
  259. "subu %[temp17], %[temp10], %[temp17] \n\t"
  260. "addu %[temp6], %[temp6], %[temp14] \n\t"
  261. "addu %[temp10], %[temp16], %[temp6] \n\t"
  262. "subu %[temp6], %[temp16], %[temp6] \n\t"
  263. "addu %[temp14], %[temp2], %[temp17] \n\t"
  264. "subu %[temp2], %[temp2], %[temp17] \n\t"
  265. "mul %[temp17], %[temp15], %[kC1] \n\t"
  266. "mul %[temp15], %[temp15], %[kC2] \n\t"
  267. "addu %[temp16], %[temp3], %[temp11] \n\t"
  268. "subu %[temp3], %[temp3], %[temp11] \n\t"
  269. "mul %[temp11], %[temp7], %[kC2] \n\t"
  270. "mul %[temp7], %[temp7], %[kC1] \n\t"
  271. "addiu %[temp8], %[temp8], 4 \n\t"
  272. "addiu %[temp12], %[temp12], 4 \n\t"
  273. "addiu %[temp0], %[temp0], 4 \n\t"
  274. "addiu %[temp4], %[temp4], 4 \n\t"
  275. "sra %[temp17], %[temp17], 16 \n\t"
  276. "sra %[temp15], %[temp15], 16 \n\t"
  277. "sra %[temp11], %[temp11], 16 \n\t"
  278. "sra %[temp7], %[temp7], 16 \n\t"
  279. "subu %[temp17], %[temp11], %[temp17] \n\t"
  280. "addu %[temp7], %[temp7], %[temp15] \n\t"
  281. "addu %[temp15], %[temp3], %[temp17] \n\t"
  282. "subu %[temp3], %[temp3], %[temp17] \n\t"
  283. "addu %[temp11], %[temp16], %[temp7] \n\t"
  284. "subu %[temp7], %[temp16], %[temp7] \n\t"
  285. "addu %[temp16], %[temp8], %[temp10] \n\t"
  286. "subu %[temp8], %[temp8], %[temp10] \n\t"
  287. "mul %[temp10], %[temp9], %[kC2] \n\t"
  288. "mul %[temp17], %[temp11], %[kC1] \n\t"
  289. "mul %[temp9], %[temp9], %[kC1] \n\t"
  290. "mul %[temp11], %[temp11], %[kC2] \n\t"
  291. "sra %[temp10], %[temp10], 16 \n\t"
  292. "sra %[temp17], %[temp17], 16 \n\t"
  293. "sra %[temp9], %[temp9], 16 \n\t"
  294. "sra %[temp11], %[temp11], 16 \n\t"
  295. "subu %[temp17], %[temp10], %[temp17] \n\t"
  296. "addu %[temp11], %[temp9], %[temp11] \n\t"
  297. "addu %[temp10], %[temp12], %[temp14] \n\t"
  298. "subu %[temp12], %[temp12], %[temp14] \n\t"
  299. "mul %[temp14], %[temp13], %[kC2] \n\t"
  300. "mul %[temp9], %[temp15], %[kC1] \n\t"
  301. "mul %[temp13], %[temp13], %[kC1] \n\t"
  302. "mul %[temp15], %[temp15], %[kC2] \n\t"
  303. "sra %[temp14], %[temp14], 16 \n\t"
  304. "sra %[temp9], %[temp9], 16 \n\t"
  305. "sra %[temp13], %[temp13], 16 \n\t"
  306. "sra %[temp15], %[temp15], 16 \n\t"
  307. "subu %[temp9], %[temp14], %[temp9] \n\t"
  308. "addu %[temp15], %[temp13], %[temp15] \n\t"
  309. "addu %[temp14], %[temp0], %[temp2] \n\t"
  310. "subu %[temp0], %[temp0], %[temp2] \n\t"
  311. "mul %[temp2], %[temp1], %[kC2] \n\t"
  312. "mul %[temp13], %[temp3], %[kC1] \n\t"
  313. "mul %[temp1], %[temp1], %[kC1] \n\t"
  314. "mul %[temp3], %[temp3], %[kC2] \n\t"
  315. "sra %[temp2], %[temp2], 16 \n\t"
  316. "sra %[temp13], %[temp13], 16 \n\t"
  317. "sra %[temp1], %[temp1], 16 \n\t"
  318. "sra %[temp3], %[temp3], 16 \n\t"
  319. "subu %[temp13], %[temp2], %[temp13] \n\t"
  320. "addu %[temp3], %[temp1], %[temp3] \n\t"
  321. "addu %[temp2], %[temp4], %[temp6] \n\t"
  322. "subu %[temp4], %[temp4], %[temp6] \n\t"
  323. "mul %[temp6], %[temp5], %[kC2] \n\t"
  324. "mul %[temp1], %[temp7], %[kC1] \n\t"
  325. "mul %[temp5], %[temp5], %[kC1] \n\t"
  326. "mul %[temp7], %[temp7], %[kC2] \n\t"
  327. "sra %[temp6], %[temp6], 16 \n\t"
  328. "sra %[temp1], %[temp1], 16 \n\t"
  329. "sra %[temp5], %[temp5], 16 \n\t"
  330. "sra %[temp7], %[temp7], 16 \n\t"
  331. "subu %[temp1], %[temp6], %[temp1] \n\t"
  332. "addu %[temp7], %[temp5], %[temp7] \n\t"
  333. "addu %[temp5], %[temp16], %[temp11] \n\t"
  334. "subu %[temp16], %[temp16], %[temp11] \n\t"
  335. "addu %[temp11], %[temp8], %[temp17] \n\t"
  336. "subu %[temp8], %[temp8], %[temp17] \n\t"
  337. "sra %[temp5], %[temp5], 3 \n\t"
  338. "sra %[temp16], %[temp16], 3 \n\t"
  339. "sra %[temp11], %[temp11], 3 \n\t"
  340. "sra %[temp8], %[temp8], 3 \n\t"
  341. "addu %[temp17], %[temp10], %[temp15] \n\t"
  342. "subu %[temp10], %[temp10], %[temp15] \n\t"
  343. "addu %[temp15], %[temp12], %[temp9] \n\t"
  344. "subu %[temp12], %[temp12], %[temp9] \n\t"
  345. "sra %[temp17], %[temp17], 3 \n\t"
  346. "sra %[temp10], %[temp10], 3 \n\t"
  347. "sra %[temp15], %[temp15], 3 \n\t"
  348. "sra %[temp12], %[temp12], 3 \n\t"
  349. "addu %[temp9], %[temp14], %[temp3] \n\t"
  350. "subu %[temp14], %[temp14], %[temp3] \n\t"
  351. "addu %[temp3], %[temp0], %[temp13] \n\t"
  352. "subu %[temp0], %[temp0], %[temp13] \n\t"
  353. "sra %[temp9], %[temp9], 3 \n\t"
  354. "sra %[temp14], %[temp14], 3 \n\t"
  355. "sra %[temp3], %[temp3], 3 \n\t"
  356. "sra %[temp0], %[temp0], 3 \n\t"
  357. "addu %[temp13], %[temp2], %[temp7] \n\t"
  358. "subu %[temp2], %[temp2], %[temp7] \n\t"
  359. "addu %[temp7], %[temp4], %[temp1] \n\t"
  360. "subu %[temp4], %[temp4], %[temp1] \n\t"
  361. "sra %[temp13], %[temp13], 3 \n\t"
  362. "sra %[temp2], %[temp2], 3 \n\t"
  363. "sra %[temp7], %[temp7], 3 \n\t"
  364. "sra %[temp4], %[temp4], 3 \n\t"
  365. "addiu %[temp6], $zero, 255 \n\t"
  366. "lbu %[temp1], 0+0*" XSTR(BPS) "(%[dst]) \n\t"
  367. "addu %[temp1], %[temp1], %[temp5] \n\t"
  368. "sra %[temp5], %[temp1], 8 \n\t"
  369. "sra %[temp18], %[temp1], 31 \n\t"
  370. "beqz %[temp5], 1f \n\t"
  371. "xor %[temp1], %[temp1], %[temp1] \n\t"
  372. "movz %[temp1], %[temp6], %[temp18] \n\t"
  373. "1: \n\t"
  374. "lbu %[temp18], 1+0*" XSTR(BPS) "(%[dst]) \n\t"
  375. "sb %[temp1], 0+0*" XSTR(BPS) "(%[dst]) \n\t"
  376. "addu %[temp18], %[temp18], %[temp11] \n\t"
  377. "sra %[temp11], %[temp18], 8 \n\t"
  378. "sra %[temp1], %[temp18], 31 \n\t"
  379. "beqz %[temp11], 2f \n\t"
  380. "xor %[temp18], %[temp18], %[temp18] \n\t"
  381. "movz %[temp18], %[temp6], %[temp1] \n\t"
  382. "2: \n\t"
  383. "lbu %[temp1], 2+0*" XSTR(BPS) "(%[dst]) \n\t"
  384. "sb %[temp18], 1+0*" XSTR(BPS) "(%[dst]) \n\t"
  385. "addu %[temp1], %[temp1], %[temp8] \n\t"
  386. "sra %[temp8], %[temp1], 8 \n\t"
  387. "sra %[temp18], %[temp1], 31 \n\t"
  388. "beqz %[temp8], 3f \n\t"
  389. "xor %[temp1], %[temp1], %[temp1] \n\t"
  390. "movz %[temp1], %[temp6], %[temp18] \n\t"
  391. "3: \n\t"
  392. "lbu %[temp18], 3+0*" XSTR(BPS) "(%[dst]) \n\t"
  393. "sb %[temp1], 2+0*" XSTR(BPS) "(%[dst]) \n\t"
  394. "addu %[temp18], %[temp18], %[temp16] \n\t"
  395. "sra %[temp16], %[temp18], 8 \n\t"
  396. "sra %[temp1], %[temp18], 31 \n\t"
  397. "beqz %[temp16], 4f \n\t"
  398. "xor %[temp18], %[temp18], %[temp18] \n\t"
  399. "movz %[temp18], %[temp6], %[temp1] \n\t"
  400. "4: \n\t"
  401. "sb %[temp18], 3+0*" XSTR(BPS) "(%[dst]) \n\t"
  402. "lbu %[temp5], 0+1*" XSTR(BPS) "(%[dst]) \n\t"
  403. "lbu %[temp8], 1+1*" XSTR(BPS) "(%[dst]) \n\t"
  404. "lbu %[temp11], 2+1*" XSTR(BPS) "(%[dst]) \n\t"
  405. "lbu %[temp16], 3+1*" XSTR(BPS) "(%[dst]) \n\t"
  406. "addu %[temp5], %[temp5], %[temp17] \n\t"
  407. "addu %[temp8], %[temp8], %[temp15] \n\t"
  408. "addu %[temp11], %[temp11], %[temp12] \n\t"
  409. "addu %[temp16], %[temp16], %[temp10] \n\t"
  410. "sra %[temp18], %[temp5], 8 \n\t"
  411. "sra %[temp1], %[temp5], 31 \n\t"
  412. "beqz %[temp18], 5f \n\t"
  413. "xor %[temp5], %[temp5], %[temp5] \n\t"
  414. "movz %[temp5], %[temp6], %[temp1] \n\t"
  415. "5: \n\t"
  416. "sra %[temp18], %[temp8], 8 \n\t"
  417. "sra %[temp1], %[temp8], 31 \n\t"
  418. "beqz %[temp18], 6f \n\t"
  419. "xor %[temp8], %[temp8], %[temp8] \n\t"
  420. "movz %[temp8], %[temp6], %[temp1] \n\t"
  421. "6: \n\t"
  422. "sra %[temp18], %[temp11], 8 \n\t"
  423. "sra %[temp1], %[temp11], 31 \n\t"
  424. "sra %[temp17], %[temp16], 8 \n\t"
  425. "sra %[temp15], %[temp16], 31 \n\t"
  426. "beqz %[temp18], 7f \n\t"
  427. "xor %[temp11], %[temp11], %[temp11] \n\t"
  428. "movz %[temp11], %[temp6], %[temp1] \n\t"
  429. "7: \n\t"
  430. "beqz %[temp17], 8f \n\t"
  431. "xor %[temp16], %[temp16], %[temp16] \n\t"
  432. "movz %[temp16], %[temp6], %[temp15] \n\t"
  433. "8: \n\t"
  434. "sb %[temp5], 0+1*" XSTR(BPS) "(%[dst]) \n\t"
  435. "sb %[temp8], 1+1*" XSTR(BPS) "(%[dst]) \n\t"
  436. "sb %[temp11], 2+1*" XSTR(BPS) "(%[dst]) \n\t"
  437. "sb %[temp16], 3+1*" XSTR(BPS) "(%[dst]) \n\t"
  438. "lbu %[temp5], 0+2*" XSTR(BPS) "(%[dst]) \n\t"
  439. "lbu %[temp8], 1+2*" XSTR(BPS) "(%[dst]) \n\t"
  440. "lbu %[temp11], 2+2*" XSTR(BPS) "(%[dst]) \n\t"
  441. "lbu %[temp16], 3+2*" XSTR(BPS) "(%[dst]) \n\t"
  442. "addu %[temp5], %[temp5], %[temp9] \n\t"
  443. "addu %[temp8], %[temp8], %[temp3] \n\t"
  444. "addu %[temp11], %[temp11], %[temp0] \n\t"
  445. "addu %[temp16], %[temp16], %[temp14] \n\t"
  446. "sra %[temp18], %[temp5], 8 \n\t"
  447. "sra %[temp1], %[temp5], 31 \n\t"
  448. "sra %[temp17], %[temp8], 8 \n\t"
  449. "sra %[temp15], %[temp8], 31 \n\t"
  450. "sra %[temp12], %[temp11], 8 \n\t"
  451. "sra %[temp10], %[temp11], 31 \n\t"
  452. "sra %[temp9], %[temp16], 8 \n\t"
  453. "sra %[temp3], %[temp16], 31 \n\t"
  454. "beqz %[temp18], 9f \n\t"
  455. "xor %[temp5], %[temp5], %[temp5] \n\t"
  456. "movz %[temp5], %[temp6], %[temp1] \n\t"
  457. "9: \n\t"
  458. "beqz %[temp17], 10f \n\t"
  459. "xor %[temp8], %[temp8], %[temp8] \n\t"
  460. "movz %[temp8], %[temp6], %[temp15] \n\t"
  461. "10: \n\t"
  462. "beqz %[temp12], 11f \n\t"
  463. "xor %[temp11], %[temp11], %[temp11] \n\t"
  464. "movz %[temp11], %[temp6], %[temp10] \n\t"
  465. "11: \n\t"
  466. "beqz %[temp9], 12f \n\t"
  467. "xor %[temp16], %[temp16], %[temp16] \n\t"
  468. "movz %[temp16], %[temp6], %[temp3] \n\t"
  469. "12: \n\t"
  470. "sb %[temp5], 0+2*" XSTR(BPS) "(%[dst]) \n\t"
  471. "sb %[temp8], 1+2*" XSTR(BPS) "(%[dst]) \n\t"
  472. "sb %[temp11], 2+2*" XSTR(BPS) "(%[dst]) \n\t"
  473. "sb %[temp16], 3+2*" XSTR(BPS) "(%[dst]) \n\t"
  474. "lbu %[temp5], 0+3*" XSTR(BPS) "(%[dst]) \n\t"
  475. "lbu %[temp8], 1+3*" XSTR(BPS) "(%[dst]) \n\t"
  476. "lbu %[temp11], 2+3*" XSTR(BPS) "(%[dst]) \n\t"
  477. "lbu %[temp16], 3+3*" XSTR(BPS) "(%[dst]) \n\t"
  478. "addu %[temp5], %[temp5], %[temp13] \n\t"
  479. "addu %[temp8], %[temp8], %[temp7] \n\t"
  480. "addu %[temp11], %[temp11], %[temp4] \n\t"
  481. "addu %[temp16], %[temp16], %[temp2] \n\t"
  482. "sra %[temp18], %[temp5], 8 \n\t"
  483. "sra %[temp1], %[temp5], 31 \n\t"
  484. "sra %[temp17], %[temp8], 8 \n\t"
  485. "sra %[temp15], %[temp8], 31 \n\t"
  486. "sra %[temp12], %[temp11], 8 \n\t"
  487. "sra %[temp10], %[temp11], 31 \n\t"
  488. "sra %[temp9], %[temp16], 8 \n\t"
  489. "sra %[temp3], %[temp16], 31 \n\t"
  490. "beqz %[temp18], 13f \n\t"
  491. "xor %[temp5], %[temp5], %[temp5] \n\t"
  492. "movz %[temp5], %[temp6], %[temp1] \n\t"
  493. "13: \n\t"
  494. "beqz %[temp17], 14f \n\t"
  495. "xor %[temp8], %[temp8], %[temp8] \n\t"
  496. "movz %[temp8], %[temp6], %[temp15] \n\t"
  497. "14: \n\t"
  498. "beqz %[temp12], 15f \n\t"
  499. "xor %[temp11], %[temp11], %[temp11] \n\t"
  500. "movz %[temp11], %[temp6], %[temp10] \n\t"
  501. "15: \n\t"
  502. "beqz %[temp9], 16f \n\t"
  503. "xor %[temp16], %[temp16], %[temp16] \n\t"
  504. "movz %[temp16], %[temp6], %[temp3] \n\t"
  505. "16: \n\t"
  506. "sb %[temp5], 0+3*" XSTR(BPS) "(%[dst]) \n\t"
  507. "sb %[temp8], 1+3*" XSTR(BPS) "(%[dst]) \n\t"
  508. "sb %[temp11], 2+3*" XSTR(BPS) "(%[dst]) \n\t"
  509. "sb %[temp16], 3+3*" XSTR(BPS) "(%[dst]) \n\t"
  510. : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
  511. [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
  512. [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
  513. [temp9]"=&r"(temp9), [temp10]"=&r"(temp10), [temp11]"=&r"(temp11),
  514. [temp12]"=&r"(temp12), [temp13]"=&r"(temp13), [temp14]"=&r"(temp14),
  515. [temp15]"=&r"(temp15), [temp16]"=&r"(temp16), [temp17]"=&r"(temp17),
  516. [temp18]"=&r"(temp18)
  517. : [in]"r"(p_in), [kC1]"r"(kC1), [kC2]"r"(kC2), [dst]"r"(dst)
  518. : "memory", "hi", "lo"
  519. );
  520. }
  521. static void TransformTwo(const int16_t* in, uint8_t* dst, int do_two) {
  522. TransformOne(in, dst);
  523. if (do_two) {
  524. TransformOne(in + 16, dst + 4);
  525. }
  526. }
  527. //------------------------------------------------------------------------------
  528. // Entry point
  529. extern void VP8DspInitMIPS32(void);
  530. WEBP_TSAN_IGNORE_FUNCTION void VP8DspInitMIPS32(void) {
  531. VP8InitClipTables();
  532. VP8Transform = TransformTwo;
  533. VP8VFilter16 = VFilter16;
  534. VP8HFilter16 = HFilter16;
  535. VP8VFilter8 = VFilter8;
  536. VP8HFilter8 = HFilter8;
  537. VP8VFilter16i = VFilter16i;
  538. VP8HFilter16i = HFilter16i;
  539. VP8VFilter8i = VFilter8i;
  540. VP8HFilter8i = HFilter8i;
  541. VP8SimpleVFilter16 = SimpleVFilter16;
  542. VP8SimpleHFilter16 = SimpleHFilter16;
  543. VP8SimpleVFilter16i = SimpleVFilter16i;
  544. VP8SimpleHFilter16i = SimpleHFilter16i;
  545. }
  546. #else // !WEBP_USE_MIPS32
  547. WEBP_DSP_INIT_STUB(VP8DspInitMIPS32)
  548. #endif // WEBP_USE_MIPS32