2 /* filter_neon.S - NEON optimised filter functions
4 * Copyright (c) 2011 Glenn Randers-Pehrson
5 * Written by Mans Rullgard, 2011.
6 * Last changed in libpng 1.5.7 [December 15, 2011]
8 * This code is released under the libpng license.
9 * For conditions of distribution and use, see the disclaimer
10 * and license in png.h
13 /* This is required to get the symbol renames, which are #defines, and also
14 * includes the value of PNG_FILTER_OPTIMIZATIONS.
16 #define PNG_VERSION_INFO_ONLY
17 #include "../pngpriv.h"
19 #if defined(PNG_FILTER_OPTIMIZATIONS) && defined(__arm__) && \
21 #if defined(__linux__) && defined(__ELF__)
22 .section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
34 .macro func name, export=0
36 ELF .size \name, . - \name
44 ELF .type \name, STT_FUNC
49 func png_read_filter_row_sub4_neon, export=1
50 ldr r3, [r0, #4] @ rowbytes
53 vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
58 vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
65 func png_read_filter_row_sub3_neon, export=1
66 ldr r3, [r0, #4] @ rowbytes
71 vld1.8 {q11}, [r0], r12
73 vext.8 d5, d22, d23, #3
75 vext.8 d6, d22, d23, #6
77 vext.8 d7, d23, d23, #1
78 vld1.8 {q11}, [r0], r12
79 vst1.32 {d0[0]}, [r1,:32], r2
81 vst1.32 {d1[0]}, [r1], r2
83 vst1.32 {d2[0]}, [r1], r2
84 vst1.32 {d3[0]}, [r1], r2
91 func png_read_filter_row_up_neon, export=1
92 ldr r3, [r0, #4] @ rowbytes
94 vld1.8 {q0}, [r1,:128]
95 vld1.8 {q1}, [r2,:128]!
97 vst1.8 {q0}, [r1,:128]!
104 func png_read_filter_row_avg4_neon, export=1
105 ldr r12, [r0, #4] @ rowbytes
108 vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
109 vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]!
118 vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
125 func png_read_filter_row_avg3_neon, export=1
127 ldr r12, [r0, #4] @ rowbytes
132 vld1.8 {q11}, [r0], lr
134 vld1.8 {q10}, [r2], lr
135 vext.8 d5, d22, d23, #3
137 vext.8 d17, d20, d21, #3
139 vext.8 d6, d22, d23, #6
141 vext.8 d18, d20, d21, #6
143 vext.8 d7, d23, d23, #1
144 vld1.8 {q11}, [r0], lr
145 vst1.32 {d0[0]}, [r1,:32], r4
147 vst1.32 {d1[0]}, [r1], r4
148 vext.8 d19, d21, d21, #1
151 vst1.32 {d2[0]}, [r1], r4
153 vst1.32 {d3[0]}, [r1], r4
160 .macro paeth rx, ra, rb, rc
161 vaddl.u8 q12, \ra, \rb @ a + b
162 vaddl.u8 q15, \rc, \rc @ 2*c
163 vabdl.u8 q13, \rb, \rc @ pa
164 vabdl.u8 q14, \ra, \rc @ pb
165 vabd.u16 q15, q12, q15 @ pc
166 vcle.u16 q12, q13, q14 @ pa <= pb
167 vcle.u16 q13, q13, q15 @ pa <= pc
168 vcle.u16 q14, q14, q15 @ pb <= pc
169 vand q12, q12, q13 @ pa <= pb && pa <= pc
176 func png_read_filter_row_paeth4_neon, export=1
177 ldr r12, [r0, #4] @ rowbytes
181 vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
182 vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]!
183 paeth d0, d3, d16, d20
185 paeth d1, d0, d17, d16
187 paeth d2, d1, d18, d17
189 paeth d3, d2, d19, d18
192 vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
199 func png_read_filter_row_paeth3_neon, export=1
201 ldr r12, [r0, #4] @ rowbytes
207 vld1.8 {q11}, [r0], lr
209 vld1.8 {q10}, [r2], lr
210 paeth d0, d3, d20, d4
211 vext.8 d5, d22, d23, #3
213 vext.8 d17, d20, d21, #3
214 paeth d1, d0, d17, d20
215 vst1.32 {d0[0]}, [r1,:32], r4
216 vext.8 d6, d22, d23, #6
218 vext.8 d18, d20, d21, #6
219 paeth d2, d1, d18, d17
220 vext.8 d7, d23, d23, #1
221 vld1.8 {q11}, [r0], lr
222 vst1.32 {d1[0]}, [r1], r4
224 vext.8 d19, d21, d21, #1
225 paeth d3, d2, d19, d18
226 vst1.32 {d2[0]}, [r1], r4
229 vst1.32 {d3[0]}, [r1], r4
235 #endif /* FILTER_OPTIMIZATIONS && __arm__ && __ARM_NEON__ */