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.

180 lines
6.1KB

  1. /*
  2. * Alpha optimized DSP utils
  3. * Copyright (c) 2002 Falk Hueffner <falk@debian.org>
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "regdef.h"
  22. /* Some nicer register names. */
  23. #define ta t10
  24. #define tb t11
  25. #define tc t12
  26. #define td AT
  27. /* Danger: these overlap with the argument list and the return value */
  28. #define te a5
  29. #define tf a4
  30. #define tg a3
  31. #define th v0
  32. .set noat
  33. .set noreorder
  34. .arch pca56
  35. .text
  36. /*****************************************************************************
  37. * int pix_abs16x16_mvi_asm(uint8_t *pix1, uint8_t *pix2, int line_size)
  38. *
  39. * This code is written with a pca56 in mind. For ev6, one should
  40. * really take the increased latency of 3 cycles for MVI instructions
  41. * into account.
  42. *
  43. * It is important to keep the loading and first use of a register as
  44. * far apart as possible, because if a register is accessed before it
  45. * has been fetched from memory, the CPU will stall.
  46. */
  47. .align 4
  48. .globl pix_abs16x16_mvi_asm
  49. .ent pix_abs16x16_mvi_asm
  50. pix_abs16x16_mvi_asm:
  51. .frame sp, 0, ra, 0
  52. .prologue 0
  53. and a2, 7, t0
  54. clr v0
  55. beq t0, $aligned
  56. .align 4
  57. $unaligned:
  58. /* Registers:
  59. line 0:
  60. t0: left_u -> left lo -> left
  61. t1: mid
  62. t2: right_u -> right hi -> right
  63. t3: ref left
  64. t4: ref right
  65. line 1:
  66. t5: left_u -> left lo -> left
  67. t6: mid
  68. t7: right_u -> right hi -> right
  69. t8: ref left
  70. t9: ref right
  71. temp:
  72. ta: left hi
  73. tb: right lo
  74. tc: error left
  75. td: error right */
  76. /* load line 0 */
  77. ldq_u t0, 0(a2) # left_u
  78. ldq_u t1, 8(a2) # mid
  79. ldq_u t2, 16(a2) # right_u
  80. ldq t3, 0(a1) # ref left
  81. ldq t4, 8(a1) # ref right
  82. addq a1, a3, a1 # pix1
  83. addq a2, a3, a2 # pix2
  84. /* load line 1 */
  85. ldq_u t5, 0(a2) # left_u
  86. ldq_u t6, 8(a2) # mid
  87. ldq_u t7, 16(a2) # right_u
  88. ldq t8, 0(a1) # ref left
  89. ldq t9, 8(a1) # ref right
  90. addq a1, a3, a1 # pix1
  91. addq a2, a3, a2 # pix2
  92. /* calc line 0 */
  93. extql t0, a2, t0 # left lo
  94. extqh t1, a2, ta # left hi
  95. extql t1, a2, tb # right lo
  96. or t0, ta, t0 # left
  97. extqh t2, a2, t2 # right hi
  98. perr t3, t0, tc # error left
  99. or t2, tb, t2 # right
  100. perr t4, t2, td # error right
  101. addq v0, tc, v0 # add error left
  102. addq v0, td, v0 # add error left
  103. /* calc line 1 */
  104. extql t5, a2, t5 # left lo
  105. extqh t6, a2, ta # left hi
  106. extql t6, a2, tb # right lo
  107. or t5, ta, t5 # left
  108. extqh t7, a2, t7 # right hi
  109. perr t8, t5, tc # error left
  110. or t7, tb, t7 # right
  111. perr t9, t7, td # error right
  112. addq v0, tc, v0 # add error left
  113. addq v0, td, v0 # add error left
  114. /* loop */
  115. subq a4, 2, a4 # h -= 2
  116. bne a4, $unaligned
  117. ret
  118. .align 4
  119. $aligned:
  120. /* load line 0 */
  121. ldq t0, 0(a2) # left
  122. ldq t1, 8(a2) # right
  123. addq a2, a3, a2 # pix2
  124. ldq t2, 0(a1) # ref left
  125. ldq t3, 8(a1) # ref right
  126. addq a1, a3, a1 # pix1
  127. /* load line 1 */
  128. ldq t4, 0(a2) # left
  129. ldq t5, 8(a2) # right
  130. addq a2, a3, a2 # pix2
  131. ldq t6, 0(a1) # ref left
  132. ldq t7, 8(a1) # ref right
  133. addq a1, a3, a1 # pix1
  134. /* load line 2 */
  135. ldq t8, 0(a2) # left
  136. ldq t9, 8(a2) # right
  137. addq a2, a3, a2 # pix2
  138. ldq ta, 0(a1) # ref left
  139. ldq tb, 8(a1) # ref right
  140. addq a1, a3, a1 # pix1
  141. /* load line 3 */
  142. ldq tc, 0(a2) # left
  143. ldq td, 8(a2) # right
  144. addq a2, a3, a2 # pix2
  145. ldq te, 0(a1) # ref left
  146. ldq a0, 8(a1) # ref right
  147. /* calc line 0 */
  148. perr t0, t2, t0 # error left
  149. addq a1, a3, a1 # pix1
  150. perr t1, t3, t1 # error right
  151. addq v0, t0, v0 # add error left
  152. /* calc line 1 */
  153. perr t4, t6, t0 # error left
  154. addq v0, t1, v0 # add error right
  155. perr t5, t7, t1 # error right
  156. addq v0, t0, v0 # add error left
  157. /* calc line 2 */
  158. perr t8, ta, t0 # error left
  159. addq v0, t1, v0 # add error right
  160. perr t9, tb, t1 # error right
  161. addq v0, t0, v0 # add error left
  162. /* calc line 3 */
  163. perr tc, te, t0 # error left
  164. addq v0, t1, v0 # add error right
  165. perr td, a0, t1 # error right
  166. addq v0, t0, v0 # add error left
  167. addq v0, t1, v0 # add error right
  168. /* loop */
  169. subq a4, 4, a4 # h -= 4
  170. bne a4, $aligned
  171. ret
  172. .end pix_abs16x16_mvi_asm