Skip to content

Commit 8e23ebe

Browse files
sunyuechiRémi Denis-Courmont
authored andcommitted
lavc/svq1enc: R-V V ssd_int8_vs_int16
C908 ssd_int8_vs_int16_c: 207.7 ssd_int8_vs_int16_rvv_i32: 14.2 Signed-off-by: Rémi Denis-Courmont <[email protected]>
1 parent d595e0a commit 8e23ebe

File tree

5 files changed

+89
-0
lines changed

5 files changed

+89
-0
lines changed

libavcodec/riscv/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ RVV-OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_rvv.o
4242
OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o
4343
RV-OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_rvi.o
4444
RVV-OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_rvv.o
45+
OBJS-$(CONFIG_SVQ1_ENCODER) += riscv/svqenc_init.o
46+
RVV-OBJS-$(CONFIG_SVQ1_ENCODER) += riscv/svqenc_rvv.o
4547
OBJS-$(CONFIG_TAK_DECODER) += riscv/takdsp_init.o
4648
RVV-OBJS-$(CONFIG_TAK_DECODER) += riscv/takdsp_rvv.o
4749
OBJS-$(CONFIG_UTVIDEO_DECODER) += riscv/utvideodsp_init.o

libavcodec/riscv/svqenc_init.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS).
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 "config.h"
22+
23+
#include "libavutil/attributes.h"
24+
#include "libavutil/cpu.h"
25+
#include "libavcodec/svq1encdsp.h"
26+
27+
int ff_ssd_int8_vs_int16_rvv(const int8_t *pix1, const int16_t *pix2,
28+
intptr_t size);
29+
30+
av_cold void ff_svq1enc_init_riscv(SVQ1EncDSPContext *c)
31+
{
32+
#if HAVE_RVV
33+
int flags = av_get_cpu_flags();
34+
35+
if (flags & AV_CPU_FLAG_RVV_I32) {
36+
if (flags & AV_CPU_FLAG_RVB_ADDR) {
37+
c->ssd_int8_vs_int16 = ff_ssd_int8_vs_int16_rvv;
38+
}
39+
}
40+
#endif
41+
}

libavcodec/riscv/svqenc_rvv.S

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS).
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_ssd_int8_vs_int16_rvv, zve32x
24+
vsetvli t0, zero, e32, m8, ta, ma
25+
vmv.v.x v24, zero
26+
1:
27+
vsetvli t0, a2, e8, m2, tu, ma
28+
vle16.v v8, (a1)
29+
sub a2, a2, t0
30+
vle8.v v0, (a0)
31+
vwsub.wv v16, v8, v0
32+
vsetvli zero, zero, e16, m4, tu, ma
33+
add a0, a0, t0
34+
vwmacc.vv v24, v16, v16
35+
sh1add a1, t0, a1
36+
bnez a2, 1b
37+
vsetvli zero, zero, e32, m8, ta, ma
38+
vmv.s.x v0, zero
39+
vredsum.vs v0, v24, v0
40+
vmv.x.s a0, v0
41+
42+
ret
43+
endfunc

libavcodec/svq1enc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ void ff_svq1enc_init(SVQ1EncDSPContext *c)
766766

767767
#if ARCH_PPC
768768
ff_svq1enc_init_ppc(c);
769+
#elif ARCH_RISCV
770+
ff_svq1enc_init_riscv(c);
769771
#elif ARCH_X86
770772
ff_svq1enc_init_x86(c);
771773
#endif

libavcodec/svq1encdsp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ typedef struct SVQ1EncDSPContext {
3030

3131
void ff_svq1enc_init(SVQ1EncDSPContext *c);
3232
void ff_svq1enc_init_ppc(SVQ1EncDSPContext *c);
33+
void ff_svq1enc_init_riscv(SVQ1EncDSPContext *c);
3334
void ff_svq1enc_init_x86(SVQ1EncDSPContext *c);
3435

3536
#endif /* AVCODEC_SVQ1ENCDSP_H */

0 commit comments

Comments
 (0)