output.S 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) 2016 Clément Bœsch <clement stupeflix.com>
  3. * Copyright (c) 2016 Matthieu Bouron <matthieu.bouron stupeflix.com>
  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 "libavutil/arm/asm.S"
  22. function ff_yuv2planeX_8_neon, export=1
  23. push {r4-r12, lr}
  24. vpush {q4-q7}
  25. ldr r4, [sp, #104] @ dstW
  26. ldr r5, [sp, #108] @ dither
  27. ldr r6, [sp, #112] @ offset
  28. vld1.8 {d0}, [r5] @ load 8x8-bit dither values
  29. cmp r6, #0 @ check offsetting which can be 0 or 3 only
  30. beq 1f
  31. vext.u8 d0, d0, d0, #3 @ honor offseting which can be 3 only
  32. 1: vmovl.u8 q0, d0 @ extend dither to 16-bit
  33. vshll.u16 q1, d0, #12 @ extend dither to 32-bit with left shift by 12 (part 1)
  34. vshll.u16 q2, d1, #12 @ extend dither to 32-bit with left shift by 12 (part 2)
  35. mov r7, #0 @ i = 0
  36. 2: vmov.u8 q3, q1 @ initialize accumulator with dithering values (part 1)
  37. vmov.u8 q4, q2 @ initialize accumulator with dithering values (part 2)
  38. mov r8, r1 @ tmpFilterSize = filterSize
  39. mov r9, r2 @ srcp
  40. mov r10, r0 @ filterp
  41. 3: ldr r11, [r9], #4 @ get pointer @ src[j]
  42. ldr r12, [r9], #4 @ get pointer @ src[j+1]
  43. add r11, r11, r7, lsl #1 @ &src[j][i]
  44. add r12, r12, r7, lsl #1 @ &src[j+1][i]
  45. vld1.16 {q5}, [r11] @ read 8x16-bit @ src[j ][i + {0..7}]: A,B,C,D,E,F,G,H
  46. vld1.16 {q6}, [r12] @ read 8x16-bit @ src[j+1][i + {0..7}]: I,J,K,L,M,N,O,P
  47. ldr r11, [r10], #4 @ read 2x16-bit coeffs (X, Y) at (filter[j], filter[j+1])
  48. vmov.16 q7, q5 @ copy 8x16-bit @ src[j ][i + {0..7}] for following inplace zip instruction
  49. vmov.16 q8, q6 @ copy 8x16-bit @ src[j+1][i + {0..7}] for following inplace zip instruction
  50. vzip.16 q7, q8 @ A,I,B,J,C,K,D,L,E,M,F,N,G,O,H,P
  51. vdup.32 q15, r11 @ X,Y,X,Y,X,Y,X,Y
  52. vmull.s16 q9, d14, d30 @ A*X,I*Y,B*X,J*Y
  53. vmull.s16 q10, d15, d31 @ C*X,K*Y,D*X,L*Y
  54. vmull.s16 q11, d16, d30 @ E*X,M*Y,F*X,N*Y
  55. vmull.s16 q12, d17, d31 @ G*X,O*Y,H*X,P*Y
  56. vpadd.s32 d10, d18, d19 @ A*X+I*Y,B*X+J*Y
  57. vpadd.s32 d11, d20, d21 @ C*X+K*Y,D*X+L*Y
  58. vpadd.s32 d12, d22, d23 @ E*X+M*Y,F*X+N*Y
  59. vpadd.s32 d13, d24, d25 @ G*X+O*Y,H*X+P*Y
  60. vadd.s32 q3, q5 @ update val accumulator (part 1)
  61. vadd.s32 q4, q6 @ update val accumulator (part 2)
  62. subs r8, #2 @ tmpFilterSize -= 2
  63. bgt 3b @ loop until filterSize is consumed
  64. vshr.s32 q3, q3, #19 @ val>>19 (part 1)
  65. vshr.s32 q4, q4, #19 @ val>>19 (part 2)
  66. vqmovun.s32 d6, q3 @ clip16(val>>19) (part 1)
  67. vqmovun.s32 d7, q4 @ clip16(val>>19) (part 2)
  68. vqmovn.u16 d6, q3 @ merge part 1 and part 2
  69. vst1.8 {d6}, [r3]! @ write destination
  70. add r7, #8 @ i += 8
  71. subs r4, r4, #8 @ dstW -= 8
  72. bgt 2b @ loop until width is consumed
  73. vpop {q4-q7}
  74. pop {r4-r12, lr}
  75. mov pc, lr
  76. endfunc