/media/libvpx/vp8/decoder/arm/neon/idct_dequant_full_2x_neon.asm

http://github.com/zpao/v8monkey · Assembly · 197 lines · 100 code · 30 blank · 67 comment · 0 complexity · 7a751b0cf3183249a0c957475e60c1a5 MD5 · raw file

  1. ;
  2. ; Copyright (c) 2010 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. EXPORT |idct_dequant_full_2x_neon|
  11. ARM
  12. REQUIRE8
  13. PRESERVE8
  14. AREA ||.text||, CODE, READONLY, ALIGN=2
  15. ;void idct_dequant_full_2x_neon(short *q, short *dq, unsigned char *pre,
  16. ; unsigned char *dst, int pitch, int stride);
  17. ; r0 *q,
  18. ; r1 *dq,
  19. ; r2 *pre
  20. ; r3 *dst
  21. ; sp pitch
  22. ; sp+4 stride
  23. |idct_dequant_full_2x_neon| PROC
  24. vld1.16 {q0, q1}, [r1] ; dq (same l/r)
  25. vld1.16 {q2, q3}, [r0] ; l q
  26. ldr r1, [sp] ; pitch
  27. add r0, r0, #32
  28. vld1.16 {q4, q5}, [r0] ; r q
  29. add r12, r2, #4
  30. ; interleave the predictors
  31. vld1.32 {d28[0]}, [r2], r1 ; l pre
  32. vld1.32 {d28[1]}, [r12], r1 ; r pre
  33. vld1.32 {d29[0]}, [r2], r1
  34. vld1.32 {d29[1]}, [r12], r1
  35. vld1.32 {d30[0]}, [r2], r1
  36. vld1.32 {d30[1]}, [r12], r1
  37. vld1.32 {d31[0]}, [r2]
  38. vld1.32 {d31[1]}, [r12]
  39. adr r2, cospi8sqrt2minus1 ; pointer to the first constant
  40. ; dequant: q[i] = q[i] * dq[i]
  41. vmul.i16 q2, q2, q0
  42. vmul.i16 q3, q3, q1
  43. vmul.i16 q4, q4, q0
  44. vmul.i16 q5, q5, q1
  45. vld1.16 {d0}, [r2]
  46. ; q2: l0r0 q3: l8r8
  47. ; q4: l4r4 q5: l12r12
  48. vswp d5, d8
  49. vswp d7, d10
  50. ; _CONSTANTS_ * 4,12 >> 16
  51. ; q6: 4 * sinpi : c1/temp1
  52. ; q7: 12 * sinpi : d1/temp2
  53. ; q8: 4 * cospi
  54. ; q9: 12 * cospi
  55. vqdmulh.s16 q6, q4, d0[2] ; sinpi8sqrt2
  56. vqdmulh.s16 q7, q5, d0[2]
  57. vqdmulh.s16 q8, q4, d0[0] ; cospi8sqrt2minus1
  58. vqdmulh.s16 q9, q5, d0[0]
  59. vqadd.s16 q10, q2, q3 ; a1 = 0 + 8
  60. vqsub.s16 q11, q2, q3 ; b1 = 0 - 8
  61. ; vqdmulh only accepts signed values. this was a problem because
  62. ; our constant had the high bit set, and was treated as a negative value.
  63. ; vqdmulh also doubles the value before it shifts by 16. we need to
  64. ; compensate for this. in the case of sinpi8sqrt2, the lowest bit is 0,
  65. ; so we can shift the constant without losing precision. this avoids
  66. ; shift again afterward, but also avoids the sign issue. win win!
  67. ; for cospi8sqrt2minus1 the lowest bit is 1, so we lose precision if we
  68. ; pre-shift it
  69. vshr.s16 q8, q8, #1
  70. vshr.s16 q9, q9, #1
  71. ; q4: 4 + 4 * cospi : d1/temp1
  72. ; q5: 12 + 12 * cospi : c1/temp2
  73. vqadd.s16 q4, q4, q8
  74. vqadd.s16 q5, q5, q9
  75. ; c1 = temp1 - temp2
  76. ; d1 = temp1 + temp2
  77. vqsub.s16 q2, q6, q5
  78. vqadd.s16 q3, q4, q7
  79. ; [0]: a1+d1
  80. ; [1]: b1+c1
  81. ; [2]: b1-c1
  82. ; [3]: a1-d1
  83. vqadd.s16 q4, q10, q3
  84. vqadd.s16 q5, q11, q2
  85. vqsub.s16 q6, q11, q2
  86. vqsub.s16 q7, q10, q3
  87. ; rotate
  88. vtrn.32 q4, q6
  89. vtrn.32 q5, q7
  90. vtrn.16 q4, q5
  91. vtrn.16 q6, q7
  92. ; idct loop 2
  93. ; q4: l 0, 4, 8,12 r 0, 4, 8,12
  94. ; q5: l 1, 5, 9,13 r 1, 5, 9,13
  95. ; q6: l 2, 6,10,14 r 2, 6,10,14
  96. ; q7: l 3, 7,11,15 r 3, 7,11,15
  97. ; q8: 1 * sinpi : c1/temp1
  98. ; q9: 3 * sinpi : d1/temp2
  99. ; q10: 1 * cospi
  100. ; q11: 3 * cospi
  101. vqdmulh.s16 q8, q5, d0[2] ; sinpi8sqrt2
  102. vqdmulh.s16 q9, q7, d0[2]
  103. vqdmulh.s16 q10, q5, d0[0] ; cospi8sqrt2minus1
  104. vqdmulh.s16 q11, q7, d0[0]
  105. vqadd.s16 q2, q4, q6 ; a1 = 0 + 2
  106. vqsub.s16 q3, q4, q6 ; b1 = 0 - 2
  107. ; see note on shifting above
  108. vshr.s16 q10, q10, #1
  109. vshr.s16 q11, q11, #1
  110. ; q10: 1 + 1 * cospi : d1/temp1
  111. ; q11: 3 + 3 * cospi : c1/temp2
  112. vqadd.s16 q10, q5, q10
  113. vqadd.s16 q11, q7, q11
  114. ; q8: c1 = temp1 - temp2
  115. ; q9: d1 = temp1 + temp2
  116. vqsub.s16 q8, q8, q11
  117. vqadd.s16 q9, q10, q9
  118. ; a1+d1
  119. ; b1+c1
  120. ; b1-c1
  121. ; a1-d1
  122. vqadd.s16 q4, q2, q9
  123. vqadd.s16 q5, q3, q8
  124. vqsub.s16 q6, q3, q8
  125. vqsub.s16 q7, q2, q9
  126. ; +4 >> 3 (rounding)
  127. vrshr.s16 q4, q4, #3 ; lo
  128. vrshr.s16 q5, q5, #3
  129. vrshr.s16 q6, q6, #3 ; hi
  130. vrshr.s16 q7, q7, #3
  131. vtrn.32 q4, q6
  132. vtrn.32 q5, q7
  133. vtrn.16 q4, q5
  134. vtrn.16 q6, q7
  135. ; adding pre
  136. ; input is still packed. pre was read interleaved
  137. vaddw.u8 q4, q4, d28
  138. vaddw.u8 q5, q5, d29
  139. vaddw.u8 q6, q6, d30
  140. vaddw.u8 q7, q7, d31
  141. vmov.i16 q14, #0
  142. vmov q15, q14
  143. vst1.16 {q14, q15}, [r0] ; write over high input
  144. sub r0, r0, #32
  145. vst1.16 {q14, q15}, [r0] ; write over low input
  146. ;saturate and narrow
  147. vqmovun.s16 d0, q4 ; lo
  148. vqmovun.s16 d1, q5
  149. vqmovun.s16 d2, q6 ; hi
  150. vqmovun.s16 d3, q7
  151. ldr r1, [sp, #4] ; stride
  152. add r2, r3, #4 ; hi
  153. vst1.32 {d0[0]}, [r3], r1 ; lo
  154. vst1.32 {d0[1]}, [r2], r1 ; hi
  155. vst1.32 {d1[0]}, [r3], r1
  156. vst1.32 {d1[1]}, [r2], r1
  157. vst1.32 {d2[0]}, [r3], r1
  158. vst1.32 {d2[1]}, [r2], r1
  159. vst1.32 {d3[0]}, [r3]
  160. vst1.32 {d3[1]}, [r2]
  161. bx lr
  162. ENDP ; |idct_dequant_full_2x_neon|
  163. ; Constant Pool
  164. cospi8sqrt2minus1 DCD 0x4e7b
  165. ; because the lowest bit in 0x8a8c is 0, we can pre-shift this
  166. sinpi8sqrt2 DCD 0x4546
  167. END