Imported Upstream version 6.1
[platform/upstream/ffmpeg.git] / libavcodec / riscv / fmtconvert_rvv.S
1 /*
2  * Copyright © 2022 Rémi Denis-Courmont.
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/riscv/asm.S"
22
23 func ff_int32_to_float_fmul_scalar_rvv, zve32f
24 NOHWF   fmv.w.x     fa0, a2
25 NOHWF   mv          a2, a3
26 1:
27         vsetvli     t0, a2, e32, m8, ta, ma
28         vle32.v     v24, (a1)
29         sub         a2, a2, t0
30         vfcvt.f.x.v v24, v24
31         sh2add      a1, t0, a1
32         vfmul.vf    v24, v24, fa0
33         vse32.v     v24, (a0)
34         sh2add      a0, t0, a0
35         bnez        a2, 1b
36
37         ret
38 endfunc
39
40 func ff_int32_to_float_fmul_array8_rvv, zve32f
41         srai        a4, a4, 3
42
43 1:      vsetvli     t0, a4, e32, m1, ta, ma
44         vle32.v     v24, (a3)
45         slli        t2, t0, 2 + 3
46         vlseg8e32.v v16, (a2)
47         vsetvli     t3, zero, e32, m8, ta, ma
48         vfcvt.f.x.v v16, v16
49         vsetvli     zero, a4, e32, m1, ta, ma
50         vfmul.vv    v16, v16, v24
51         sub         a4, a4, t0
52         vfmul.vv    v17, v17, v24
53         sh2add      a3, t0, a3
54         vfmul.vv    v18, v18, v24
55         add         a2, a2, t2
56         vfmul.vv    v19, v19, v24
57         vfmul.vv    v20, v20, v24
58         vfmul.vv    v21, v21, v24
59         vfmul.vv    v22, v22, v24
60         vfmul.vv    v23, v23, v24
61         vsseg8e32.v v16, (a1)
62         add         a1, a1, t2
63         bnez        a4, 1b
64
65         ret
66 endfunc