1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * Copyright (c) 2016 Clément Bœsch <clement stupeflix.com>
3cabdff1aSopenharmony_ci * Copyright (c) 2019-2021 Sebastian Pop <spop@amazon.com>
4cabdff1aSopenharmony_ci * Copyright (c) 2022 Jonathan Swinney <jswinney@amazon.com>
5cabdff1aSopenharmony_ci *
6cabdff1aSopenharmony_ci * This file is part of FFmpeg.
7cabdff1aSopenharmony_ci *
8cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
9cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
10cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
11cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
12cabdff1aSopenharmony_ci *
13cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
14cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
15cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16cabdff1aSopenharmony_ci * Lesser General Public License for more details.
17cabdff1aSopenharmony_ci *
18cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
19cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
20cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21cabdff1aSopenharmony_ci */
22cabdff1aSopenharmony_ci
23cabdff1aSopenharmony_ci#include "libavutil/aarch64/asm.S"
24cabdff1aSopenharmony_ci
25cabdff1aSopenharmony_ci/*
26cabdff1aSopenharmony_ci;-----------------------------------------------------------------------------
27cabdff1aSopenharmony_ci; horizontal line scaling
28cabdff1aSopenharmony_ci;
29cabdff1aSopenharmony_ci; void hscale<source_width>to<intermediate_nbits>_<filterSize>_<opt>
30cabdff1aSopenharmony_ci;                               (SwsContext *c, int{16,32}_t *dst,
31cabdff1aSopenharmony_ci;                                int dstW, const uint{8,16}_t *src,
32cabdff1aSopenharmony_ci;                                const int16_t *filter,
33cabdff1aSopenharmony_ci;                                const int32_t *filterPos, int filterSize);
34cabdff1aSopenharmony_ci;
35cabdff1aSopenharmony_ci; Scale one horizontal line. Input is either 8-bit width or 16-bit width
36cabdff1aSopenharmony_ci; ($source_width can be either 8, 9, 10 or 16, difference is whether we have to
37cabdff1aSopenharmony_ci; downscale before multiplying). Filter is 14 bits. Output is either 15 bits
38cabdff1aSopenharmony_ci; (in int16_t) or 19 bits (in int32_t), as given in $intermediate_nbits. Each
39cabdff1aSopenharmony_ci; output pixel is generated from $filterSize input pixels, the position of
40cabdff1aSopenharmony_ci; the first pixel is given in filterPos[nOutputPixel].
41cabdff1aSopenharmony_ci;----------------------------------------------------------------------------- */
42cabdff1aSopenharmony_ci
43cabdff1aSopenharmony_cifunction ff_hscale8to15_X8_neon, export=1
44cabdff1aSopenharmony_ci        sbfiz               x7, x6, #1, #32             // filterSize*2 (*2 because int16)
45cabdff1aSopenharmony_ci1:      ldr                 w8, [x5], #4                // filterPos[idx]
46cabdff1aSopenharmony_ci        ldr                 w0, [x5], #4                // filterPos[idx + 1]
47cabdff1aSopenharmony_ci        ldr                 w11, [x5], #4               // filterPos[idx + 2]
48cabdff1aSopenharmony_ci        ldr                 w9, [x5], #4                // filterPos[idx + 3]
49cabdff1aSopenharmony_ci        mov                 x16, x4                     // filter0 = filter
50cabdff1aSopenharmony_ci        add                 x12, x16, x7                // filter1 = filter0 + filterSize*2
51cabdff1aSopenharmony_ci        add                 x13, x12, x7                // filter2 = filter1 + filterSize*2
52cabdff1aSopenharmony_ci        add                 x4, x13, x7                 // filter3 = filter2 + filterSize*2
53cabdff1aSopenharmony_ci        movi                v0.2D, #0                   // val sum part 1 (for dst[0])
54cabdff1aSopenharmony_ci        movi                v1.2D, #0                   // val sum part 2 (for dst[1])
55cabdff1aSopenharmony_ci        movi                v2.2D, #0                   // val sum part 3 (for dst[2])
56cabdff1aSopenharmony_ci        movi                v3.2D, #0                   // val sum part 4 (for dst[3])
57cabdff1aSopenharmony_ci        add                 x17, x3, w8, UXTW           // srcp + filterPos[0]
58cabdff1aSopenharmony_ci        add                 x8,  x3, w0, UXTW           // srcp + filterPos[1]
59cabdff1aSopenharmony_ci        add                 x0, x3, w11, UXTW           // srcp + filterPos[2]
60cabdff1aSopenharmony_ci        add                 x11, x3, w9, UXTW           // srcp + filterPos[3]
61cabdff1aSopenharmony_ci        mov                 w15, w6                     // filterSize counter
62cabdff1aSopenharmony_ci2:      ld1                 {v4.8B}, [x17], #8          // srcp[filterPos[0] + {0..7}]
63cabdff1aSopenharmony_ci        ld1                 {v5.8H}, [x16], #16         // load 8x16-bit filter values, part 1
64cabdff1aSopenharmony_ci        ld1                 {v6.8B}, [x8], #8           // srcp[filterPos[1] + {0..7}]
65cabdff1aSopenharmony_ci        ld1                 {v7.8H}, [x12], #16         // load 8x16-bit at filter+filterSize
66cabdff1aSopenharmony_ci        uxtl                v4.8H, v4.8B                // unpack part 1 to 16-bit
67cabdff1aSopenharmony_ci        smlal               v0.4S, v4.4H, v5.4H         // v0 accumulates srcp[filterPos[0] + {0..3}] * filter[{0..3}]
68cabdff1aSopenharmony_ci        smlal2              v0.4S, v4.8H, v5.8H         // v0 accumulates srcp[filterPos[0] + {4..7}] * filter[{4..7}]
69cabdff1aSopenharmony_ci        ld1                 {v16.8B}, [x0], #8          // srcp[filterPos[2] + {0..7}]
70cabdff1aSopenharmony_ci        ld1                 {v17.8H}, [x13], #16        // load 8x16-bit at filter+2*filterSize
71cabdff1aSopenharmony_ci        uxtl                v6.8H, v6.8B                // unpack part 2 to 16-bit
72cabdff1aSopenharmony_ci        smlal               v1.4S, v6.4H, v7.4H         // v1 accumulates srcp[filterPos[1] + {0..3}] * filter[{0..3}]
73cabdff1aSopenharmony_ci        uxtl                v16.8H, v16.8B              // unpack part 3 to 16-bit
74cabdff1aSopenharmony_ci        smlal               v2.4S, v16.4H, v17.4H       // v2 accumulates srcp[filterPos[2] + {0..3}] * filter[{0..3}]
75cabdff1aSopenharmony_ci        smlal2              v2.4S, v16.8H, v17.8H       // v2 accumulates srcp[filterPos[2] + {4..7}] * filter[{4..7}]
76cabdff1aSopenharmony_ci        ld1                 {v18.8B}, [x11], #8         // srcp[filterPos[3] + {0..7}]
77cabdff1aSopenharmony_ci        smlal2              v1.4S, v6.8H, v7.8H         // v1 accumulates srcp[filterPos[1] + {4..7}] * filter[{4..7}]
78cabdff1aSopenharmony_ci        ld1                 {v19.8H}, [x4], #16         // load 8x16-bit at filter+3*filterSize
79cabdff1aSopenharmony_ci        subs                w15, w15, #8                // j -= 8: processed 8/filterSize
80cabdff1aSopenharmony_ci        uxtl                v18.8H, v18.8B              // unpack part 4 to 16-bit
81cabdff1aSopenharmony_ci        smlal               v3.4S, v18.4H, v19.4H       // v3 accumulates srcp[filterPos[3] + {0..3}] * filter[{0..3}]
82cabdff1aSopenharmony_ci        smlal2              v3.4S, v18.8H, v19.8H       // v3 accumulates srcp[filterPos[3] + {4..7}] * filter[{4..7}]
83cabdff1aSopenharmony_ci        b.gt                2b                          // inner loop if filterSize not consumed completely
84cabdff1aSopenharmony_ci        addp                v0.4S, v0.4S, v1.4S         // part01 horizontal pair adding
85cabdff1aSopenharmony_ci        addp                v2.4S, v2.4S, v3.4S         // part23 horizontal pair adding
86cabdff1aSopenharmony_ci        addp                v0.4S, v0.4S, v2.4S         // part0123 horizontal pair adding
87cabdff1aSopenharmony_ci        subs                w2, w2, #4                  // dstW -= 4
88cabdff1aSopenharmony_ci        sqshrn              v0.4H, v0.4S, #7            // shift and clip the 2x16-bit final values
89cabdff1aSopenharmony_ci        st1                 {v0.4H}, [x1], #8           // write to destination part0123
90cabdff1aSopenharmony_ci        b.gt                1b                          // loop until end of line
91cabdff1aSopenharmony_ci        ret
92cabdff1aSopenharmony_ciendfunc
93cabdff1aSopenharmony_ci
94cabdff1aSopenharmony_cifunction ff_hscale8to15_4_neon, export=1
95cabdff1aSopenharmony_ci// x0  SwsContext *c (not used)
96cabdff1aSopenharmony_ci// x1  int16_t *dst
97cabdff1aSopenharmony_ci// x2  int dstW
98cabdff1aSopenharmony_ci// x3  const uint8_t *src
99cabdff1aSopenharmony_ci// x4  const int16_t *filter
100cabdff1aSopenharmony_ci// x5  const int32_t *filterPos
101cabdff1aSopenharmony_ci// x6  int filterSize
102cabdff1aSopenharmony_ci// x8-x15 registers for gathering src data
103cabdff1aSopenharmony_ci
104cabdff1aSopenharmony_ci// v0      madd accumulator 4S
105cabdff1aSopenharmony_ci// v1-v4   filter values (16 bit) 8H
106cabdff1aSopenharmony_ci// v5      madd accumulator 4S
107cabdff1aSopenharmony_ci// v16-v19 src values (8 bit) 8B
108cabdff1aSopenharmony_ci
109cabdff1aSopenharmony_ci// This implementation has 4 sections:
110cabdff1aSopenharmony_ci//  1. Prefetch src data
111cabdff1aSopenharmony_ci//  2. Interleaved prefetching src data and madd
112cabdff1aSopenharmony_ci//  3. Complete madd
113cabdff1aSopenharmony_ci//  4. Complete remaining iterations when dstW % 8 != 0
114cabdff1aSopenharmony_ci
115cabdff1aSopenharmony_ci        sub                 sp, sp, #32                 // allocate 32 bytes on the stack
116cabdff1aSopenharmony_ci        cmp                 w2, #16                     // if dstW <16, skip to the last block used for wrapping up
117cabdff1aSopenharmony_ci        b.lt                2f
118cabdff1aSopenharmony_ci
119cabdff1aSopenharmony_ci        // load 8 values from filterPos to be used as offsets into src
120cabdff1aSopenharmony_ci        ldp                 w8, w9,  [x5]               // filterPos[idx + 0], [idx + 1]
121cabdff1aSopenharmony_ci        ldp                 w10, w11, [x5, #8]          // filterPos[idx + 2], [idx + 3]
122cabdff1aSopenharmony_ci        ldp                 w12, w13, [x5, #16]         // filterPos[idx + 4], [idx + 5]
123cabdff1aSopenharmony_ci        ldp                 w14, w15, [x5, #24]         // filterPos[idx + 6], [idx + 7]
124cabdff1aSopenharmony_ci        add                 x5, x5, #32                 // advance filterPos
125cabdff1aSopenharmony_ci
126cabdff1aSopenharmony_ci        // gather random access data from src into contiguous memory
127cabdff1aSopenharmony_ci        ldr                 w8, [x3, w8, UXTW]          // src[filterPos[idx + 0]][0..3]
128cabdff1aSopenharmony_ci        ldr                 w9, [x3, w9, UXTW]          // src[filterPos[idx + 1]][0..3]
129cabdff1aSopenharmony_ci        ldr                 w10, [x3, w10, UXTW]        // src[filterPos[idx + 2]][0..3]
130cabdff1aSopenharmony_ci        ldr                 w11, [x3, w11, UXTW]        // src[filterPos[idx + 3]][0..3]
131cabdff1aSopenharmony_ci        ldr                 w12, [x3, w12, UXTW]        // src[filterPos[idx + 4]][0..3]
132cabdff1aSopenharmony_ci        ldr                 w13, [x3, w13, UXTW]        // src[filterPos[idx + 5]][0..3]
133cabdff1aSopenharmony_ci        ldr                 w14, [x3, w14, UXTW]        // src[filterPos[idx + 6]][0..3]
134cabdff1aSopenharmony_ci        ldr                 w15, [x3, w15, UXTW]        // src[filterPos[idx + 7]][0..3]
135cabdff1aSopenharmony_ci        stp                 w8, w9, [sp]                // *scratch_mem = { src[filterPos[idx + 0]][0..3], src[filterPos[idx + 1]][0..3] }
136cabdff1aSopenharmony_ci        stp                 w10, w11, [sp, #8]          // *scratch_mem = { src[filterPos[idx + 2]][0..3], src[filterPos[idx + 3]][0..3] }
137cabdff1aSopenharmony_ci        stp                 w12, w13, [sp, #16]         // *scratch_mem = { src[filterPos[idx + 4]][0..3], src[filterPos[idx + 5]][0..3] }
138cabdff1aSopenharmony_ci        stp                 w14, w15, [sp, #24]         // *scratch_mem = { src[filterPos[idx + 6]][0..3], src[filterPos[idx + 7]][0..3] }
139cabdff1aSopenharmony_ci
140cabdff1aSopenharmony_ci1:
141cabdff1aSopenharmony_ci        ld4                 {v16.8B, v17.8B, v18.8B, v19.8B}, [sp] // transpose 8 bytes each from src into 4 registers
142cabdff1aSopenharmony_ci
143cabdff1aSopenharmony_ci        // load 8 values from filterPos to be used as offsets into src
144cabdff1aSopenharmony_ci        ldp                 w8, w9,  [x5]               // filterPos[idx + 0][0..3], [idx + 1][0..3], next iteration
145cabdff1aSopenharmony_ci        ldp                 w10, w11, [x5, #8]          // filterPos[idx + 2][0..3], [idx + 3][0..3], next iteration
146cabdff1aSopenharmony_ci        ldp                 w12, w13, [x5, #16]         // filterPos[idx + 4][0..3], [idx + 5][0..3], next iteration
147cabdff1aSopenharmony_ci        ldp                 w14, w15, [x5, #24]         // filterPos[idx + 6][0..3], [idx + 7][0..3], next iteration
148cabdff1aSopenharmony_ci
149cabdff1aSopenharmony_ci        movi                v0.2D, #0                   // Clear madd accumulator for idx 0..3
150cabdff1aSopenharmony_ci        movi                v5.2D, #0                   // Clear madd accumulator for idx 4..7
151cabdff1aSopenharmony_ci
152cabdff1aSopenharmony_ci        ld4                 {v1.8H, v2.8H, v3.8H, v4.8H}, [x4], #64 // load filter idx + 0..7
153cabdff1aSopenharmony_ci
154cabdff1aSopenharmony_ci        add                 x5, x5, #32                 // advance filterPos
155cabdff1aSopenharmony_ci
156cabdff1aSopenharmony_ci        // interleaved SIMD and prefetching intended to keep ld/st and vector pipelines busy
157cabdff1aSopenharmony_ci        uxtl                v16.8H, v16.8B              // unsigned extend long, covert src data to 16-bit
158cabdff1aSopenharmony_ci        uxtl                v17.8H, v17.8B              // unsigned extend long, covert src data to 16-bit
159cabdff1aSopenharmony_ci        ldr                 w8, [x3, w8, UXTW]          // src[filterPos[idx + 0]], next iteration
160cabdff1aSopenharmony_ci        ldr                 w9, [x3, w9, UXTW]          // src[filterPos[idx + 1]], next iteration
161cabdff1aSopenharmony_ci        uxtl                v18.8H, v18.8B              // unsigned extend long, covert src data to 16-bit
162cabdff1aSopenharmony_ci        uxtl                v19.8H, v19.8B              // unsigned extend long, covert src data to 16-bit
163cabdff1aSopenharmony_ci        ldr                 w10, [x3, w10, UXTW]        // src[filterPos[idx + 2]], next iteration
164cabdff1aSopenharmony_ci        ldr                 w11, [x3, w11, UXTW]        // src[filterPos[idx + 3]], next iteration
165cabdff1aSopenharmony_ci
166cabdff1aSopenharmony_ci        smlal               v0.4S, v1.4H, v16.4H        // multiply accumulate inner loop j = 0, idx = 0..3
167cabdff1aSopenharmony_ci        smlal               v0.4S, v2.4H, v17.4H        // multiply accumulate inner loop j = 1, idx = 0..3
168cabdff1aSopenharmony_ci        ldr                 w12, [x3, w12, UXTW]        // src[filterPos[idx + 4]], next iteration
169cabdff1aSopenharmony_ci        ldr                 w13, [x3, w13, UXTW]        // src[filterPos[idx + 5]], next iteration
170cabdff1aSopenharmony_ci        smlal               v0.4S, v3.4H, v18.4H        // multiply accumulate inner loop j = 2, idx = 0..3
171cabdff1aSopenharmony_ci        smlal               v0.4S, v4.4H, v19.4H        // multiply accumulate inner loop j = 3, idx = 0..3
172cabdff1aSopenharmony_ci        ldr                 w14, [x3, w14, UXTW]        // src[filterPos[idx + 6]], next iteration
173cabdff1aSopenharmony_ci        ldr                 w15, [x3, w15, UXTW]        // src[filterPos[idx + 7]], next iteration
174cabdff1aSopenharmony_ci
175cabdff1aSopenharmony_ci        smlal2              v5.4S, v1.8H, v16.8H        // multiply accumulate inner loop j = 0, idx = 4..7
176cabdff1aSopenharmony_ci        smlal2              v5.4S, v2.8H, v17.8H        // multiply accumulate inner loop j = 1, idx = 4..7
177cabdff1aSopenharmony_ci        stp                 w8, w9, [sp]                // *scratch_mem = { src[filterPos[idx + 0]][0..3], src[filterPos[idx + 1]][0..3] }
178cabdff1aSopenharmony_ci        stp                 w10, w11, [sp, #8]          // *scratch_mem = { src[filterPos[idx + 2]][0..3], src[filterPos[idx + 3]][0..3] }
179cabdff1aSopenharmony_ci        smlal2              v5.4S, v3.8H, v18.8H        // multiply accumulate inner loop j = 2, idx = 4..7
180cabdff1aSopenharmony_ci        smlal2              v5.4S, v4.8H, v19.8H        // multiply accumulate inner loop j = 3, idx = 4..7
181cabdff1aSopenharmony_ci        stp                 w12, w13, [sp, #16]         // *scratch_mem = { src[filterPos[idx + 4]][0..3], src[filterPos[idx + 5]][0..3] }
182cabdff1aSopenharmony_ci        stp                 w14, w15, [sp, #24]         // *scratch_mem = { src[filterPos[idx + 6]][0..3], src[filterPos[idx + 7]][0..3] }
183cabdff1aSopenharmony_ci
184cabdff1aSopenharmony_ci        sub                 w2, w2, #8                  // dstW -= 8
185cabdff1aSopenharmony_ci        sqshrn              v0.4H, v0.4S, #7            // shift and clip the 2x16-bit final values
186cabdff1aSopenharmony_ci        sqshrn              v1.4H, v5.4S, #7            // shift and clip the 2x16-bit final values
187cabdff1aSopenharmony_ci        st1                 {v0.4H, v1.4H}, [x1], #16   // write to dst[idx + 0..7]
188cabdff1aSopenharmony_ci        cmp                 w2, #16                     // continue on main loop if there are at least 16 iterations left
189cabdff1aSopenharmony_ci        b.ge                1b
190cabdff1aSopenharmony_ci
191cabdff1aSopenharmony_ci        // last full iteration
192cabdff1aSopenharmony_ci        ld4                 {v16.8B, v17.8B, v18.8B, v19.8B}, [sp]
193cabdff1aSopenharmony_ci        ld4                 {v1.8H, v2.8H, v3.8H, v4.8H}, [x4], #64 // load filter idx + 0..7
194cabdff1aSopenharmony_ci
195cabdff1aSopenharmony_ci        movi                v0.2D, #0                   // Clear madd accumulator for idx 0..3
196cabdff1aSopenharmony_ci        movi                v5.2D, #0                   // Clear madd accumulator for idx 4..7
197cabdff1aSopenharmony_ci
198cabdff1aSopenharmony_ci        uxtl                v16.8H, v16.8B              // unsigned extend long, covert src data to 16-bit
199cabdff1aSopenharmony_ci        uxtl                v17.8H, v17.8B              // unsigned extend long, covert src data to 16-bit
200cabdff1aSopenharmony_ci        uxtl                v18.8H, v18.8B              // unsigned extend long, covert src data to 16-bit
201cabdff1aSopenharmony_ci        uxtl                v19.8H, v19.8B              // unsigned extend long, covert src data to 16-bit
202cabdff1aSopenharmony_ci
203cabdff1aSopenharmony_ci        smlal               v0.4S, v1.4H, v16.4H        // multiply accumulate inner loop j = 0, idx = 0..3
204cabdff1aSopenharmony_ci        smlal               v0.4S, v2.4H, v17.4H        // multiply accumulate inner loop j = 1, idx = 0..3
205cabdff1aSopenharmony_ci        smlal               v0.4S, v3.4H, v18.4H        // multiply accumulate inner loop j = 2, idx = 0..3
206cabdff1aSopenharmony_ci        smlal               v0.4S, v4.4H, v19.4H        // multiply accumulate inner loop j = 3, idx = 0..3
207cabdff1aSopenharmony_ci
208cabdff1aSopenharmony_ci        smlal2              v5.4S, v1.8H, v16.8H        // multiply accumulate inner loop j = 0, idx = 4..7
209cabdff1aSopenharmony_ci        smlal2              v5.4S, v2.8H, v17.8H        // multiply accumulate inner loop j = 1, idx = 4..7
210cabdff1aSopenharmony_ci        smlal2              v5.4S, v3.8H, v18.8H        // multiply accumulate inner loop j = 2, idx = 4..7
211cabdff1aSopenharmony_ci        smlal2              v5.4S, v4.8H, v19.8H        // multiply accumulate inner loop j = 3, idx = 4..7
212cabdff1aSopenharmony_ci
213cabdff1aSopenharmony_ci        subs                w2, w2, #8                  // dstW -= 8
214cabdff1aSopenharmony_ci        sqshrn              v0.4H, v0.4S, #7            // shift and clip the 2x16-bit final values
215cabdff1aSopenharmony_ci        sqshrn              v1.4H, v5.4S, #7            // shift and clip the 2x16-bit final values
216cabdff1aSopenharmony_ci        st1                 {v0.4H, v1.4H}, [x1], #16   // write to dst[idx + 0..7]
217cabdff1aSopenharmony_ci
218cabdff1aSopenharmony_ci        cbnz                w2, 2f                      // if >0 iterations remain, jump to the wrap up section
219cabdff1aSopenharmony_ci
220cabdff1aSopenharmony_ci        add                 sp, sp, #32                 // clean up stack
221cabdff1aSopenharmony_ci        ret
222cabdff1aSopenharmony_ci
223cabdff1aSopenharmony_ci        // finish up when dstW % 8 != 0 or dstW < 16
224cabdff1aSopenharmony_ci2:
225cabdff1aSopenharmony_ci        // load src
226cabdff1aSopenharmony_ci        ldr                 w8, [x5], #4                // filterPos[i]
227cabdff1aSopenharmony_ci        add                 x9, x3, w8, UXTW            // calculate the address for src load
228cabdff1aSopenharmony_ci        ld1                 {v5.S}[0], [x9]             // src[filterPos[i] + 0..3]
229cabdff1aSopenharmony_ci        // load filter
230cabdff1aSopenharmony_ci        ld1                 {v6.4H}, [x4], #8           // filter[filterSize * i + 0..3]
231cabdff1aSopenharmony_ci
232cabdff1aSopenharmony_ci        uxtl                v5.8H, v5.8B                // unsigned exten long, convert src data to 16-bit
233cabdff1aSopenharmony_ci        smull               v0.4S, v5.4H, v6.4H         // 4 iterations of src[...] * filter[...]
234cabdff1aSopenharmony_ci        addv                s0, v0.4S                   // add up products of src and filter values
235cabdff1aSopenharmony_ci        sqshrn              h0, s0, #7                  // shift and clip the 2x16-bit final value
236cabdff1aSopenharmony_ci        st1                 {v0.H}[0], [x1], #2         // dst[i] = ...
237cabdff1aSopenharmony_ci        sub                 w2, w2, #1                  // dstW--
238cabdff1aSopenharmony_ci        cbnz                w2, 2b
239cabdff1aSopenharmony_ci
240cabdff1aSopenharmony_ci        add                 sp, sp, #32                 // clean up stack
241cabdff1aSopenharmony_ci        ret
242cabdff1aSopenharmony_ciendfunc
243