2 * ARM NEON optimised MDCT
3 * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
5 * This file is part of FFmpeg.
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.
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.
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
26 #define ff_fft_calc_neon X(ff_fft_calc_neon)
28 function ff_imdct_half_neon, export=1
32 ldr lr, [r0, #28] @ mdct_bits
33 ldr r4, [r0, #32] @ tcos
34 ldr r3, [r0, #8] @ revtab
35 lsl r12, r12, lr @ n = 1 << nbits
36 lsr lr, r12, #2 @ n4 = n >> 2
37 add r7, r2, r12, lsl #1
41 vld2.32 {d16-d17},[r7,:128],r12 @ d16=x,n1 d17=x,n0
42 vld2.32 {d0-d1}, [r2,:128]! @ d0 =m0,x d1 =m1,x
44 vld2.32 {d2,d3}, [r4,:128]! @ d2=c0,c1 d3=s0,s2
56 add r8, r1, r8, lsl #3
57 add r6, r1, r6, lsl #3
59 vld2.32 {d16-d17},[r7,:128],r12
60 vld2.32 {d0-d1}, [r2,:128]!
62 vld2.32 {d2,d3}, [r4,:128]! @ d2=c0,c1 d3=s0,s2
65 vst2.32 {d4[0],d5[0]}, [r6,:64]
66 vst2.32 {d4[1],d5[1]}, [r8,:64]
69 vst2.32 {d4[0],d5[0]}, [r6,:64]
70 vst2.32 {d4[1],d5[1]}, [r8,:64]
77 ldr lr, [r4, #28] @ mdct_bits
78 ldr r4, [r4, #32] @ tcos
79 lsl r12, r12, lr @ n = 1 << nbits
80 lsr lr, r12, #3 @ n8 = n >> 3
82 add r4, r4, lr, lsl #3
83 add r6, r6, lr, lsl #3
91 vld2.32 {d0-d1}, [r3,:128], r7 @ d0 =i1,r1 d1 =i0,r0
92 vld2.32 {d20-d21},[r6,:128]! @ d20=i2,r2 d21=i3,r3
93 vld2.32 {d16,d18},[r1,:128], r7 @ d16=c1,c0 d18=s1,s0
97 vld2.32 {d17,d19},[r4,:128]! @ d17=c2,c3 d19=s2,s3
100 vmul.f32 d6, d20, d19
101 vmul.f32 d22, d1, d16
102 vmul.f32 d23, d21, d17
103 vmul.f32 d24, d0, d16
104 vmul.f32 d25, d20, d17
110 vld2.32 {d0-d1}, [r3,:128], r7
111 vld2.32 {d20-d21},[r6,:128]!
112 vld2.32 {d16,d18},[r1,:128], r7 @ d16=c1,c0 d18=s1,s0
114 vst2.32 {d4,d6}, [r0,:128], r7
115 vst2.32 {d5,d7}, [r8,:128]!
119 vst2.32 {d4,d6}, [r0,:128]
120 vst2.32 {d5,d7}, [r8,:128]
125 function ff_imdct_calc_neon, export=1
134 bl ff_imdct_half_neon
136 add r0, r5, r4, lsl #2
137 add r1, r5, r4, lsl #1
144 vld1.32 {d0-d1}, [r2,:128], r3
147 vld1.32 {d2-d3}, [r1,:128]!
152 vst1.32 {d2}, [r0,:64], r6
153 vst1.32 {d3}, [r0,:64], r6
154 vst1.32 {d4-d5}, [r5,:128]!
161 function ff_mdct_calc_neon, export=1
165 ldr lr, [r0, #28] @ mdct_bits
166 ldr r4, [r0, #32] @ tcos
167 ldr r3, [r0, #8] @ revtab
168 lsl lr, r12, lr @ n = 1 << nbits
169 add r7, r2, lr @ in4u
170 sub r9, r7, #16 @ in4d
171 add r2, r7, lr, lsl #1 @ in3u
172 add r8, r9, lr, lsl #1 @ in3d
173 add r5, r4, lr, lsl #1
178 vld2.32 {d16,d18},[r9,:128],r12 @ in0u0,in0u1 in4d1,in4d0
179 vld2.32 {d17,d19},[r8,:128],r12 @ in2u0,in2u1 in3d1,in3d0
180 vld2.32 {d0, d2}, [r7,:128]! @ in4u0,in4u1 in2d1,in2d0
181 vrev64.32 q9, q9 @ in4d0,in4d1 in3d0,in3d1
182 vld2.32 {d1, d3}, [r2,:128]! @ in3u0,in3u1 in1d1,in1d0
183 vsub.f32 d0, d18, d0 @ in4d-in4u I
184 vld2.32 {d20,d21},[r4,:128]! @ c0,c1 s0,s1
185 vrev64.32 q1, q1 @ in2d0,in2d1 in1d0,in1d1
186 vld2.32 {d30,d31},[r5,:128],r12 @ c2,c3 s2,s3
187 vadd.f32 d1, d1, d19 @ in3u+in3d -R
188 vsub.f32 d16, d16, d2 @ in0u-in2d R
189 vadd.f32 d17, d17, d3 @ in2u+in1d -I
191 vmul.f32 d7, d0, d21 @ I*s
192 ldr r10, [r3, lr, lsr #1]
193 vmul.f32 d6, d1, d20 @ -R*c
195 vmul.f32 d4, d1, d21 @ -R*s
196 vmul.f32 d5, d0, d20 @ I*c
197 vmul.f32 d24, d16, d30 @ R*c
198 vmul.f32 d25, d17, d31 @ -I*s
199 vmul.f32 d22, d16, d31 @ R*s
200 vmul.f32 d23, d17, d30 @ I*c
202 vsub.f32 d6, d6, d7 @ -R*c-I*s
203 vadd.f32 d7, d4, d5 @ -R*s+I*c
204 vsub.f32 d24, d25, d24 @ I*s-R*c
205 vadd.f32 d25, d22, d23 @ R*s-I*c
208 vld2.32 {d16,d18},[r9,:128],r12 @ in0u0,in0u1 in4d1,in4d0
209 vld2.32 {d17,d19},[r8,:128],r12 @ in2u0,in2u1 in3d1,in3d0
210 vneg.f32 d7, d7 @ R*s-I*c
211 vld2.32 {d0, d2}, [r7,:128]! @ in4u0,in4u1 in2d1,in2d0
212 vrev64.32 q9, q9 @ in4d0,in4d1 in3d0,in3d1
213 vld2.32 {d1, d3}, [r2,:128]! @ in3u0,in3u1 in1d1,in1d0
214 vsub.f32 d0, d18, d0 @ in4d-in4u I
215 vld2.32 {d20,d21},[r4,:128]! @ c0,c1 s0,s1
216 vrev64.32 q1, q1 @ in2d0,in2d1 in1d0,in1d1
217 vld2.32 {d30,d31},[r5,:128],r12 @ c2,c3 s2,s3
218 vadd.f32 d1, d1, d19 @ in3u+in3d -R
219 vsub.f32 d16, d16, d2 @ in0u-in2d R
220 vadd.f32 d17, d17, d3 @ in2u+in1d -I
221 uxth r12, r6, ror #16
223 add r12, r1, r12, lsl #3
224 add r6, r1, r6, lsl #3
225 vst2.32 {d6[0],d7[0]}, [r6,:64]
226 vst2.32 {d6[1],d7[1]}, [r12,:64]
227 uxth r6, r10, ror #16
229 add r6 , r1, r6, lsl #3
230 add r10, r1, r10, lsl #3
231 vst2.32 {d24[0],d25[0]},[r10,:64]
232 vst2.32 {d24[1],d25[1]},[r6,:64]
235 vneg.f32 d7, d7 @ R*s-I*c
236 uxth r12, r6, ror #16
238 add r12, r1, r12, lsl #3
239 add r6, r1, r6, lsl #3
240 vst2.32 {d6[0],d7[0]}, [r6,:64]
241 vst2.32 {d6[1],d7[1]}, [r12,:64]
242 uxth r6, r10, ror #16
244 add r6 , r1, r6, lsl #3
245 add r10, r1, r10, lsl #3
246 vst2.32 {d24[0],d25[0]},[r10,:64]
247 vst2.32 {d24[1],d25[1]},[r6,:64]
254 ldr lr, [r4, #28] @ mdct_bits
255 ldr r4, [r4, #32] @ tcos
256 lsl r12, r12, lr @ n = 1 << nbits
257 lsr lr, r12, #3 @ n8 = n >> 3
259 add r4, r4, lr, lsl #3
260 add r6, r6, lr, lsl #3
268 vld2.32 {d0-d1}, [r3,:128], r7 @ d0 =r1,i1 d1 =r0,i0
269 vld2.32 {d20-d21},[r6,:128]! @ d20=r2,i2 d21=r3,i3
270 vld2.32 {d16,d18},[r1,:128], r7 @ c1,c0 s1,s0
273 vmul.f32 d7, d0, d18 @ r1*s1,r0*s0
274 vld2.32 {d17,d19},[r4,:128]! @ c2,c3 s2,s3
275 vmul.f32 d4, d1, d18 @ i1*s1,i0*s0
276 vmul.f32 d5, d21, d19 @ i2*s2,i3*s3
277 vmul.f32 d6, d20, d19 @ r2*s2,r3*s3
278 vmul.f32 d24, d0, d16 @ r1*c1,r0*c0
279 vmul.f32 d25, d20, d17 @ r2*c2,r3*c3
280 vmul.f32 d22, d21, d17 @ i2*c2,i3*c3
281 vmul.f32 d23, d1, d16 @ i1*c1,i0*c0
282 vadd.f32 d4, d4, d24 @ i1*s1+r1*c1,i0*s0+r0*c0
283 vadd.f32 d5, d5, d25 @ i2*s2+r2*c2,i3*s3+r3*c3
284 vsub.f32 d6, d22, d6 @ i2*c2-r2*s2,i3*c3-r3*s3
285 vsub.f32 d7, d23, d7 @ i1*c1-r1*s1,i0*c0-r0*s0
288 vld2.32 {d0-d1}, [r3,:128], r7
289 vld2.32 {d20-d21},[r6,:128]!
290 vld2.32 {d16,d18},[r1,:128], r7 @ c1,c0 s1,s0
292 vst2.32 {d4,d6}, [r0,:128], r7
293 vst2.32 {d5,d7}, [r8,:128]!
297 vst2.32 {d4,d6}, [r0,:128]
298 vst2.32 {d5,d7}, [r8,:128]