aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/arm/sbrdsp_neon.S
blob: e66abd682a8fe1efcd338693038d58c708997411 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
/*
 * Copyright (c) 2012 Mans Rullgard
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "libavutil/arm/asm.S"

function ff_sbr_sum64x5_neon, export=1
        push            {lr}
        add             r1,  r0,  # 64*4
        add             r2,  r0,  #128*4
        add             r3,  r0,  #192*4
        add             lr,  r0,  #256*4
        mov             r12, #64
1:
        vld1.32         {q0},     [r0,:128]
        vld1.32         {q1},     [r1,:128]!
        vadd.f32        q0,  q0,  q1
        vld1.32         {q2},     [r2,:128]!
        vadd.f32        q0,  q0,  q2
        vld1.32         {q3},     [r3,:128]!
        vadd.f32        q0,  q0,  q3
        vld1.32         {q8},     [lr,:128]!
        vadd.f32        q0,  q0,  q8
        vst1.32         {q0},     [r0,:128]!
        subs            r12, #4
        bgt             1b
        pop             {pc}
endfunc

function ff_sbr_sum_square_neon, export=1
        vmov.f32        q0,  #0.0
1:
        vld1.32         {q1},     [r0,:128]!
        vmla.f32        q0,  q1,  q1
        subs            r1,  r1,  #2
        bgt             1b
        vadd.f32        d0,  d0,  d1
        vpadd.f32       d0,  d0,  d0
NOVFP   vmov.32         r0,  d0[0]
        bx              lr
endfunc

function ff_sbr_neg_odd_64_neon, export=1
        mov             r1,  r0
        vmov.i32        q8,  #1<<31
        vld2.32         {q0,q1},  [r0,:128]!
        veor            q1,  q1,  q8
        vld2.32         {q2,q3},  [r0,:128]!
    .rept 3
        vst2.32         {q0,q1},  [r1,:128]!
        veor            q3,  q3,  q8
        vld2.32         {q0,q1},  [r0,:128]!
        vst2.32         {q2,q3},  [r1,:128]!
        veor            q1,  q1,  q8
        vld2.32         {q2,q3},  [r0,:128]!
    .endr
        veor            q3,  q3,  q8
        vst2.32         {q0,q1},  [r1,:128]!
        vst2.32         {q2,q3},  [r1,:128]!
        bx              lr
endfunc

function ff_sbr_qmf_pre_shuffle_neon, export=1
        add             r1,  r0,  #60*4
        add             r2,  r0,  #64*4
        vld1.32         {d0},     [r0,:64]!
        vst1.32         {d0},     [r2,:64]!
        mov             r3,  #-16
        mov             r12, #24
        vmov.i32        q8,  #1<<31
        vld1.32         {q0},     [r1,:128], r3
        vld1.32         {d2},     [r0,:64]!
1:
        vld1.32         {d3,d4},  [r0,:128]!
        vrev64.32       q0,  q0
        vld1.32         {q9},     [r1,:128], r3
        veor            q0,  q0,  q8
        vld1.32         {d5,d6},  [r0,:128]!
        vswp            d0,  d1
        vrev64.32       q9,  q9
        vst2.32         {q0,q1},  [r2,:64]!
        vmov            q10, q2
        veor            q9,  q9,  q8
        vmov            d2,  d6
        vswp            d18, d19
        vld1.32         {q0},     [r1,:128], r3
        vst2.32         {q9,q10}, [r2,:64]!
        subs            r12, r12, #8
        bgt             1b
        vld1.32         {d3,d4},  [r0,:128]!
        vrev64.32       q0,  q0
        vld1.32         {q9},     [r1,:128], r3
        veor            q0,  q0,  q8
        vld1.32         {d5},     [r0,:64]!
        vswp            d0,  d1
        vrev64.32       q9,  q9
        vst2.32         {q0,q1},  [r2,:64]!
        vswp            d4,  d5
        veor            q1,  q9,  q8
        vst2.32         {d3,d5},  [r2,:64]!
        vst2.32         {d2[0],d4[0]}, [r2,:64]!
        bx              lr
endfunc

function ff_sbr_qmf_post_shuffle_neon, export=1
        add             r2,  r1,  #60*4
        mov             r3,  #-16
        mov             r12, #32
        vmov.i32        q8,  #1<<31
        vld1.32         {q0},     [r2,:128], r3
        vld1.32         {q1},     [r1,:128]!
1:
        pld             [r2, #-32]
        vrev64.32       q0,  q0
        vswp            d2,  d3
        veor            q0,  q0,  q8
        vld1.32         {q2},     [r2,:128], r3
        vld1.32         {q3},     [r1,:128]!
        vst2.32         {d1,d3},  [r0,:128]!
        vst2.32         {d0,d2},  [r0,:128]!
        pld             [r2, #-32]
        vrev64.32       q2,  q2
        vswp            d6,  d7
        veor            q2,  q2,  q8
        vld1.32         {q0},     [r2,:128], r3
        vld1.32         {q1},     [r1,:128]!
        vst2.32         {d5,d7},  [r0,:128]!
        vst2.32         {d4,d6},  [r0,:128]!
        subs            r12, r12, #8
        bgt             1b
        bx              lr
endfunc

function ff_sbr_qmf_deint_neg_neon, export=1
        add             r1,  r1,  #60*4
        add             r2,  r0,  #62*4
        mov             r3,  #-16
        mov             r12, #32
        vmov.i32        d2,  #1<<31
1:
        vld2.32         {d0,d1},  [r1,:128], r3
        veor            d0,  d0,  d2
        vrev64.32       d1,  d1
        vst1.32         {d0},     [r2,:64]
        vst1.32         {d1},     [r0,:64]!
        sub             r2,  r2,  #8
        subs            r12, r12, #2
        bgt             1b
        bx              lr
endfunc

function ff_sbr_qmf_deint_bfly_neon, export=1
        push            {lr}
        add             r2,  r2,  #60*4
        add             r3,  r0,  #124*4
        mov             r12, #64
        mov             lr,  #-16
1:
        vld1.32         {q0},     [r1,:128]!
        vld1.32         {q1},     [r2,:128], lr
        vrev64.32       q2,  q0
        vrev64.32       q3,  q1
        vadd.f32        d3,  d4,  d3
        vadd.f32        d2,  d5,  d2
        vsub.f32        d0,  d0,  d7
        vsub.f32        d1,  d1,  d6
        vst1.32         {q1},     [r3,:128], lr
        vst1.32         {q0},     [r0,:128]!
        subs            r12, r12, #4
        bgt             1b
        pop             {pc}
endfunc

function ff_sbr_hf_g_filt_neon, export=1
        ldr             r12, [sp]
        add             r1,  r1,  r12, lsl #3
        mov             r12, #40*2*4
        sub             r3,  r3,  #1
        vld2.32         {d2[],d3[]},[r2,:64]!
        vld1.32         {d0},     [r1,:64], r12
1:
        vld1.32         {d1},     [r1,:64], r12
        vmul.f32        q3,  q0,  q1
        vld2.32         {d2[],d3[]},[r2,:64]!
        vld1.32         {d0},     [r1,:64], r12
        vst1.32         {q3},     [r0,:64]!
        subs            r3,  r3,  #2
        bgt             1b
        it              lt
        bxlt            lr
        vmul.f32        d0,  d0,  d2
        vst1.32         {d0},     [r0,:64]!
        bx              lr
endfunc

function ff_sbr_hf_gen_neon, export=1
NOVFP   vld1.32         {d1[]},   [sp,:32]
VFP     vdup.32         d1,  d0[0]
        vmul.f32        d0,  d1,  d1
        vld1.32         {d3},     [r2,:64]
        vld1.32         {d2},     [r3,:64]
        vmul.f32        q0,  q0,  q1
        ldrd            r2,  r3,  [sp, #4*!HAVE_VFP_ARGS]
        vtrn.32         d0,  d1
        vneg.f32        d18, d1
        vtrn.32         d18, d1
        add             r0,  r0,  r2,  lsl #3
        add             r1,  r1,  r2,  lsl #3
        sub             r1,  r1,  #2*8
        sub             r3,  r3,  r2
        vld1.32         {q1},     [r1,:128]!
1:
        vld1.32         {q3},     [r1,:128]!
        vrev64.32       q2,  q1
        vmov            q8,  q3
        vrev64.32       d20, d3
        vrev64.32       d21, d6
        vmla.f32        q3,  q1,  d0[0]
        vmla.f32        d6,  d4,  d18
        vmla.f32        d7,  d20, d18
        vmla.f32        d6,  d3,  d0[1]
        vmla.f32        d7,  d16, d0[1]
        vmla.f32        d6,  d5,  d1
        vmla.f32        d7,  d21, d1
        vmov            q1,  q8
        vst1.32         {q3},     [r0,:128]!
        subs            r3,  r3,  #2
        bgt             1b
        bx              lr
endfunc

function ff_sbr_autocorrelate_neon, export=1
        vld1.32         {q0},     [r0,:128]!
        vmov.f32        q1,  #0.0
        vmov.f32        q3,  #0.0
        vmov.f32        d20, #0.0
        vmul.f32        d21, d1,  d1
        vmov            q8,  q0
        vmov            q11, q0
        mov             r12, #36
1:
        vld1.32         {q2},     [r0,:128]!
        vrev64.32       q12, q2
        vmla.f32        q10, q2,  q2
        vmla.f32        d2,  d1,  d4
        vmla.f32        d3,  d1,  d24
        vmla.f32        d6,  d0,  d4
        vmla.f32        d7,  d0,  d24
        vmla.f32        d2,  d4,  d5
        vmla.f32        d3,  d4,  d25
        vmla.f32        d6,  d1,  d5
        vmla.f32        d7,  d1,  d25
        vmov            q0,  q2
        subs            r12, r12, #2
        bgt             1b
        vld1.32         {q2},     [r0,:128]!
        vrev64.32       q12, q2
        vmla.f32        d2,  d1,  d4
        vmla.f32        d3,  d1,  d24
        vmla.f32        d6,  d0,  d4
        vmla.f32        d7,  d0,  d24
        vadd.f32        d20, d20, d21
        vrev64.32       d18, d17
        vmla.f32        d6,  d1,  d5
        vmla.f32        d7,  d1,  d25
        vmov            q0,  q1
        vmla.f32        d0,  d16, d17
        vmla.f32        d1,  d16, d18
        vmla.f32        d2,  d4,  d5
        vmla.f32        d3,  d4,  d25
        vneg.f32        s15, s15
        vmov            d21, d20
        vpadd.f32       d0,  d0,  d2
        vpadd.f32       d7,  d6,  d7
        vtrn.32         d1,  d3
        vsub.f32        d6,  d1,  d3
        vmla.f32        d20, d22, d22
        vmla.f32        d21, d4,  d4
        vtrn.32         d0,  d6
        vpadd.f32       d20, d20, d21
        vst1.32         {q3},     [r1,:128]!
        vst1.32         {d20[1]}, [r1,:32]
        add             r1,  r1,  #2*4
        vst1.32         {d0},     [r1,:64]
        add             r1,  r1,  #4*4
        vst1.32         {d20[0]}, [r1,:32]
        bx              lr
endfunc

function ff_sbr_hf_apply_noise_0_neon, export=1
        vmov.i32        d3,  #0
.Lhf_apply_noise_0:
        push            {r4,lr}
        movrelx         r4,  X(ff_sbr_noise_table)
        ldr             r12, [sp, #12]
        add             r3,  r3,  #1
        bfc             r3,  #9,  #23
        sub             r12, r12, #1
1:
        add             lr,  r4,  r3,  lsl #3
        vld2.32         {q0},     [r0,:64]
        vld2.32         {q3},     [lr,:64]
        vld1.32         {d2},     [r1,:64]!
        vld1.32         {d18},    [r2,:64]!
        vceq.f32        d16, d2,  #0
        veor            d2,  d2,  d3
        vmov            q2,  q0
        vmla.f32        d0,  d6,  d18
        vmla.f32        d1,  d7,  d18
        vadd.f32        d4,  d4,  d2
        add             r3,  r3,  #2
        bfc             r3,  #9,  #23
        vbif            d0,  d4,  d16
        vbif            d1,  d5,  d16
        vst2.32         {q0},     [r0,:64]!
        subs            r12, r12, #2
        bgt             1b
        blt             2f
        add             lr,  r4,  r3,  lsl #3
        vld1.32         {d0},     [r0,:64]
        vld1.32         {d6},     [lr,:64]
        vld1.32         {d2[]},   [r1,:32]!
        vld1.32         {d3[]},   [r2,:32]!
        vceq.f32        d4,  d2,  #0
        veor            d2,  d2,  d3
        vmov            d1,  d0
        vmla.f32        d0,  d6,  d3
        vadd.f32        s2,  s2,  s4
        vbif            d0,  d1,  d4
        vst1.32         {d0},     [r0,:64]!
2:
        pop             {r4,pc}
endfunc

function ff_sbr_hf_apply_noise_1_neon, export=1
        ldr             r12, [sp]
        push            {r4,lr}
        lsl             r12, r12, #31
        eor             lr,  r12, #1<<31
        vmov            d3,  r12, lr
.Lhf_apply_noise_1:
        movrelx         r4,  X(ff_sbr_noise_table)
        ldr             r12, [sp, #12]
        add             r3,  r3,  #1
        bfc             r3,  #9,  #23
        sub             r12, r12, #1
1:
        add             lr,  r4,  r3,  lsl #3
        vld2.32         {q0},     [r0,:64]
        vld2.32         {q3},     [lr,:64]
        vld1.32         {d2},     [r1,:64]!
        vld1.32         {d18},    [r2,:64]!
        vceq.f32        d16, d2,  #0
        veor            d2,  d2,  d3
        vmov            q2,  q0
        vmla.f32        d0,  d6,  d18
        vmla.f32        d1,  d7,  d18
        vadd.f32        d5,  d5,  d2
        add             r3,  r3,  #2
        bfc             r3,  #9,  #23
        vbif            d0,  d4,  d16
        vbif            d1,  d5,  d16
        vst2.32         {q0},     [r0,:64]!
        subs            r12, r12, #2
        bgt             1b
        blt             2f
        add             lr,  r4,  r3,  lsl #3
        vld1.32         {d0},     [r0,:64]
        vld1.32         {d6},     [lr,:64]
        vld1.32         {d2[]},   [r1,:32]!
        vld1.32         {d18[]},  [r2,:32]!
        vceq.f32        d4,  d2,  #0
        veor            d2,  d2,  d3
        vmov            d1,  d0
        vmla.f32        d0,  d6,  d18
        vadd.f32        s3,  s3,  s5
        vbif            d0,  d1,  d4
        vst1.32         {d0},     [r0,:64]!
2:
        pop             {r4,pc}
endfunc

function ff_sbr_hf_apply_noise_2_neon, export=1
        vmov.i32        d3,  #1<<31
        b               .Lhf_apply_noise_0
endfunc

function ff_sbr_hf_apply_noise_3_neon, export=1
        ldr             r12, [sp]
        push            {r4,lr}
        lsl             r12, r12, #31
        eor             lr,  r12, #1<<31
        vmov            d3,  lr, r12
        b               .Lhf_apply_noise_1
endfunc