lavc/g722dsp: add RISC-V V DSP function

This commit is contained in:
Rémi Denis-Courmont 2023-08-15 20:54:37 +03:00
parent 6f8ac298da
commit 9bc5676e40
5 changed files with 111 additions and 0 deletions

View File

@ -71,6 +71,8 @@ av_cold void ff_g722dsp_init(G722DSPContext *c)
#if ARCH_ARM
ff_g722dsp_init_arm(c);
#elif ARCH_RISCV
ff_g722dsp_init_riscv(c);
#elif ARCH_X86
ff_g722dsp_init_x86(c);
#endif

View File

@ -29,6 +29,7 @@ typedef struct G722DSPContext {
void ff_g722dsp_init(G722DSPContext *c);
void ff_g722dsp_init_arm(G722DSPContext *c);
void ff_g722dsp_init_riscv(G722DSPContext *c);
void ff_g722dsp_init_x86(G722DSPContext *c);
#endif /* AVCODEC_G722DSP_H */

View File

@ -10,6 +10,8 @@ OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o \
RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o
OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_init.o
RVV-OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_rvv.o
OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_init.o
RVV-OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_rvv.o
OBJS-$(CONFIG_H264CHROMA) += riscv/h264_chroma_init_riscv.o
RVV-OBJS-$(CONFIG_H264CHROMA) += riscv/h264_mc_chroma.o
OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_init.o

View File

@ -0,0 +1,40 @@
/*
* Copyright © 2023 Rémi Denis-Courmont.
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <stdint.h>
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/riscv/cpu.h"
#include "libavcodec/g722dsp.h"
extern void ff_g722_apply_qmf_rvv(const int16_t *prev_samples, int xout[2]);
av_cold void ff_g722dsp_init_riscv(G722DSPContext *dsp)
{
#if HAVE_RVV
int flags = av_get_cpu_flags();
if ((flags & AV_CPU_FLAG_RVV_I32) && ff_get_rv_vlenb() >= 16)
dsp->apply_qmf = ff_g722_apply_qmf_rvv;
#endif
}

View File

@ -0,0 +1,66 @@
/*
* Copyright © 2023 Rémi Denis-Courmont.
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/riscv/asm.S"
func ff_g722_apply_qmf_rvv, zve32x
lla t0, qmf_coeffs
vsetivli zero, 12, e16, m2, ta, ma
vlseg2e16.v v28, (a0)
vlseg2e16.v v24, (t0)
vwmul.vv v16, v28, v24
vwmul.vv v20, v30, v26
vsetivli zero, 12, e32, m4, ta, ma
vmv.s.x v10, zero
vredsum.vs v8, v16, v10
vredsum.vs v9, v20, v10
vmv.x.s t0, v8
vmv.x.s t1, v9
sw t0, 4(a1)
sw t1, 0(a1)
ret
endfunc
const qmf_coeffs, align=2
.short 3
.short -11
.short -11
.short 53
.short 12
.short -156
.short 32
.short 362
.short -210
.short -805
.short 951
.short 3876
.short 3876
.short 951
.short -805
.short -210
.short 362
.short 32
.short -156
.short 12
.short 53
.short -11
.short -11
.short 3
endconst