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.

186 lines
6.2KB

  1. /*
  2. * Alpha optimized DSP utils
  3. * Copyright (c) 2002 Falk Hueffner <falk@debian.org>
  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. #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. #ifdef CONFIG_GPROF
  54. lda AT, _mcount
  55. jsr AT, (AT), _mcount
  56. #endif
  57. and a1, 7, t0
  58. clr v0
  59. lda a3, 16
  60. beq t0, $aligned
  61. .align 4
  62. $unaligned:
  63. /* Registers:
  64. line 0:
  65. t0: left_u -> left lo -> left
  66. t1: mid
  67. t2: right_u -> right hi -> right
  68. t3: ref left
  69. t4: ref right
  70. line 1:
  71. t5: left_u -> left lo -> left
  72. t6: mid
  73. t7: right_u -> right hi -> right
  74. t8: ref left
  75. t9: ref right
  76. temp:
  77. ta: left hi
  78. tb: right lo
  79. tc: error left
  80. td: error right */
  81. /* load line 0 */
  82. ldq_u t0, 0(a1) # left_u
  83. ldq_u t1, 8(a1) # mid
  84. ldq_u t2, 16(a1) # right_u
  85. ldq t3, 0(a0) # ref left
  86. ldq t4, 8(a0) # ref right
  87. addq a0, a2, a0 # pix1
  88. addq a1, a2, a1 # pix2
  89. /* load line 1 */
  90. ldq_u t5, 0(a1) # left_u
  91. ldq_u t6, 8(a1) # mid
  92. ldq_u t7, 16(a1) # right_u
  93. ldq t8, 0(a0) # ref left
  94. ldq t9, 8(a0) # ref right
  95. addq a0, a2, a0 # pix1
  96. addq a1, a2, a1 # pix2
  97. /* calc line 0 */
  98. extql t0, a1, t0 # left lo
  99. extqh t1, a1, ta # left hi
  100. extql t1, a1, tb # right lo
  101. or t0, ta, t0 # left
  102. extqh t2, a1, t2 # right hi
  103. perr t3, t0, tc # error left
  104. or t2, tb, t2 # right
  105. perr t4, t2, td # error right
  106. addq v0, tc, v0 # add error left
  107. addq v0, td, v0 # add error left
  108. /* calc line 1 */
  109. extql t5, a1, t5 # left lo
  110. extqh t6, a1, ta # left hi
  111. extql t6, a1, tb # right lo
  112. or t5, ta, t5 # left
  113. extqh t7, a1, t7 # right hi
  114. perr t8, t5, tc # error left
  115. or t7, tb, t7 # right
  116. perr t9, t7, td # error right
  117. addq v0, tc, v0 # add error left
  118. addq v0, td, v0 # add error left
  119. /* loop */
  120. subq a3, 2, a3 # h -= 2
  121. bne a3, $unaligned
  122. ret
  123. .align 4
  124. $aligned:
  125. /* load line 0 */
  126. ldq t0, 0(a1) # left
  127. ldq t1, 8(a1) # right
  128. addq a1, a2, a1 # pix2
  129. ldq t2, 0(a0) # ref left
  130. ldq t3, 8(a0) # ref right
  131. addq a0, a2, a0 # pix1
  132. /* load line 1 */
  133. ldq t4, 0(a1) # left
  134. ldq t5, 8(a1) # right
  135. addq a1, a2, a1 # pix2
  136. ldq t6, 0(a0) # ref left
  137. ldq t7, 8(a0) # ref right
  138. addq a0, a2, a0 # pix1
  139. /* load line 2 */
  140. ldq t8, 0(a1) # left
  141. ldq t9, 8(a1) # right
  142. addq a1, a2, a1 # pix2
  143. ldq ta, 0(a0) # ref left
  144. ldq tb, 8(a0) # ref right
  145. addq a0, a2, a0 # pix1
  146. /* load line 3 */
  147. ldq tc, 0(a1) # left
  148. ldq td, 8(a1) # right
  149. addq a1, a2, a1 # pix2
  150. ldq te, 0(a0) # ref left
  151. ldq tf, 8(a0) # ref right
  152. /* calc line 0 */
  153. perr t0, t2, t0 # error left
  154. addq a0, a2, a0 # pix1
  155. perr t1, t3, t1 # error right
  156. addq v0, t0, v0 # add error left
  157. /* calc line 1 */
  158. perr t4, t6, t0 # error left
  159. addq v0, t1, v0 # add error right
  160. perr t5, t7, t1 # error right
  161. addq v0, t0, v0 # add error left
  162. /* calc line 2 */
  163. perr t8, ta, t0 # error left
  164. addq v0, t1, v0 # add error right
  165. perr t9, tb, t1 # error right
  166. addq v0, t0, v0 # add error left
  167. /* calc line 3 */
  168. perr tc, te, t0 # error left
  169. addq v0, t1, v0 # add error right
  170. perr td, tf, t1 # error right
  171. addq v0, t0, v0 # add error left
  172. addq v0, t1, v0 # add error right
  173. /* loop */
  174. subq a3, 4, a3 # h -= 4
  175. bne a3, $aligned
  176. ret
  177. .end pix_abs16x16_mvi_asm