1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * Copyright (c) 2016 Clément Bœsch <clement stupeflix.com>
3cabdff1aSopenharmony_ci * Copyright (c) 2016 Matthieu Bouron <matthieu.bouron stupeflix.com>
4cabdff1aSopenharmony_ci *
5cabdff1aSopenharmony_ci * This file is part of FFmpeg.
6cabdff1aSopenharmony_ci *
7cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
8cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
9cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
10cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
11cabdff1aSopenharmony_ci *
12cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
13cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
14cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15cabdff1aSopenharmony_ci * Lesser General Public License for more details.
16cabdff1aSopenharmony_ci *
17cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
18cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
19cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20cabdff1aSopenharmony_ci */
21cabdff1aSopenharmony_ci
22cabdff1aSopenharmony_ci#include "libavutil/arm/asm.S"
23cabdff1aSopenharmony_ci
24cabdff1aSopenharmony_cifunction ff_hscale_8_to_15_neon, export=1
25cabdff1aSopenharmony_ci    push                {r4-r12, lr}
26cabdff1aSopenharmony_ci    vpush               {q4-q7}
27cabdff1aSopenharmony_ci    ldr                 r4, [sp, #104]                                 @ filter
28cabdff1aSopenharmony_ci    ldr                 r5, [sp, #108]                                 @ filterPos
29cabdff1aSopenharmony_ci    ldr                 r6, [sp, #112]                                 @ filterSize
30cabdff1aSopenharmony_ci    add                 r10, r4, r6, lsl #1                            @ filter2 = filter + filterSize * 2
31cabdff1aSopenharmony_ci1:  ldr                 r8, [r5], #4                                   @ filterPos[0]
32cabdff1aSopenharmony_ci    ldr                 r9, [r5], #4                                   @ filterPos[1]
33cabdff1aSopenharmony_ci    vmov.s32            q4, #0                                         @ val accumulator
34cabdff1aSopenharmony_ci    vmov.s32            q5, #0                                         @ val accumulator
35cabdff1aSopenharmony_ci    mov                 r7, r6                                         @ tmpfilterSize = filterSize
36cabdff1aSopenharmony_ci    mov                 r0, r3                                         @ srcp
37cabdff1aSopenharmony_ci2:  add                 r11, r0, r8                                    @ srcp + filterPos[0]
38cabdff1aSopenharmony_ci    add                 r12, r0, r9                                    @ srcp + filterPos[1]
39cabdff1aSopenharmony_ci    vld1.8              d0, [r11]                                      @ srcp[filterPos[0] + {0..7}]
40cabdff1aSopenharmony_ci    vld1.8              d2, [r12]                                      @ srcp[filterPos[1] + {0..7}]
41cabdff1aSopenharmony_ci    vld1.16             {q2}, [r4]!                                    @ load 8x16-bit filter values
42cabdff1aSopenharmony_ci    vld1.16             {q3}, [r10]!                                   @ load 8x16-bit filter values
43cabdff1aSopenharmony_ci    vmovl.u8            q0, d0                                         @ unpack src values to 16-bit
44cabdff1aSopenharmony_ci    vmovl.u8            q1, d2                                         @ unpack src values to 16-bit
45cabdff1aSopenharmony_ci    vmull.s16           q8, d0, d4                                     @ srcp[filterPos[0] + {0..7}] * filter[{0..7}] (part 1)
46cabdff1aSopenharmony_ci    vmull.s16           q9, d1, d5                                     @ srcp[filterPos[0] + {0..7}] * filter[{0..7}] (part 2)
47cabdff1aSopenharmony_ci    vmull.s16           q10, d2, d6                                    @ srcp[filterPos[1] + {0..7}] * filter[{0..7}] (part 1)
48cabdff1aSopenharmony_ci    vmull.s16           q11, d3, d7                                    @ srcp[filterPos[1] + {0..7}] * filter[{0..7}] (part 2)
49cabdff1aSopenharmony_ci    vpadd.s32           d16, d16, d17                                  @ horizontal pair adding of the 8x32-bit multiplied values into 4x32-bit (part 1)
50cabdff1aSopenharmony_ci    vpadd.s32           d17, d18, d19                                  @ horizontal pair adding of the 8x32-bit multiplied values into 4x32-bit (part 2)
51cabdff1aSopenharmony_ci    vpadd.s32           d20, d20, d21                                  @ horizontal pair adding of the 8x32-bit multiplied values into 4x32-bit (part 1)
52cabdff1aSopenharmony_ci    vpadd.s32           d21, d22, d23                                  @ horizontal pair adding of the 8x32-bit multiplied values into 4x32-bit (part 2)
53cabdff1aSopenharmony_ci    vadd.s32            q4, q8                                         @ update val accumulator
54cabdff1aSopenharmony_ci    vadd.s32            q5, q10                                        @ update val accumulator
55cabdff1aSopenharmony_ci    add                 r0, #8                                         @ srcp += 8
56cabdff1aSopenharmony_ci    subs                r7, #8                                         @ tmpfilterSize -= 8
57cabdff1aSopenharmony_ci    bgt                 2b                                             @ loop until tmpfilterSize is consumed
58cabdff1aSopenharmony_ci    mov                 r4, r10                                        @ filter = filter2
59cabdff1aSopenharmony_ci    add                 r10, r10, r6, lsl #1                           @ filter2 += filterSize * 2
60cabdff1aSopenharmony_ci    vpadd.s32           d8, d8, d9                                     @ horizontal pair adding of the 8x32-bit sums into 4x32-bit (part 1)
61cabdff1aSopenharmony_ci    vpadd.s32           d9, d10, d11                                   @ horizontal pair adding of the 8x32-bit sums into 4x32-bit (part 2)
62cabdff1aSopenharmony_ci    vpadd.s32           d8, d8, d9                                     @ horizontal pair adding of the 4x32-bit sums into 2x32-bit
63cabdff1aSopenharmony_ci    vqshrn.s32          d8, q4, #7                                     @ shift and clip the 2x16-bit final values
64cabdff1aSopenharmony_ci    vst1.32             {d8[0]},[r1]!                                  @ write destination
65cabdff1aSopenharmony_ci    subs                r2, #2                                         @ dstW -= 2
66cabdff1aSopenharmony_ci    bgt                 1b                                             @ loop until end of line
67cabdff1aSopenharmony_ci    vpop                {q4-q7}
68cabdff1aSopenharmony_ci    pop                 {r4-r12, lr}
69cabdff1aSopenharmony_ci    mov pc, lr
70cabdff1aSopenharmony_ciendfunc
71