Merge commit 'ab05d3934de8e932dbd77979a687e6598e67535c'
[ffmpeg.git] / libswresample / aarch64 / resample.S
1 /*
2  * Copyright (c) 2017 Matthieu Bouron <matthieu.bouron gmail.com>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg 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.
10  *
11  * FFmpeg 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.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #include "libavutil/aarch64/asm.S"
22
23 function ff_resample_common_apply_filter_x4_float_neon, export=1
24     movi                v0.4S, #0                                      // accumulator
25 1:  ld1                 {v1.4S}, [x1], #16                             // src[0..3]
26     ld1                 {v2.4S}, [x2], #16                             // filter[0..3]
27     fmla                v0.4S, v1.4S, v2.4S                            // accumulator += src[0..3] * filter[0..3]
28     subs                w3, w3, #4                                     // filter_length -= 4
29     b.gt                1b                                             // loop until filter_length
30     faddp               v0.4S, v0.4S, v0.4S                            // pair adding of the 4x32-bit accumulated values
31     faddp               v0.4S, v0.4S, v0.4S                            // pair adding of the 4x32-bit accumulated values
32     st1                 {v0.S}[0], [x0], #4                            // write accumulator
33     ret
34 endfunc
35
36 function ff_resample_common_apply_filter_x8_float_neon, export=1
37     movi                v0.4S, #0                                      // accumulator
38 1:  ld1                 {v1.4S}, [x1], #16                             // src[0..3]
39     ld1                 {v2.4S}, [x2], #16                             // filter[0..3]
40     ld1                 {v3.4S}, [x1], #16                             // src[4..7]
41     ld1                 {v4.4S}, [x2], #16                             // filter[4..7]
42     fmla                v0.4S, v1.4S, v2.4S                            // accumulator += src[0..3] * filter[0..3]
43     fmla                v0.4S, v3.4S, v4.4S                            // accumulator += src[4..7] * filter[4..7]
44     subs                w3, w3, #8                                     // filter_length -= 8
45     b.gt                1b                                             // loop until filter_length
46     faddp               v0.4S, v0.4S, v0.4S                            // pair adding of the 4x32-bit accumulated values
47     faddp               v0.4S, v0.4S, v0.4S                            // pair adding of the 4x32-bit accumulated values
48     st1                 {v0.S}[0], [x0], #4                            // write accumulator
49     ret
50 endfunc
51
52 function ff_resample_common_apply_filter_x4_s16_neon, export=1
53     movi                v0.4S, #0                                      // accumulator
54 1:  ld1                 {v1.4H}, [x1], #8                              // src[0..3]
55     ld1                 {v2.4H}, [x2], #8                              // filter[0..3]
56     smlal               v0.4S, v1.4H, v2.4H                            // accumulator += src[0..3] * filter[0..3]
57     subs                w3, w3, #4                                     // filter_length -= 4
58     b.gt                1b                                             // loop until filter_length
59     addp                v0.4S, v0.4S, v0.4S                            // pair adding of the 4x32-bit accumulated values
60     addp                v0.4S, v0.4S, v0.4S                            // pair adding of the 4x32-bit accumulated values
61     st1                 {v0.S}[0], [x0], #4                            // write accumulator
62     ret
63 endfunc
64
65 function ff_resample_common_apply_filter_x8_s16_neon, export=1
66     movi                v0.4S, #0                                      // accumulator
67 1:  ld1                 {v1.8H}, [x1], #16                             // src[0..7]
68     ld1                 {v2.8H}, [x2], #16                             // filter[0..7]
69     smlal               v0.4S, v1.4H, v2.4H                            // accumulator += src[0..3] * filter[0..3]
70     smlal2              v0.4S, v1.8H, v2.8H                            // accumulator += src[4..7] * filter[4..7]
71     subs                w3, w3, #8                                     // filter_length -= 8
72     b.gt                1b                                             // loop until filter_length
73     addp                v0.4S, v0.4S, v0.4S                            // pair adding of the 4x32-bit accumulated values
74     addp                v0.4S, v0.4S, v0.4S                            // pair adding of the 4x32-bit accumulated values
75     st1                 {v0.S}[0], [x0], #4                            // write accumulator
76     ret
77 endfunc