2 * Copyright (c) 2014 Janne Grunau <janne-libav@jannau.net>
4 * This file is part of Libav.
6 * Libav is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * Libav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "libavutil/aarch64/asm.S"
23 #define FRAC_BITS 23 // fractional bits for sb_samples and dct
24 #define WFRAC_BITS 16 // fractional bits for window
25 #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
27 const tbl_rev128.s, align=4
34 .macro apply_window type, st
35 function ff_mpadsp_apply_window_\type\()_neon, export=1
38 ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x7], #64
39 ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x7], #64
40 st1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x8], #64
41 st1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x8], #64
42 movrel x15, tbl_rev128.s
52 add x5, x3, x4, lsl #5
53 sub x5, x5, x4 // samples2
57 ld1r {v16.2s}, [x2] // dither_state
60 movi v30.2d, #(1<<OUT_SHIFT)-1
61 trn1 v31.2d, v29.2d, v30.2d
62 trn2 v30.2d, v30.2d, v29.2d
63 trn1 v16.2d, v16.2d, v29.2d
72 sub x6, x1, x14, lsl #4
73 add x7, x7, x14, lsl #4
74 add x11, x6, #(32)<<2 // w + 32
75 add x12, x7, #(32)<<2 // w2 + 32
83 ld1 {v1.4s}, [x10], x9
86 tbl v6.16b, {v0.16b}, v27.16b
87 tbl v7.16b, {v1.16b}, v27.16b
88 ld1 {v4.4s}, [x11], x9
89 ld1 {v5.4s}, [x12], x9
101 sub x10, x10, #64<<5 // 64 * 8 * sizeof(int32_t)
104 and v28.16b, v16.16b, v30.16b
105 ext v28.16b, v29.16b, v28.16b, #8
108 round_sample v19, 1, 1
110 round_sample v16, 1, 0
111 shrn v16.2s, v16.2d, #OUT_SHIFT
112 round_sample v19, 0, 0
113 shrn v19.2s, v19.2d, #OUT_SHIFT
114 round_sample v17, 0, 1
115 round_sample v18, 1, 1
116 round_sample v17, 1, 0
117 shrn2 v16.4s, v17.2d, #OUT_SHIFT
118 round_sample v18, 0, 0
119 shrn2 v19.4s, v18.2d, #OUT_SHIFT
123 ext v18.16b, v18.16b, v18.16b, #8
126 st1 {v16.\st\()}[0], [x3], x4
128 st1 {v18.\st\()}[1], [x5], x13
130 st1 {v16.\st\()}[1], [x3], x4
131 st1 {v18.\st\()}[0], [x5], x13
132 st1 {v16.\st\()}[2], [x3], x4
133 st1 {v18.\st\()}[3], [x5], x13
134 st1 {v16.\st\()}[3], [x3], x4
135 st1 {v18.\st\()}[2], [x5], x13
144 // computing samples[16]
146 ld1 {v0.2s}, [x6], x9
147 ld1 {v1.2s}, [x0], x9
149 ld1 {v2.2s}, [x6], x9
150 ld1 {v3.2s}, [x0], x9
152 ld1 {v0.2s}, [x6], x9
153 ld1 {v1.2s}, [x0], x9
156 ld1 {v2.2s}, [x6], x9
157 ld1 {v3.2s}, [x0], x9
162 and v28.16b, v16.16b, v30.16b
163 shrn v20.2s, v16.2d, #OUT_SHIFT
166 st1 {v28.s}[0], [x2] // save dither_state
182 .macro round_sample r, idx, next
183 add \r\().2d, \r\().2d, v28.2d
185 and v28.16b, \r\().16b, v30.16b
187 and v28.16b, \r\().16b, v31.16b
191 ext v28.16b, v28.16b, v29.16b, #8
193 ext v28.16b, v29.16b, v28.16b, #8
198 smlal \d\().2d, \s1\().2s, \s2\().2s
200 .macro MLA2 d, s1, s2
201 smlal2 \d\().2d, \s1\().4s, \s2\().4s
204 smlsl \d\().2d, \s1\().2s, \s2\().2s
206 .macro MLS2 d, s1, s2
207 smlsl2 \d\().2d, \s1\().4s, \s2\().4s
209 apply_window fixed, h
212 // nothing to do for round_sample and ML{A,S}2
213 .macro round_sample r, idx, next
215 .macro MLA2 d, s1, s2
217 .macro MLS2 d, s1, s2
220 fmla \d\().4s, \s1\().4s, \s2\().4s
223 fmls \d\().4s, \s1\().4s, \s2\().4s
225 apply_window float, s