itrans8_dspr2.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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_config.h"
  11. #include "./vpx_dsp_rtcd.h"
  12. #include "vpx_dsp/mips/inv_txfm_dspr2.h"
  13. #include "vpx_dsp/txfm_common.h"
  14. #if HAVE_DSPR2
  15. void idct8_rows_dspr2(const int16_t *input, int16_t *output, uint32_t no_rows) {
  16. int step1_0, step1_1, step1_2, step1_3, step1_4, step1_5, step1_6, step1_7;
  17. const int const_2_power_13 = 8192;
  18. int Temp0, Temp1, Temp2, Temp3, Temp4;
  19. int i;
  20. for (i = no_rows; i--;) {
  21. __asm__ __volatile__(
  22. /*
  23. temp_1 = (input[0] + input[4]) * cospi_16_64;
  24. step2_0 = dct_const_round_shift(temp_1);
  25. temp_2 = (input[0] - input[4]) * cospi_16_64;
  26. step2_1 = dct_const_round_shift(temp_2);
  27. */
  28. "lh %[Temp0], 0(%[input]) \n\t"
  29. "lh %[Temp1], 8(%[input]) \n\t"
  30. "mtlo %[const_2_power_13], $ac0 \n\t"
  31. "mthi $zero, $ac0 \n\t"
  32. "mtlo %[const_2_power_13], $ac1 \n\t"
  33. "mthi $zero, $ac1 \n\t"
  34. "add %[Temp2], %[Temp0], %[Temp1] \n\t"
  35. "madd $ac0, %[Temp2], %[cospi_16_64] \n\t"
  36. "extp %[Temp4], $ac0, 31 \n\t"
  37. "sub %[Temp3], %[Temp0], %[Temp1] \n\t"
  38. "madd $ac1, %[Temp3], %[cospi_16_64] \n\t"
  39. "mtlo %[const_2_power_13], $ac0 \n\t"
  40. "mthi $zero, $ac0 \n\t"
  41. "extp %[Temp2], $ac1, 31 \n\t"
  42. /*
  43. temp_1 = input[2] * cospi_24_64 - input[6] * cospi_8_64;
  44. step2_2 = dct_const_round_shift(temp_1);
  45. */
  46. "lh %[Temp0], 4(%[input]) \n\t"
  47. "lh %[Temp1], 12(%[input]) \n\t"
  48. "madd $ac0, %[Temp0], %[cospi_24_64] \n\t"
  49. "msub $ac0, %[Temp1], %[cospi_8_64] \n\t"
  50. "mtlo %[const_2_power_13], $ac1 \n\t"
  51. "mthi $zero, $ac1 \n\t"
  52. "extp %[Temp3], $ac0, 31 \n\t"
  53. /*
  54. step1_1 = step2_1 + step2_2;
  55. step1_2 = step2_1 - step2_2;
  56. */
  57. "add %[step1_1], %[Temp2], %[Temp3] \n\t"
  58. "sub %[step1_2], %[Temp2], %[Temp3] \n\t"
  59. /*
  60. temp_2 = input[2] * cospi_8_64 + input[6] * cospi_24_64;
  61. step2_3 = dct_const_round_shift(temp_2);
  62. */
  63. "madd $ac1, %[Temp0], %[cospi_8_64] \n\t"
  64. "madd $ac1, %[Temp1], %[cospi_24_64] \n\t"
  65. "extp %[Temp1], $ac1, 31 \n\t"
  66. "mtlo %[const_2_power_13], $ac0 \n\t"
  67. "mthi $zero, $ac0 \n\t"
  68. /*
  69. step1_0 = step2_0 + step2_3;
  70. step1_3 = step2_0 - step2_3;
  71. */
  72. "add %[step1_0], %[Temp4], %[Temp1] \n\t"
  73. "sub %[step1_3], %[Temp4], %[Temp1] \n\t"
  74. /*
  75. temp_1 = input[1] * cospi_28_64 - input[7] * cospi_4_64;
  76. step1_4 = dct_const_round_shift(temp_1);
  77. */
  78. "lh %[Temp0], 2(%[input]) \n\t"
  79. "madd $ac0, %[Temp0], %[cospi_28_64] \n\t"
  80. "mtlo %[const_2_power_13], $ac1 \n\t"
  81. "mthi $zero, $ac1 \n\t"
  82. "lh %[Temp1], 14(%[input]) \n\t"
  83. "lh %[Temp0], 2(%[input]) \n\t"
  84. "msub $ac0, %[Temp1], %[cospi_4_64] \n\t"
  85. "extp %[step1_4], $ac0, 31 \n\t"
  86. /*
  87. temp_2 = input[1] * cospi_4_64 + input[7] * cospi_28_64;
  88. step1_7 = dct_const_round_shift(temp_2);
  89. */
  90. "madd $ac1, %[Temp0], %[cospi_4_64] \n\t"
  91. "madd $ac1, %[Temp1], %[cospi_28_64] \n\t"
  92. "extp %[step1_7], $ac1, 31 \n\t"
  93. /*
  94. temp_1 = input[5] * cospi_12_64 - input[3] * cospi_20_64;
  95. step1_5 = dct_const_round_shift(temp_1);
  96. */
  97. "mtlo %[const_2_power_13], $ac0 \n\t"
  98. "mthi $zero, $ac0 \n\t"
  99. "lh %[Temp0], 10(%[input]) \n\t"
  100. "madd $ac0, %[Temp0], %[cospi_12_64] \n\t"
  101. "lh %[Temp1], 6(%[input]) \n\t"
  102. "msub $ac0, %[Temp1], %[cospi_20_64] \n\t"
  103. "extp %[step1_5], $ac0, 31 \n\t"
  104. /*
  105. temp_2 = input[5] * cospi_20_64 + input[3] * cospi_12_64;
  106. step1_6 = dct_const_round_shift(temp_2);
  107. */
  108. "mtlo %[const_2_power_13], $ac1 \n\t"
  109. "mthi $zero, $ac1 \n\t"
  110. "lh %[Temp0], 10(%[input]) \n\t"
  111. "madd $ac1, %[Temp0], %[cospi_20_64] \n\t"
  112. "lh %[Temp1], 6(%[input]) \n\t"
  113. "madd $ac1, %[Temp1], %[cospi_12_64] \n\t"
  114. "extp %[step1_6], $ac1, 31 \n\t"
  115. /*
  116. temp_1 = (step1_7 - step1_6 - step1_4 + step1_5) * cospi_16_64;
  117. temp_2 = (step1_4 - step1_5 - step1_6 + step1_7) * cospi_16_64;
  118. */
  119. "sub %[Temp0], %[step1_7], %[step1_6] \n\t"
  120. "sub %[Temp0], %[Temp0], %[step1_4] \n\t"
  121. "add %[Temp0], %[Temp0], %[step1_5] \n\t"
  122. "sub %[Temp1], %[step1_4], %[step1_5] \n\t"
  123. "sub %[Temp1], %[Temp1], %[step1_6] \n\t"
  124. "add %[Temp1], %[Temp1], %[step1_7] \n\t"
  125. "mtlo %[const_2_power_13], $ac0 \n\t"
  126. "mthi $zero, $ac0 \n\t"
  127. "mtlo %[const_2_power_13], $ac1 \n\t"
  128. "mthi $zero, $ac1 \n\t"
  129. "madd $ac0, %[Temp0], %[cospi_16_64] \n\t"
  130. "madd $ac1, %[Temp1], %[cospi_16_64] \n\t"
  131. /*
  132. step1_4 = step1_4 + step1_5;
  133. step1_7 = step1_6 + step1_7;
  134. */
  135. "add %[step1_4], %[step1_4], %[step1_5] \n\t"
  136. "add %[step1_7], %[step1_7], %[step1_6] \n\t"
  137. "extp %[step1_5], $ac0, 31 \n\t"
  138. "extp %[step1_6], $ac1, 31 \n\t"
  139. "add %[Temp0], %[step1_0], %[step1_7] \n\t"
  140. "sh %[Temp0], 0(%[output]) \n\t"
  141. "add %[Temp1], %[step1_1], %[step1_6] \n\t"
  142. "sh %[Temp1], 16(%[output]) \n\t"
  143. "add %[Temp0], %[step1_2], %[step1_5] \n\t"
  144. "sh %[Temp0], 32(%[output]) \n\t"
  145. "add %[Temp1], %[step1_3], %[step1_4] \n\t"
  146. "sh %[Temp1], 48(%[output]) \n\t"
  147. "sub %[Temp0], %[step1_3], %[step1_4] \n\t"
  148. "sh %[Temp0], 64(%[output]) \n\t"
  149. "sub %[Temp1], %[step1_2], %[step1_5] \n\t"
  150. "sh %[Temp1], 80(%[output]) \n\t"
  151. "sub %[Temp0], %[step1_1], %[step1_6] \n\t"
  152. "sh %[Temp0], 96(%[output]) \n\t"
  153. "sub %[Temp1], %[step1_0], %[step1_7] \n\t"
  154. "sh %[Temp1], 112(%[output]) \n\t"
  155. : [step1_0] "=&r"(step1_0), [step1_1] "=&r"(step1_1),
  156. [step1_2] "=&r"(step1_2), [step1_3] "=&r"(step1_3),
  157. [step1_4] "=&r"(step1_4), [step1_5] "=&r"(step1_5),
  158. [step1_6] "=&r"(step1_6), [step1_7] "=&r"(step1_7),
  159. [Temp0] "=&r"(Temp0), [Temp1] "=&r"(Temp1), [Temp2] "=&r"(Temp2),
  160. [Temp3] "=&r"(Temp3), [Temp4] "=&r"(Temp4)
  161. : [const_2_power_13] "r"(const_2_power_13),
  162. [cospi_16_64] "r"(cospi_16_64), [cospi_28_64] "r"(cospi_28_64),
  163. [cospi_4_64] "r"(cospi_4_64), [cospi_12_64] "r"(cospi_12_64),
  164. [cospi_20_64] "r"(cospi_20_64), [cospi_8_64] "r"(cospi_8_64),
  165. [cospi_24_64] "r"(cospi_24_64), [output] "r"(output),
  166. [input] "r"(input));
  167. input += 8;
  168. output += 1;
  169. }
  170. }
  171. void idct8_columns_add_blk_dspr2(int16_t *input, uint8_t *dest, int stride) {
  172. int step1_0, step1_1, step1_2, step1_3, step1_4, step1_5, step1_6, step1_7;
  173. int Temp0, Temp1, Temp2, Temp3;
  174. int i;
  175. const int const_2_power_13 = 8192;
  176. const int const_255 = 255;
  177. uint8_t *dest_pix;
  178. for (i = 0; i < 8; ++i) {
  179. dest_pix = (dest + i);
  180. __asm__ __volatile__(
  181. /*
  182. temp_1 = (input[0] + input[4]) * cospi_16_64;
  183. step2_0 = dct_const_round_shift(temp_1);
  184. temp_2 = (input[0] - input[4]) * cospi_16_64;
  185. step2_1 = dct_const_round_shift(temp_2);
  186. */
  187. "lh %[Temp0], 0(%[input]) \n\t"
  188. "lh %[Temp1], 8(%[input]) \n\t"
  189. "mtlo %[const_2_power_13], $ac0 \n\t"
  190. "mthi $zero, $ac0 \n\t"
  191. "mtlo %[const_2_power_13], $ac1 \n\t"
  192. "mthi $zero, $ac1 \n\t"
  193. "add %[Temp2], %[Temp0], %[Temp1] \n\t"
  194. "madd $ac0, %[Temp2], %[cospi_16_64] \n\t"
  195. "extp %[step1_6], $ac0, 31 \n\t"
  196. "sub %[Temp3], %[Temp0], %[Temp1] \n\t"
  197. "madd $ac1, %[Temp3], %[cospi_16_64] \n\t"
  198. "mtlo %[const_2_power_13], $ac0 \n\t"
  199. "mthi $zero, $ac0 \n\t"
  200. "extp %[Temp2], $ac1, 31 \n\t"
  201. /*
  202. temp_1 = input[2] * cospi_24_64 - input[6] * cospi_8_64;
  203. step2_2 = dct_const_round_shift(temp_1);
  204. */
  205. "lh %[Temp0], 4(%[input]) \n\t"
  206. "lh %[Temp1], 12(%[input]) \n\t"
  207. "madd $ac0, %[Temp0], %[cospi_24_64] \n\t"
  208. "msub $ac0, %[Temp1], %[cospi_8_64] \n\t"
  209. "mtlo %[const_2_power_13], $ac1 \n\t"
  210. "mthi $zero, $ac1 \n\t"
  211. "extp %[Temp3], $ac0, 31 \n\t"
  212. /*
  213. step1_1 = step2_1 + step2_2;
  214. step1_2 = step2_1 - step2_2;
  215. */
  216. "add %[step1_1], %[Temp2], %[Temp3] \n\t"
  217. "sub %[step1_2], %[Temp2], %[Temp3] \n\t"
  218. /*
  219. temp_2 = input[2] * cospi_8_64 + input[6] * cospi_24_64;
  220. step2_3 = dct_const_round_shift(temp_2);
  221. */
  222. "madd $ac1, %[Temp0], %[cospi_8_64] \n\t"
  223. "madd $ac1, %[Temp1], %[cospi_24_64] \n\t"
  224. "extp %[Temp1], $ac1, 31 \n\t"
  225. "mtlo %[const_2_power_13], $ac0 \n\t"
  226. "mthi $zero, $ac0 \n\t"
  227. /*
  228. step1_0 = step2_0 + step2_3;
  229. step1_3 = step2_0 - step2_3;
  230. */
  231. "add %[step1_0], %[step1_6], %[Temp1] \n\t"
  232. "sub %[step1_3], %[step1_6], %[Temp1] \n\t"
  233. /*
  234. temp_1 = input[1] * cospi_28_64 - input[7] * cospi_4_64;
  235. step1_4 = dct_const_round_shift(temp_1);
  236. */
  237. "lh %[Temp0], 2(%[input]) \n\t"
  238. "madd $ac0, %[Temp0], %[cospi_28_64] \n\t"
  239. "mtlo %[const_2_power_13], $ac1 \n\t"
  240. "mthi $zero, $ac1 \n\t"
  241. "lh %[Temp1], 14(%[input]) \n\t"
  242. "lh %[Temp0], 2(%[input]) \n\t"
  243. "msub $ac0, %[Temp1], %[cospi_4_64] \n\t"
  244. "extp %[step1_4], $ac0, 31 \n\t"
  245. /*
  246. temp_2 = input[1] * cospi_4_64 + input[7] * cospi_28_64;
  247. step1_7 = dct_const_round_shift(temp_2);
  248. */
  249. "madd $ac1, %[Temp0], %[cospi_4_64] \n\t"
  250. "madd $ac1, %[Temp1], %[cospi_28_64] \n\t"
  251. "extp %[step1_7], $ac1, 31 \n\t"
  252. /*
  253. temp_1 = input[5] * cospi_12_64 - input[3] * cospi_20_64;
  254. step1_5 = dct_const_round_shift(temp_1);
  255. */
  256. "mtlo %[const_2_power_13], $ac0 \n\t"
  257. "mthi $zero, $ac0 \n\t"
  258. "lh %[Temp0], 10(%[input]) \n\t"
  259. "madd $ac0, %[Temp0], %[cospi_12_64] \n\t"
  260. "lh %[Temp1], 6(%[input]) \n\t"
  261. "msub $ac0, %[Temp1], %[cospi_20_64] \n\t"
  262. "extp %[step1_5], $ac0, 31 \n\t"
  263. /*
  264. temp_2 = input[5] * cospi_20_64 + input[3] * cospi_12_64;
  265. step1_6 = dct_const_round_shift(temp_2);
  266. */
  267. "mtlo %[const_2_power_13], $ac1 \n\t"
  268. "mthi $zero, $ac1 \n\t"
  269. "lh %[Temp0], 10(%[input]) \n\t"
  270. "madd $ac1, %[Temp0], %[cospi_20_64] \n\t"
  271. "lh %[Temp1], 6(%[input]) \n\t"
  272. "madd $ac1, %[Temp1], %[cospi_12_64] \n\t"
  273. "extp %[step1_6], $ac1, 31 \n\t"
  274. /*
  275. temp_1 = (step1_7 - step1_6 - step1_4 + step1_5) * cospi_16_64;
  276. temp_2 = (step1_4 - step1_5 - step1_6 + step1_7) * cospi_16_64;
  277. */
  278. "sub %[Temp0], %[step1_7], %[step1_6] \n\t"
  279. "sub %[Temp0], %[Temp0], %[step1_4] \n\t"
  280. "add %[Temp0], %[Temp0], %[step1_5] \n\t"
  281. "sub %[Temp1], %[step1_4], %[step1_5] \n\t"
  282. "sub %[Temp1], %[Temp1], %[step1_6] \n\t"
  283. "add %[Temp1], %[Temp1], %[step1_7] \n\t"
  284. "mtlo %[const_2_power_13], $ac0 \n\t"
  285. "mthi $zero, $ac0 \n\t"
  286. "mtlo %[const_2_power_13], $ac1 \n\t"
  287. "mthi $zero, $ac1 \n\t"
  288. "madd $ac0, %[Temp0], %[cospi_16_64] \n\t"
  289. "madd $ac1, %[Temp1], %[cospi_16_64] \n\t"
  290. /*
  291. step1_4 = step1_4 + step1_5;
  292. step1_7 = step1_6 + step1_7;
  293. */
  294. "add %[step1_4], %[step1_4], %[step1_5] \n\t"
  295. "add %[step1_7], %[step1_7], %[step1_6] \n\t"
  296. "extp %[step1_5], $ac0, 31 \n\t"
  297. "extp %[step1_6], $ac1, 31 \n\t"
  298. /* add block */
  299. "lbu %[Temp1], 0(%[dest_pix]) \n\t"
  300. "add %[Temp0], %[step1_0], %[step1_7] \n\t"
  301. "addi %[Temp0], %[Temp0], 16 \n\t"
  302. "sra %[Temp0], %[Temp0], 5 \n\t"
  303. "add %[Temp1], %[Temp1], %[Temp0] \n\t"
  304. "add %[Temp0], %[step1_1], %[step1_6] \n\t"
  305. "slt %[Temp2], %[Temp1], %[const_255] \n\t"
  306. "slt %[Temp3], $zero, %[Temp1] \n\t"
  307. "movz %[Temp1], %[const_255], %[Temp2] \n\t"
  308. "movz %[Temp1], $zero, %[Temp3] \n\t"
  309. "sb %[Temp1], 0(%[dest_pix]) \n\t"
  310. "addu %[dest_pix], %[dest_pix], %[stride] \n\t"
  311. "lbu %[Temp1], 0(%[dest_pix]) \n\t"
  312. "addi %[Temp0], %[Temp0], 16 \n\t"
  313. "sra %[Temp0], %[Temp0], 5 \n\t"
  314. "add %[Temp1], %[Temp1], %[Temp0] \n\t"
  315. "add %[Temp0], %[step1_2], %[step1_5] \n\t"
  316. "slt %[Temp2], %[Temp1], %[const_255] \n\t"
  317. "slt %[Temp3], $zero, %[Temp1] \n\t"
  318. "movz %[Temp1], %[const_255], %[Temp2] \n\t"
  319. "movz %[Temp1], $zero, %[Temp3] \n\t"
  320. "sb %[Temp1], 0(%[dest_pix]) \n\t"
  321. "addu %[dest_pix], %[dest_pix], %[stride] \n\t"
  322. "lbu %[Temp1], 0(%[dest_pix]) \n\t"
  323. "addi %[Temp0], %[Temp0], 16 \n\t"
  324. "sra %[Temp0], %[Temp0], 5 \n\t"
  325. "add %[Temp1], %[Temp1], %[Temp0] \n\t"
  326. "add %[Temp0], %[step1_3], %[step1_4] \n\t"
  327. "slt %[Temp2], %[Temp1], %[const_255] \n\t"
  328. "slt %[Temp3], $zero, %[Temp1] \n\t"
  329. "movz %[Temp1], %[const_255], %[Temp2] \n\t"
  330. "movz %[Temp1], $zero, %[Temp3] \n\t"
  331. "sb %[Temp1], 0(%[dest_pix]) \n\t"
  332. "addu %[dest_pix], %[dest_pix], %[stride] \n\t"
  333. "lbu %[Temp1], 0(%[dest_pix]) \n\t"
  334. "addi %[Temp0], %[Temp0], 16 \n\t"
  335. "sra %[Temp0], %[Temp0], 5 \n\t"
  336. "add %[Temp1], %[Temp1], %[Temp0] \n\t"
  337. "sub %[Temp0], %[step1_3], %[step1_4] \n\t"
  338. "slt %[Temp2], %[Temp1], %[const_255] \n\t"
  339. "slt %[Temp3], $zero, %[Temp1] \n\t"
  340. "movz %[Temp1], %[const_255], %[Temp2] \n\t"
  341. "movz %[Temp1], $zero, %[Temp3] \n\t"
  342. "sb %[Temp1], 0(%[dest_pix]) \n\t"
  343. "addu %[dest_pix], %[dest_pix], %[stride] \n\t"
  344. "lbu %[Temp1], 0(%[dest_pix]) \n\t"
  345. "addi %[Temp0], %[Temp0], 16 \n\t"
  346. "sra %[Temp0], %[Temp0], 5 \n\t"
  347. "add %[Temp1], %[Temp1], %[Temp0] \n\t"
  348. "sub %[Temp0], %[step1_2], %[step1_5] \n\t"
  349. "slt %[Temp2], %[Temp1], %[const_255] \n\t"
  350. "slt %[Temp3], $zero, %[Temp1] \n\t"
  351. "movz %[Temp1], %[const_255], %[Temp2] \n\t"
  352. "movz %[Temp1], $zero, %[Temp3] \n\t"
  353. "sb %[Temp1], 0(%[dest_pix]) \n\t"
  354. "addu %[dest_pix], %[dest_pix], %[stride] \n\t"
  355. "lbu %[Temp1], 0(%[dest_pix]) \n\t"
  356. "addi %[Temp0], %[Temp0], 16 \n\t"
  357. "sra %[Temp0], %[Temp0], 5 \n\t"
  358. "add %[Temp1], %[Temp1], %[Temp0] \n\t"
  359. "sub %[Temp0], %[step1_1], %[step1_6] \n\t"
  360. "slt %[Temp2], %[Temp1], %[const_255] \n\t"
  361. "slt %[Temp3], $zero, %[Temp1] \n\t"
  362. "movz %[Temp1], %[const_255], %[Temp2] \n\t"
  363. "movz %[Temp1], $zero, %[Temp3] \n\t"
  364. "sb %[Temp1], 0(%[dest_pix]) \n\t"
  365. "addu %[dest_pix], %[dest_pix], %[stride] \n\t"
  366. "lbu %[Temp1], 0(%[dest_pix]) \n\t"
  367. "addi %[Temp0], %[Temp0], 16 \n\t"
  368. "sra %[Temp0], %[Temp0], 5 \n\t"
  369. "add %[Temp1], %[Temp1], %[Temp0] \n\t"
  370. "sub %[Temp0], %[step1_0], %[step1_7] \n\t"
  371. "slt %[Temp2], %[Temp1], %[const_255] \n\t"
  372. "slt %[Temp3], $zero, %[Temp1] \n\t"
  373. "movz %[Temp1], %[const_255], %[Temp2] \n\t"
  374. "movz %[Temp1], $zero, %[Temp3] \n\t"
  375. "sb %[Temp1], 0(%[dest_pix]) \n\t"
  376. "addu %[dest_pix], %[dest_pix], %[stride] \n\t"
  377. "lbu %[Temp1], 0(%[dest_pix]) \n\t"
  378. "addi %[Temp0], %[Temp0], 16 \n\t"
  379. "sra %[Temp0], %[Temp0], 5 \n\t"
  380. "add %[Temp1], %[Temp1], %[Temp0] \n\t"
  381. "slt %[Temp2], %[Temp1], %[const_255] \n\t"
  382. "slt %[Temp3], $zero, %[Temp1] \n\t"
  383. "movz %[Temp1], %[const_255], %[Temp2] \n\t"
  384. "movz %[Temp1], $zero, %[Temp3] \n\t"
  385. "sb %[Temp1], 0(%[dest_pix]) \n\t"
  386. : [step1_0] "=&r"(step1_0), [step1_1] "=&r"(step1_1),
  387. [step1_2] "=&r"(step1_2), [step1_3] "=&r"(step1_3),
  388. [step1_4] "=&r"(step1_4), [step1_5] "=&r"(step1_5),
  389. [step1_6] "=&r"(step1_6), [step1_7] "=&r"(step1_7),
  390. [Temp0] "=&r"(Temp0), [Temp1] "=&r"(Temp1), [Temp2] "=&r"(Temp2),
  391. [Temp3] "=&r"(Temp3), [dest_pix] "+r"(dest_pix)
  392. : [const_2_power_13] "r"(const_2_power_13), [const_255] "r"(const_255),
  393. [cospi_16_64] "r"(cospi_16_64), [cospi_28_64] "r"(cospi_28_64),
  394. [cospi_4_64] "r"(cospi_4_64), [cospi_12_64] "r"(cospi_12_64),
  395. [cospi_20_64] "r"(cospi_20_64), [cospi_8_64] "r"(cospi_8_64),
  396. [cospi_24_64] "r"(cospi_24_64), [input] "r"(input),
  397. [stride] "r"(stride));
  398. input += 8;
  399. }
  400. }
  401. void vpx_idct8x8_64_add_dspr2(const int16_t *input, uint8_t *dest, int stride) {
  402. DECLARE_ALIGNED(32, int16_t, out[8 * 8]);
  403. int16_t *outptr = out;
  404. uint32_t pos = 45;
  405. /* bit positon for extract from acc */
  406. __asm__ __volatile__("wrdsp %[pos], 1 \n\t" : : [pos] "r"(pos));
  407. // First transform rows
  408. idct8_rows_dspr2(input, outptr, 8);
  409. // Then transform columns and add to dest
  410. idct8_columns_add_blk_dspr2(&out[0], dest, stride);
  411. }
  412. void vpx_idct8x8_12_add_dspr2(const int16_t *input, uint8_t *dest, int stride) {
  413. DECLARE_ALIGNED(32, int16_t, out[8 * 8]);
  414. int16_t *outptr = out;
  415. uint32_t pos = 45;
  416. /* bit positon for extract from acc */
  417. __asm__ __volatile__("wrdsp %[pos], 1 \n\t" : : [pos] "r"(pos));
  418. // First transform rows
  419. idct8_rows_dspr2(input, outptr, 4);
  420. outptr += 4;
  421. __asm__ __volatile__(
  422. "sw $zero, 0(%[outptr]) \n\t"
  423. "sw $zero, 4(%[outptr]) \n\t"
  424. "sw $zero, 16(%[outptr]) \n\t"
  425. "sw $zero, 20(%[outptr]) \n\t"
  426. "sw $zero, 32(%[outptr]) \n\t"
  427. "sw $zero, 36(%[outptr]) \n\t"
  428. "sw $zero, 48(%[outptr]) \n\t"
  429. "sw $zero, 52(%[outptr]) \n\t"
  430. "sw $zero, 64(%[outptr]) \n\t"
  431. "sw $zero, 68(%[outptr]) \n\t"
  432. "sw $zero, 80(%[outptr]) \n\t"
  433. "sw $zero, 84(%[outptr]) \n\t"
  434. "sw $zero, 96(%[outptr]) \n\t"
  435. "sw $zero, 100(%[outptr]) \n\t"
  436. "sw $zero, 112(%[outptr]) \n\t"
  437. "sw $zero, 116(%[outptr]) \n\t"
  438. :
  439. : [outptr] "r"(outptr));
  440. // Then transform columns and add to dest
  441. idct8_columns_add_blk_dspr2(&out[0], dest, stride);
  442. }
  443. void vpx_idct8x8_1_add_dspr2(const int16_t *input, uint8_t *dest, int stride) {
  444. uint32_t pos = 45;
  445. int32_t out;
  446. int32_t r;
  447. int32_t a1, absa1;
  448. int32_t t1, t2, vector_a1, vector_1, vector_2;
  449. /* bit positon for extract from acc */
  450. __asm__ __volatile__("wrdsp %[pos], 1 \n\t"
  451. :
  452. : [pos] "r"(pos));
  453. out = DCT_CONST_ROUND_SHIFT_TWICE_COSPI_16_64(input[0]);
  454. __asm__ __volatile__(
  455. "addi %[out], %[out], 16 \n\t"
  456. "sra %[a1], %[out], 5 \n\t"
  457. : [out] "+r"(out), [a1] "=r"(a1)
  458. :);
  459. if (a1 < 0) {
  460. /* use quad-byte
  461. * input and output memory are four byte aligned */
  462. __asm__ __volatile__(
  463. "abs %[absa1], %[a1] \n\t"
  464. "replv.qb %[vector_a1], %[absa1] \n\t"
  465. : [absa1] "=r"(absa1), [vector_a1] "=r"(vector_a1)
  466. : [a1] "r"(a1));
  467. for (r = 8; r--;) {
  468. __asm__ __volatile__(
  469. "lw %[t1], 0(%[dest]) \n\t"
  470. "lw %[t2], 4(%[dest]) \n\t"
  471. "subu_s.qb %[vector_1], %[t1], %[vector_a1] \n\t"
  472. "subu_s.qb %[vector_2], %[t2], %[vector_a1] \n\t"
  473. "sw %[vector_1], 0(%[dest]) \n\t"
  474. "sw %[vector_2], 4(%[dest]) \n\t"
  475. "add %[dest], %[dest], %[stride] \n\t"
  476. : [t1] "=&r"(t1), [t2] "=&r"(t2), [vector_1] "=&r"(vector_1),
  477. [vector_2] "=&r"(vector_2), [dest] "+&r"(dest)
  478. : [stride] "r"(stride), [vector_a1] "r"(vector_a1));
  479. }
  480. } else if (a1 > 255) {
  481. int32_t a11, a12, vector_a11, vector_a12;
  482. /* use quad-byte
  483. * input and output memory are four byte aligned */
  484. a11 = a1 >> 2;
  485. a12 = a1 - (a11 * 3);
  486. __asm__ __volatile__(
  487. "replv.qb %[vector_a11], %[a11] \n\t"
  488. "replv.qb %[vector_a12], %[a12] \n\t"
  489. : [vector_a11] "=&r"(vector_a11), [vector_a12] "=&r"(vector_a12)
  490. : [a11] "r"(a11), [a12] "r"(a12));
  491. for (r = 8; r--;) {
  492. __asm__ __volatile__(
  493. "lw %[t1], 0(%[dest]) \n\t"
  494. "lw %[t2], 4(%[dest]) \n\t"
  495. "addu_s.qb %[vector_1], %[t1], %[vector_a11] \n\t"
  496. "addu_s.qb %[vector_2], %[t2], %[vector_a11] \n\t"
  497. "addu_s.qb %[vector_1], %[vector_1], %[vector_a11] \n\t"
  498. "addu_s.qb %[vector_2], %[vector_2], %[vector_a11] \n\t"
  499. "addu_s.qb %[vector_1], %[vector_1], %[vector_a11] \n\t"
  500. "addu_s.qb %[vector_2], %[vector_2], %[vector_a11] \n\t"
  501. "addu_s.qb %[vector_1], %[vector_1], %[vector_a12] \n\t"
  502. "addu_s.qb %[vector_2], %[vector_2], %[vector_a12] \n\t"
  503. "sw %[vector_1], 0(%[dest]) \n\t"
  504. "sw %[vector_2], 4(%[dest]) \n\t"
  505. "add %[dest], %[dest], %[stride] \n\t"
  506. : [t1] "=&r"(t1), [t2] "=&r"(t2), [vector_1] "=&r"(vector_1),
  507. [vector_2] "=&r"(vector_2), [dest] "+r"(dest)
  508. : [stride] "r"(stride), [vector_a11] "r"(vector_a11),
  509. [vector_a12] "r"(vector_a12));
  510. }
  511. } else {
  512. /* use quad-byte
  513. * input and output memory are four byte aligned */
  514. __asm__ __volatile__("replv.qb %[vector_a1], %[a1] \n\t"
  515. : [vector_a1] "=r"(vector_a1)
  516. : [a1] "r"(a1));
  517. for (r = 8; r--;) {
  518. __asm__ __volatile__(
  519. "lw %[t1], 0(%[dest]) \n\t"
  520. "lw %[t2], 4(%[dest]) \n\t"
  521. "addu_s.qb %[vector_1], %[t1], %[vector_a1] \n\t"
  522. "addu_s.qb %[vector_2], %[t2], %[vector_a1] \n\t"
  523. "sw %[vector_1], 0(%[dest]) \n\t"
  524. "sw %[vector_2], 4(%[dest]) \n\t"
  525. "add %[dest], %[dest], %[stride] \n\t"
  526. : [t1] "=&r"(t1), [t2] "=&r"(t2), [vector_1] "=&r"(vector_1),
  527. [vector_2] "=&r"(vector_2), [dest] "+r"(dest)
  528. : [stride] "r"(stride), [vector_a1] "r"(vector_a1));
  529. }
  530. }
  531. }
  532. void iadst8_dspr2(const int16_t *input, int16_t *output) {
  533. int s0, s1, s2, s3, s4, s5, s6, s7;
  534. int x0, x1, x2, x3, x4, x5, x6, x7;
  535. x0 = input[7];
  536. x1 = input[0];
  537. x2 = input[5];
  538. x3 = input[2];
  539. x4 = input[3];
  540. x5 = input[4];
  541. x6 = input[1];
  542. x7 = input[6];
  543. if (!(x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7)) {
  544. output[0] = output[1] = output[2] = output[3] = output[4] = output[5] =
  545. output[6] = output[7] = 0;
  546. return;
  547. }
  548. // stage 1
  549. s0 = cospi_2_64 * x0 + cospi_30_64 * x1;
  550. s1 = cospi_30_64 * x0 - cospi_2_64 * x1;
  551. s2 = cospi_10_64 * x2 + cospi_22_64 * x3;
  552. s3 = cospi_22_64 * x2 - cospi_10_64 * x3;
  553. s4 = cospi_18_64 * x4 + cospi_14_64 * x5;
  554. s5 = cospi_14_64 * x4 - cospi_18_64 * x5;
  555. s6 = cospi_26_64 * x6 + cospi_6_64 * x7;
  556. s7 = cospi_6_64 * x6 - cospi_26_64 * x7;
  557. x0 = ROUND_POWER_OF_TWO((s0 + s4), DCT_CONST_BITS);
  558. x1 = ROUND_POWER_OF_TWO((s1 + s5), DCT_CONST_BITS);
  559. x2 = ROUND_POWER_OF_TWO((s2 + s6), DCT_CONST_BITS);
  560. x3 = ROUND_POWER_OF_TWO((s3 + s7), DCT_CONST_BITS);
  561. x4 = ROUND_POWER_OF_TWO((s0 - s4), DCT_CONST_BITS);
  562. x5 = ROUND_POWER_OF_TWO((s1 - s5), DCT_CONST_BITS);
  563. x6 = ROUND_POWER_OF_TWO((s2 - s6), DCT_CONST_BITS);
  564. x7 = ROUND_POWER_OF_TWO((s3 - s7), DCT_CONST_BITS);
  565. // stage 2
  566. s0 = x0;
  567. s1 = x1;
  568. s2 = x2;
  569. s3 = x3;
  570. s4 = cospi_8_64 * x4 + cospi_24_64 * x5;
  571. s5 = cospi_24_64 * x4 - cospi_8_64 * x5;
  572. s6 = -cospi_24_64 * x6 + cospi_8_64 * x7;
  573. s7 = cospi_8_64 * x6 + cospi_24_64 * x7;
  574. x0 = s0 + s2;
  575. x1 = s1 + s3;
  576. x2 = s0 - s2;
  577. x3 = s1 - s3;
  578. x4 = ROUND_POWER_OF_TWO((s4 + s6), DCT_CONST_BITS);
  579. x5 = ROUND_POWER_OF_TWO((s5 + s7), DCT_CONST_BITS);
  580. x6 = ROUND_POWER_OF_TWO((s4 - s6), DCT_CONST_BITS);
  581. x7 = ROUND_POWER_OF_TWO((s5 - s7), DCT_CONST_BITS);
  582. // stage 3
  583. s2 = cospi_16_64 * (x2 + x3);
  584. s3 = cospi_16_64 * (x2 - x3);
  585. s6 = cospi_16_64 * (x6 + x7);
  586. s7 = cospi_16_64 * (x6 - x7);
  587. x2 = ROUND_POWER_OF_TWO((s2), DCT_CONST_BITS);
  588. x3 = ROUND_POWER_OF_TWO((s3), DCT_CONST_BITS);
  589. x6 = ROUND_POWER_OF_TWO((s6), DCT_CONST_BITS);
  590. x7 = ROUND_POWER_OF_TWO((s7), DCT_CONST_BITS);
  591. output[0] = x0;
  592. output[1] = -x4;
  593. output[2] = x6;
  594. output[3] = -x2;
  595. output[4] = x3;
  596. output[5] = -x7;
  597. output[6] = x5;
  598. output[7] = -x1;
  599. }
  600. #endif // HAVE_DSPR2