You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1120 lines
47KB

  1. /*
  2. * iWMMXt optimized DSP utils
  3. * copyright (c) 2004 AGAWA Koji
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #ifndef FFMPEG_DSPUTIL_IWMMXT_RND_H
  22. #define FFMPEG_DSPUTIL_IWMMXT_RND_H
  23. void DEF(put, pixels8)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  24. {
  25. int stride = line_size;
  26. __asm__ __volatile__ (
  27. "and r12, %[pixels], #7 \n\t"
  28. "bic %[pixels], %[pixels], #7 \n\t"
  29. "tmcr wcgr1, r12 \n\t"
  30. "add r4, %[pixels], %[line_size] \n\t"
  31. "add r5, %[block], %[line_size] \n\t"
  32. "mov %[line_size], %[line_size], lsl #1 \n\t"
  33. "1: \n\t"
  34. "wldrd wr0, [%[pixels]] \n\t"
  35. "subs %[h], %[h], #2 \n\t"
  36. "wldrd wr1, [%[pixels], #8] \n\t"
  37. "add %[pixels], %[pixels], %[line_size] \n\t"
  38. "wldrd wr3, [r4] \n\t"
  39. "pld [%[pixels]] \n\t"
  40. "pld [%[pixels], #32] \n\t"
  41. "wldrd wr4, [r4, #8] \n\t"
  42. "add r4, r4, %[line_size] \n\t"
  43. "walignr1 wr8, wr0, wr1 \n\t"
  44. "pld [r4] \n\t"
  45. "pld [r4, #32] \n\t"
  46. "walignr1 wr10, wr3, wr4 \n\t"
  47. "wstrd wr8, [%[block]] \n\t"
  48. "add %[block], %[block], %[line_size] \n\t"
  49. "wstrd wr10, [r5] \n\t"
  50. "add r5, r5, %[line_size] \n\t"
  51. "bne 1b \n\t"
  52. : [block]"+r"(block), [pixels]"+r"(pixels), [line_size]"+r"(stride), [h]"+r"(h)
  53. :
  54. : "memory", "r4", "r5", "r12");
  55. }
  56. void DEF(avg, pixels8)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  57. {
  58. int stride = line_size;
  59. __asm__ __volatile__ (
  60. "and r12, %[pixels], #7 \n\t"
  61. "bic %[pixels], %[pixels], #7 \n\t"
  62. "tmcr wcgr1, r12 \n\t"
  63. "add r4, %[pixels], %[line_size] \n\t"
  64. "add r5, %[block], %[line_size] \n\t"
  65. "mov %[line_size], %[line_size], lsl #1 \n\t"
  66. "1: \n\t"
  67. "wldrd wr0, [%[pixels]] \n\t"
  68. "subs %[h], %[h], #2 \n\t"
  69. "wldrd wr1, [%[pixels], #8] \n\t"
  70. "add %[pixels], %[pixels], %[line_size] \n\t"
  71. "wldrd wr3, [r4] \n\t"
  72. "pld [%[pixels]] \n\t"
  73. "pld [%[pixels], #32] \n\t"
  74. "wldrd wr4, [r4, #8] \n\t"
  75. "add r4, r4, %[line_size] \n\t"
  76. "walignr1 wr8, wr0, wr1 \n\t"
  77. "wldrd wr0, [%[block]] \n\t"
  78. "wldrd wr2, [r5] \n\t"
  79. "pld [r4] \n\t"
  80. "pld [r4, #32] \n\t"
  81. "walignr1 wr10, wr3, wr4 \n\t"
  82. WAVG2B" wr8, wr8, wr0 \n\t"
  83. WAVG2B" wr10, wr10, wr2 \n\t"
  84. "wstrd wr8, [%[block]] \n\t"
  85. "add %[block], %[block], %[line_size] \n\t"
  86. "wstrd wr10, [r5] \n\t"
  87. "pld [%[block]] \n\t"
  88. "pld [%[block], #32] \n\t"
  89. "add r5, r5, %[line_size] \n\t"
  90. "pld [r5] \n\t"
  91. "pld [r5, #32] \n\t"
  92. "bne 1b \n\t"
  93. : [block]"+r"(block), [pixels]"+r"(pixels), [line_size]"+r"(stride), [h]"+r"(h)
  94. :
  95. : "memory", "r4", "r5", "r12");
  96. }
  97. void DEF(put, pixels16)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  98. {
  99. int stride = line_size;
  100. __asm__ __volatile__ (
  101. "and r12, %[pixels], #7 \n\t"
  102. "bic %[pixels], %[pixels], #7 \n\t"
  103. "tmcr wcgr1, r12 \n\t"
  104. "add r4, %[pixels], %[line_size] \n\t"
  105. "add r5, %[block], %[line_size] \n\t"
  106. "mov %[line_size], %[line_size], lsl #1 \n\t"
  107. "1: \n\t"
  108. "wldrd wr0, [%[pixels]] \n\t"
  109. "wldrd wr1, [%[pixels], #8] \n\t"
  110. "subs %[h], %[h], #2 \n\t"
  111. "wldrd wr2, [%[pixels], #16] \n\t"
  112. "add %[pixels], %[pixels], %[line_size] \n\t"
  113. "wldrd wr3, [r4] \n\t"
  114. "pld [%[pixels]] \n\t"
  115. "pld [%[pixels], #32] \n\t"
  116. "walignr1 wr8, wr0, wr1 \n\t"
  117. "wldrd wr4, [r4, #8] \n\t"
  118. "walignr1 wr9, wr1, wr2 \n\t"
  119. "wldrd wr5, [r4, #16] \n\t"
  120. "add r4, r4, %[line_size] \n\t"
  121. "pld [r4] \n\t"
  122. "pld [r4, #32] \n\t"
  123. "walignr1 wr10, wr3, wr4 \n\t"
  124. "wstrd wr8, [%[block]] \n\t"
  125. "walignr1 wr11, wr4, wr5 \n\t"
  126. "wstrd wr9, [%[block], #8] \n\t"
  127. "add %[block], %[block], %[line_size] \n\t"
  128. "wstrd wr10, [r5] \n\t"
  129. "wstrd wr11, [r5, #8] \n\t"
  130. "add r5, r5, %[line_size] \n\t"
  131. "bne 1b \n\t"
  132. : [block]"+r"(block), [pixels]"+r"(pixels), [line_size]"+r"(stride), [h]"+r"(h)
  133. :
  134. : "memory", "r4", "r5", "r12");
  135. }
  136. void DEF(avg, pixels16)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  137. {
  138. int stride = line_size;
  139. __asm__ __volatile__ (
  140. "pld [%[pixels]] \n\t"
  141. "pld [%[pixels], #32] \n\t"
  142. "pld [%[block]] \n\t"
  143. "pld [%[block], #32] \n\t"
  144. "and r12, %[pixels], #7 \n\t"
  145. "bic %[pixels], %[pixels], #7 \n\t"
  146. "tmcr wcgr1, r12 \n\t"
  147. "add r4, %[pixels], %[line_size]\n\t"
  148. "add r5, %[block], %[line_size] \n\t"
  149. "mov %[line_size], %[line_size], lsl #1 \n\t"
  150. "1: \n\t"
  151. "wldrd wr0, [%[pixels]] \n\t"
  152. "wldrd wr1, [%[pixels], #8] \n\t"
  153. "subs %[h], %[h], #2 \n\t"
  154. "wldrd wr2, [%[pixels], #16] \n\t"
  155. "add %[pixels], %[pixels], %[line_size] \n\t"
  156. "wldrd wr3, [r4] \n\t"
  157. "pld [%[pixels]] \n\t"
  158. "pld [%[pixels], #32] \n\t"
  159. "walignr1 wr8, wr0, wr1 \n\t"
  160. "wldrd wr4, [r4, #8] \n\t"
  161. "walignr1 wr9, wr1, wr2 \n\t"
  162. "wldrd wr5, [r4, #16] \n\t"
  163. "add r4, r4, %[line_size] \n\t"
  164. "wldrd wr0, [%[block]] \n\t"
  165. "pld [r4] \n\t"
  166. "wldrd wr1, [%[block], #8] \n\t"
  167. "pld [r4, #32] \n\t"
  168. "wldrd wr2, [r5] \n\t"
  169. "walignr1 wr10, wr3, wr4 \n\t"
  170. "wldrd wr3, [r5, #8] \n\t"
  171. WAVG2B" wr8, wr8, wr0 \n\t"
  172. WAVG2B" wr9, wr9, wr1 \n\t"
  173. WAVG2B" wr10, wr10, wr2 \n\t"
  174. "wstrd wr8, [%[block]] \n\t"
  175. "walignr1 wr11, wr4, wr5 \n\t"
  176. WAVG2B" wr11, wr11, wr3 \n\t"
  177. "wstrd wr9, [%[block], #8] \n\t"
  178. "add %[block], %[block], %[line_size] \n\t"
  179. "wstrd wr10, [r5] \n\t"
  180. "pld [%[block]] \n\t"
  181. "pld [%[block], #32] \n\t"
  182. "wstrd wr11, [r5, #8] \n\t"
  183. "add r5, r5, %[line_size] \n\t"
  184. "pld [r5] \n\t"
  185. "pld [r5, #32] \n\t"
  186. "bne 1b \n\t"
  187. : [block]"+r"(block), [pixels]"+r"(pixels), [line_size]"+r"(stride), [h]"+r"(h)
  188. :
  189. : "memory", "r4", "r5", "r12");
  190. }
  191. void DEF(put, pixels8_x2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  192. {
  193. int stride = line_size;
  194. // [wr0 wr1 wr2 wr3] for previous line
  195. // [wr4 wr5 wr6 wr7] for current line
  196. SET_RND(wr15); // =2 for rnd and =1 for no_rnd version
  197. __asm__ __volatile__(
  198. "pld [%[pixels]] \n\t"
  199. "pld [%[pixels], #32] \n\t"
  200. "and r12, %[pixels], #7 \n\t"
  201. "bic %[pixels], %[pixels], #7 \n\t"
  202. "tmcr wcgr1, r12 \n\t"
  203. "add r12, r12, #1 \n\t"
  204. "add r4, %[pixels], %[line_size]\n\t"
  205. "tmcr wcgr2, r12 \n\t"
  206. "add r5, %[block], %[line_size] \n\t"
  207. "mov %[line_size], %[line_size], lsl #1 \n\t"
  208. "1: \n\t"
  209. "wldrd wr10, [%[pixels]] \n\t"
  210. "cmp r12, #8 \n\t"
  211. "wldrd wr11, [%[pixels], #8] \n\t"
  212. "add %[pixels], %[pixels], %[line_size] \n\t"
  213. "wldrd wr13, [r4] \n\t"
  214. "pld [%[pixels]] \n\t"
  215. "wldrd wr14, [r4, #8] \n\t"
  216. "pld [%[pixels], #32] \n\t"
  217. "add r4, r4, %[line_size] \n\t"
  218. "walignr1 wr0, wr10, wr11 \n\t"
  219. "pld [r4] \n\t"
  220. "pld [r4, #32] \n\t"
  221. "walignr1 wr2, wr13, wr14 \n\t"
  222. "wmoveq wr4, wr11 \n\t"
  223. "wmoveq wr6, wr14 \n\t"
  224. "walignr2ne wr4, wr10, wr11 \n\t"
  225. "walignr2ne wr6, wr13, wr14 \n\t"
  226. WAVG2B" wr0, wr0, wr4 \n\t"
  227. WAVG2B" wr2, wr2, wr6 \n\t"
  228. "wstrd wr0, [%[block]] \n\t"
  229. "subs %[h], %[h], #2 \n\t"
  230. "wstrd wr2, [r5] \n\t"
  231. "add %[block], %[block], %[line_size] \n\t"
  232. "add r5, r5, %[line_size] \n\t"
  233. "bne 1b \n\t"
  234. : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
  235. :
  236. : "r4", "r5", "r12", "memory");
  237. }
  238. void DEF(put, pixels16_x2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  239. {
  240. int stride = line_size;
  241. // [wr0 wr1 wr2 wr3] for previous line
  242. // [wr4 wr5 wr6 wr7] for current line
  243. SET_RND(wr15); // =2 for rnd and =1 for no_rnd version
  244. __asm__ __volatile__(
  245. "pld [%[pixels]] \n\t"
  246. "pld [%[pixels], #32] \n\t"
  247. "and r12, %[pixels], #7 \n\t"
  248. "bic %[pixels], %[pixels], #7 \n\t"
  249. "tmcr wcgr1, r12 \n\t"
  250. "add r12, r12, #1 \n\t"
  251. "add r4, %[pixels], %[line_size]\n\t"
  252. "tmcr wcgr2, r12 \n\t"
  253. "add r5, %[block], %[line_size] \n\t"
  254. "mov %[line_size], %[line_size], lsl #1 \n\t"
  255. "1: \n\t"
  256. "wldrd wr10, [%[pixels]] \n\t"
  257. "cmp r12, #8 \n\t"
  258. "wldrd wr11, [%[pixels], #8] \n\t"
  259. "wldrd wr12, [%[pixels], #16] \n\t"
  260. "add %[pixels], %[pixels], %[line_size] \n\t"
  261. "wldrd wr13, [r4] \n\t"
  262. "pld [%[pixels]] \n\t"
  263. "wldrd wr14, [r4, #8] \n\t"
  264. "pld [%[pixels], #32] \n\t"
  265. "wldrd wr15, [r4, #16] \n\t"
  266. "add r4, r4, %[line_size] \n\t"
  267. "walignr1 wr0, wr10, wr11 \n\t"
  268. "pld [r4] \n\t"
  269. "pld [r4, #32] \n\t"
  270. "walignr1 wr1, wr11, wr12 \n\t"
  271. "walignr1 wr2, wr13, wr14 \n\t"
  272. "walignr1 wr3, wr14, wr15 \n\t"
  273. "wmoveq wr4, wr11 \n\t"
  274. "wmoveq wr5, wr12 \n\t"
  275. "wmoveq wr6, wr14 \n\t"
  276. "wmoveq wr7, wr15 \n\t"
  277. "walignr2ne wr4, wr10, wr11 \n\t"
  278. "walignr2ne wr5, wr11, wr12 \n\t"
  279. "walignr2ne wr6, wr13, wr14 \n\t"
  280. "walignr2ne wr7, wr14, wr15 \n\t"
  281. WAVG2B" wr0, wr0, wr4 \n\t"
  282. WAVG2B" wr1, wr1, wr5 \n\t"
  283. "wstrd wr0, [%[block]] \n\t"
  284. WAVG2B" wr2, wr2, wr6 \n\t"
  285. "wstrd wr1, [%[block], #8] \n\t"
  286. WAVG2B" wr3, wr3, wr7 \n\t"
  287. "add %[block], %[block], %[line_size] \n\t"
  288. "wstrd wr2, [r5] \n\t"
  289. "subs %[h], %[h], #2 \n\t"
  290. "wstrd wr3, [r5, #8] \n\t"
  291. "add r5, r5, %[line_size] \n\t"
  292. "bne 1b \n\t"
  293. : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
  294. :
  295. : "r4", "r5", "r12", "memory");
  296. }
  297. void DEF(avg, pixels8_x2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  298. {
  299. int stride = line_size;
  300. // [wr0 wr1 wr2 wr3] for previous line
  301. // [wr4 wr5 wr6 wr7] for current line
  302. SET_RND(wr15); // =2 for rnd and =1 for no_rnd version
  303. __asm__ __volatile__(
  304. "pld [%[pixels]] \n\t"
  305. "pld [%[pixels], #32] \n\t"
  306. "pld [%[block]] \n\t"
  307. "pld [%[block], #32] \n\t"
  308. "and r12, %[pixels], #7 \n\t"
  309. "bic %[pixels], %[pixels], #7 \n\t"
  310. "tmcr wcgr1, r12 \n\t"
  311. "add r12, r12, #1 \n\t"
  312. "add r4, %[pixels], %[line_size]\n\t"
  313. "tmcr wcgr2, r12 \n\t"
  314. "add r5, %[block], %[line_size] \n\t"
  315. "mov %[line_size], %[line_size], lsl #1 \n\t"
  316. "pld [r5] \n\t"
  317. "pld [r5, #32] \n\t"
  318. "1: \n\t"
  319. "wldrd wr10, [%[pixels]] \n\t"
  320. "cmp r12, #8 \n\t"
  321. "wldrd wr11, [%[pixels], #8] \n\t"
  322. "add %[pixels], %[pixels], %[line_size] \n\t"
  323. "wldrd wr13, [r4] \n\t"
  324. "pld [%[pixels]] \n\t"
  325. "wldrd wr14, [r4, #8] \n\t"
  326. "pld [%[pixels], #32] \n\t"
  327. "add r4, r4, %[line_size] \n\t"
  328. "walignr1 wr0, wr10, wr11 \n\t"
  329. "pld [r4] \n\t"
  330. "pld [r4, #32] \n\t"
  331. "walignr1 wr2, wr13, wr14 \n\t"
  332. "wmoveq wr4, wr11 \n\t"
  333. "wmoveq wr6, wr14 \n\t"
  334. "walignr2ne wr4, wr10, wr11 \n\t"
  335. "wldrd wr10, [%[block]] \n\t"
  336. "walignr2ne wr6, wr13, wr14 \n\t"
  337. "wldrd wr12, [r5] \n\t"
  338. WAVG2B" wr0, wr0, wr4 \n\t"
  339. WAVG2B" wr2, wr2, wr6 \n\t"
  340. WAVG2B" wr0, wr0, wr10 \n\t"
  341. WAVG2B" wr2, wr2, wr12 \n\t"
  342. "wstrd wr0, [%[block]] \n\t"
  343. "subs %[h], %[h], #2 \n\t"
  344. "wstrd wr2, [r5] \n\t"
  345. "add %[block], %[block], %[line_size] \n\t"
  346. "add r5, r5, %[line_size] \n\t"
  347. "pld [%[block]] \n\t"
  348. "pld [%[block], #32] \n\t"
  349. "pld [r5] \n\t"
  350. "pld [r5, #32] \n\t"
  351. "bne 1b \n\t"
  352. : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
  353. :
  354. : "r4", "r5", "r12", "memory");
  355. }
  356. void DEF(avg, pixels16_x2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  357. {
  358. int stride = line_size;
  359. // [wr0 wr1 wr2 wr3] for previous line
  360. // [wr4 wr5 wr6 wr7] for current line
  361. SET_RND(wr15); // =2 for rnd and =1 for no_rnd version
  362. __asm__ __volatile__(
  363. "pld [%[pixels]] \n\t"
  364. "pld [%[pixels], #32] \n\t"
  365. "pld [%[block]] \n\t"
  366. "pld [%[block], #32] \n\t"
  367. "and r12, %[pixels], #7 \n\t"
  368. "bic %[pixels], %[pixels], #7 \n\t"
  369. "tmcr wcgr1, r12 \n\t"
  370. "add r12, r12, #1 \n\t"
  371. "add r4, %[pixels], %[line_size]\n\t"
  372. "tmcr wcgr2, r12 \n\t"
  373. "add r5, %[block], %[line_size] \n\t"
  374. "mov %[line_size], %[line_size], lsl #1 \n\t"
  375. "pld [r5] \n\t"
  376. "pld [r5, #32] \n\t"
  377. "1: \n\t"
  378. "wldrd wr10, [%[pixels]] \n\t"
  379. "cmp r12, #8 \n\t"
  380. "wldrd wr11, [%[pixels], #8] \n\t"
  381. "wldrd wr12, [%[pixels], #16] \n\t"
  382. "add %[pixels], %[pixels], %[line_size] \n\t"
  383. "wldrd wr13, [r4] \n\t"
  384. "pld [%[pixels]] \n\t"
  385. "wldrd wr14, [r4, #8] \n\t"
  386. "pld [%[pixels], #32] \n\t"
  387. "wldrd wr15, [r4, #16] \n\t"
  388. "add r4, r4, %[line_size] \n\t"
  389. "walignr1 wr0, wr10, wr11 \n\t"
  390. "pld [r4] \n\t"
  391. "pld [r4, #32] \n\t"
  392. "walignr1 wr1, wr11, wr12 \n\t"
  393. "walignr1 wr2, wr13, wr14 \n\t"
  394. "walignr1 wr3, wr14, wr15 \n\t"
  395. "wmoveq wr4, wr11 \n\t"
  396. "wmoveq wr5, wr12 \n\t"
  397. "wmoveq wr6, wr14 \n\t"
  398. "wmoveq wr7, wr15 \n\t"
  399. "walignr2ne wr4, wr10, wr11 \n\t"
  400. "walignr2ne wr5, wr11, wr12 \n\t"
  401. "walignr2ne wr6, wr13, wr14 \n\t"
  402. "walignr2ne wr7, wr14, wr15 \n\t"
  403. "wldrd wr10, [%[block]] \n\t"
  404. WAVG2B" wr0, wr0, wr4 \n\t"
  405. "wldrd wr11, [%[block], #8] \n\t"
  406. WAVG2B" wr1, wr1, wr5 \n\t"
  407. "wldrd wr12, [r5] \n\t"
  408. WAVG2B" wr2, wr2, wr6 \n\t"
  409. "wldrd wr13, [r5, #8] \n\t"
  410. WAVG2B" wr3, wr3, wr7 \n\t"
  411. WAVG2B" wr0, wr0, wr10 \n\t"
  412. WAVG2B" wr1, wr1, wr11 \n\t"
  413. WAVG2B" wr2, wr2, wr12 \n\t"
  414. WAVG2B" wr3, wr3, wr13 \n\t"
  415. "wstrd wr0, [%[block]] \n\t"
  416. "subs %[h], %[h], #2 \n\t"
  417. "wstrd wr1, [%[block], #8] \n\t"
  418. "add %[block], %[block], %[line_size] \n\t"
  419. "wstrd wr2, [r5] \n\t"
  420. "pld [%[block]] \n\t"
  421. "wstrd wr3, [r5, #8] \n\t"
  422. "add r5, r5, %[line_size] \n\t"
  423. "pld [%[block], #32] \n\t"
  424. "pld [r5] \n\t"
  425. "pld [r5, #32] \n\t"
  426. "bne 1b \n\t"
  427. : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
  428. :
  429. :"r4", "r5", "r12", "memory");
  430. }
  431. void DEF(avg, pixels8_y2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  432. {
  433. int stride = line_size;
  434. // [wr0 wr1 wr2 wr3] for previous line
  435. // [wr4 wr5 wr6 wr7] for current line
  436. __asm__ __volatile__(
  437. "pld [%[pixels]] \n\t"
  438. "pld [%[pixels], #32] \n\t"
  439. "and r12, %[pixels], #7 \n\t"
  440. "tmcr wcgr1, r12 \n\t"
  441. "bic %[pixels], %[pixels], #7 \n\t"
  442. "wldrd wr10, [%[pixels]] \n\t"
  443. "wldrd wr11, [%[pixels], #8] \n\t"
  444. "pld [%[block]] \n\t"
  445. "add %[pixels], %[pixels], %[line_size] \n\t"
  446. "walignr1 wr0, wr10, wr11 \n\t"
  447. "pld [%[pixels]] \n\t"
  448. "pld [%[pixels], #32] \n\t"
  449. "1: \n\t"
  450. "wldrd wr10, [%[pixels]] \n\t"
  451. "wldrd wr11, [%[pixels], #8] \n\t"
  452. "add %[pixels], %[pixels], %[line_size] \n\t"
  453. "pld [%[pixels]] \n\t"
  454. "pld [%[pixels], #32] \n\t"
  455. "walignr1 wr4, wr10, wr11 \n\t"
  456. "wldrd wr10, [%[block]] \n\t"
  457. WAVG2B" wr8, wr0, wr4 \n\t"
  458. WAVG2B" wr8, wr8, wr10 \n\t"
  459. "wstrd wr8, [%[block]] \n\t"
  460. "add %[block], %[block], %[line_size] \n\t"
  461. "wldrd wr10, [%[pixels]] \n\t"
  462. "wldrd wr11, [%[pixels], #8] \n\t"
  463. "pld [%[block]] \n\t"
  464. "add %[pixels], %[pixels], %[line_size] \n\t"
  465. "pld [%[pixels]] \n\t"
  466. "pld [%[pixels], #32] \n\t"
  467. "walignr1 wr0, wr10, wr11 \n\t"
  468. "wldrd wr10, [%[block]] \n\t"
  469. WAVG2B" wr8, wr0, wr4 \n\t"
  470. WAVG2B" wr8, wr8, wr10 \n\t"
  471. "wstrd wr8, [%[block]] \n\t"
  472. "add %[block], %[block], %[line_size] \n\t"
  473. "subs %[h], %[h], #2 \n\t"
  474. "pld [%[block]] \n\t"
  475. "bne 1b \n\t"
  476. : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
  477. :
  478. : "cc", "memory", "r12");
  479. }
  480. void DEF(put, pixels16_y2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  481. {
  482. int stride = line_size;
  483. // [wr0 wr1 wr2 wr3] for previous line
  484. // [wr4 wr5 wr6 wr7] for current line
  485. __asm__ __volatile__(
  486. "pld [%[pixels]] \n\t"
  487. "pld [%[pixels], #32] \n\t"
  488. "and r12, %[pixels], #7 \n\t"
  489. "tmcr wcgr1, r12 \n\t"
  490. "bic %[pixels], %[pixels], #7 \n\t"
  491. "wldrd wr10, [%[pixels]] \n\t"
  492. "wldrd wr11, [%[pixels], #8] \n\t"
  493. "wldrd wr12, [%[pixels], #16] \n\t"
  494. "add %[pixels], %[pixels], %[line_size] \n\t"
  495. "pld [%[pixels]] \n\t"
  496. "pld [%[pixels], #32] \n\t"
  497. "walignr1 wr0, wr10, wr11 \n\t"
  498. "walignr1 wr1, wr11, wr12 \n\t"
  499. "1: \n\t"
  500. "wldrd wr10, [%[pixels]] \n\t"
  501. "wldrd wr11, [%[pixels], #8] \n\t"
  502. "wldrd wr12, [%[pixels], #16] \n\t"
  503. "add %[pixels], %[pixels], %[line_size] \n\t"
  504. "pld [%[pixels]] \n\t"
  505. "pld [%[pixels], #32] \n\t"
  506. "walignr1 wr4, wr10, wr11 \n\t"
  507. "walignr1 wr5, wr11, wr12 \n\t"
  508. WAVG2B" wr8, wr0, wr4 \n\t"
  509. WAVG2B" wr9, wr1, wr5 \n\t"
  510. "wstrd wr8, [%[block]] \n\t"
  511. "wstrd wr9, [%[block], #8] \n\t"
  512. "add %[block], %[block], %[line_size] \n\t"
  513. "wldrd wr10, [%[pixels]] \n\t"
  514. "wldrd wr11, [%[pixels], #8] \n\t"
  515. "wldrd wr12, [%[pixels], #16] \n\t"
  516. "add %[pixels], %[pixels], %[line_size] \n\t"
  517. "pld [%[pixels]] \n\t"
  518. "pld [%[pixels], #32] \n\t"
  519. "walignr1 wr0, wr10, wr11 \n\t"
  520. "walignr1 wr1, wr11, wr12 \n\t"
  521. WAVG2B" wr8, wr0, wr4 \n\t"
  522. WAVG2B" wr9, wr1, wr5 \n\t"
  523. "wstrd wr8, [%[block]] \n\t"
  524. "wstrd wr9, [%[block], #8] \n\t"
  525. "add %[block], %[block], %[line_size] \n\t"
  526. "subs %[h], %[h], #2 \n\t"
  527. "bne 1b \n\t"
  528. : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
  529. :
  530. : "r4", "r5", "r12", "memory");
  531. }
  532. void DEF(avg, pixels16_y2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  533. {
  534. int stride = line_size;
  535. // [wr0 wr1 wr2 wr3] for previous line
  536. // [wr4 wr5 wr6 wr7] for current line
  537. __asm__ __volatile__(
  538. "pld [%[pixels]] \n\t"
  539. "pld [%[pixels], #32] \n\t"
  540. "and r12, %[pixels], #7 \n\t"
  541. "tmcr wcgr1, r12 \n\t"
  542. "bic %[pixels], %[pixels], #7 \n\t"
  543. "wldrd wr10, [%[pixels]] \n\t"
  544. "wldrd wr11, [%[pixels], #8] \n\t"
  545. "pld [%[block]] \n\t"
  546. "wldrd wr12, [%[pixels], #16] \n\t"
  547. "add %[pixels], %[pixels], %[line_size] \n\t"
  548. "pld [%[pixels]] \n\t"
  549. "pld [%[pixels], #32] \n\t"
  550. "walignr1 wr0, wr10, wr11 \n\t"
  551. "walignr1 wr1, wr11, wr12 \n\t"
  552. "1: \n\t"
  553. "wldrd wr10, [%[pixels]] \n\t"
  554. "wldrd wr11, [%[pixels], #8] \n\t"
  555. "wldrd wr12, [%[pixels], #16] \n\t"
  556. "add %[pixels], %[pixels], %[line_size] \n\t"
  557. "pld [%[pixels]] \n\t"
  558. "pld [%[pixels], #32] \n\t"
  559. "walignr1 wr4, wr10, wr11 \n\t"
  560. "walignr1 wr5, wr11, wr12 \n\t"
  561. "wldrd wr10, [%[block]] \n\t"
  562. "wldrd wr11, [%[block], #8] \n\t"
  563. WAVG2B" wr8, wr0, wr4 \n\t"
  564. WAVG2B" wr9, wr1, wr5 \n\t"
  565. WAVG2B" wr8, wr8, wr10 \n\t"
  566. WAVG2B" wr9, wr9, wr11 \n\t"
  567. "wstrd wr8, [%[block]] \n\t"
  568. "wstrd wr9, [%[block], #8] \n\t"
  569. "add %[block], %[block], %[line_size] \n\t"
  570. "wldrd wr10, [%[pixels]] \n\t"
  571. "wldrd wr11, [%[pixels], #8] \n\t"
  572. "pld [%[block]] \n\t"
  573. "wldrd wr12, [%[pixels], #16] \n\t"
  574. "add %[pixels], %[pixels], %[line_size] \n\t"
  575. "pld [%[pixels]] \n\t"
  576. "pld [%[pixels], #32] \n\t"
  577. "walignr1 wr0, wr10, wr11 \n\t"
  578. "walignr1 wr1, wr11, wr12 \n\t"
  579. "wldrd wr10, [%[block]] \n\t"
  580. "wldrd wr11, [%[block], #8] \n\t"
  581. WAVG2B" wr8, wr0, wr4 \n\t"
  582. WAVG2B" wr9, wr1, wr5 \n\t"
  583. WAVG2B" wr8, wr8, wr10 \n\t"
  584. WAVG2B" wr9, wr9, wr11 \n\t"
  585. "wstrd wr8, [%[block]] \n\t"
  586. "wstrd wr9, [%[block], #8] \n\t"
  587. "add %[block], %[block], %[line_size] \n\t"
  588. "subs %[h], %[h], #2 \n\t"
  589. "pld [%[block]] \n\t"
  590. "bne 1b \n\t"
  591. : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
  592. :
  593. : "r4", "r5", "r12", "memory");
  594. }
  595. void DEF(put, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  596. {
  597. // [wr0 wr1 wr2 wr3] for previous line
  598. // [wr4 wr5 wr6 wr7] for current line
  599. SET_RND(wr15); // =2 for rnd and =1 for no_rnd version
  600. __asm__ __volatile__(
  601. "pld [%[pixels]] \n\t"
  602. "mov r12, #2 \n\t"
  603. "pld [%[pixels], #32] \n\t"
  604. "tmcr wcgr0, r12 \n\t" /* for shift value */
  605. "and r12, %[pixels], #7 \n\t"
  606. "bic %[pixels], %[pixels], #7 \n\t"
  607. "tmcr wcgr1, r12 \n\t"
  608. // [wr0 wr1 wr2 wr3] <= *
  609. // [wr4 wr5 wr6 wr7]
  610. "wldrd wr12, [%[pixels]] \n\t"
  611. "add r12, r12, #1 \n\t"
  612. "wldrd wr13, [%[pixels], #8] \n\t"
  613. "tmcr wcgr2, r12 \n\t"
  614. "add %[pixels], %[pixels], %[line_size] \n\t"
  615. "cmp r12, #8 \n\t"
  616. "pld [%[pixels]] \n\t"
  617. "pld [%[pixels], #32] \n\t"
  618. "walignr1 wr2, wr12, wr13 \n\t"
  619. "wmoveq wr10, wr13 \n\t"
  620. "walignr2ne wr10, wr12, wr13 \n\t"
  621. "wunpckelub wr0, wr2 \n\t"
  622. "wunpckehub wr1, wr2 \n\t"
  623. "wunpckelub wr8, wr10 \n\t"
  624. "wunpckehub wr9, wr10 \n\t"
  625. "waddhus wr0, wr0, wr8 \n\t"
  626. "waddhus wr1, wr1, wr9 \n\t"
  627. "1: \n\t"
  628. // [wr0 wr1 wr2 wr3]
  629. // [wr4 wr5 wr6 wr7] <= *
  630. "wldrd wr12, [%[pixels]] \n\t"
  631. "cmp r12, #8 \n\t"
  632. "wldrd wr13, [%[pixels], #8] \n\t"
  633. "add %[pixels], %[pixels], %[line_size] \n\t"
  634. "walignr1 wr6, wr12, wr13 \n\t"
  635. "pld [%[pixels]] \n\t"
  636. "pld [%[pixels], #32] \n\t"
  637. "wmoveq wr10, wr13 \n\t"
  638. "walignr2ne wr10, wr12, wr13 \n\t"
  639. "wunpckelub wr4, wr6 \n\t"
  640. "wunpckehub wr5, wr6 \n\t"
  641. "wunpckelub wr8, wr10 \n\t"
  642. "wunpckehub wr9, wr10 \n\t"
  643. "waddhus wr4, wr4, wr8 \n\t"
  644. "waddhus wr5, wr5, wr9 \n\t"
  645. "waddhus wr8, wr0, wr4 \n\t"
  646. "waddhus wr9, wr1, wr5 \n\t"
  647. "waddhus wr8, wr8, wr15 \n\t"
  648. "waddhus wr9, wr9, wr15 \n\t"
  649. "wsrlhg wr8, wr8, wcgr0 \n\t"
  650. "wsrlhg wr9, wr9, wcgr0 \n\t"
  651. "wpackhus wr8, wr8, wr9 \n\t"
  652. "wstrd wr8, [%[block]] \n\t"
  653. "add %[block], %[block], %[line_size] \n\t"
  654. // [wr0 wr1 wr2 wr3] <= *
  655. // [wr4 wr5 wr6 wr7]
  656. "wldrd wr12, [%[pixels]] \n\t"
  657. "wldrd wr13, [%[pixels], #8] \n\t"
  658. "add %[pixels], %[pixels], %[line_size] \n\t"
  659. "walignr1 wr2, wr12, wr13 \n\t"
  660. "pld [%[pixels]] \n\t"
  661. "pld [%[pixels], #32] \n\t"
  662. "wmoveq wr10, wr13 \n\t"
  663. "walignr2ne wr10, wr12, wr13 \n\t"
  664. "wunpckelub wr0, wr2 \n\t"
  665. "wunpckehub wr1, wr2 \n\t"
  666. "wunpckelub wr8, wr10 \n\t"
  667. "wunpckehub wr9, wr10 \n\t"
  668. "waddhus wr0, wr0, wr8 \n\t"
  669. "waddhus wr1, wr1, wr9 \n\t"
  670. "waddhus wr8, wr0, wr4 \n\t"
  671. "waddhus wr9, wr1, wr5 \n\t"
  672. "waddhus wr8, wr8, wr15 \n\t"
  673. "waddhus wr9, wr9, wr15 \n\t"
  674. "wsrlhg wr8, wr8, wcgr0 \n\t"
  675. "wsrlhg wr9, wr9, wcgr0 \n\t"
  676. "wpackhus wr8, wr8, wr9 \n\t"
  677. "subs %[h], %[h], #2 \n\t"
  678. "wstrd wr8, [%[block]] \n\t"
  679. "add %[block], %[block], %[line_size] \n\t"
  680. "bne 1b \n\t"
  681. : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block)
  682. : [line_size]"r"(line_size)
  683. : "r12", "memory");
  684. }
  685. void DEF(put, pixels16_xy2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  686. {
  687. // [wr0 wr1 wr2 wr3] for previous line
  688. // [wr4 wr5 wr6 wr7] for current line
  689. SET_RND(wr15); // =2 for rnd and =1 for no_rnd version
  690. __asm__ __volatile__(
  691. "pld [%[pixels]] \n\t"
  692. "mov r12, #2 \n\t"
  693. "pld [%[pixels], #32] \n\t"
  694. "tmcr wcgr0, r12 \n\t" /* for shift value */
  695. /* alignment */
  696. "and r12, %[pixels], #7 \n\t"
  697. "bic %[pixels], %[pixels], #7 \n\t"
  698. "tmcr wcgr1, r12 \n\t"
  699. "add r12, r12, #1 \n\t"
  700. "tmcr wcgr2, r12 \n\t"
  701. // [wr0 wr1 wr2 wr3] <= *
  702. // [wr4 wr5 wr6 wr7]
  703. "wldrd wr12, [%[pixels]] \n\t"
  704. "cmp r12, #8 \n\t"
  705. "wldrd wr13, [%[pixels], #8] \n\t"
  706. "wldrd wr14, [%[pixels], #16] \n\t"
  707. "add %[pixels], %[pixels], %[line_size] \n\t"
  708. "pld [%[pixels]] \n\t"
  709. "walignr1 wr2, wr12, wr13 \n\t"
  710. "pld [%[pixels], #32] \n\t"
  711. "walignr1 wr3, wr13, wr14 \n\t"
  712. "wmoveq wr10, wr13 \n\t"
  713. "wmoveq wr11, wr14 \n\t"
  714. "walignr2ne wr10, wr12, wr13 \n\t"
  715. "walignr2ne wr11, wr13, wr14 \n\t"
  716. "wunpckelub wr0, wr2 \n\t"
  717. "wunpckehub wr1, wr2 \n\t"
  718. "wunpckelub wr2, wr3 \n\t"
  719. "wunpckehub wr3, wr3 \n\t"
  720. "wunpckelub wr8, wr10 \n\t"
  721. "wunpckehub wr9, wr10 \n\t"
  722. "wunpckelub wr10, wr11 \n\t"
  723. "wunpckehub wr11, wr11 \n\t"
  724. "waddhus wr0, wr0, wr8 \n\t"
  725. "waddhus wr1, wr1, wr9 \n\t"
  726. "waddhus wr2, wr2, wr10 \n\t"
  727. "waddhus wr3, wr3, wr11 \n\t"
  728. "1: \n\t"
  729. // [wr0 wr1 wr2 wr3]
  730. // [wr4 wr5 wr6 wr7] <= *
  731. "wldrd wr12, [%[pixels]] \n\t"
  732. "cmp r12, #8 \n\t"
  733. "wldrd wr13, [%[pixels], #8] \n\t"
  734. "wldrd wr14, [%[pixels], #16] \n\t"
  735. "add %[pixels], %[pixels], %[line_size] \n\t"
  736. "walignr1 wr6, wr12, wr13 \n\t"
  737. "pld [%[pixels]] \n\t"
  738. "pld [%[pixels], #32] \n\t"
  739. "walignr1 wr7, wr13, wr14 \n\t"
  740. "wmoveq wr10, wr13 \n\t"
  741. "wmoveq wr11, wr14 \n\t"
  742. "walignr2ne wr10, wr12, wr13 \n\t"
  743. "walignr2ne wr11, wr13, wr14 \n\t"
  744. "wunpckelub wr4, wr6 \n\t"
  745. "wunpckehub wr5, wr6 \n\t"
  746. "wunpckelub wr6, wr7 \n\t"
  747. "wunpckehub wr7, wr7 \n\t"
  748. "wunpckelub wr8, wr10 \n\t"
  749. "wunpckehub wr9, wr10 \n\t"
  750. "wunpckelub wr10, wr11 \n\t"
  751. "wunpckehub wr11, wr11 \n\t"
  752. "waddhus wr4, wr4, wr8 \n\t"
  753. "waddhus wr5, wr5, wr9 \n\t"
  754. "waddhus wr6, wr6, wr10 \n\t"
  755. "waddhus wr7, wr7, wr11 \n\t"
  756. "waddhus wr8, wr0, wr4 \n\t"
  757. "waddhus wr9, wr1, wr5 \n\t"
  758. "waddhus wr10, wr2, wr6 \n\t"
  759. "waddhus wr11, wr3, wr7 \n\t"
  760. "waddhus wr8, wr8, wr15 \n\t"
  761. "waddhus wr9, wr9, wr15 \n\t"
  762. "waddhus wr10, wr10, wr15 \n\t"
  763. "waddhus wr11, wr11, wr15 \n\t"
  764. "wsrlhg wr8, wr8, wcgr0 \n\t"
  765. "wsrlhg wr9, wr9, wcgr0 \n\t"
  766. "wsrlhg wr10, wr10, wcgr0 \n\t"
  767. "wsrlhg wr11, wr11, wcgr0 \n\t"
  768. "wpackhus wr8, wr8, wr9 \n\t"
  769. "wpackhus wr9, wr10, wr11 \n\t"
  770. "wstrd wr8, [%[block]] \n\t"
  771. "wstrd wr9, [%[block], #8] \n\t"
  772. "add %[block], %[block], %[line_size] \n\t"
  773. // [wr0 wr1 wr2 wr3] <= *
  774. // [wr4 wr5 wr6 wr7]
  775. "wldrd wr12, [%[pixels]] \n\t"
  776. "wldrd wr13, [%[pixels], #8] \n\t"
  777. "wldrd wr14, [%[pixels], #16] \n\t"
  778. "add %[pixels], %[pixels], %[line_size] \n\t"
  779. "walignr1 wr2, wr12, wr13 \n\t"
  780. "pld [%[pixels]] \n\t"
  781. "pld [%[pixels], #32] \n\t"
  782. "walignr1 wr3, wr13, wr14 \n\t"
  783. "wmoveq wr10, wr13 \n\t"
  784. "wmoveq wr11, wr14 \n\t"
  785. "walignr2ne wr10, wr12, wr13 \n\t"
  786. "walignr2ne wr11, wr13, wr14 \n\t"
  787. "wunpckelub wr0, wr2 \n\t"
  788. "wunpckehub wr1, wr2 \n\t"
  789. "wunpckelub wr2, wr3 \n\t"
  790. "wunpckehub wr3, wr3 \n\t"
  791. "wunpckelub wr8, wr10 \n\t"
  792. "wunpckehub wr9, wr10 \n\t"
  793. "wunpckelub wr10, wr11 \n\t"
  794. "wunpckehub wr11, wr11 \n\t"
  795. "waddhus wr0, wr0, wr8 \n\t"
  796. "waddhus wr1, wr1, wr9 \n\t"
  797. "waddhus wr2, wr2, wr10 \n\t"
  798. "waddhus wr3, wr3, wr11 \n\t"
  799. "waddhus wr8, wr0, wr4 \n\t"
  800. "waddhus wr9, wr1, wr5 \n\t"
  801. "waddhus wr10, wr2, wr6 \n\t"
  802. "waddhus wr11, wr3, wr7 \n\t"
  803. "waddhus wr8, wr8, wr15 \n\t"
  804. "waddhus wr9, wr9, wr15 \n\t"
  805. "waddhus wr10, wr10, wr15 \n\t"
  806. "waddhus wr11, wr11, wr15 \n\t"
  807. "wsrlhg wr8, wr8, wcgr0 \n\t"
  808. "wsrlhg wr9, wr9, wcgr0 \n\t"
  809. "wsrlhg wr10, wr10, wcgr0 \n\t"
  810. "wsrlhg wr11, wr11, wcgr0 \n\t"
  811. "wpackhus wr8, wr8, wr9 \n\t"
  812. "wpackhus wr9, wr10, wr11 \n\t"
  813. "wstrd wr8, [%[block]] \n\t"
  814. "wstrd wr9, [%[block], #8] \n\t"
  815. "add %[block], %[block], %[line_size] \n\t"
  816. "subs %[h], %[h], #2 \n\t"
  817. "bne 1b \n\t"
  818. : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block)
  819. : [line_size]"r"(line_size)
  820. : "r12", "memory");
  821. }
  822. void DEF(avg, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  823. {
  824. // [wr0 wr1 wr2 wr3] for previous line
  825. // [wr4 wr5 wr6 wr7] for current line
  826. SET_RND(wr15); // =2 for rnd and =1 for no_rnd version
  827. __asm__ __volatile__(
  828. "pld [%[block]] \n\t"
  829. "pld [%[block], #32] \n\t"
  830. "pld [%[pixels]] \n\t"
  831. "mov r12, #2 \n\t"
  832. "pld [%[pixels], #32] \n\t"
  833. "tmcr wcgr0, r12 \n\t" /* for shift value */
  834. "and r12, %[pixels], #7 \n\t"
  835. "bic %[pixels], %[pixels], #7 \n\t"
  836. "tmcr wcgr1, r12 \n\t"
  837. // [wr0 wr1 wr2 wr3] <= *
  838. // [wr4 wr5 wr6 wr7]
  839. "wldrd wr12, [%[pixels]] \n\t"
  840. "add r12, r12, #1 \n\t"
  841. "wldrd wr13, [%[pixels], #8] \n\t"
  842. "tmcr wcgr2, r12 \n\t"
  843. "add %[pixels], %[pixels], %[line_size] \n\t"
  844. "cmp r12, #8 \n\t"
  845. "pld [%[pixels]] \n\t"
  846. "pld [%[pixels], #32] \n\t"
  847. "walignr1 wr2, wr12, wr13 \n\t"
  848. "wmoveq wr10, wr13 \n\t"
  849. "walignr2ne wr10, wr12, wr13 \n\t"
  850. "wunpckelub wr0, wr2 \n\t"
  851. "wunpckehub wr1, wr2 \n\t"
  852. "wunpckelub wr8, wr10 \n\t"
  853. "wunpckehub wr9, wr10 \n\t"
  854. "waddhus wr0, wr0, wr8 \n\t"
  855. "waddhus wr1, wr1, wr9 \n\t"
  856. "1: \n\t"
  857. // [wr0 wr1 wr2 wr3]
  858. // [wr4 wr5 wr6 wr7] <= *
  859. "wldrd wr12, [%[pixels]] \n\t"
  860. "cmp r12, #8 \n\t"
  861. "wldrd wr13, [%[pixels], #8] \n\t"
  862. "add %[pixels], %[pixels], %[line_size] \n\t"
  863. "walignr1 wr6, wr12, wr13 \n\t"
  864. "pld [%[pixels]] \n\t"
  865. "pld [%[pixels], #32] \n\t"
  866. "wmoveq wr10, wr13 \n\t"
  867. "walignr2ne wr10, wr12, wr13 \n\t"
  868. "wunpckelub wr4, wr6 \n\t"
  869. "wunpckehub wr5, wr6 \n\t"
  870. "wunpckelub wr8, wr10 \n\t"
  871. "wunpckehub wr9, wr10 \n\t"
  872. "waddhus wr4, wr4, wr8 \n\t"
  873. "waddhus wr5, wr5, wr9 \n\t"
  874. "waddhus wr8, wr0, wr4 \n\t"
  875. "waddhus wr9, wr1, wr5 \n\t"
  876. "waddhus wr8, wr8, wr15 \n\t"
  877. "waddhus wr9, wr9, wr15 \n\t"
  878. "wldrd wr12, [%[block]] \n\t"
  879. "wsrlhg wr8, wr8, wcgr0 \n\t"
  880. "wsrlhg wr9, wr9, wcgr0 \n\t"
  881. "wpackhus wr8, wr8, wr9 \n\t"
  882. WAVG2B" wr8, wr8, wr12 \n\t"
  883. "wstrd wr8, [%[block]] \n\t"
  884. "add %[block], %[block], %[line_size] \n\t"
  885. "wldrd wr12, [%[pixels]] \n\t"
  886. "pld [%[block]] \n\t"
  887. "pld [%[block], #32] \n\t"
  888. // [wr0 wr1 wr2 wr3] <= *
  889. // [wr4 wr5 wr6 wr7]
  890. "wldrd wr13, [%[pixels], #8] \n\t"
  891. "add %[pixels], %[pixels], %[line_size] \n\t"
  892. "walignr1 wr2, wr12, wr13 \n\t"
  893. "pld [%[pixels]] \n\t"
  894. "pld [%[pixels], #32] \n\t"
  895. "wmoveq wr10, wr13 \n\t"
  896. "walignr2ne wr10, wr12, wr13 \n\t"
  897. "wunpckelub wr0, wr2 \n\t"
  898. "wunpckehub wr1, wr2 \n\t"
  899. "wunpckelub wr8, wr10 \n\t"
  900. "wunpckehub wr9, wr10 \n\t"
  901. "waddhus wr0, wr0, wr8 \n\t"
  902. "waddhus wr1, wr1, wr9 \n\t"
  903. "waddhus wr8, wr0, wr4 \n\t"
  904. "waddhus wr9, wr1, wr5 \n\t"
  905. "waddhus wr8, wr8, wr15 \n\t"
  906. "waddhus wr9, wr9, wr15 \n\t"
  907. "wldrd wr12, [%[block]] \n\t"
  908. "wsrlhg wr8, wr8, wcgr0 \n\t"
  909. "wsrlhg wr9, wr9, wcgr0 \n\t"
  910. "wpackhus wr8, wr8, wr9 \n\t"
  911. "subs %[h], %[h], #2 \n\t"
  912. WAVG2B" wr8, wr8, wr12 \n\t"
  913. "wstrd wr8, [%[block]] \n\t"
  914. "add %[block], %[block], %[line_size] \n\t"
  915. "pld [%[block]] \n\t"
  916. "pld [%[block], #32] \n\t"
  917. "bne 1b \n\t"
  918. : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block)
  919. : [line_size]"r"(line_size)
  920. : "r12", "memory");
  921. }
  922. void DEF(avg, pixels16_xy2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
  923. {
  924. // [wr0 wr1 wr2 wr3] for previous line
  925. // [wr4 wr5 wr6 wr7] for current line
  926. SET_RND(wr15); // =2 for rnd and =1 for no_rnd version
  927. __asm__ __volatile__(
  928. "pld [%[block]] \n\t"
  929. "pld [%[block], #32] \n\t"
  930. "pld [%[pixels]] \n\t"
  931. "mov r12, #2 \n\t"
  932. "pld [%[pixels], #32] \n\t"
  933. "tmcr wcgr0, r12 \n\t" /* for shift value */
  934. /* alignment */
  935. "and r12, %[pixels], #7 \n\t"
  936. "bic %[pixels], %[pixels], #7 \n\t"
  937. "tmcr wcgr1, r12 \n\t"
  938. "add r12, r12, #1 \n\t"
  939. "tmcr wcgr2, r12 \n\t"
  940. // [wr0 wr1 wr2 wr3] <= *
  941. // [wr4 wr5 wr6 wr7]
  942. "wldrd wr12, [%[pixels]] \n\t"
  943. "cmp r12, #8 \n\t"
  944. "wldrd wr13, [%[pixels], #8] \n\t"
  945. "wldrd wr14, [%[pixels], #16] \n\t"
  946. "add %[pixels], %[pixels], %[line_size] \n\t"
  947. "pld [%[pixels]] \n\t"
  948. "walignr1 wr2, wr12, wr13 \n\t"
  949. "pld [%[pixels], #32] \n\t"
  950. "walignr1 wr3, wr13, wr14 \n\t"
  951. "wmoveq wr10, wr13 \n\t"
  952. "wmoveq wr11, wr14 \n\t"
  953. "walignr2ne wr10, wr12, wr13 \n\t"
  954. "walignr2ne wr11, wr13, wr14 \n\t"
  955. "wunpckelub wr0, wr2 \n\t"
  956. "wunpckehub wr1, wr2 \n\t"
  957. "wunpckelub wr2, wr3 \n\t"
  958. "wunpckehub wr3, wr3 \n\t"
  959. "wunpckelub wr8, wr10 \n\t"
  960. "wunpckehub wr9, wr10 \n\t"
  961. "wunpckelub wr10, wr11 \n\t"
  962. "wunpckehub wr11, wr11 \n\t"
  963. "waddhus wr0, wr0, wr8 \n\t"
  964. "waddhus wr1, wr1, wr9 \n\t"
  965. "waddhus wr2, wr2, wr10 \n\t"
  966. "waddhus wr3, wr3, wr11 \n\t"
  967. "1: \n\t"
  968. // [wr0 wr1 wr2 wr3]
  969. // [wr4 wr5 wr6 wr7] <= *
  970. "wldrd wr12, [%[pixels]] \n\t"
  971. "cmp r12, #8 \n\t"
  972. "wldrd wr13, [%[pixels], #8] \n\t"
  973. "wldrd wr14, [%[pixels], #16] \n\t"
  974. "add %[pixels], %[pixels], %[line_size] \n\t"
  975. "walignr1 wr6, wr12, wr13 \n\t"
  976. "pld [%[pixels]] \n\t"
  977. "pld [%[pixels], #32] \n\t"
  978. "walignr1 wr7, wr13, wr14 \n\t"
  979. "wmoveq wr10, wr13 \n\t"
  980. "wmoveq wr11, wr14 \n\t"
  981. "walignr2ne wr10, wr12, wr13 \n\t"
  982. "walignr2ne wr11, wr13, wr14 \n\t"
  983. "wunpckelub wr4, wr6 \n\t"
  984. "wunpckehub wr5, wr6 \n\t"
  985. "wunpckelub wr6, wr7 \n\t"
  986. "wunpckehub wr7, wr7 \n\t"
  987. "wunpckelub wr8, wr10 \n\t"
  988. "wunpckehub wr9, wr10 \n\t"
  989. "wunpckelub wr10, wr11 \n\t"
  990. "wunpckehub wr11, wr11 \n\t"
  991. "waddhus wr4, wr4, wr8 \n\t"
  992. "waddhus wr5, wr5, wr9 \n\t"
  993. "waddhus wr6, wr6, wr10 \n\t"
  994. "waddhus wr7, wr7, wr11 \n\t"
  995. "waddhus wr8, wr0, wr4 \n\t"
  996. "waddhus wr9, wr1, wr5 \n\t"
  997. "waddhus wr10, wr2, wr6 \n\t"
  998. "waddhus wr11, wr3, wr7 \n\t"
  999. "waddhus wr8, wr8, wr15 \n\t"
  1000. "waddhus wr9, wr9, wr15 \n\t"
  1001. "waddhus wr10, wr10, wr15 \n\t"
  1002. "waddhus wr11, wr11, wr15 \n\t"
  1003. "wsrlhg wr8, wr8, wcgr0 \n\t"
  1004. "wsrlhg wr9, wr9, wcgr0 \n\t"
  1005. "wldrd wr12, [%[block]] \n\t"
  1006. "wldrd wr13, [%[block], #8] \n\t"
  1007. "wsrlhg wr10, wr10, wcgr0 \n\t"
  1008. "wsrlhg wr11, wr11, wcgr0 \n\t"
  1009. "wpackhus wr8, wr8, wr9 \n\t"
  1010. "wpackhus wr9, wr10, wr11 \n\t"
  1011. WAVG2B" wr8, wr8, wr12 \n\t"
  1012. WAVG2B" wr9, wr9, wr13 \n\t"
  1013. "wstrd wr8, [%[block]] \n\t"
  1014. "wstrd wr9, [%[block], #8] \n\t"
  1015. "add %[block], %[block], %[line_size] \n\t"
  1016. // [wr0 wr1 wr2 wr3] <= *
  1017. // [wr4 wr5 wr6 wr7]
  1018. "wldrd wr12, [%[pixels]] \n\t"
  1019. "pld [%[block]] \n\t"
  1020. "wldrd wr13, [%[pixels], #8] \n\t"
  1021. "pld [%[block], #32] \n\t"
  1022. "wldrd wr14, [%[pixels], #16] \n\t"
  1023. "add %[pixels], %[pixels], %[line_size] \n\t"
  1024. "walignr1 wr2, wr12, wr13 \n\t"
  1025. "pld [%[pixels]] \n\t"
  1026. "pld [%[pixels], #32] \n\t"
  1027. "walignr1 wr3, wr13, wr14 \n\t"
  1028. "wmoveq wr10, wr13 \n\t"
  1029. "wmoveq wr11, wr14 \n\t"
  1030. "walignr2ne wr10, wr12, wr13 \n\t"
  1031. "walignr2ne wr11, wr13, wr14 \n\t"
  1032. "wunpckelub wr0, wr2 \n\t"
  1033. "wunpckehub wr1, wr2 \n\t"
  1034. "wunpckelub wr2, wr3 \n\t"
  1035. "wunpckehub wr3, wr3 \n\t"
  1036. "wunpckelub wr8, wr10 \n\t"
  1037. "wunpckehub wr9, wr10 \n\t"
  1038. "wunpckelub wr10, wr11 \n\t"
  1039. "wunpckehub wr11, wr11 \n\t"
  1040. "waddhus wr0, wr0, wr8 \n\t"
  1041. "waddhus wr1, wr1, wr9 \n\t"
  1042. "waddhus wr2, wr2, wr10 \n\t"
  1043. "waddhus wr3, wr3, wr11 \n\t"
  1044. "waddhus wr8, wr0, wr4 \n\t"
  1045. "waddhus wr9, wr1, wr5 \n\t"
  1046. "waddhus wr10, wr2, wr6 \n\t"
  1047. "waddhus wr11, wr3, wr7 \n\t"
  1048. "waddhus wr8, wr8, wr15 \n\t"
  1049. "waddhus wr9, wr9, wr15 \n\t"
  1050. "waddhus wr10, wr10, wr15 \n\t"
  1051. "waddhus wr11, wr11, wr15 \n\t"
  1052. "wsrlhg wr8, wr8, wcgr0 \n\t"
  1053. "wsrlhg wr9, wr9, wcgr0 \n\t"
  1054. "wldrd wr12, [%[block]] \n\t"
  1055. "wldrd wr13, [%[block], #8] \n\t"
  1056. "wsrlhg wr10, wr10, wcgr0 \n\t"
  1057. "wsrlhg wr11, wr11, wcgr0 \n\t"
  1058. "wpackhus wr8, wr8, wr9 \n\t"
  1059. "wpackhus wr9, wr10, wr11 \n\t"
  1060. WAVG2B" wr8, wr8, wr12 \n\t"
  1061. WAVG2B" wr9, wr9, wr13 \n\t"
  1062. "wstrd wr8, [%[block]] \n\t"
  1063. "wstrd wr9, [%[block], #8] \n\t"
  1064. "add %[block], %[block], %[line_size] \n\t"
  1065. "subs %[h], %[h], #2 \n\t"
  1066. "pld [%[block]] \n\t"
  1067. "pld [%[block], #32] \n\t"
  1068. "bne 1b \n\t"
  1069. : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block)
  1070. : [line_size]"r"(line_size)
  1071. : "r12", "memory");
  1072. }
  1073. #endif /* FFMPEG_DSPUTIL_IWMMXT_RND_H */