...
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_init.o riscv/sbrdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_rvv.o riscv/sbrdsp_rvv.o
|
||||
OBJS-$(CONFIG_AAC_ENCODER) += riscv/aacencdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_AAC_ENCODER) += riscv/aacencdsp_rvv.o
|
||||
OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_init.o
|
||||
RV-OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_rvb.o
|
||||
RVV-OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_rvv.o
|
||||
RVVB-OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_rvvb.o
|
||||
OBJS-$(CONFIG_ALAC_DECODER) += riscv/alacdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_ALAC_DECODER) += riscv/alacdsp_rvv.o
|
||||
OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o
|
||||
RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o
|
||||
OBJS-$(CONFIG_BLOCKDSP) += riscv/blockdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_BLOCKDSP) += riscv/blockdsp_rvv.o
|
||||
OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o
|
||||
RV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvb.o
|
||||
RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o
|
||||
RVVB-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvvb.o
|
||||
OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_rvv.o
|
||||
OBJS-$(CONFIG_FLAC_DECODER) += riscv/flacdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_FLAC_DECODER) += riscv/flacdsp_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_JPEG2000_DECODER) += riscv/jpeg2000dsp_init.o
|
||||
RVV-OBJS-$(CONFIG_JPEG2000_DECODER) += riscv/jpeg2000dsp_rvv.o
|
||||
OBJS-$(CONFIG_H263DSP) += riscv/h263dsp_init.o
|
||||
RVV-OBJS-$(CONFIG_H263DSP) += riscv/h263dsp_rvv.o
|
||||
OBJS-$(CONFIG_H264CHROMA) += riscv/h264_chroma_init_riscv.o
|
||||
RVV-OBJS-$(CONFIG_H264CHROMA) += riscv/h264_mc_chroma.o
|
||||
OBJS-$(CONFIG_H264DSP) += riscv/h264dsp_init.o
|
||||
RVV-OBJS-$(CONFIG_H264DSP) += riscv/h264addpx_rvv.o riscv/h264dsp_rvv.o \
|
||||
riscv/h264idct_rvv.o
|
||||
OBJS-$(CONFIG_H264QPEL) += riscv/h264qpel_init.o
|
||||
RVV-OBJS-$(CONFIG_H264QPEL) += riscv/h264qpel_rvv.o
|
||||
OBJS-$(CONFIG_HEVC_DECODER) += riscv/hevcdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_HEVC_DECODER) += riscv/h26x/h2656_inter_rvv.o
|
||||
OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_rvv.o
|
||||
OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_rvv.o
|
||||
OBJS-$(CONFIG_LLAUDDSP) += riscv/llauddsp_init.o
|
||||
RVV-OBJS-$(CONFIG_LLAUDDSP) += riscv/llauddsp_rvv.o
|
||||
OBJS-$(CONFIG_LLVIDDSP) += riscv/llviddsp_init.o
|
||||
RVV-OBJS-$(CONFIG_LLVIDDSP) += riscv/llviddsp_rvv.o
|
||||
OBJS-$(CONFIG_LLVIDENCDSP) += riscv/llvidencdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_LLVIDENCDSP) += riscv/llvidencdsp_rvv.o
|
||||
OBJS-$(CONFIG_LPC) += riscv/lpc_init.o
|
||||
RVV-OBJS-$(CONFIG_LPC) += riscv/lpc_rvv.o
|
||||
OBJS-$(CONFIG_ME_CMP) += riscv/me_cmp_init.o
|
||||
RVV-OBJS-$(CONFIG_ME_CMP) += riscv/me_cmp_rvv.o
|
||||
OBJS-$(CONFIG_MPEGVIDEOENCDSP) += riscv/mpegvideoencdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_MPEGVIDEOENCDSP) += riscv/mpegvideoencdsp_rvv.o
|
||||
OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_rvv.o
|
||||
OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o
|
||||
RV-OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_rvi.o
|
||||
RVV-OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_rvv.o
|
||||
OBJS-$(CONFIG_RV34DSP) += riscv/rv34dsp_init.o
|
||||
RVV-OBJS-$(CONFIG_RV34DSP) += riscv/rv34dsp_rvv.o
|
||||
OBJS-$(CONFIG_RV40_DECODER) += riscv/rv40dsp_init.o
|
||||
RVV-OBJS-$(CONFIG_RV40_DECODER) += riscv/rv40dsp_rvv.o
|
||||
RV-OBJS-$(CONFIG_STARTCODE) += riscv/startcode_rvb.o
|
||||
RVV-OBJS-$(CONFIG_STARTCODE) += riscv/startcode_rvv.o
|
||||
OBJS-$(CONFIG_SVQ1_ENCODER) += riscv/svqenc_init.o
|
||||
RVV-OBJS-$(CONFIG_SVQ1_ENCODER) += riscv/svqenc_rvv.o
|
||||
OBJS-$(CONFIG_TAK_DECODER) += riscv/takdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_TAK_DECODER) += riscv/takdsp_rvv.o
|
||||
OBJS-$(CONFIG_UTVIDEO_DECODER) += riscv/utvideodsp_init.o
|
||||
RVV-OBJS-$(CONFIG_UTVIDEO_DECODER) += riscv/utvideodsp_rvv.o
|
||||
OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_init.o
|
||||
RV-OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_rvi.o
|
||||
RVV-OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_rvv.o
|
||||
OBJS-$(CONFIG_VIDEODSP) += riscv/videodsp_init.o
|
||||
RV-OBJS-$(CONFIG_VIDEODSP) += riscv/videodsp.o
|
||||
OBJS-$(CONFIG_VP7_DECODER) += riscv/vp7dsp_init.o
|
||||
RVV-OBJS-$(CONFIG_VP7_DECODER) += riscv/vp7dsp_rvv.o
|
||||
OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_init.o
|
||||
RV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvi.o
|
||||
RVV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvv.o
|
||||
OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9dsp_init.o
|
||||
RV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_mc_rvi.o
|
||||
RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o \
|
||||
riscv/vp9_mc_rvv.o
|
||||
OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o
|
||||
RVV-OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_rvv.o
|
||||
|
||||
SHLIBOBJS += riscv/cpu_common.o
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* AAC encoder assembly optimizations
|
||||
* Copyright (c) 2023 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/aacencdsp.h"
|
||||
|
||||
void ff_abs_pow34_rvv(float *out, const float *in, const int size);
|
||||
void ff_aac_quant_bands_rvv(int *, const float *, const float *, int, int,
|
||||
int, const float, const float);
|
||||
|
||||
av_cold void ff_aacenc_dsp_init_riscv(AACEncDSPContext *s)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_F32) {
|
||||
if (flags & AV_CPU_FLAG_RVB) {
|
||||
s->abs_pow34 = ff_abs_pow34_rvv;
|
||||
s->quant_bands = ff_aac_quant_bands_rvv;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
* Copyright © 2024 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_abs_pow34_rvv, zve32f, zba
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a2, e32, m8, ta, ma
|
||||
sub a2, a2, t0
|
||||
vle32.v v0, (a1)
|
||||
sh2add a1, t0, a1
|
||||
vfabs.v v0, v0
|
||||
vfsqrt.v v8, v0
|
||||
vfmul.vv v8, v8, v0
|
||||
vfsqrt.v v8, v8
|
||||
vse32.v v8, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_aac_quant_bands_rvv, zve32f, zba
|
||||
lpad 0
|
||||
NOHWF fmv.w.x fa0, a6
|
||||
NOHWF fmv.w.x fa1, a7
|
||||
fcvt.s.w ft0, a5
|
||||
bnez a4, .L1 # signed?
|
||||
.irp signed, 0, 1
|
||||
.L\signed:
|
||||
vsetvli t0, a3, e32, m8, ta, ma
|
||||
vle32.v v16, (a2)
|
||||
sub a3, a3, t0
|
||||
.if \signed
|
||||
vle32.v v8, (a1)
|
||||
sh2add a1, t0, a1
|
||||
.endif
|
||||
vfmul.vf v16, v16, fa0
|
||||
sh2add a2, t0, a2
|
||||
vfadd.vf v16, v16, fa1
|
||||
vfmin.vf v16, v16, ft0
|
||||
.if \signed
|
||||
vfsgnjx.vv v16, v16, v8
|
||||
.endif
|
||||
vfcvt.rtz.x.f.v v16, v16
|
||||
vse32.v v16, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a3, .L\signed
|
||||
|
||||
ret
|
||||
.endr
|
||||
endfunc
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright © 2022 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/aacpsdsp.h"
|
||||
|
||||
void ff_ps_add_squares_rvv(float *dst, const float (*src)[2], int n);
|
||||
void ff_ps_mul_pair_single_rvv(float (*dst)[2], float (*src0)[2], float *src1,
|
||||
int n);
|
||||
void ff_ps_hybrid_analysis_rvv(float (*out)[2], float (*in)[2],
|
||||
const float (*filter)[8][2], ptrdiff_t, int n);
|
||||
void ff_ps_hybrid_analysis_ileave_rvv(float (*out)[32][2], float L[2][38][64],
|
||||
int i, int len);
|
||||
void ff_ps_hybrid_synthesis_deint_rvv(float out[2][38][64], float (*in)[32][2],
|
||||
int i, int len);
|
||||
|
||||
void ff_ps_stereo_interpolate_rvv(float (*l)[2], float (*r)[2],
|
||||
float h[2][4], float h_step[2][4], int len);
|
||||
|
||||
av_cold void ff_psdsp_init_riscv(PSDSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_I32) {
|
||||
if (flags & AV_CPU_FLAG_RVV_F32) {
|
||||
if (flags & AV_CPU_FLAG_RVB) {
|
||||
if (flags & AV_CPU_FLAG_RVV_I64)
|
||||
c->add_squares = ff_ps_add_squares_rvv;
|
||||
|
||||
c->mul_pair_single = ff_ps_mul_pair_single_rvv;
|
||||
}
|
||||
c->hybrid_analysis = ff_ps_hybrid_analysis_rvv;
|
||||
}
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVB) {
|
||||
c->hybrid_analysis_ileave = ff_ps_hybrid_analysis_ileave_rvv;
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_I64)
|
||||
c->hybrid_synthesis_deint = ff_ps_hybrid_synthesis_deint_rvv;
|
||||
if (flags & AV_CPU_FLAG_RVV_F32)
|
||||
c->stereo_interpolate[0] = ff_ps_stereo_interpolate_rvv;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,266 @@
|
||||
/*
|
||||
* Copyright © 2022-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_ps_add_squares_rvv, zve64f, zba
|
||||
lpad 0
|
||||
li t1, 32
|
||||
1:
|
||||
vsetvli t0, a2, e32, m4, ta, ma
|
||||
vle64.v v8, (a1)
|
||||
sub a2, a2, t0
|
||||
vnsrl.wx v24, v8, zero
|
||||
vle32.v v16, (a0)
|
||||
sh3add a1, t0, a1
|
||||
vnsrl.wx v28, v8, t1
|
||||
vfmacc.vv v16, v24, v24
|
||||
vfmacc.vv v16, v28, v28
|
||||
vse32.v v16, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_ps_mul_pair_single_rvv, zve32f, zba
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a3, e32, m4, ta, ma
|
||||
vlseg2e32.v v24, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v16, (a2)
|
||||
sh3add a1, t0, a1
|
||||
vfmul.vv v24, v24, v16
|
||||
sh2add a2, t0, a2
|
||||
vfmul.vv v28, v28, v16
|
||||
vsseg2e32.v v24, (a0)
|
||||
sh3add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_ps_hybrid_analysis_rvv, zve32f
|
||||
lpad 0
|
||||
/* We need 26 FP registers, for 20 scratch ones. Spill fs0-fs5. */
|
||||
addi sp, sp, -48
|
||||
.irp n, 0, 1, 2, 3, 4, 5
|
||||
HWD fsd fs\n, (8 * \n)(sp)
|
||||
NOHWD fsw fs\n, (4 * \n)(sp)
|
||||
.endr
|
||||
|
||||
.macro input, j, fd0, fd1, fd2, fd3
|
||||
flw \fd0, (4 * ((\j * 2) + 0))(a1)
|
||||
flw fs4, (4 * (((12 - \j) * 2) + 0))(a1)
|
||||
flw \fd1, (4 * ((\j * 2) + 1))(a1)
|
||||
fsub.s \fd3, \fd0, fs4
|
||||
flw fs5, (4 * (((12 - \j) * 2) + 1))(a1)
|
||||
fadd.s \fd2, \fd1, fs5
|
||||
fadd.s \fd0, \fd0, fs4
|
||||
fsub.s \fd1, \fd1, fs5
|
||||
.endm
|
||||
|
||||
// re0, re1, im0, im1
|
||||
input 0, ft0, ft1, ft2, ft3
|
||||
input 1, ft4, ft5, ft6, ft7
|
||||
input 2, ft8, ft9, ft10, ft11
|
||||
input 3, fa0, fa1, fa2, fa3
|
||||
input 4, fa4, fa5, fa6, fa7
|
||||
input 5, fs0, fs1, fs2, fs3
|
||||
flw fs4, (4 * ((6 * 2) + 0))(a1)
|
||||
flw fs5, (4 * ((6 * 2) + 1))(a1)
|
||||
|
||||
add t2, a2, 6 * 2 * 4 // point to filter[i][6][0]
|
||||
li t4, 8 * 2 * 4 // filter byte stride
|
||||
slli a3, a3, 3 // output byte stride
|
||||
1:
|
||||
.macro filter, vs0, vs1, fo0, fo1, fo2, fo3
|
||||
vfmacc.vf v8, \fo0, \vs0
|
||||
vfmacc.vf v10, \fo2, \vs0
|
||||
vfnmsac.vf v8, \fo1, \vs1
|
||||
vfmacc.vf v10, \fo3, \vs1
|
||||
.endm
|
||||
|
||||
vsetvli t0, a4, e32, m2, ta, ma
|
||||
/*
|
||||
* The filter (a2) has 16 segments, of which 13 need to be extracted.
|
||||
* R-V V supports only up to 8 segments, so unrolling is unavoidable.
|
||||
*/
|
||||
vlse32.v v28, (t2), t4
|
||||
addi t1, a2, 16
|
||||
vfmul.vf v8, v28, fs4
|
||||
vlsseg4e32.v v16, (a2), t4
|
||||
vfmul.vf v10, v28, fs5
|
||||
filter v16, v18, ft0, ft1, ft2, ft3
|
||||
vlsseg4e32.v v24, (t1), t4
|
||||
filter v20, v22, ft4, ft5, ft6, ft7
|
||||
addi t1, a2, 32
|
||||
filter v24, v26, ft8, ft9, ft10, ft11
|
||||
vlsseg4e32.v v16, (t1), t4
|
||||
sub a4, a4, t0
|
||||
filter v28, v30, fa0, fa1, fa2, fa3
|
||||
slli t1, t0, 3 + 1 + 2 // ctz(8 * 2 * 4)
|
||||
filter v16, v18, fa4, fa5, fa6, fa7
|
||||
mul t0, t0, a3
|
||||
filter v20, v22, fs0, fs1, fs2, fs3
|
||||
add a2, a2, t1
|
||||
add t2, t2, t1
|
||||
vssseg2e32.v v8, (a0), a3
|
||||
add a0, a0, t0
|
||||
bnez a4, 1b
|
||||
|
||||
.irp n, 5, 4, 3, 2, 1, 0
|
||||
HWD fld fs\n, (8 * \n)(sp)
|
||||
NOHWD flw fs\n, (4 * \n)(sp)
|
||||
.endr
|
||||
addi sp, sp, 48
|
||||
ret
|
||||
.purgem input
|
||||
.purgem filter
|
||||
endfunc
|
||||
|
||||
func ff_ps_hybrid_analysis_ileave_rvv, zve32x /* no zve32f here */, zba
|
||||
lpad 0
|
||||
slli t0, a2, 5 + 1 + 2 // ctz(32 * 2 * 4)
|
||||
sh2add a1, a2, a1
|
||||
add a0, a0, t0
|
||||
addi a2, a2, -64
|
||||
li t1, 38 * 64 * 4
|
||||
li t6, 64 * 4 // (uint8_t *)L[x][j+1][i] - L[x][j][i]
|
||||
add a4, a1, t1 // &L[1]
|
||||
beqz a2, 3f
|
||||
1:
|
||||
mv t0, a0
|
||||
mv t1, a1
|
||||
mv t3, a3
|
||||
mv t4, a4
|
||||
addi a2, a2, 1
|
||||
2:
|
||||
vsetvli t5, t3, e32, m4, ta, ma
|
||||
vlse32.v v16, (t1), t6
|
||||
sub t3, t3, t5
|
||||
vlse32.v v20, (t4), t6
|
||||
mul t2, t5, t6
|
||||
vsseg2e32.v v16, (t0)
|
||||
sh3add t0, t5, t0
|
||||
add t1, t1, t2
|
||||
add t4, t4, t2
|
||||
bnez t3, 2b
|
||||
|
||||
add a0, a0, 32 * 2 * 4
|
||||
add a1, a1, 4
|
||||
add a4, a4, 4
|
||||
bnez a2, 1b
|
||||
3:
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_ps_hybrid_synthesis_deint_rvv, zve64x, zba
|
||||
slli t0, a2, 5 + 1 + 2
|
||||
sh2add a0, a2, a0
|
||||
add a1, a1, t0
|
||||
addi t2, a2, -64
|
||||
li t0, 38 * 64
|
||||
li t1, 32 * 2 * 4
|
||||
li t4, 8 - 16384 // offset from in[64][n][0] to in[0][n + 1][0]
|
||||
slli t5, a2, 5 + 1 + 2 // and from in[0][n+1][0] to in[0][n+1][s]
|
||||
neg t2, t2
|
||||
li t3, 32
|
||||
add a4, t4, t5
|
||||
sh2add t0, t0, a0
|
||||
1:
|
||||
mv t4, t2
|
||||
addi a3, a3, -1
|
||||
2:
|
||||
vsetvli t5, t4, e32, m4, ta, ma
|
||||
vlse64.v v16, (a1), t1 /* sizeof (float[32][2]) */
|
||||
sub t4, t4, t5
|
||||
vnsrl.wx v24, v16, zero
|
||||
slli t6, t5, 5 + 1 + 2
|
||||
vnsrl.wx v28, v16, t3 /* 32 */
|
||||
add a1, a1, t6
|
||||
vse32.v v24, (a0)
|
||||
sh2add a0, t5, a0
|
||||
vse32.v v28, (t0)
|
||||
sh2add t0, t5, t0
|
||||
bnez t4, 2b
|
||||
|
||||
add a1, a1, a4
|
||||
sh2add a0, a2, a0
|
||||
sh2add t0, a2, t0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_ps_stereo_interpolate_rvv, zve32f, b
|
||||
lpad 0
|
||||
vsetvli t0, zero, e32, m2, ta, ma
|
||||
vid.v v24
|
||||
flw ft0, (a2)
|
||||
vadd.vi v24, v24, 1 // v24[i] = i + 1
|
||||
flw ft1, 4(a2)
|
||||
vfcvt.f.xu.v v24, v24
|
||||
flw ft2, 8(a2)
|
||||
vfmv.v.f v16, ft0
|
||||
flw ft3, 12(a2)
|
||||
vfmv.v.f v18, ft1
|
||||
flw ft0, (a3)
|
||||
vfmv.v.f v20, ft2
|
||||
flw ft1, 4(a3)
|
||||
vfmv.v.f v22, ft3
|
||||
flw ft2, 8(a3)
|
||||
flw ft3, 12(a3)
|
||||
fcvt.s.wu ft4, t0 // (float)(vlenb / sizeof (float))
|
||||
vfmacc.vf v16, ft0, v24 // h0 += (i + 1) * h0_step
|
||||
fmul.s ft0, ft0, ft4
|
||||
vfmacc.vf v18, ft1, v24
|
||||
fmul.s ft1, ft1, ft4
|
||||
vfmacc.vf v20, ft2, v24
|
||||
fmul.s ft2, ft2, ft4
|
||||
vfmacc.vf v22, ft3, v24
|
||||
fmul.s ft3, ft3, ft4
|
||||
1:
|
||||
min t0, t0, a4
|
||||
vsetvli zero, t0, e32, m2, ta, ma
|
||||
vlseg2e32.v v0, (a0) // v0:l_re, v2:l_im
|
||||
sub a4, a4, t0
|
||||
vlseg2e32.v v4, (a1) // v4:r_re, v6:r_im
|
||||
vfmul.vv v8, v0, v16
|
||||
vfmul.vv v10, v2, v16
|
||||
vfmul.vv v12, v0, v18
|
||||
vfmul.vv v14, v2, v18
|
||||
vfmacc.vv v8, v4, v20
|
||||
vfmacc.vv v10, v6, v20
|
||||
vfmacc.vv v12, v4, v22
|
||||
vfmacc.vv v14, v6, v22
|
||||
vsseg2e32.v v8, (a0)
|
||||
sh3add a0, t0, a0
|
||||
vsseg2e32.v v12, (a1)
|
||||
sh3add a1, t0, a1
|
||||
vfadd.vf v16, v16, ft0 // h0 += (vlenb / sizeof (float)) * h0_step
|
||||
vfadd.vf v18, v18, ft1
|
||||
vfadd.vf v20, v20, ft2
|
||||
vfadd.vf v22, v22, ft3
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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 <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/ac3dsp.h"
|
||||
|
||||
void ff_ac3_exponent_min_rvb(uint8_t *exp, int, int);
|
||||
void ff_ac3_exponent_min_rvv(uint8_t *exp, int, int);
|
||||
void ff_extract_exponents_rvb(uint8_t *exp, int32_t *coef, int nb_coefs);
|
||||
void ff_extract_exponents_rvvb(uint8_t *exp, int32_t *coef, int nb_coefs);
|
||||
void ff_float_to_fixed24_rvv(int32_t *dst, const float *src, size_t len);
|
||||
void ff_sum_square_butterfly_int32_rvv(int64_t *, const int32_t *,
|
||||
const int32_t *, int);
|
||||
void ff_sum_square_butterfly_float_rvv(float *, const float *,
|
||||
const float *, int);
|
||||
|
||||
av_cold void ff_ac3dsp_init_riscv(AC3DSPContext *c)
|
||||
{
|
||||
#if HAVE_RV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVB_BASIC) {
|
||||
c->ac3_exponent_min = ff_ac3_exponent_min_rvb;
|
||||
c->extract_exponents = ff_extract_exponents_rvb;
|
||||
}
|
||||
|
||||
# if HAVE_RVV
|
||||
if (flags & AV_CPU_FLAG_RVV_I32) {
|
||||
c->ac3_exponent_min = ff_ac3_exponent_min_rvv;
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVB) {
|
||||
# if HAVE_RV_ZVBB
|
||||
if (flags & AV_CPU_FLAG_RV_ZVBB)
|
||||
c->extract_exponents = ff_extract_exponents_rvvb;
|
||||
# endif
|
||||
if (flags & AV_CPU_FLAG_RVV_F32) {
|
||||
c->float_to_fixed24 = ff_float_to_fixed24_rvv;
|
||||
c->sum_square_butterfly_float =
|
||||
ff_sum_square_butterfly_float_rvv;
|
||||
}
|
||||
# if __riscv_xlen >= 64
|
||||
if (flags & AV_CPU_FLAG_RVV_I64)
|
||||
c->sum_square_butterfly_int32 =
|
||||
ff_sum_square_butterfly_int32_rvv;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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_ac3_exponent_min_rvb, zbb
|
||||
lpad 0
|
||||
beqz a1, 3f
|
||||
1:
|
||||
addi a2, a2, -1
|
||||
lb t3, (a0)
|
||||
addi t0, a0, 256
|
||||
mv t1, a1
|
||||
2:
|
||||
lb t4, (t0)
|
||||
addi t1, t1, -1
|
||||
addi t0, t0, 256
|
||||
minu t3, t3, t4
|
||||
bnez t1, 2b
|
||||
|
||||
sb t3, (a0)
|
||||
addi a0, a0, 1
|
||||
bnez a2, 1b
|
||||
3:
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_extract_exponents_rvb, zbb
|
||||
lpad 0
|
||||
1:
|
||||
lw t0, (a1)
|
||||
addi a0, a0, 1
|
||||
neg t1, t0
|
||||
addi a1, a1, 4
|
||||
max t0, t0, t1
|
||||
addi a2, a2, -1
|
||||
clz t0, t0
|
||||
addi t0, t0, 24 - __riscv_xlen
|
||||
sb t0, -1(a0)
|
||||
bgtz a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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_ac3_exponent_min_rvv, zve32x
|
||||
lpad 0
|
||||
beqz a1, 3f
|
||||
1:
|
||||
vsetvli t2, a2, e8, m8, ta, ma
|
||||
vle8.v v8, (a0)
|
||||
addi t0, a0, 256
|
||||
sub a2, a2, t2
|
||||
mv t1, a1
|
||||
2:
|
||||
vle8.v v16, (t0)
|
||||
addi t1, t1, -1
|
||||
vminu.vv v8, v8, v16
|
||||
addi t0, t0, 256
|
||||
bnez t1, 2b
|
||||
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, t2
|
||||
bnez a2, 1b
|
||||
3:
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_float_to_fixed24_rvv, zve32f, zba
|
||||
lpad 0
|
||||
li t1, 1 << 24
|
||||
fcvt.s.w f0, t1
|
||||
1:
|
||||
vsetvli t0, a2, e32, m8, ta, ma
|
||||
sub a2, a2, t0
|
||||
vle32.v v0, (a1)
|
||||
vfmul.vf v0, v0, f0
|
||||
vfcvt.x.f.v v0, v0
|
||||
sh2add a1, t0, a1
|
||||
vse32.v v0, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
#if __riscv_xlen >= 64
|
||||
func ff_sum_square_butterfly_int32_rvv, zve64x, zba
|
||||
lpad 0
|
||||
vsetvli t0, zero, e64, m8, ta, ma
|
||||
vmv.v.x v0, zero
|
||||
vmv.v.x v8, zero
|
||||
1:
|
||||
vsetvli t0, a3, e32, m2, tu, ma
|
||||
vle32.v v16, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v20, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vadd.vv v24, v16, v20
|
||||
sh2add a2, t0, a2
|
||||
vsub.vv v28, v16, v20
|
||||
vwmacc.vv v0, v16, v16
|
||||
vwmacc.vv v4, v20, v20
|
||||
vwmacc.vv v8, v24, v24
|
||||
vwmacc.vv v12, v28, v28
|
||||
bnez a3, 1b
|
||||
|
||||
vsetvli t0, zero, e64, m4, ta, ma
|
||||
vmv.s.x v16, zero
|
||||
vmv.s.x v17, zero
|
||||
vredsum.vs v16, v0, v16
|
||||
vmv.s.x v18, zero
|
||||
vredsum.vs v17, v4, v17
|
||||
vmv.s.x v19, zero
|
||||
vredsum.vs v18, v8, v18
|
||||
vmv.x.s t0, v16
|
||||
vredsum.vs v19, v12, v19
|
||||
vmv.x.s t1, v17
|
||||
sd t0, (a0)
|
||||
vmv.x.s t2, v18
|
||||
sd t1, 8(a0)
|
||||
vmv.x.s t3, v19
|
||||
sd t2, 16(a0)
|
||||
sd t3, 24(a0)
|
||||
ret
|
||||
endfunc
|
||||
#endif
|
||||
|
||||
func ff_sum_square_butterfly_float_rvv, zve32f, zba
|
||||
lpad 0
|
||||
vsetvli t0, zero, e32, m8, ta, ma
|
||||
vmv.v.x v0, zero
|
||||
vmv.v.x v8, zero
|
||||
1:
|
||||
vsetvli t0, a3, e32, m4, tu, ma
|
||||
vle32.v v16, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v20, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vfadd.vv v24, v16, v20
|
||||
sh2add a2, t0, a2
|
||||
vfsub.vv v28, v16, v20
|
||||
vfmacc.vv v0, v16, v16
|
||||
vfmacc.vv v4, v20, v20
|
||||
vfmacc.vv v8, v24, v24
|
||||
vfmacc.vv v12, v28, v28
|
||||
bnez a3, 1b
|
||||
|
||||
vsetvli t0, zero, e32, m4, ta, ma
|
||||
vmv.s.x v16, zero
|
||||
vmv.s.x v17, zero
|
||||
vfredsum.vs v16, v0, v16
|
||||
vmv.s.x v18, zero
|
||||
vfredsum.vs v17, v4, v17
|
||||
vmv.s.x v19, zero
|
||||
vfredsum.vs v18, v8, v18
|
||||
vfmv.f.s ft0, v16
|
||||
vfredsum.vs v19, v12, v19
|
||||
vfmv.f.s ft1, v17
|
||||
fsw ft0, (a0)
|
||||
vfmv.f.s ft2, v18
|
||||
fsw ft1, 4(a0)
|
||||
vfmv.f.s ft3, v19
|
||||
fsw ft2, 8(a0)
|
||||
fsw ft3, 12(a0)
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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_extract_exponents_rvvb, zve32x, zvbb, zba
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a2, e32, m8, ta, ma
|
||||
vle32.v v8, (a1)
|
||||
sub a2, a2, t0
|
||||
vneg.v v16, v8
|
||||
sh2add a1, t0, a1
|
||||
vmax.vv v8, v8, v16
|
||||
vclz.v v8, v8
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vncvt.x.x.w v4, v8
|
||||
vsetvli zero, zero, e8, m2, ta, ma
|
||||
vncvt.x.x.w v2, v4
|
||||
vadd.vi v2, v2, 24 - 32
|
||||
vse8.v v2, (a0)
|
||||
add a0, a0, t0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright © 2022 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 <stdint.h>
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavcodec/alacdsp.h"
|
||||
|
||||
void ff_alac_decorrelate_stereo_rvv(int32_t *buffer[2], int nb_samples,
|
||||
int decorr_shift, int decorr_left_weight);
|
||||
void ff_alac_append_extra_bits_mono_rvv(int32_t *buffer[2],
|
||||
int32_t *extra_bits_buf[2],
|
||||
int extra_bits, int channels,
|
||||
int nb_samples);
|
||||
void ff_alac_append_extra_bits_stereo_rvv(int32_t *buffer[2],
|
||||
int32_t *extra_bits_buf[2],
|
||||
int extra_bits, int channels,
|
||||
int nb_samples);
|
||||
|
||||
av_cold void ff_alacdsp_init_riscv(ALACDSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV && (__riscv_xlen == 64)
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
|
||||
c->decorrelate_stereo = ff_alac_decorrelate_stereo_rvv;
|
||||
c->append_extra_bits[0] = ff_alac_append_extra_bits_mono_rvv;
|
||||
c->append_extra_bits[1] = ff_alac_append_extra_bits_stereo_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright © 2022 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"
|
||||
|
||||
#if (__riscv_xlen == 64)
|
||||
func ff_alac_decorrelate_stereo_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a4, 8(a0)
|
||||
ld a0, 0(a0)
|
||||
1:
|
||||
vsetvli t0, a1, e32, m4, ta, ma
|
||||
vle32.v v24, (a4)
|
||||
sub a1, a1, t0
|
||||
vle32.v v16, (a0)
|
||||
vmul.vx v8, v24, a3
|
||||
vadd.vv v24, v24, v16
|
||||
vsra.vx v8, v8, a2
|
||||
vsub.vv v16, v16, v8
|
||||
vsub.vv v24, v24, v8
|
||||
vse32.v v16, (a4)
|
||||
sh2add a4, t0, a4
|
||||
vse32.v v24, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a1, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_alac_append_extra_bits_mono_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a4, e32, m8, ta, ma
|
||||
vle32.v v16, (a0)
|
||||
sub a4, a4, t0
|
||||
vle32.v v24, (a1)
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v16, v16, a2
|
||||
vor.vv v16, v24, v16
|
||||
vse32.v v16, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_alac_append_extra_bits_stereo_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a6, 8(a0)
|
||||
ld a0, (a0)
|
||||
ld a7, 8(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a4, e32, m8, ta, ma
|
||||
vle32.v v16, (a0)
|
||||
sub a4, a4, t0
|
||||
vle32.v v0, (a6)
|
||||
vsll.vx v16, v16, a2
|
||||
vsll.vx v0, v0, a2
|
||||
vle32.v v24, (a1)
|
||||
sh2add a1, t0, a1
|
||||
vle32.v v8, (a7)
|
||||
sh2add a7, t0, a7
|
||||
vor.vv v16, v24, v16
|
||||
vor.vv v0, v8, v0
|
||||
vse32.v v16, (a0)
|
||||
sh2add a0, t0, a0
|
||||
vse32.v v0, (a6)
|
||||
sh2add a6, t0, a6
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright © 2022 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/audiodsp.h"
|
||||
|
||||
int32_t ff_scalarproduct_int16_rvv(const int16_t *v1, const int16_t *v2, int len);
|
||||
void ff_vector_clip_int32_rvv(int32_t *dst, const int32_t *src, int32_t min,
|
||||
int32_t max, unsigned int len);
|
||||
void ff_vector_clipf_rvv(float *dst, const float *src, int len, float min, float max);
|
||||
|
||||
av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
|
||||
c->scalarproduct_int16 = ff_scalarproduct_int16_rvv;
|
||||
c->vector_clip_int32 = ff_vector_clip_int32_rvv;
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_F32)
|
||||
c->vector_clipf = ff_vector_clipf_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright © 2022 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_scalarproduct_int16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
vsetvli t0, zero, e32, m8, ta, ma
|
||||
vmv.v.x v8, zero
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetvli t0, a2, e16, m4, tu, ma
|
||||
vle16.v v16, (a0)
|
||||
sub a2, a2, t0
|
||||
vle16.v v24, (a1)
|
||||
sh1add a0, t0, a0
|
||||
vwmacc.vv v8, v16, v24
|
||||
sh1add a1, t0, a1
|
||||
bnez a2, 1b
|
||||
|
||||
vsetvli t0, zero, e32, m8, ta, ma
|
||||
vredsum.vs v0, v8, v0
|
||||
vmv.x.s a0, v0
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_vector_clip_int32_rvv, zve32x, zba
|
||||
1:
|
||||
vsetvli t0, a4, e32, m8, ta, ma
|
||||
vle32.v v8, (a1)
|
||||
sub a4, a4, t0
|
||||
vmax.vx v8, v8, a2
|
||||
sh2add a1, t0, a1
|
||||
vmin.vx v8, v8, a3
|
||||
vse32.v v8, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_vector_clipf_rvv, zve32f, zba
|
||||
lpad 0
|
||||
NOHWF fmv.w.x fa0, a3
|
||||
NOHWF fmv.w.x fa1, a4
|
||||
1:
|
||||
vsetvli t0, a2, e32, m8, ta, ma
|
||||
vle32.v v8, (a1)
|
||||
sub a2, a2, t0
|
||||
vfmax.vf v8, v8, fa0
|
||||
sh2add a1, t0, a1
|
||||
vfmin.vf v8, v8, fa1
|
||||
vse32.v v8, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/blockdsp.h"
|
||||
|
||||
void ff_clear_block_rvv(int16_t *block);
|
||||
void ff_clear_blocks_rvv(int16_t *block);
|
||||
void ff_fill_block16_rvv(uint8_t *block, uint8_t value, ptrdiff_t line_size,
|
||||
int h);
|
||||
void ff_fill_block8_rvv(uint8_t *block, uint8_t value, ptrdiff_t line_size,
|
||||
int h);
|
||||
|
||||
av_cold void ff_blockdsp_init_riscv(BlockDSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_I64 && ff_rv_vlen_least(128)) {
|
||||
c->clear_block = ff_clear_block_rvv;
|
||||
c->clear_blocks = ff_clear_blocks_rvv;
|
||||
c->fill_block_tab[0] = ff_fill_block16_rvv;
|
||||
c->fill_block_tab[1] = ff_fill_block8_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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_clear_block_rvv, zve64x
|
||||
lpad 0
|
||||
vsetivli zero, 16, e64, m8, ta, ma
|
||||
vmv.v.i v0, 0
|
||||
vse64.v v0, (a0)
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_clear_blocks_rvv, zve64x
|
||||
lpad 0
|
||||
vsetivli zero, 16, e64, m8, ta, ma
|
||||
vmv.v.i v0, 0
|
||||
|
||||
.rept 5
|
||||
vse64.v v0, (a0)
|
||||
addi a0, a0, 128
|
||||
.endr
|
||||
vse64.v v0, (a0)
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_fill_block16_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli t0, 16, e8, m1, ta, ma
|
||||
vmv.v.x v8, a1
|
||||
1:
|
||||
addi a3, a3, -1
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_fill_block8_rvv, zve64x
|
||||
lpad 0
|
||||
vsetvli t0, zero, e8, m4, ta, ma
|
||||
vmv.v.x v8, a1
|
||||
vsetvli t0, a3, e64, m4, ta, ma
|
||||
vsse64.v v8, (a0), a2
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright © 2022 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 <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/bswapdsp.h"
|
||||
|
||||
void ff_bswap32_buf_rvb(uint32_t *dst, const uint32_t *src, int len);
|
||||
void ff_bswap16_buf_rvv(uint16_t *dst, const uint16_t *src, int len);
|
||||
void ff_bswap32_buf_rvvb(uint32_t *dst, const uint32_t *src, int len);
|
||||
void ff_bswap16_buf_rvvb(uint16_t *dst, const uint16_t *src, int len);
|
||||
|
||||
av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c)
|
||||
{
|
||||
#if HAVE_RV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
#if (__riscv_xlen >= 64)
|
||||
if (flags & AV_CPU_FLAG_RVB_BASIC)
|
||||
c->bswap_buf = ff_bswap32_buf_rvb;
|
||||
#endif
|
||||
#if HAVE_RVV
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
|
||||
c->bswap16_buf = ff_bswap16_buf_rvv;
|
||||
#if HAVE_RV_ZVBB
|
||||
if (flags & AV_CPU_FLAG_RV_ZVBB) {
|
||||
c->bswap_buf = ff_bswap32_buf_rvvb;
|
||||
c->bswap16_buf = ff_bswap16_buf_rvvb;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright © 2022 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"
|
||||
#include "libavutil/riscv/bswap_rvb.S"
|
||||
|
||||
#if (__riscv_xlen >= 64)
|
||||
func ff_bswap32_buf_rvb, zbb
|
||||
lpad 0
|
||||
slli a2, a2, 2
|
||||
bswap32_rvb a0, a1, a2
|
||||
endfunc
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright © 2022 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_bswap16_buf_rvv, zve32x, zba
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a2, e16, m8, ta, ma
|
||||
vle16.v v8, (a1)
|
||||
sub a2, a2, t0
|
||||
vsll.vi v16, v8, 8
|
||||
sh1add a1, t0, a1
|
||||
vsrl.vi v24, v8, 8
|
||||
vor.vv v8, v16, v24
|
||||
vse16.v v8, (a0)
|
||||
sh1add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright © 2024 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_bswap32_buf_rvvb, zve32x, zvbb, zba
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a2, e32, m8, ta, ma
|
||||
vle32.v v8, (a1)
|
||||
sub a2, a2, t0
|
||||
vrev8.v v8, v8
|
||||
sh2add a1, t0, a1
|
||||
vse32.v v8, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_bswap16_buf_rvvb, zve32x, zvbb, zba
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a2, e16, m8, ta, ma
|
||||
vle16.v v8, (a1)
|
||||
sub a2, a2, t0
|
||||
vrev8.v v8, v8
|
||||
sh1add a1, t0, a1
|
||||
vse16.v v8, (a0)
|
||||
sh1add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1 @@
|
||||
#include "libavutil/riscv/cpu_common.c"
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 <stdint.h>
|
||||
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavcodec/exrdsp.h"
|
||||
|
||||
void ff_reorder_pixels_rvv(uint8_t *dst, const uint8_t *src, ptrdiff_t size);
|
||||
|
||||
av_cold void ff_exrdsp_init_riscv(ExrDSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB))
|
||||
c->reorder_pixels = ff_reorder_pixels_rvv;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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_reorder_pixels_rvv, zve32x, zba
|
||||
lpad 0
|
||||
srai a2, a2, 1
|
||||
add t1, a1, a2
|
||||
1:
|
||||
vsetvli t0, a2, e8, m4, ta, ma
|
||||
vle8.v v0, (a1)
|
||||
sub a2, a2, t0
|
||||
vle8.v v4, (t1)
|
||||
add a1, t0, a1
|
||||
vsseg2e8.v v0, (a0)
|
||||
add t1, t0, t1
|
||||
sh1add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright © 2024 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
|
||||
*/
|
||||
|
||||
#define VILL -0x8000
|
||||
|
||||
.data
|
||||
ff_vtype_e8:
|
||||
ff_vtype_e8_1:
|
||||
.half VILL
|
||||
ff_vtype_e8_2:
|
||||
.half VILL
|
||||
ff_vtype_e8_4:
|
||||
.half VILL
|
||||
ff_vtype_e8_8:
|
||||
.half VILL
|
||||
ff_vtype_e8_16:
|
||||
.half VILL
|
||||
ff_vtype_e8_32:
|
||||
.half VILL
|
||||
|
||||
ff_vtype_e16:
|
||||
ff_vtype_e16_1:
|
||||
.half VILL
|
||||
ff_vtype_e16_2:
|
||||
.half VILL
|
||||
ff_vtype_e16_4:
|
||||
.half VILL
|
||||
ff_vtype_e16_8:
|
||||
.half VILL
|
||||
ff_vtype_e16_16:
|
||||
.half VILL
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/flacdsp.h"
|
||||
|
||||
void ff_flac_lpc16_rvv(int32_t *decoded, const int coeffs[32],
|
||||
int pred_order, int qlevel, int len);
|
||||
void ff_flac_lpc32_rvv(int32_t *decoded, const int coeffs[32],
|
||||
int pred_order, int qlevel, int len);
|
||||
void ff_flac_lpc32_rvv_simple(int32_t *decoded, const int coeffs[32],
|
||||
int pred_order, int qlevel, int len);
|
||||
void ff_flac_lpc33_rvv(int64_t *, const int32_t *, const int coeffs[32],
|
||||
int pred_order, int qlevel, int len);
|
||||
void ff_flac_wasted32_rvv(int32_t *, int shift, int len);
|
||||
void ff_flac_wasted33_rvv(int64_t *, const int32_t *, int shift, int len);
|
||||
void ff_flac_decorrelate_indep2_16_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
void ff_flac_decorrelate_indep4_16_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
void ff_flac_decorrelate_indep6_16_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
void ff_flac_decorrelate_indep8_16_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
void ff_flac_decorrelate_ls_16_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
void ff_flac_decorrelate_rs_16_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
void ff_flac_decorrelate_ms_16_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
void ff_flac_decorrelate_indep2_32_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
void ff_flac_decorrelate_indep4_32_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
void ff_flac_decorrelate_indep6_32_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
void ff_flac_decorrelate_indep8_32_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
void ff_flac_decorrelate_ls_32_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
void ff_flac_decorrelate_rs_32_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
void ff_flac_decorrelate_ms_32_rvv(uint8_t **out, int32_t **in,
|
||||
int channels, int len, int shift);
|
||||
|
||||
av_cold void ff_flacdsp_init_riscv(FLACDSPContext *c, enum AVSampleFormat fmt,
|
||||
int channels)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
|
||||
int vlenb = ff_get_rv_vlenb();
|
||||
|
||||
if (vlenb >= 16) {
|
||||
c->lpc16 = ff_flac_lpc16_rvv;
|
||||
|
||||
# if (__riscv_xlen >= 64)
|
||||
if (flags & AV_CPU_FLAG_RVV_I64) {
|
||||
if (vlenb > 16) {
|
||||
c->lpc32 = ff_flac_lpc32_rvv_simple;
|
||||
c->lpc33 = ff_flac_lpc33_rvv;
|
||||
} else
|
||||
c->lpc32 = ff_flac_lpc32_rvv;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
c->wasted32 = ff_flac_wasted32_rvv;
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_I64)
|
||||
c->wasted33 = ff_flac_wasted33_rvv;
|
||||
|
||||
# if (__riscv_xlen >= 64)
|
||||
switch (fmt) {
|
||||
case AV_SAMPLE_FMT_S16:
|
||||
switch (channels) {
|
||||
case 2:
|
||||
c->decorrelate[0] = ff_flac_decorrelate_indep2_16_rvv;
|
||||
break;
|
||||
case 4:
|
||||
c->decorrelate[0] = ff_flac_decorrelate_indep4_16_rvv;
|
||||
break;
|
||||
case 6:
|
||||
c->decorrelate[0] = ff_flac_decorrelate_indep6_16_rvv;
|
||||
break;
|
||||
case 8:
|
||||
c->decorrelate[0] = ff_flac_decorrelate_indep8_16_rvv;
|
||||
break;
|
||||
}
|
||||
c->decorrelate[1] = ff_flac_decorrelate_ls_16_rvv;
|
||||
c->decorrelate[2] = ff_flac_decorrelate_rs_16_rvv;
|
||||
c->decorrelate[3] = ff_flac_decorrelate_ms_16_rvv;
|
||||
break;
|
||||
case AV_SAMPLE_FMT_S32:
|
||||
switch (channels) {
|
||||
case 2:
|
||||
c->decorrelate[0] = ff_flac_decorrelate_indep2_32_rvv;
|
||||
break;
|
||||
case 4:
|
||||
c->decorrelate[0] = ff_flac_decorrelate_indep4_32_rvv;
|
||||
break;
|
||||
case 6:
|
||||
c->decorrelate[0] = ff_flac_decorrelate_indep6_32_rvv;
|
||||
break;
|
||||
case 8:
|
||||
c->decorrelate[0] = ff_flac_decorrelate_indep8_32_rvv;
|
||||
break;
|
||||
}
|
||||
c->decorrelate[1] = ff_flac_decorrelate_ls_32_rvv;
|
||||
c->decorrelate[2] = ff_flac_decorrelate_rs_32_rvv;
|
||||
c->decorrelate[3] = ff_flac_decorrelate_ms_32_rvv;
|
||||
break;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,625 @@
|
||||
/*
|
||||
* 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_flac_lpc16_rvv, zve32x, b
|
||||
lpad 0
|
||||
vtype_vli t0, a2, t2, e32, ta, ma
|
||||
vsetvl zero, a2, t0
|
||||
vle32.v v8, (a1)
|
||||
sub a4, a4, a2
|
||||
vle32.v v16, (a0)
|
||||
sh2add a0, a2, a0
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vmul.vv v24, v8, v16
|
||||
lw t0, (a0)
|
||||
vredsum.vs v24, v24, v0
|
||||
addi a4, a4, -1
|
||||
vmv.x.s t1, v24
|
||||
sra t1, t1, a3
|
||||
add t0, t0, t1
|
||||
vslide1down.vx v16, v16, t0
|
||||
sw t0, (a0)
|
||||
addi a0, a0, 4
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
#if (__riscv_xlen == 64)
|
||||
func ff_flac_lpc32_rvv, zve64x, zba
|
||||
lpad 0
|
||||
addi t2, a2, -16
|
||||
ble t2, zero, ff_flac_lpc32_rvv_simple
|
||||
vsetivli zero, 1, e64, m1, ta, ma
|
||||
vmv.s.x v0, zero
|
||||
vsetvli zero, a2, e32, m8, ta, ma
|
||||
vle32.v v8, (a1)
|
||||
sub a4, a4, a2
|
||||
vle32.v v16, (a0)
|
||||
sh2add a0, a2, a0
|
||||
1:
|
||||
vsetvli t1, zero, e32, m4, ta, ma
|
||||
vwmul.vv v24, v8, v16
|
||||
vsetvli zero, t2, e32, m4, tu, ma
|
||||
vwmacc.vv v24, v12, v20
|
||||
vsetvli t1, zero, e64, m8, ta, ma
|
||||
vredsum.vs v24, v24, v0
|
||||
lw t0, (a0)
|
||||
addi a4, a4, -1
|
||||
vmv.x.s t1, v24
|
||||
vsetvli zero, a2, e32, m8, ta, ma
|
||||
sra t1, t1, a3
|
||||
add t0, t0, t1
|
||||
vslide1down.vx v16, v16, t0
|
||||
sw t0, (a0)
|
||||
addi a0, a0, 4
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_lpc32_rvv_simple, zve64x, b
|
||||
lpad 0
|
||||
vtype_vli t3, a2, t1, e64, ta, ma
|
||||
vntypei t2, t3
|
||||
vsetvl zero, a2, t3 // e64
|
||||
vmv.s.x v0, zero
|
||||
vsetvl zero, zero, t2 // e32
|
||||
vle32.v v8, (a1)
|
||||
sub a4, a4, a2
|
||||
vle32.v v16, (a0)
|
||||
sh2add a0, a2, a0
|
||||
1:
|
||||
vwmul.vv v24, v8, v16
|
||||
vsetvl zero, zero, t3 // e64
|
||||
vredsum.vs v24, v24, v0
|
||||
lw t0, (a0)
|
||||
addi a4, a4, -1
|
||||
vmv.x.s t1, v24
|
||||
vsetvl zero, zero, t2 // e32
|
||||
sra t1, t1, a3
|
||||
add t0, t0, t1
|
||||
vslide1down.vx v16, v16, t0
|
||||
sw t0, (a0)
|
||||
addi a0, a0, 4
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_lpc33_rvv, zve64x, b
|
||||
lpad 0
|
||||
vtype_vli t0, a3, t1, e64, ta, ma
|
||||
vsetvl zero, a3, t0
|
||||
vmv.s.x v0, zero
|
||||
sh2add a1, a3, a1
|
||||
vle32.v v24, (a2)
|
||||
sub a5, a5, a3
|
||||
vle64.v v16, (a0)
|
||||
sh3add a0, a3, a0
|
||||
vsext.vf2 v8, v24
|
||||
1:
|
||||
vmul.vv v24, v8, v16
|
||||
lw t0, (a1)
|
||||
addi a1, a1, 4
|
||||
vredsum.vs v24, v24, v0
|
||||
addi a5, a5, -1
|
||||
vmv.x.s t1, v24
|
||||
sra t1, t1, a4
|
||||
add t0, t0, t1
|
||||
vslide1down.vx v16, v16, t0
|
||||
sd t0, (a0)
|
||||
addi a0, a0, 8
|
||||
bnez a5, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
#endif
|
||||
|
||||
func ff_flac_wasted32_rvv, zve32x, zba
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a2, e32, m8, ta, ma
|
||||
vle32.v v8, (a0)
|
||||
sub a2, a2, t0
|
||||
vsll.vx v8, v8, a1
|
||||
vse32.v v8, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_wasted33_rvv, zve64x, zba
|
||||
lpad 0
|
||||
srli t0, a2, 5
|
||||
li t1, 1
|
||||
bnez t0, 2f
|
||||
sll a2, t1, a2
|
||||
1:
|
||||
vsetvli t0, a3, e32, m4, ta, ma
|
||||
vle32.v v8, (a1)
|
||||
sub a3, a3, t0
|
||||
vwmulsu.vx v16, v8, a2
|
||||
sh2add a1, t0, a1
|
||||
vse64.v v16, (a0)
|
||||
sh3add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
|
||||
2: // Pessimistic case: wasted >= 32
|
||||
vsetvli t0, a3, e64, m8, ta, ma
|
||||
vle32.v v8, (a1)
|
||||
sub a3, a3, t0
|
||||
vsext.vf2 v16, v8
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v16, v16, a2
|
||||
vse64.v v16, (a0)
|
||||
sh3add a0, t0, a0
|
||||
bnez a3, 2b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
#if (__riscv_xlen == 64)
|
||||
func ff_flac_decorrelate_indep2_16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m8, ta, ma
|
||||
vle32.v v0, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v8, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v0, v0, a4
|
||||
sh2add a2, t0, a2
|
||||
vsll.vx v8, v8, a4
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vncvt.x.x.w v16, v0
|
||||
vncvt.x.x.w v20, v8
|
||||
vsseg2e16.v v16, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_decorrelate_indep4_16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld t1, 16(a1)
|
||||
ld t2, 24(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m4, ta, ma
|
||||
vle32.v v0, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v4, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v0, v0, a4
|
||||
sh2add a2, t0, a2
|
||||
vle32.v v8, (t1)
|
||||
sh2add t1, t0, t1
|
||||
vsll.vx v4, v4, a4
|
||||
vle32.v v12, (t2)
|
||||
sh2add t2, t0, t2
|
||||
vsll.vx v8, v8, a4
|
||||
vsll.vx v12, v12, a4
|
||||
vsetvli zero, zero, e16, m2, ta, ma
|
||||
vncvt.x.x.w v16, v0
|
||||
vncvt.x.x.w v18, v4
|
||||
vncvt.x.x.w v20, v8
|
||||
vncvt.x.x.w v22, v12
|
||||
vsseg4e16.v v16, (a0)
|
||||
sh3add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_decorrelate_indep6_16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld t1, 16(a1)
|
||||
ld t2, 24(a1)
|
||||
ld t3, 32(a1)
|
||||
ld t4, 40(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m2, ta, ma
|
||||
vle32.v v0, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v2, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v0, v0, a4
|
||||
sh2add a2, t0, a2
|
||||
vle32.v v4, (t1)
|
||||
sh2add t1, t0, t1
|
||||
vsll.vx v2, v2, a4
|
||||
vle32.v v6, (t2)
|
||||
sh2add t2, t0, t2
|
||||
vsll.vx v4, v4, a4
|
||||
vle32.v v8, (t3)
|
||||
sh2add t3, t0, t3
|
||||
vsll.vx v6, v6, a4
|
||||
vle32.v v10, (t4)
|
||||
sh2add t4, t0, t4
|
||||
vsll.vx v8, v8, a4
|
||||
slli t0, t0, 2
|
||||
vsll.vx v10, v10, a4
|
||||
sh1add t0, t0, t0 // t0 *= 3
|
||||
vsetvli zero, zero, e16, m1, ta, ma
|
||||
vncvt.x.x.w v16, v0
|
||||
vncvt.x.x.w v17, v2
|
||||
vncvt.x.x.w v18, v4
|
||||
vncvt.x.x.w v19, v6
|
||||
vncvt.x.x.w v20, v8
|
||||
vncvt.x.x.w v21, v10
|
||||
vsseg6e16.v v16, (a0)
|
||||
add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_decorrelate_indep8_16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld t1, 16(a1)
|
||||
ld t2, 24(a1)
|
||||
ld t3, 32(a1)
|
||||
ld t4, 40(a1)
|
||||
ld t5, 48(a1)
|
||||
ld t6, 56(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m2, ta, ma
|
||||
vle32.v v0, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v2, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v0, v0, a4
|
||||
vle32.v v4, (t1)
|
||||
sh2add a2, t0, a2
|
||||
vsll.vx v2, v2, a4
|
||||
sh2add t1, t0, t1
|
||||
vle32.v v6, (t2)
|
||||
vsll.vx v4, v4, a4
|
||||
sh2add t2, t0, t2
|
||||
vle32.v v8, (t3)
|
||||
sh2add t3, t0, t3
|
||||
vsll.vx v6, v6, a4
|
||||
vle32.v v10, (t4)
|
||||
sh2add t4, t0, t4
|
||||
vsll.vx v8, v8, a4
|
||||
vle32.v v12, (t5)
|
||||
sh2add t5, t0, t5
|
||||
vsll.vx v10, v10, a4
|
||||
vle32.v v14, (t6)
|
||||
sh2add t6, t0, t6
|
||||
vsll.vx v12, v12, a4
|
||||
slli t0, t0, 4
|
||||
vsll.vx v14, v14, a4
|
||||
vsetvli zero, zero, e16, m1, ta, ma
|
||||
vncvt.x.x.w v16, v0
|
||||
vncvt.x.x.w v17, v2
|
||||
vncvt.x.x.w v18, v4
|
||||
vncvt.x.x.w v19, v6
|
||||
vncvt.x.x.w v20, v8
|
||||
vncvt.x.x.w v21, v10
|
||||
vncvt.x.x.w v22, v12
|
||||
vncvt.x.x.w v23, v14
|
||||
vsseg8e16.v v16, (a0)
|
||||
add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_decorrelate_ls_16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m8, ta, ma
|
||||
vle32.v v0, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v8, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v0, v0, a4
|
||||
sh2add a2, t0, a2
|
||||
vsll.vx v8, v8, a4
|
||||
vsub.vv v8, v0, v8
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vncvt.x.x.w v16, v0
|
||||
vncvt.x.x.w v20, v8
|
||||
vsseg2e16.v v16, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_decorrelate_rs_16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m8, ta, ma
|
||||
vle32.v v0, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v8, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v0, v0, a4
|
||||
sh2add a2, t0, a2
|
||||
vsll.vx v8, v8, a4
|
||||
vadd.vv v0, v0, v8
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vncvt.x.x.w v16, v0
|
||||
vncvt.x.x.w v20, v8
|
||||
vsseg2e16.v v16, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_decorrelate_ms_16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m8, ta, ma
|
||||
vle32.v v8, (a2)
|
||||
sub a3, a3, t0
|
||||
vle32.v v0, (a1)
|
||||
sh2add a1, t0, a1
|
||||
vsra.vi v16, v8, 1
|
||||
sh2add a2, t0, a2
|
||||
vsub.vv v24, v0, v16
|
||||
vadd.vv v16, v24, v8
|
||||
vsll.vx v8, v24, a4
|
||||
vsll.vx v0, v16, a4
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vncvt.x.x.w v0, v0
|
||||
vncvt.x.x.w v4, v8
|
||||
vsseg2e16.v v0, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_decorrelate_indep2_32_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m4, ta, ma
|
||||
vle32.v v0, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v4, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v0, v0, a4
|
||||
sh2add a2, t0, a2
|
||||
vsll.vx v4, v4, a4
|
||||
vsseg2e32.v v0, (a0)
|
||||
sh3add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_decorrelate_indep4_32_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld t1, 16(a1)
|
||||
ld t2, 24(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m2, ta, ma
|
||||
vle32.v v0, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v2, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v0, v0, a4
|
||||
sh2add a2, t0, a2
|
||||
vle32.v v4, (t1)
|
||||
sh2add t1, t0, t1
|
||||
vsll.vx v2, v2, a4
|
||||
vle32.v v6, (t2)
|
||||
sh2add t2, t0, t2
|
||||
vsll.vx v4, v4, a4
|
||||
slli t0, t0, 4
|
||||
vsll.vx v6, v6, a4
|
||||
vsseg4e32.v v0, (a0)
|
||||
add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_decorrelate_indep6_32_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld t1, 16(a1)
|
||||
ld t2, 24(a1)
|
||||
ld t3, 32(a1)
|
||||
ld t4, 40(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m1, ta, ma
|
||||
vle32.v v0, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v1, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v0, v0, a4
|
||||
sh2add a2, t0, a2
|
||||
vle32.v v2, (t1)
|
||||
sh2add t1, t0, t1
|
||||
vsll.vx v1, v1, a4
|
||||
vle32.v v3, (t2)
|
||||
sh2add t2, t0, t2
|
||||
vsll.vx v2, v2, a4
|
||||
vle32.v v4, (t3)
|
||||
sh2add t3, t0, t3
|
||||
vsll.vx v3, v3, a4
|
||||
vle32.v v5, (t4)
|
||||
sh2add t4, t0, t4
|
||||
vsll.vx v4, v4, a4
|
||||
slli t0, t0, 3
|
||||
vsll.vx v5, v5, a4
|
||||
sh1add t0, t0, t0 // t0 *= 3
|
||||
vsseg6e32.v v0, (a0)
|
||||
add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_decorrelate_indep8_32_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld t1, 16(a1)
|
||||
ld t2, 24(a1)
|
||||
ld t3, 32(a1)
|
||||
ld t4, 40(a1)
|
||||
ld t5, 48(a1)
|
||||
ld t6, 56(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m1, ta, ma
|
||||
vle32.v v0, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v1, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v0, v0, a4
|
||||
vle32.v v2, (t1)
|
||||
sh2add a2, t0, a2
|
||||
vsll.vx v1, v1, a4
|
||||
sh2add t1, t0, t1
|
||||
vle32.v v3, (t2)
|
||||
vsll.vx v2, v2, a4
|
||||
sh2add t2, t0, t2
|
||||
vle32.v v4, (t3)
|
||||
sh2add t3, t0, t3
|
||||
vsll.vx v3, v3, a4
|
||||
vle32.v v5, (t4)
|
||||
sh2add t4, t0, t4
|
||||
vsll.vx v4, v4, a4
|
||||
vle32.v v6, (t5)
|
||||
sh2add t5, t0, t5
|
||||
vsll.vx v5, v5, a4
|
||||
vle32.v v7, (t6)
|
||||
sh2add t6, t0, t6
|
||||
vsll.vx v6, v6, a4
|
||||
slli t0, t0, 5
|
||||
vsll.vx v7, v7, a4
|
||||
vsseg8e32.v v0, (a0)
|
||||
add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_decorrelate_ls_32_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m4, ta, ma
|
||||
vle32.v v0, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v4, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v0, v0, a4
|
||||
sh2add a2, t0, a2
|
||||
vsll.vx v4, v4, a4
|
||||
vsub.vv v4, v0, v4
|
||||
vsseg2e32.v v0, (a0)
|
||||
sh3add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_decorrelate_rs_32_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m4, ta, ma
|
||||
vle32.v v0, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v4, (a2)
|
||||
sh2add a1, t0, a1
|
||||
vsll.vx v0, v0, a4
|
||||
sh2add a2, t0, a2
|
||||
vsll.vx v4, v4, a4
|
||||
vadd.vv v0, v0, v4
|
||||
vsseg2e32.v v0, (a0)
|
||||
sh3add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_flac_decorrelate_ms_32_rvv, zve32x, zba
|
||||
lpad 0
|
||||
ld a0, (a0)
|
||||
ld a2, 8(a1)
|
||||
ld a1, (a1)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m4, ta, ma
|
||||
vle32.v v4, (a2)
|
||||
sub a3, a3, t0
|
||||
vle32.v v0, (a1)
|
||||
sh2add a1, t0, a1
|
||||
vsra.vi v8, v4, 1
|
||||
sh2add a2, t0, a2
|
||||
vsub.vv v12, v0, v8
|
||||
vadd.vv v8, v12, v4
|
||||
vsll.vx v4, v12, a4
|
||||
vsll.vx v0, v8, a4
|
||||
vsseg2e32.v v0, (a0)
|
||||
sh3add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright © 2022 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 <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/fmtconvert.h"
|
||||
|
||||
void ff_int32_to_float_fmul_scalar_rvv(float *dst, const int32_t *src,
|
||||
float mul, int len);
|
||||
void ff_int32_to_float_fmul_array8_rvv(FmtConvertContext *c, float *dst,
|
||||
const int32_t *src, const float *mul,
|
||||
int len);
|
||||
|
||||
av_cold void ff_fmt_convert_init_riscv(FmtConvertContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_F32) && (flags & AV_CPU_FLAG_RVB)) {
|
||||
c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_rvv;
|
||||
c->int32_to_float_fmul_array8 = ff_int32_to_float_fmul_array8_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright © 2022 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_int32_to_float_fmul_scalar_rvv, zve32f, zba
|
||||
lpad 0
|
||||
NOHWF fmv.w.x fa0, a2
|
||||
NOHWF mv a2, a3
|
||||
1:
|
||||
vsetvli t0, a2, e32, m8, ta, ma
|
||||
vle32.v v24, (a1)
|
||||
sub a2, a2, t0
|
||||
vfcvt.f.x.v v24, v24
|
||||
sh2add a1, t0, a1
|
||||
vfmul.vf v24, v24, fa0
|
||||
vse32.v v24, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_int32_to_float_fmul_array8_rvv, zve32f, zba
|
||||
lpad 0
|
||||
srai a4, a4, 3
|
||||
|
||||
1: vsetvli t0, a4, e32, m1, ta, ma
|
||||
vle32.v v24, (a3)
|
||||
slli t2, t0, 2 + 3
|
||||
vlseg8e32.v v16, (a2)
|
||||
vsetvli t3, zero, e32, m8, ta, ma
|
||||
vfcvt.f.x.v v16, v16
|
||||
vsetvli zero, a4, e32, m1, ta, ma
|
||||
vfmul.vv v16, v16, v24
|
||||
sub a4, a4, t0
|
||||
vfmul.vv v17, v17, v24
|
||||
sh2add a3, t0, a3
|
||||
vfmul.vv v18, v18, v24
|
||||
add a2, a2, t2
|
||||
vfmul.vv v19, v19, v24
|
||||
vfmul.vv v20, v20, v24
|
||||
vfmul.vv v21, v21, v24
|
||||
vfmul.vv v22, v22, v24
|
||||
vfmul.vv v23, v23, v24
|
||||
vsseg8e32.v v16, (a1)
|
||||
add a1, a1, t2
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -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_rv_vlen_least(128))
|
||||
dsp->apply_qmf = ff_g722_apply_qmf_rvv;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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
|
||||
lpad 0
|
||||
lla t0, qmf_coeffs
|
||||
vsetivli zero, 12, e16, m2, ta, ma
|
||||
vlseg2e16.v v28, (a0)
|
||||
addi t1, t0, 12 * 2
|
||||
vle16.v v24, (t0)
|
||||
vle16.v v26, (t1)
|
||||
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 12
|
||||
.short 32
|
||||
.short -210
|
||||
.short 951
|
||||
.short 3876
|
||||
.short -805
|
||||
.short 362
|
||||
.short -156
|
||||
.short 53
|
||||
.short -11
|
||||
.short -11
|
||||
.short 53
|
||||
.short -156
|
||||
.short 362
|
||||
.short -805
|
||||
.short 3876
|
||||
.short 951
|
||||
.short -210
|
||||
.short 32
|
||||
.short 12
|
||||
.short -11
|
||||
.short 3
|
||||
endconst
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright © 2022 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/h263dsp.h"
|
||||
|
||||
void ff_h263_h_loop_filter_rvv(uint8_t *src, int stride, int q);
|
||||
void ff_h263_v_loop_filter_rvv(uint8_t *src, int stride, int q);
|
||||
|
||||
av_cold void ff_h263dsp_init_riscv(H263DSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && ff_rv_vlen_least(128)) {
|
||||
c->h263_h_loop_filter = ff_h263_h_loop_filter_rvv;
|
||||
c->h263_v_loop_filter = ff_h263_v_loop_filter_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright © 2024 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"
|
||||
|
||||
.option push
|
||||
.option norelax
|
||||
func ff_h263_h_loop_filter_rvv, zve32x
|
||||
lpad 0
|
||||
addi a0, a0, -2
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
vlsseg4e8.v v8, (a0), a1
|
||||
jal t0, 1f
|
||||
vssseg4e8.v v8, (a0), a1
|
||||
ret
|
||||
1:
|
||||
auipc t1, %pcrel_hi(ff_h263_loop_filter_strength)
|
||||
vwsubu.vv v14, v10, v9 # p2 - p1
|
||||
add t1, t1, a2
|
||||
vwsubu.vv v12, v8, v11 # p0 - p3
|
||||
vsetvli zero, zero, e16, m1, ta, mu
|
||||
vsll.vi v14, v14, 2
|
||||
lbu t1, %pcrel_lo(1b)(t1) # strength
|
||||
vadd.vv v16, v12, v14
|
||||
# Divide by 8 toward 0. v16 is a signed 10-bit value at this point.
|
||||
vsrl.vi v18, v16, 16 - 3 # v18 = (v16 < 0) ? 7 : 0
|
||||
slli t2, t1, 1 # 2 * strength
|
||||
vadd.vv v16, v16, v18
|
||||
# v16 (d) is signed 7-bit, but later arithmetic require 9 bits.
|
||||
vsra.vi v16, v16, 3 # d
|
||||
vmv.v.x v20, t2
|
||||
vmslt.vi v0, v16, 0
|
||||
vneg.v v18, v16
|
||||
vneg.v v20, v20, v0.t # sign(d) * 2 * strength
|
||||
vmax.vv v18, v16, v18 # |d|
|
||||
vsub.vv v20, v20, v16 # d1 if strength <= |d| <= 2 * strength
|
||||
vmsge.vx v0, v18, t2
|
||||
vsrl.vi v14, v12, 16 - 2 # v14 = (v12 < 0) ? 3 : 0
|
||||
vmerge.vxm v20, v20, zero, v0 # d1 if strength <= |d|
|
||||
vadd.vv v12, v12, v14
|
||||
vmsge.vx v0, v18, t1
|
||||
vsra.vi v12, v12, 2 # (p0 - p3) / 4
|
||||
vmerge.vvm v16, v16, v20, v0 # d1
|
||||
vzext.vf2 v24, v8 # p0 as u16 (because vwrsubu.wv does not exist)
|
||||
vneg.v v14, v16
|
||||
vzext.vf2 v26, v9 # p1 as u16
|
||||
vmax.vv v14, v16, v14 # |d1|
|
||||
vzext.vf2 v28, v10 # p2 as u16
|
||||
vsra.vi v14, v14, 1 # ad1
|
||||
vadd.vv v26, v26, v16 # p1 + d1
|
||||
vneg.v v18, v14 # -ad1
|
||||
vmin.vv v12, v12, v14
|
||||
vsub.vv v28, v28, v16 # p2 - d1
|
||||
vmax.vv v12, v12, v18 # d2
|
||||
vmax.vx v26, v26, zero
|
||||
vsub.vv v24, v24, v12 # p0 - d2
|
||||
vmax.vx v28, v28, zero
|
||||
vsetvli zero, zero, e8, mf2, ta, ma
|
||||
vwaddu.wv v30, v12, v11 # p3 + d2
|
||||
vncvt.x.x.w v8, v24
|
||||
vnclipu.wi v9, v26, 0
|
||||
vnclipu.wi v10, v28, 0
|
||||
vncvt.x.x.w v11, v30
|
||||
jr t0
|
||||
endfunc
|
||||
.option pop
|
||||
|
||||
func ff_h263_v_loop_filter_rvv, zve32x
|
||||
lpad 0
|
||||
sub a4, a0, a1
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
vle8.v v10, (a0)
|
||||
sub a3, a4, a1
|
||||
vle8.v v9, (a4)
|
||||
add a5, a0, a1
|
||||
vle8.v v8, (a3)
|
||||
vle8.v v11, (a5)
|
||||
jal t0, 1b
|
||||
vse8.v v8, (a3)
|
||||
vse8.v v9, (a4)
|
||||
vse8.v v10, (a0)
|
||||
vse8.v v11, (a5)
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2023 SiFive, Inc. All rights reserved.
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/h264chroma.h"
|
||||
#include "config.h"
|
||||
|
||||
void h264_put_chroma_mc8_rvv(uint8_t *p_dst, const uint8_t *p_src, ptrdiff_t stride, int h, int x, int y);
|
||||
void h264_avg_chroma_mc8_rvv(uint8_t *p_dst, const uint8_t *p_src, ptrdiff_t stride, int h, int x, int y);
|
||||
void h264_put_chroma_mc4_rvv(uint8_t *p_dst, const uint8_t *p_src, ptrdiff_t stride, int h, int x, int y);
|
||||
void h264_avg_chroma_mc4_rvv(uint8_t *p_dst, const uint8_t *p_src, ptrdiff_t stride, int h, int x, int y);
|
||||
void h264_put_chroma_mc2_rvv(uint8_t *p_dst, const uint8_t *p_src, ptrdiff_t stride, int h, int x, int y);
|
||||
void h264_avg_chroma_mc2_rvv(uint8_t *p_dst, const uint8_t *p_src, ptrdiff_t stride, int h, int x, int y);
|
||||
|
||||
av_cold void ff_h264chroma_init_riscv(H264ChromaContext *c, int bit_depth)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (bit_depth == 8 && (flags & AV_CPU_FLAG_RVV_I32) &&
|
||||
(flags & AV_CPU_FLAG_RVB) && ff_rv_vlen_least(128)) {
|
||||
c->put_h264_chroma_pixels_tab[0] = h264_put_chroma_mc8_rvv;
|
||||
c->avg_h264_chroma_pixels_tab[0] = h264_avg_chroma_mc8_rvv;
|
||||
c->put_h264_chroma_pixels_tab[1] = h264_put_chroma_mc4_rvv;
|
||||
c->avg_h264_chroma_pixels_tab[1] = h264_avg_chroma_mc4_rvv;
|
||||
c->put_h264_chroma_pixels_tab[2] = h264_put_chroma_mc2_rvv;
|
||||
c->avg_h264_chroma_pixels_tab[2] = h264_avg_chroma_mc2_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,382 @@
|
||||
/*
|
||||
* Copyright (c) 2023 SiFive, Inc. All rights reserved.
|
||||
*
|
||||
* 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"
|
||||
|
||||
.macro do_chroma_mc type unroll
|
||||
csrw vxrm, zero
|
||||
slli t2, a5, 3
|
||||
mul t1, a5, a4
|
||||
sh3add a5, a4, t2
|
||||
slli a4, a4, 3
|
||||
sub a5, t1, a5
|
||||
sub a7, a4, t1
|
||||
addi a6, a5, 64
|
||||
sub t0, t2, t1
|
||||
vsetvli t3, t6, e8, m1, ta, mu
|
||||
beqz t1, 2f
|
||||
blez a3, 8f
|
||||
li t4, 0
|
||||
li t2, 0
|
||||
li t5, 1
|
||||
addi a5, t3, 1
|
||||
slli t3, a2, (1 + \unroll)
|
||||
1: # if (xy != 0)
|
||||
add a4, a1, t4
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
.ifc \unroll,1
|
||||
addi t2, t2, 4
|
||||
.else
|
||||
addi t2, t2, 2
|
||||
.endif
|
||||
vle8.v v10, (a4)
|
||||
add a4, a4, a2
|
||||
vslide1down.vx v11, v10, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v8, v10, a6
|
||||
vwmaccu.vx v8, a7, v11
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vle8.v v12, (a4)
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
add a4, a4, a2
|
||||
vwmaccu.vx v8, t0, v12
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vslide1down.vx v13, v12, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v10, v12, a6
|
||||
vwmaccu.vx v8, t1, v13
|
||||
vwmaccu.vx v10, a7, v13
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vle8.v v14, (a4)
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
add a4, a4, a2
|
||||
vwmaccu.vx v10, t0, v14
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vslide1down.vx v15, v14, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v12, v14, a6
|
||||
vwmaccu.vx v10, t1, v15
|
||||
vwmaccu.vx v12, a7, v15
|
||||
vnclipu.wi v15, v8, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v9, (a0)
|
||||
vaaddu.vv v15, v15, v9
|
||||
.endif
|
||||
vse8.v v15, (a0)
|
||||
add a0, a0, a2
|
||||
vnclipu.wi v8, v10, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v9, (a0)
|
||||
vaaddu.vv v8, v8, v9
|
||||
.endif
|
||||
add t4, t4, t3
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
.ifc \unroll,1
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vle8.v v14, (a4)
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
add a4, a4, a2
|
||||
vwmaccu.vx v12, t0, v14
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vslide1down.vx v15, v14, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v16, v14, a6
|
||||
vwmaccu.vx v12, t1, v15
|
||||
vwmaccu.vx v16, a7, v15
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vle8.v v14, (a4)
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmaccu.vx v16, t0, v14
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vslide1down.vx v14, v14, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmaccu.vx v16, t1, v14
|
||||
vnclipu.wi v8, v12, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v9, (a0)
|
||||
vaaddu.vv v8, v8, v9
|
||||
.endif
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
vnclipu.wi v8, v16, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v9, (a0)
|
||||
vaaddu.vv v8, v8, v9
|
||||
.endif
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
.endif
|
||||
blt t2, a3, 1b
|
||||
j 8f
|
||||
2:
|
||||
bnez a4, 4f
|
||||
beqz t2, 4f
|
||||
blez a3, 8f
|
||||
li a4, 0
|
||||
li t1, 0
|
||||
slli a7, a2, (1 + \unroll)
|
||||
3: # if ((x8 - xy) == 0 && (y8 -xy) != 0)
|
||||
add a5, a1, a4
|
||||
vsetvli zero, zero, e8, m1, ta, ma
|
||||
.ifc \unroll,1
|
||||
addi t1, t1, 4
|
||||
.else
|
||||
addi t1, t1, 2
|
||||
.endif
|
||||
vle8.v v8, (a5)
|
||||
add a5, a5, a2
|
||||
add t2, a5, a2
|
||||
vwmulu.vx v10, v8, a6
|
||||
vle8.v v8, (a5)
|
||||
vwmulu.vx v12, v8, a6
|
||||
vle8.v v9, (t2)
|
||||
add t2, t2, a2
|
||||
add a5, t2, a2
|
||||
vwmaccu.vx v10, t0, v8
|
||||
add a4, a4, a7
|
||||
vwmaccu.vx v12, t0, v9
|
||||
vnclipu.wi v15, v10, 6
|
||||
vwmulu.vx v10, v9, a6
|
||||
vnclipu.wi v9, v12, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v16, (a0)
|
||||
vaaddu.vv v15, v15, v16
|
||||
.endif
|
||||
vse8.v v15, (a0)
|
||||
add a0, a0, a2
|
||||
.ifc \type,avg
|
||||
vle8.v v16, (a0)
|
||||
vaaddu.vv v9, v9, v16
|
||||
.endif
|
||||
vse8.v v9, (a0)
|
||||
add a0, a0, a2
|
||||
.ifc \unroll,1
|
||||
vle8.v v8, (t2)
|
||||
vle8.v v14, (a5)
|
||||
vwmaccu.vx v10, t0, v8
|
||||
vwmulu.vx v12, v8, a6
|
||||
vnclipu.wi v8, v10, 6
|
||||
vwmaccu.vx v12, t0, v14
|
||||
.ifc \type,avg
|
||||
vle8.v v16, (a0)
|
||||
vaaddu.vv v8, v8, v16
|
||||
.endif
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
vnclipu.wi v8, v12, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v16, (a0)
|
||||
vaaddu.vv v8, v8, v16
|
||||
.endif
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
.endif
|
||||
blt t1, a3, 3b
|
||||
j 8f
|
||||
4:
|
||||
beqz a4, 6f
|
||||
bnez t2, 6f
|
||||
blez a3, 8f
|
||||
li a4, 0
|
||||
li t2, 0
|
||||
addi t0, t3, 1
|
||||
slli t1, a2, (1 + \unroll)
|
||||
5: # if ((x8 - xy) != 0 && (y8 -xy) == 0)
|
||||
add a5, a1, a4
|
||||
vsetvli zero, t0, e8, m1, ta, ma
|
||||
.ifc \unroll,1
|
||||
addi t2, t2, 4
|
||||
.else
|
||||
addi t2, t2, 2
|
||||
.endif
|
||||
vle8.v v8, (a5)
|
||||
add a5, a5, a2
|
||||
vslide1down.vx v9, v8, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v10, v8, a6
|
||||
vwmaccu.vx v10, a7, v9
|
||||
vsetvli zero, t0, e8, m1, ta, ma
|
||||
vle8.v v8, (a5)
|
||||
add a5, a5, a2
|
||||
vslide1down.vx v9, v8, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v12, v8, a6
|
||||
vwmaccu.vx v12, a7, v9
|
||||
vnclipu.wi v16, v10, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a0)
|
||||
vaaddu.vv v16, v16, v18
|
||||
.endif
|
||||
vse8.v v16, (a0)
|
||||
add a0, a0, a2
|
||||
vnclipu.wi v10, v12, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a0)
|
||||
vaaddu.vv v10, v10, v18
|
||||
.endif
|
||||
add a4, a4, t1
|
||||
vse8.v v10, (a0)
|
||||
add a0, a0, a2
|
||||
.ifc \unroll,1
|
||||
vsetvli zero, t0, e8, m1, ta, ma
|
||||
vle8.v v8, (a5)
|
||||
add a5, a5, a2
|
||||
vslide1down.vx v9, v8, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v14, v8, a6
|
||||
vwmaccu.vx v14, a7, v9
|
||||
vsetvli zero, t0, e8, m1, ta, ma
|
||||
vle8.v v8, (a5)
|
||||
vslide1down.vx v9, v8, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v12, v8, a6
|
||||
vnclipu.wi v8, v14, 6
|
||||
vwmaccu.vx v12, a7, v9
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a0)
|
||||
vaaddu.vv v8, v8, v18
|
||||
.endif
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
vnclipu.wi v8, v12, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a0)
|
||||
vaaddu.vv v8, v8, v18
|
||||
.endif
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
.endif
|
||||
blt t2, a3, 5b
|
||||
j 8f
|
||||
6:
|
||||
blez a3, 8f
|
||||
li a4, 0
|
||||
li t2, 0
|
||||
slli a7, a2, (1 + \unroll)
|
||||
7: # the final else, none of the above conditions are met
|
||||
add t0, a1, a4
|
||||
vsetvli zero, zero, e8, m1, ta, ma
|
||||
add a5, a0, a4
|
||||
add a4, a4, a7
|
||||
.ifc \unroll,1
|
||||
addi t2, t2, 4
|
||||
.else
|
||||
addi t2, t2, 2
|
||||
.endif
|
||||
vle8.v v8, (t0)
|
||||
add t0, t0, a2
|
||||
add t1, t0, a2
|
||||
vwmulu.vx v10, v8, a6
|
||||
vle8.v v8, (t0)
|
||||
add t0, t1, a2
|
||||
vnclipu.wi v13, v10, 6
|
||||
vwmulu.vx v10, v8, a6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a5)
|
||||
vaaddu.vv v13, v13, v18
|
||||
.endif
|
||||
vse8.v v13, (a5)
|
||||
add a5, a5, a2
|
||||
vnclipu.wi v8, v10, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a5)
|
||||
vaaddu.vv v8, v8, v18
|
||||
.endif
|
||||
vse8.v v8, (a5)
|
||||
add a5, a5, a2
|
||||
.ifc \unroll,1
|
||||
vle8.v v9, (t1)
|
||||
vle8.v v12, (t0)
|
||||
vwmulu.vx v10, v9, a6
|
||||
vnclipu.wi v8, v10, 6
|
||||
vwmulu.vx v10, v12, a6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a5)
|
||||
vaaddu.vv v8, v8, v18
|
||||
.endif
|
||||
vse8.v v8, (a5)
|
||||
add a5, a5, a2
|
||||
vnclipu.wi v8, v10, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a5)
|
||||
vaaddu.vv v8, v8, v18
|
||||
.endif
|
||||
vse8.v v8, (a5)
|
||||
.endif
|
||||
blt t2, a3, 7b
|
||||
8:
|
||||
ret
|
||||
.endm
|
||||
|
||||
.variant_cc h264_put_chroma_mc_rvv
|
||||
func h264_put_chroma_mc_rvv, zve32x, zba
|
||||
11:
|
||||
li a7, 3
|
||||
blt a3, a7, 12f
|
||||
do_chroma_mc put 1
|
||||
12:
|
||||
do_chroma_mc put 0
|
||||
endfunc
|
||||
|
||||
.variant_cc h264_avg_chroma_mc_rvv
|
||||
func h264_avg_chroma_mc_rvv, zve32x, zba
|
||||
21:
|
||||
li a7, 3
|
||||
blt a3, a7, 22f
|
||||
do_chroma_mc avg 1
|
||||
22:
|
||||
do_chroma_mc avg 0
|
||||
endfunc
|
||||
|
||||
func h264_put_chroma_mc8_rvv, zve32x
|
||||
lpad 0
|
||||
li t6, 8
|
||||
j 11b
|
||||
endfunc
|
||||
|
||||
func h264_put_chroma_mc4_rvv, zve32x
|
||||
lpad 0
|
||||
li t6, 4
|
||||
j 11b
|
||||
endfunc
|
||||
|
||||
func h264_put_chroma_mc2_rvv, zve32x
|
||||
lpad 0
|
||||
li t6, 2
|
||||
j 11b
|
||||
endfunc
|
||||
|
||||
func h264_avg_chroma_mc8_rvv, zve32x
|
||||
lpad 0
|
||||
li t6, 8
|
||||
j 21b
|
||||
endfunc
|
||||
|
||||
func h264_avg_chroma_mc4_rvv, zve32x
|
||||
lpad 0
|
||||
li t6, 4
|
||||
j 21b
|
||||
endfunc
|
||||
|
||||
func h264_avg_chroma_mc2_rvv, zve32x
|
||||
lpad 0
|
||||
li t6, 2
|
||||
j 21b
|
||||
endfunc
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright © 2024 Rémi Denis-Courmont.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "libavutil/riscv/asm.S"
|
||||
|
||||
.macro sx rd, addr
|
||||
#if (__riscv_xlen == 32)
|
||||
sw \rd, \addr
|
||||
#elif (__riscv_xlen == 64)
|
||||
sd \rd, \addr
|
||||
#else
|
||||
sq \rd, \addr
|
||||
#endif
|
||||
.endm
|
||||
|
||||
func ff_h264_add_pixels4_8_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, 4, e8, mf4, ta, ma
|
||||
vlse32.v v8, (a0), a2
|
||||
vsetivli zero, 4 * 4, e8, m1, ta, ma
|
||||
vle16.v v16, (a1)
|
||||
.equ offset, 0
|
||||
.rept 256 / __riscv_xlen
|
||||
sx zero, offset(a1)
|
||||
.equ offset, offset + (__riscv_xlen / 8)
|
||||
.endr
|
||||
vncvt.x.x.w v24, v16
|
||||
vadd.vv v8, v8, v24
|
||||
vsetivli zero, 4, e8, mf4, ta, ma
|
||||
vsse32.v v8, (a0), a2
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h264_add_pixels4_16_rvv, zve64x
|
||||
lpad 0
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
vlse64.v v8, (a0), a2
|
||||
vsetivli zero, 4 * 4, e16, m2, ta, ma
|
||||
vle32.v v16, (a1)
|
||||
.equ offset, 0
|
||||
.rept 512 / __riscv_xlen
|
||||
sx zero, offset(a1)
|
||||
.equ offset, offset + (__riscv_xlen / 8)
|
||||
.endr
|
||||
vncvt.x.x.w v24, v16
|
||||
vadd.vv v8, v8, v24
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
vsse64.v v8, (a0), a2
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h264_add_pixels8_8_rvv, zve64x
|
||||
lpad 0
|
||||
li t0, 8 * 8
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
vlse64.v v8, (a0), a2
|
||||
vsetvli zero, t0, e8, m4, ta, ma
|
||||
vle16.v v16, (a1)
|
||||
.equ offset, 0
|
||||
.rept 1024 / __riscv_xlen
|
||||
sx zero, offset(a1)
|
||||
.equ offset, offset + (__riscv_xlen / 8)
|
||||
.endr
|
||||
vncvt.x.x.w v24, v16
|
||||
vadd.vv v8, v8, v24
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
vsse64.v v8, (a0), a2
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h264_add_pixels8_16_rvv, zve32x
|
||||
lpad 0
|
||||
li t0, 8
|
||||
vsetivli zero, 8, e16, m1, ta, ma
|
||||
1:
|
||||
vle32.v v16, (a1)
|
||||
addi t0, t0, -1
|
||||
vle16.v v8, (a0)
|
||||
.equ offset, 0
|
||||
.rept 256 / __riscv_xlen
|
||||
sx zero, offset(a1)
|
||||
.equ offset, offset + (__riscv_xlen / 8)
|
||||
.endr
|
||||
vncvt.x.x.w v24, v16
|
||||
addi a1, a1, 8 * 4
|
||||
vadd.vv v8, v8, v24
|
||||
vse16.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
bnez t0, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Copyright (c) 2024 J. Dekker <jdek@itanimul.li>
|
||||
* Copyright © 2024 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 <string.h>
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/h264dsp.h"
|
||||
|
||||
extern const struct {
|
||||
const h264_weight_func weight;
|
||||
const h264_biweight_func biweight;
|
||||
} ff_h264_weight_funcs_8_rvv[];
|
||||
|
||||
void ff_h264_v_loop_filter_luma_8_rvv(uint8_t *pix, ptrdiff_t stride,
|
||||
int alpha, int beta, int8_t *tc0);
|
||||
void ff_h264_h_loop_filter_luma_8_rvv(uint8_t *pix, ptrdiff_t stride,
|
||||
int alpha, int beta, int8_t *tc0);
|
||||
void ff_h264_h_loop_filter_luma_mbaff_8_rvv(uint8_t *pix, ptrdiff_t stride,
|
||||
int alpha, int beta, int8_t *tc0);
|
||||
void ff_h264_v_loop_filter_luma_intra_8_rvv(uint8_t *pix, ptrdiff_t stride,
|
||||
int alpha, int beta);
|
||||
void ff_h264_h_loop_filter_luma_intra_8_rvv(uint8_t *pix, ptrdiff_t stride,
|
||||
int alpha, int beta);
|
||||
void ff_h264_h_loop_filter_luma_mbaff_intra_8_rvv(uint8_t *pix, ptrdiff_t s,
|
||||
int a, int b);
|
||||
void ff_h264_v_loop_filter_chroma_8_rvv(uint8_t *pix, ptrdiff_t stride,
|
||||
int alpha, int beta, int8_t *tc0);
|
||||
void ff_h264_h_loop_filter_chroma_8_rvv(uint8_t *pix, ptrdiff_t stride,
|
||||
int alpha, int beta, int8_t *tc0);
|
||||
void ff_h264_h_loop_filter_chroma_mbaff_8_rvv(uint8_t *pix, ptrdiff_t stride,
|
||||
int alpha, int beta,
|
||||
int8_t *tc0);
|
||||
void ff_h264_v_loop_filter_chroma_intra_8_rvv(uint8_t *pix, ptrdiff_t stride,
|
||||
int alpha, int beta);
|
||||
void ff_h264_h_loop_filter_chroma_intra_8_rvv(uint8_t *pix, ptrdiff_t stride,
|
||||
int alpha, int beta);
|
||||
void ff_h264_h_loop_filter_chroma_mbaff_intra_8_rvv(uint8_t *pix,
|
||||
ptrdiff_t stride,
|
||||
int alpha, int beta);
|
||||
|
||||
#define IDCT_DEPTH(depth) \
|
||||
void ff_h264_idct_add_##depth##_rvv(uint8_t *d, int16_t *s, int stride); \
|
||||
void ff_h264_idct8_add_##depth##_rvv(uint8_t *d, int16_t *s, int stride); \
|
||||
void ff_h264_idct4_dc_add_##depth##_rvv(uint8_t *, int16_t *, int); \
|
||||
void ff_h264_idct8_dc_add_##depth##_rvv(uint8_t *, int16_t *, int); \
|
||||
void ff_h264_idct_add16_##depth##_rvv(uint8_t *d, const int *soffset, \
|
||||
int16_t *s, int stride, \
|
||||
const uint8_t nnzc[5 * 8]); \
|
||||
void ff_h264_idct_add16intra_##depth##_rvv(uint8_t *d, const int *soffset, \
|
||||
int16_t *s, int stride, \
|
||||
const uint8_t nnzc[5 * 8]); \
|
||||
void ff_h264_idct8_add4_##depth##_rvv(uint8_t *d, const int *soffset, \
|
||||
int16_t *s, int stride, \
|
||||
const uint8_t nnzc[5 * 8]); \
|
||||
void ff_h264_idct4_add8_##depth##_rvv(uint8_t **d, const int *soffset, \
|
||||
int16_t *s, int stride, \
|
||||
const uint8_t nnzc[5 * 8]); \
|
||||
void ff_h264_idct4_add8_422_##depth##_rvv(uint8_t **d, const int *soffset, \
|
||||
int16_t *s, int stride, \
|
||||
const uint8_t nnzc[5 * 8]);
|
||||
|
||||
IDCT_DEPTH(8)
|
||||
IDCT_DEPTH(9)
|
||||
IDCT_DEPTH(10)
|
||||
IDCT_DEPTH(12)
|
||||
IDCT_DEPTH(14)
|
||||
#undef IDCT_DEPTH
|
||||
|
||||
void ff_h264_add_pixels8_8_rvv(uint8_t *dst, int16_t *block, int stride);
|
||||
void ff_h264_add_pixels4_8_rvv(uint8_t *dst, int16_t *block, int stride);
|
||||
void ff_h264_add_pixels8_16_rvv(uint8_t *dst, int16_t *block, int stride);
|
||||
void ff_h264_add_pixels4_16_rvv(uint8_t *dst, int16_t *block, int stride);
|
||||
|
||||
extern int ff_startcode_find_candidate_rvb(const uint8_t *, int);
|
||||
extern int ff_startcode_find_candidate_rvv(const uint8_t *, int);
|
||||
|
||||
av_cold void ff_h264dsp_init_riscv(H264DSPContext *dsp, const int bit_depth,
|
||||
const int chroma_format_idc)
|
||||
{
|
||||
#if HAVE_RV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVB_BASIC)
|
||||
dsp->startcode_find_candidate = ff_startcode_find_candidate_rvb;
|
||||
# if HAVE_RVV
|
||||
if (flags & AV_CPU_FLAG_RVV_I32) {
|
||||
const bool zvl128b = ff_rv_vlen_least(128);
|
||||
|
||||
if (bit_depth == 8) {
|
||||
if (zvl128b) {
|
||||
if (flags & AV_CPU_FLAG_RVB)
|
||||
dsp->weight_h264_pixels_tab[0] =
|
||||
ff_h264_weight_funcs_8_rvv[0].weight;
|
||||
dsp->biweight_h264_pixels_tab[0] =
|
||||
ff_h264_weight_funcs_8_rvv[0].biweight;
|
||||
}
|
||||
if (flags & AV_CPU_FLAG_RVV_I64) {
|
||||
dsp->weight_h264_pixels_tab[1] =
|
||||
ff_h264_weight_funcs_8_rvv[1].weight;
|
||||
dsp->biweight_h264_pixels_tab[1] =
|
||||
ff_h264_weight_funcs_8_rvv[1].biweight;
|
||||
}
|
||||
dsp->weight_h264_pixels_tab[2] =
|
||||
ff_h264_weight_funcs_8_rvv[2].weight;
|
||||
dsp->biweight_h264_pixels_tab[2] =
|
||||
ff_h264_weight_funcs_8_rvv[2].biweight;
|
||||
dsp->weight_h264_pixels_tab[3] =
|
||||
ff_h264_weight_funcs_8_rvv[3].weight;
|
||||
dsp->biweight_h264_pixels_tab[3] =
|
||||
ff_h264_weight_funcs_8_rvv[3].biweight;
|
||||
}
|
||||
|
||||
if (bit_depth == 8 && zvl128b) {
|
||||
dsp->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_8_rvv;
|
||||
dsp->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_8_rvv;
|
||||
dsp->h264_h_loop_filter_luma_mbaff =
|
||||
ff_h264_h_loop_filter_luma_mbaff_8_rvv;
|
||||
dsp->h264_v_loop_filter_luma_intra =
|
||||
ff_h264_v_loop_filter_luma_intra_8_rvv;
|
||||
dsp->h264_h_loop_filter_luma_intra =
|
||||
ff_h264_h_loop_filter_luma_intra_8_rvv;
|
||||
dsp->h264_h_loop_filter_luma_mbaff_intra =
|
||||
ff_h264_h_loop_filter_luma_mbaff_intra_8_rvv;
|
||||
dsp->h264_v_loop_filter_chroma =
|
||||
ff_h264_v_loop_filter_chroma_8_rvv;
|
||||
dsp->h264_v_loop_filter_chroma_intra =
|
||||
ff_h264_v_loop_filter_chroma_intra_8_rvv;
|
||||
|
||||
if (chroma_format_idc <= 1) {
|
||||
dsp->h264_h_loop_filter_chroma =
|
||||
ff_h264_h_loop_filter_chroma_8_rvv;
|
||||
dsp->h264_h_loop_filter_chroma_mbaff =
|
||||
ff_h264_h_loop_filter_chroma_mbaff_8_rvv;
|
||||
dsp->h264_h_loop_filter_chroma_intra =
|
||||
ff_h264_h_loop_filter_chroma_intra_8_rvv;
|
||||
dsp->h264_h_loop_filter_chroma_mbaff_intra =
|
||||
ff_h264_h_loop_filter_chroma_mbaff_intra_8_rvv;
|
||||
}
|
||||
|
||||
dsp->h264_idct_add = ff_h264_idct_add_8_rvv;
|
||||
dsp->h264_idct8_add = ff_h264_idct8_add_8_rvv;
|
||||
if (flags & AV_CPU_FLAG_RVB) {
|
||||
dsp->h264_idct_dc_add = ff_h264_idct4_dc_add_8_rvv;
|
||||
dsp->h264_idct_add16 = ff_h264_idct_add16_8_rvv;
|
||||
dsp->h264_idct_add16intra = ff_h264_idct_add16intra_8_rvv;
|
||||
# if __riscv_xlen == 64
|
||||
dsp->h264_idct8_add4 = ff_h264_idct8_add4_8_rvv;
|
||||
if (chroma_format_idc <= 1)
|
||||
dsp->h264_idct_add8 = ff_h264_idct4_add8_8_rvv;
|
||||
else
|
||||
dsp->h264_idct_add8 = ff_h264_idct4_add8_422_8_rvv;
|
||||
# endif
|
||||
}
|
||||
if (flags & AV_CPU_FLAG_RVV_I64) {
|
||||
dsp->h264_add_pixels8_clear = ff_h264_add_pixels8_8_rvv;
|
||||
if (flags & AV_CPU_FLAG_RVB)
|
||||
dsp->h264_idct8_dc_add = ff_h264_idct8_dc_add_8_rvv;
|
||||
}
|
||||
dsp->h264_add_pixels4_clear = ff_h264_add_pixels4_8_rvv;
|
||||
}
|
||||
|
||||
#define IDCT_DEPTH(depth) \
|
||||
if (bit_depth == depth) { \
|
||||
if (zvl128b) \
|
||||
dsp->h264_idct_add = ff_h264_idct_add_##depth##_rvv; \
|
||||
if (flags & AV_CPU_FLAG_RVB) \
|
||||
dsp->h264_idct8_add = ff_h264_idct8_add_##depth##_rvv; \
|
||||
if (zvl128b && (flags & AV_CPU_FLAG_RVB)) { \
|
||||
dsp->h264_idct_dc_add = ff_h264_idct4_dc_add_##depth##_rvv; \
|
||||
dsp->h264_idct8_dc_add = ff_h264_idct8_dc_add_##depth##_rvv; \
|
||||
dsp->h264_idct_add16 = ff_h264_idct_add16_##depth##_rvv; \
|
||||
dsp->h264_idct_add16intra = \
|
||||
ff_h264_idct_add16intra_##depth##_rvv; \
|
||||
if (__riscv_xlen == 64) { \
|
||||
if (chroma_format_idc <= 1) \
|
||||
dsp->h264_idct_add8 = \
|
||||
ff_h264_idct4_add8_##depth##_rvv; \
|
||||
else \
|
||||
dsp->h264_idct_add8 = \
|
||||
ff_h264_idct4_add8_422_##depth##_rvv; \
|
||||
} \
|
||||
} \
|
||||
if (__riscv_xlen == 64 && (flags & AV_CPU_FLAG_RVB)) \
|
||||
dsp->h264_idct8_add4 = ff_h264_idct8_add4_##depth##_rvv; \
|
||||
}
|
||||
|
||||
IDCT_DEPTH(9)
|
||||
IDCT_DEPTH(10)
|
||||
IDCT_DEPTH(12)
|
||||
IDCT_DEPTH(14)
|
||||
|
||||
if (bit_depth > 8 && zvl128b) {
|
||||
dsp->h264_add_pixels8_clear = ff_h264_add_pixels8_16_rvv;
|
||||
if (flags & AV_CPU_FLAG_RVV_I64)
|
||||
dsp->h264_add_pixels4_clear = ff_h264_add_pixels4_16_rvv;
|
||||
}
|
||||
|
||||
dsp->startcode_find_candidate = ff_startcode_find_candidate_rvv;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,538 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright © 2024 Rémi Denis-Courmont.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "libavutil/riscv/asm.S"
|
||||
|
||||
.variant_cc ff_h264_weight_pixels_simple_8_rvv
|
||||
func ff_h264_weight_pixels_simple_8_rvv, zve32x, b
|
||||
csrwi vxrm, 0
|
||||
sll a5, a5, a3
|
||||
1:
|
||||
vsetvli zero, t6, e16, m2, ta, ma
|
||||
add t0, a0, a1
|
||||
vle8.v v8, (a0)
|
||||
addi a2, a2, -2
|
||||
vle8.v v9, (t0)
|
||||
vzext.vf2 v24, v8
|
||||
vzext.vf2 v26, v9
|
||||
vmul.vx v16, v24, a4
|
||||
vmul.vx v18, v26, a4
|
||||
vsadd.vx v16, v16, a5
|
||||
vsadd.vx v18, v18, a5
|
||||
vmax.vx v16, v16, zero
|
||||
vmax.vx v18, v18, zero
|
||||
vsetvli zero, zero, e8, m1, ta, ma
|
||||
vnclipu.wx v8, v16, a3
|
||||
vnclipu.wx v9, v18, a3
|
||||
vse8.v v8, (a0)
|
||||
vse8.v v9, (t0)
|
||||
sh1add a0, a1, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
.variant_cc ff_h264_biweight_pixels_simple_8_rvv
|
||||
func ff_h264_biweight_pixels_simple_8_rvv, zve32x
|
||||
csrwi vxrm, 2
|
||||
addi a7, a7, 1
|
||||
ori a7, a7, 1
|
||||
sll a7, a7, a4
|
||||
addi a4, a4, 1
|
||||
1:
|
||||
vsetvli zero, t6, e16, m2, ta, ma
|
||||
vle8.v v8, (a0)
|
||||
addi a3, a3, -1
|
||||
vle8.v v12, (a1)
|
||||
add a1, a1, a2
|
||||
vmv.v.x v16, a7
|
||||
vsetvli zero, zero, e8, m1, ta, ma
|
||||
vwmaccsu.vx v16, a5, v8
|
||||
vwmaccsu.vx v16, a6, v12
|
||||
vsetvli zero, zero, e16, m2, ta, ma
|
||||
vmax.vx v16, v16, zero
|
||||
vsetvli zero, zero, e8, m1, ta, ma
|
||||
vnclipu.wx v8, v16, a4
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
.macro h264_weight depth, w, b=
|
||||
func ff_h264_weight_pixels\w\()_\depth\()_rvv, zve64x
|
||||
lpad 0
|
||||
.ifb \b
|
||||
li t6, \w
|
||||
j ff_h264_weight_pixels_simple_\depth\()_rvv
|
||||
.else
|
||||
csrwi vxrm, 0
|
||||
sll a5, a5, a3
|
||||
1:
|
||||
vsetvli t1, a2, e\b, m2, ta, ma
|
||||
vlse\b\().v v8, (a0), a1
|
||||
vsetvli t0, zero, e16, m4, ta, ma
|
||||
vzext.vf2 v24, v8
|
||||
sub a2, a2, t1
|
||||
vmul.vx v16, v24, a4
|
||||
mul t2, t1, a1
|
||||
vsadd.vx v16, v16, a5
|
||||
vmax.vx v16, v16, zero
|
||||
vsetvli zero, zero, e8, m2, ta, ma
|
||||
vnclipu.wx v8, v16, a3
|
||||
vsetvli zero, t1, e\b, m2, ta, ma
|
||||
vsse\b\().v v8, (a0), a1
|
||||
add a0, a0, t2
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
.endif
|
||||
endfunc
|
||||
|
||||
func ff_h264_biweight_pixels\w\()_\depth\()_rvv, zve64x
|
||||
lpad 0
|
||||
li t6, \w
|
||||
.ifb \b
|
||||
j ff_h264_biweight_pixels_simple_8_rvv
|
||||
.else
|
||||
csrwi vxrm, 2
|
||||
addi a7, a7, 1
|
||||
ori a7, a7, 1
|
||||
sll a7, a7, a4
|
||||
addi a4, a4, 1
|
||||
1:
|
||||
vsetvli t1, a3, e\b, m2, ta, ma
|
||||
vlse\b\().v v8, (a0), a2
|
||||
sub a3, a3, t1
|
||||
vlse\b\().v v12, (a1), a2
|
||||
mul t2, t1, a2
|
||||
vsetvli t0, zero, e16, m4, ta, ma
|
||||
vmv.v.x v16, a7
|
||||
vsetvli zero, zero, e8, m2, ta, ma
|
||||
vwmaccsu.vx v16, a5, v8
|
||||
add a1, a1, t2
|
||||
vwmaccsu.vx v16, a6, v12
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vmax.vx v16, v16, zero
|
||||
vsetvli zero, zero, e8, m2, ta, ma
|
||||
vnclipu.wx v8, v16, a4
|
||||
vsetvli zero, t1, e\b, m2, ta, ma
|
||||
vsse\b\().v v8, (a0), a2
|
||||
add a0, a0, t2
|
||||
.endif
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
h264_weight 8, 2, 16
|
||||
h264_weight 8, 4, 32
|
||||
h264_weight 8, 8, 64
|
||||
h264_weight 8, 16
|
||||
|
||||
.global ff_h264_weight_funcs_8_rvv
|
||||
.hidden ff_h264_weight_funcs_8_rvv
|
||||
const ff_h264_weight_funcs_8_rvv, relocate=1
|
||||
.irp w, 16, 8, 4, 2
|
||||
#if __riscv_xlen == 32
|
||||
.word ff_h264_weight_pixels\w\()_8_rvv
|
||||
.word ff_h264_biweight_pixels\w\()_8_rvv
|
||||
#elif __riscv_xlen == 64
|
||||
.dword ff_h264_weight_pixels\w\()_8_rvv
|
||||
.dword ff_h264_biweight_pixels\w\()_8_rvv
|
||||
#else
|
||||
.qword ff_h264_weight_pixels\w\()_8_rvv
|
||||
.qword ff_h264_biweight_pixels\w\()_8_rvv
|
||||
#endif
|
||||
.endr
|
||||
endconst
|
||||
|
||||
.macro loop_filter type, inners, e8mul, e16mul
|
||||
.variant_cc ff_h264_loop_filter_\type\()_8_rvv
|
||||
func ff_h264_loop_filter_\type\()_8_rvv, zve32x
|
||||
# p2: v8, p1: v9, p0: v10, q0: v11, q1: v12, q2: v13
|
||||
# alpha: a2, beta: a3, tc_orig: v6
|
||||
csrwi vxrm, 0
|
||||
.ifc \type, luma
|
||||
vaaddu.vv v14, v10, v11 # (p0 + q0 + 1) / 2
|
||||
.endif
|
||||
vwsubu.vv v16, v9, v12
|
||||
.ifc \type, luma
|
||||
vwaddu.vv v18, v8, v14
|
||||
vwaddu.vv v20, v13, v14
|
||||
.endif
|
||||
vnsra.wi v24, v16, 2 # (p1 - q1) / 4
|
||||
.ifc \type, luma
|
||||
vnsrl.wi v14, v18, 1
|
||||
vnsrl.wi v15, v20, 1
|
||||
vneg.v v5, v6 # -tc_orig
|
||||
.endif
|
||||
vwsubu.vv v22, v11, v10 # q0 - p0
|
||||
.ifc \type, luma
|
||||
vwsubu.vv v18, v14, v9
|
||||
vwsubu.vv v20, v15, v12
|
||||
.endif
|
||||
vwadd.wv v16, v22, v24
|
||||
vmsge.vi v7, v6, 0 # tc_orig >= 0
|
||||
.ifc \type, luma
|
||||
vnclip.wi v14, v18, 0
|
||||
vnclip.wi v15, v20, 0
|
||||
.endif
|
||||
vnclip.wi v16, v16, 1 # clip8((q0 - p0 + (p1 - q1) / 4 + 1) >> 1)
|
||||
.ifc \type, luma
|
||||
vmin.vv v14, v14, v6
|
||||
vmin.vv v15, v15, v6
|
||||
vmax.vv v14, v14, v5 # clip(p2 + ... - p1, +/-tc_orig)
|
||||
vmax.vv v15, v15, v5 # clip(q2 + ... - q1, +/-tc_orig)
|
||||
.endif
|
||||
vwsubu.vv v20, v10, v11
|
||||
vwsubu.vv v24, v9, v10
|
||||
vwsubu.vv v26, v10, v9
|
||||
vwsubu.vv v28, v12, v11
|
||||
vwsubu.vv v30, v11, v12
|
||||
.ifc \type, luma
|
||||
vwsubu.vv v0, v8, v10
|
||||
vwsubu.vv v2, v10, v8
|
||||
vwsubu.vv v4, v13, v11
|
||||
vwsubu.vv v18, v11, v13
|
||||
.endif
|
||||
vsetvli zero, zero, e16, \e16mul, ta, ma
|
||||
vmax.vv v20, v20, v22 # abs(p0 - q0)
|
||||
vmax.vv v24, v24, v26 # abs(p1 - p0)
|
||||
vmax.vv v28, v28, v30 # abs(q1 - q0)
|
||||
.ifc \type, luma
|
||||
vmax.vv v22, v0, v2 # abs(p2 - p0)
|
||||
vmax.vv v26, v4, v18 # abs(q2 - q0)
|
||||
.endif
|
||||
vmslt.vx v1, v20, a2
|
||||
vmslt.vx v2, v24, a3
|
||||
vmand.mm v7, v7, v1
|
||||
vmslt.vx v3, v28, a3
|
||||
vmand.mm v7, v7, v2
|
||||
.ifc \type, luma
|
||||
vmslt.vx v0, v22, a3
|
||||
vmand.mm v7, v7, v3 # whether to update p0 and q0
|
||||
vmslt.vx v1, v26, a3
|
||||
vmand.mm v0, v0, v7
|
||||
.else
|
||||
vmand.mm v0, v7, v3 # whether to update p0 and q0
|
||||
.endif
|
||||
vsetvli zero, zero, e8, \e8mul, ta, mu
|
||||
.ifc \type, luma
|
||||
vadd.vi v6, v6, 1, v0.t # tc++
|
||||
vadd.vv v9, v9, v14, v0.t # p1'
|
||||
vmand.mm v0, v1, v7
|
||||
vadd.vi v6, v6, 1, v0.t # tc++
|
||||
vadd.vv v12, v12, v15, v0.t # q1'
|
||||
vmmv.m v0, v7
|
||||
.endif
|
||||
vneg.v v5, v6 # -tc
|
||||
vmin.vv v16, v16, v6
|
||||
vwcvtu.x.x.v v18, v10
|
||||
vmax.vv v16, v16, v5
|
||||
vwcvtu.x.x.v v20, v11
|
||||
vwadd.wv v18, v18, v16
|
||||
vwsub.wv v20, v20, v16
|
||||
vsetvli zero, zero, e16, \e16mul, ta, ma
|
||||
vmax.vx v18, v18, zero
|
||||
vmax.vx v20, v20, zero
|
||||
vsetvli zero, zero, e8, \e8mul, ta, mu
|
||||
vnclipu.wi v10, v18, 0, v0.t # p0'
|
||||
vnclipu.wi v11, v20, 0, v0.t # q0'
|
||||
jr t0
|
||||
endfunc
|
||||
|
||||
func ff_h264_v_loop_filter_\type\()_8_rvv, zve32x
|
||||
lpad 0
|
||||
.ifc \type, luma
|
||||
vsetivli zero, 4, e32, m1, ta, ma
|
||||
vle8.v v4, (a4)
|
||||
li t0, 0x01010101
|
||||
vzext.vf4 v6, v4
|
||||
.else
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
vle8.v v4, (a4)
|
||||
li t0, 0x0101
|
||||
vzext.vf2 v6, v4
|
||||
.endif
|
||||
sub t3, a0, a1
|
||||
vmul.vx v6, v6, t0
|
||||
vsetivli zero, 4 * \inners, e8, \e8mul, ta, ma
|
||||
vle8.v v11, (a0)
|
||||
sub t2, t3, a1
|
||||
vle8.v v10, (t3)
|
||||
add t5, a0, a1
|
||||
vle8.v v9, (t2)
|
||||
.ifc \type, luma
|
||||
sub t1, t2, a1
|
||||
.endif
|
||||
vle8.v v12, (t5)
|
||||
.ifc \type, luma
|
||||
add t6, t5, a1
|
||||
vle8.v v8, (t1)
|
||||
vle8.v v13, (t6)
|
||||
.endif
|
||||
jal t0, ff_h264_loop_filter_\type\()_8_rvv
|
||||
.ifc \type, luma
|
||||
vse8.v v9, (t2)
|
||||
vse8.v v12, (t5)
|
||||
.endif
|
||||
vse8.v v10, (t3)
|
||||
vse8.v v11, (a0)
|
||||
ret
|
||||
endfunc
|
||||
|
||||
.variant_cc ff_h264_loop_filter_\type\()_intra_8_rvv
|
||||
func ff_h264_loop_filter_\type\()_intra_8_rvv, zve32x
|
||||
# p3: v8, p2: v9, p1: v10, p0: v11, q0: v12, q1: v13, q2: v14, q3: v15
|
||||
# alpha: a2, beta: a3
|
||||
csrwi vxrm, 0
|
||||
srai a4, a2, 2
|
||||
vwsubu.vv v16, v11, v12
|
||||
addi a4, a4, 2
|
||||
vwsubu.vv v18, v12, v11
|
||||
vwsubu.vv v20, v10, v11
|
||||
vwsubu.vv v22, v11, v10
|
||||
vwsubu.vv v24, v13, v12
|
||||
vwsubu.vv v26, v12, v13
|
||||
vwsubu.vv v28, v11, v9
|
||||
vwsubu.vv v30, v9, v11
|
||||
vwsubu.vv v4, v14, v12
|
||||
vwsubu.vv v6, v12, v14
|
||||
vsetvli zero, zero, e16, \e16mul, ta, ma
|
||||
vmax.vv v16, v16, v18 # abs(p0 - q0)
|
||||
vmax.vv v20, v20, v22 # abs(p1 - p0)
|
||||
vmslt.vx v18, v16, a2
|
||||
vmax.vv v24, v24, v26 # abs(q1 - q0)
|
||||
vmslt.vx v22, v20, a3
|
||||
.ifc \type, luma
|
||||
vmax.vv v28, v28, v30 # abs(p2 - p0)
|
||||
.endif
|
||||
vmand.mm v18, v18, v22
|
||||
vmslt.vx v23, v24, a3
|
||||
.ifc \type, luma
|
||||
vmax.vv v4, v4, v6 # abs(q2 - q0)
|
||||
vmand.mm v1, v18, v23 # abs(...) < A && abs(..) < B && abs(..) < B
|
||||
vmslt.vx v3, v16, a4 # abs(p0 - q0) < (alpha / 4) + 2
|
||||
vmslt.vx v6, v28, a3 # abs(p2 - p0) < beta
|
||||
vmslt.vx v7, v4, a3 # abs(q2 - q0) < beta
|
||||
vmand.mm v2, v3, v6
|
||||
vmand.mm v3, v3, v7
|
||||
.else
|
||||
vmand.mm v0, v18, v23
|
||||
.endif
|
||||
vsetvli zero, zero, e8, \e8mul, ta, mu
|
||||
vwaddu.vv v22, v11, v13
|
||||
vwaddu.vv v30, v10, v12
|
||||
vwaddu.wv v22, v22, v10
|
||||
vwaddu.wv v30, v30, v13
|
||||
vwaddu.wv v22, v22, v10 # 2p1 + p0 + q1
|
||||
vwaddu.wv v30, v30, v13 # p1 + q0 + 2q1
|
||||
.ifc \type, luma
|
||||
vwaddu.vv v16, v10, v11
|
||||
vwaddu.vv v20, v8, v9
|
||||
vwaddu.wv v16, v16, v12 # p1 + p0 + q0
|
||||
vwaddu.vv v24, v11, v12
|
||||
vwaddu.vv v28, v14, v15
|
||||
vwaddu.wv v24, v24, v13 # p0 + q0 + q1
|
||||
vwaddu.wv v18, v16, v9 # p2 + p1 + p0 + q0
|
||||
vwaddu.wv v16, v16, v13 # p1 + p0 + q0 + q1
|
||||
vwaddu.wv v26, v24, v14 # p0 + q0 + q1 + q2
|
||||
vwaddu.wv v24, v24, v10 # p1 + p0 + q0 + q1
|
||||
vsetvli zero, zero, e16, \e16mul, ta, ma
|
||||
vsll.vi v20, v20, 1 # 2p3 +2p2
|
||||
vadd.vv v16, v16, v18 # p2 +2p1 +2p0 +2q0 + q1
|
||||
vadd.vv v20, v18, v20 # 2p3 +3p3 + p1 + p0 + q0
|
||||
vsll.vi v28, v28, 1 # 2q2 +2q3
|
||||
vadd.vv v24, v24, v26 # p1 +2p0 +2q0 +2q1 + q2
|
||||
vadd.vv v28, v26, v28 # p0 + q0 + q1 +3q2 +2q3
|
||||
vsetvli zero, zero, e8, \e8mul, ta, mu
|
||||
vmand.mm v0, v1, v2
|
||||
vnclipu.wi v11, v16, 3, v0.t # p0'
|
||||
vnclipu.wi v10, v18, 2, v0.t # p1'
|
||||
vnclipu.wi v9, v20, 3, v0.t # p2'
|
||||
vmandn.mm v0, v1, v2
|
||||
.endif
|
||||
vnclipu.wi v11, v22, 2, v0.t # p0'
|
||||
.ifc \type, luma
|
||||
vmand.mm v0, v1, v3
|
||||
vnclipu.wi v12, v24, 3, v0.t # q0'
|
||||
vnclipu.wi v13, v26, 2, v0.t # q1'
|
||||
vnclipu.wi v14, v28, 3, v0.t # q2'
|
||||
vmandn.mm v0, v1, v3
|
||||
.endif
|
||||
vnclipu.wi v12, v30, 2, v0.t # q0'
|
||||
jr t0
|
||||
endfunc
|
||||
|
||||
func ff_h264_v_loop_filter_\type\()_intra_8_rvv, zve32x
|
||||
lpad 0
|
||||
sub t3, a0, a1
|
||||
vsetivli zero, 4 * \inners, e8, \e8mul, ta, ma
|
||||
vle8.v v12, (a0)
|
||||
sub t2, t3, a1
|
||||
vle8.v v11, (t3)
|
||||
add t4, a0, a1
|
||||
vle8.v v10, (t2)
|
||||
.ifc \type, luma
|
||||
sub t1, t2, a1
|
||||
.endif
|
||||
vle8.v v13, (t4)
|
||||
.ifc \type, luma
|
||||
sub t0, t1, a1
|
||||
vle8.v v9, (t1)
|
||||
add t5, t4, a1
|
||||
vle8.v v8, (t0)
|
||||
add t6, t5, a1
|
||||
vle8.v v14, (t5)
|
||||
vle8.v v15, (t6)
|
||||
.endif
|
||||
jal t0, ff_h264_loop_filter_\type\()_intra_8_rvv
|
||||
.ifc \type, luma
|
||||
vse8.v v9, (t1)
|
||||
vse8.v v10, (t2)
|
||||
.endif
|
||||
vse8.v v11, (t3)
|
||||
vse8.v v12, (a0)
|
||||
.ifc \type, luma
|
||||
vse8.v v13, (t4)
|
||||
vse8.v v14, (t5)
|
||||
.endif
|
||||
ret
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
loop_filter luma, 4, m1, m2
|
||||
loop_filter chroma, 2, mf2, m1
|
||||
|
||||
func ff_h264_h_loop_filter_luma_8_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, 4, e32, m1, ta, ma
|
||||
vle8.v v4, (a4)
|
||||
li t0, 0x01010101
|
||||
vzext.vf4 v6, v4
|
||||
addi a0, a0, -3
|
||||
vmul.vx v6, v6, t0
|
||||
vsetivli zero, 16, e8, m1, ta, ma
|
||||
vlsseg6e8.v v8, (a0), a1
|
||||
addi a0, a0, 1
|
||||
jal t0, ff_h264_loop_filter_luma_8_rvv
|
||||
vssseg4e8.v v9, (a0), a1
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h264_h_loop_filter_luma_mbaff_8_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
vle8.v v4, (a4)
|
||||
li t0, 0x0101
|
||||
vzext.vf2 v6, v4
|
||||
addi a0, a0, -3
|
||||
vmul.vx v6, v6, t0 # tc_orig
|
||||
vsetivli zero, 8, e8, m1, ta, ma
|
||||
vlsseg6e8.v v8, (a0), a1
|
||||
addi a0, a0, 1
|
||||
jal t0, ff_h264_loop_filter_luma_8_rvv
|
||||
vssseg4e8.v v9, (a0), a1
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h264_h_loop_filter_chroma_8_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
vle8.v v4, (a4)
|
||||
li t0, 0x0101
|
||||
vzext.vf2 v6, v4
|
||||
addi a0, a0, -2
|
||||
vmul.vx v6, v6, t0
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
vlsseg4e8.v v9, (a0), a1
|
||||
addi a0, a0, 1
|
||||
jal t0, ff_h264_loop_filter_chroma_8_rvv
|
||||
vssseg2e8.v v10, (a0), a1
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h264_h_loop_filter_chroma_mbaff_8_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, 4, e8, mf4, ta, ma
|
||||
vle8.v v6, (a4)
|
||||
addi a0, a0, -2
|
||||
vsetivli zero, 4, e8, mf2, ta, ma
|
||||
vlsseg4e8.v v9, (a0), a1
|
||||
addi a0, a0, 1
|
||||
jal t0, ff_h264_loop_filter_chroma_8_rvv
|
||||
vssseg2e8.v v10, (a0), a1
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h264_h_loop_filter_luma_intra_8_rvv, zve32x
|
||||
lpad 0
|
||||
addi a0, a0, -4
|
||||
vsetivli zero, 16, e8, m1, ta, ma
|
||||
vlsseg8e8.v v8, (a0), a1
|
||||
addi a0, a0, 1
|
||||
jal t0, ff_h264_loop_filter_luma_intra_8_rvv
|
||||
vssseg6e8.v v9, (a0), a1
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h264_h_loop_filter_luma_mbaff_intra_8_rvv, zve32x
|
||||
lpad 0
|
||||
addi a0, a0, -4
|
||||
vsetivli zero, 8, e8, m1, ta, ma
|
||||
vlsseg8e8.v v8, (a0), a1
|
||||
addi a0, a0, 1
|
||||
jal t0, ff_h264_loop_filter_luma_intra_8_rvv
|
||||
vssseg6e8.v v9, (a0), a1
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h264_h_loop_filter_chroma_intra_8_rvv, zve32x
|
||||
lpad 0
|
||||
addi a0, a0, -2
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
vlsseg4e8.v v10, (a0), a1
|
||||
addi a0, a0, 1
|
||||
jal t0, ff_h264_loop_filter_chroma_intra_8_rvv
|
||||
vssseg2e8.v v11, (a0), a1
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h264_h_loop_filter_chroma_mbaff_intra_8_rvv, zve32x
|
||||
lpad 0
|
||||
addi a0, a0, -2
|
||||
vsetivli zero, 4, e8, mf2, ta, ma
|
||||
vlsseg4e8.v v10, (a0), a1
|
||||
addi a0, a0, 1
|
||||
jal t0, ff_h264_loop_filter_chroma_intra_8_rvv
|
||||
vssseg2e8.v v11, (a0), a1
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,807 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2024 J. Dekker <jdek@itanimul.li>
|
||||
* Copyright © 2024 Rémi Denis-Courmont.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "libavutil/riscv/asm.S"
|
||||
|
||||
.macro sx rd, addr
|
||||
#if (__riscv_xlen == 32)
|
||||
sw \rd, \addr
|
||||
#elif (__riscv_xlen == 64)
|
||||
sd \rd, \addr
|
||||
#else
|
||||
sq \rd, \addr
|
||||
#endif
|
||||
.endm
|
||||
|
||||
.variant_cc ff_h264_idct4_rvv
|
||||
func ff_h264_idct4_rvv, zve32x
|
||||
vsra.vi v5, v1, 1
|
||||
vsra.vi v7, v3, 1
|
||||
vadd.vv v8, v0, v2 # z0
|
||||
vsub.vv v9, v0, v2 # z1
|
||||
vsub.vv v10, v5, v3 # z2
|
||||
vadd.vv v11, v1, v7 # z3
|
||||
vadd.vv v1, v9, v10
|
||||
vsub.vv v2, v9, v10
|
||||
vadd.vv v0, v8, v11
|
||||
vsub.vv v3, v8, v11
|
||||
jr t0
|
||||
endfunc
|
||||
|
||||
func ff_h264_idct_add_8_rvv, zve32x
|
||||
lpad 0
|
||||
csrwi vxrm, 0
|
||||
.Lidct4_add_8_rvv:
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
addi t1, a1, 1 * 4 * 2
|
||||
vle16.v v0, (a1)
|
||||
addi t2, a1, 2 * 4 * 2
|
||||
vle16.v v1, (t1)
|
||||
addi t3, a1, 3 * 4 * 2
|
||||
vle16.v v2, (t2)
|
||||
vle16.v v3, (t3)
|
||||
jal t0, ff_h264_idct4_rvv
|
||||
vse16.v v0, (a1)
|
||||
vse16.v v1, (t1)
|
||||
vse16.v v2, (t2)
|
||||
vse16.v v3, (t3)
|
||||
vlseg4e16.v v0, (a1)
|
||||
.equ offset, 0
|
||||
.rept 256 / __riscv_xlen
|
||||
sx zero, offset(a1)
|
||||
.equ offset, offset + (__riscv_xlen / 8)
|
||||
.endr
|
||||
jal t0, ff_h264_idct4_rvv
|
||||
add t1, a0, a2
|
||||
vle8.v v4, (a0)
|
||||
add t2, t1, a2
|
||||
vle8.v v5, (t1)
|
||||
add t3, t2, a2
|
||||
vle8.v v6, (t2)
|
||||
vle8.v v7, (t3)
|
||||
.irp n,0,1,2,3
|
||||
vssra.vi v\n, v\n, 6
|
||||
.endr
|
||||
vsetvli zero, zero, e8, mf4, ta, ma
|
||||
vwaddu.wv v0, v0, v4
|
||||
vwaddu.wv v1, v1, v5
|
||||
vwaddu.wv v2, v2, v6
|
||||
vwaddu.wv v3, v3, v7
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
.irp n,0,1,2,3
|
||||
vmax.vx v\n, v\n, zero
|
||||
.endr
|
||||
vsetvli zero, zero, e8, mf4, ta, ma
|
||||
vnclipu.wi v4, v0, 0
|
||||
vnclipu.wi v5, v1, 0
|
||||
vnclipu.wi v6, v2, 0
|
||||
vnclipu.wi v7, v3, 0
|
||||
vse8.v v4, (a0)
|
||||
vse8.v v5, (t1)
|
||||
vse8.v v6, (t2)
|
||||
vse8.v v7, (t3)
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h264_idct_add_16_rvv, zve32x
|
||||
csrwi vxrm, 0
|
||||
.Lidct4_add_16_rvv:
|
||||
vsetivli zero, 4, e32, m1, ta, ma
|
||||
addi t1, a1, 1 * 4 * 4
|
||||
vle32.v v0, (a1)
|
||||
addi t2, a1, 2 * 4 * 4
|
||||
vle32.v v1, (t1)
|
||||
addi t3, a1, 3 * 4 * 4
|
||||
vle32.v v2, (t2)
|
||||
vle32.v v3, (t3)
|
||||
jal t0, ff_h264_idct4_rvv
|
||||
vse32.v v0, (a1)
|
||||
vse32.v v1, (t1)
|
||||
vse32.v v2, (t2)
|
||||
vse32.v v3, (t3)
|
||||
vlseg4e32.v v0, (a1)
|
||||
.equ offset, 0
|
||||
.rept 512 / __riscv_xlen
|
||||
sx zero, offset(a1)
|
||||
.equ offset, offset + (__riscv_xlen / 8)
|
||||
.endr
|
||||
jal t0, ff_h264_idct4_rvv
|
||||
add t1, a0, a2
|
||||
vle16.v v4, (a0)
|
||||
add t2, t1, a2
|
||||
vle16.v v5, (t1)
|
||||
add t3, t2, a2
|
||||
vle16.v v6, (t2)
|
||||
vle16.v v7, (t3)
|
||||
.irp n,0,1,2,3
|
||||
vssra.vi v\n, v\n, 6
|
||||
.endr
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
vwaddu.wv v0, v0, v4
|
||||
vwaddu.wv v1, v1, v5
|
||||
vwaddu.wv v2, v2, v6
|
||||
vwaddu.wv v3, v3, v7
|
||||
vsetvli zero, zero, e32, m1, ta, ma
|
||||
.irp n,0,1,2,3
|
||||
vmax.vx v\n, v\n, zero
|
||||
.endr
|
||||
.irp n,0,1,2,3
|
||||
vmin.vx v\n, v\n, a5
|
||||
.endr
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
vncvt.x.x.w v4, v0
|
||||
vncvt.x.x.w v5, v1
|
||||
vncvt.x.x.w v6, v2
|
||||
vncvt.x.x.w v7, v3
|
||||
vse16.v v4, (a0)
|
||||
vse16.v v5, (t1)
|
||||
vse16.v v6, (t2)
|
||||
vse16.v v7, (t3)
|
||||
ret
|
||||
endfunc
|
||||
|
||||
.variant_cc ff_h264_idct8_rvv
|
||||
func ff_h264_idct8_rvv, zve32x
|
||||
vsra.vi v9, v7, 1
|
||||
vsra.vi v11, v3, 1
|
||||
vsra.vi v12, v2, 1
|
||||
vsra.vi v13, v5, 1
|
||||
vsra.vi v14, v6, 1
|
||||
vsra.vi v15, v1, 1
|
||||
vadd.vv v9, v3, v9
|
||||
vsub.vv v11, v1, v11
|
||||
vsub.vv v13, v13, v1
|
||||
vadd.vv v15, v3, v15
|
||||
vsub.vv v9, v5, v9
|
||||
vadd.vv v11, v11, v7
|
||||
vadd.vv v13, v13, v7
|
||||
vadd.vv v15, v15, v5
|
||||
vadd.vv v8, v0, v4 # a0
|
||||
vsub.vv v9, v9, v7 # a1
|
||||
vsub.vv v10, v0, v4 # a2
|
||||
vsub.vv v11, v11, v3 # a3
|
||||
vsub.vv v12, v12, v6 # a4
|
||||
vadd.vv v13, v13, v5 # a5
|
||||
vadd.vv v14, v14, v2 # a6
|
||||
vadd.vv v15, v15, v1 # a7
|
||||
vsra.vi v7, v9, 2
|
||||
vsra.vi v5, v11, 2
|
||||
vsra.vi v3, v13, 2
|
||||
vsra.vi v1, v15, 2
|
||||
vadd.vv v0, v8, v14 # b0
|
||||
vadd.vv v6, v10, v12 # b2
|
||||
vsub.vv v2, v10, v12 # b4
|
||||
vsub.vv v4, v8, v14 # b6
|
||||
vsub.vv v8, v15, v7 # b7
|
||||
vsub.vv v14, v5, v13 # b5
|
||||
vadd.vv v12, v1, v9 # b1
|
||||
vadd.vv v10, v11, v3 # b3
|
||||
vadd.vv v1, v6, v14
|
||||
vsub.vv v6, v6, v14
|
||||
vsub.vv v7, v0, v8
|
||||
vadd.vv v0, v0, v8
|
||||
vsub.vv v5, v2, v10
|
||||
vadd.vv v2, v2, v10
|
||||
vadd.vv v3, v4, v12
|
||||
vsub.vv v4, v4, v12
|
||||
jr t0
|
||||
endfunc
|
||||
|
||||
func ff_h264_idct8_add_8_rvv, zve32x
|
||||
lpad 0
|
||||
csrwi vxrm, 0
|
||||
.Lidct8_add_8_rvv:
|
||||
vsetivli zero, 8, e16, m1, ta, ma
|
||||
addi t1, a1, 1 * 8 * 2
|
||||
vle16.v v0, (a1)
|
||||
addi t2, a1, 2 * 8 * 2
|
||||
vle16.v v1, (t1)
|
||||
addi t3, a1, 3 * 8 * 2
|
||||
vle16.v v2, (t2)
|
||||
addi t4, a1, 4 * 8 * 2
|
||||
vle16.v v3, (t3)
|
||||
addi t5, a1, 5 * 8 * 2
|
||||
vle16.v v4, (t4)
|
||||
addi t6, a1, 6 * 8 * 2
|
||||
vle16.v v5, (t5)
|
||||
addi a7, a1, 7 * 8 * 2
|
||||
vle16.v v6, (t6)
|
||||
vle16.v v7, (a7)
|
||||
jal t0, ff_h264_idct8_rvv
|
||||
vse16.v v0, (a1)
|
||||
vse16.v v1, (t1)
|
||||
vse16.v v2, (t2)
|
||||
vse16.v v3, (t3)
|
||||
vse16.v v4, (t4)
|
||||
vse16.v v5, (t5)
|
||||
vse16.v v6, (t6)
|
||||
vse16.v v7, (a7)
|
||||
vlseg8e16.v v0, (a1)
|
||||
.equ offset, 0
|
||||
.rept 1024 / __riscv_xlen
|
||||
sx zero, offset(a1)
|
||||
.equ offset, offset + (__riscv_xlen / 8)
|
||||
.endr
|
||||
jal t0, ff_h264_idct8_rvv
|
||||
add t1, a0, a2
|
||||
vle8.v v16, (a0)
|
||||
add t2, t1, a2
|
||||
vle8.v v17, (t1)
|
||||
add t3, t2, a2
|
||||
vle8.v v18, (t2)
|
||||
add t4, t3, a2
|
||||
vle8.v v19, (t3)
|
||||
add t5, t4, a2
|
||||
vle8.v v20, (t4)
|
||||
add t6, t5, a2
|
||||
vle8.v v21, (t5)
|
||||
add a7, t6, a2
|
||||
vle8.v v22, (t6)
|
||||
vle8.v v23, (a7)
|
||||
.irp n,0,1,2,3,4,5,6,7
|
||||
vssra.vi v\n, v\n, 6
|
||||
.endr
|
||||
vsetvli zero, zero, e8, mf2, ta, ma
|
||||
vwaddu.wv v0, v0, v16
|
||||
vwaddu.wv v1, v1, v17
|
||||
vwaddu.wv v2, v2, v18
|
||||
vwaddu.wv v3, v3, v19
|
||||
vwaddu.wv v4, v4, v20
|
||||
vwaddu.wv v5, v5, v21
|
||||
vwaddu.wv v6, v6, v22
|
||||
vwaddu.wv v7, v7, v23
|
||||
vsetvli zero, zero, e16, m1, ta, ma
|
||||
.irp n,0,1,2,3,4,5,6,7
|
||||
vmax.vx v\n, v\n, zero
|
||||
.endr
|
||||
vsetvli zero, zero, e8, mf2, ta, ma
|
||||
vnclipu.wi v16, v0, 0
|
||||
vnclipu.wi v17, v1, 0
|
||||
vnclipu.wi v18, v2, 0
|
||||
vnclipu.wi v19, v3, 0
|
||||
vnclipu.wi v20, v4, 0
|
||||
vnclipu.wi v21, v5, 0
|
||||
vnclipu.wi v22, v6, 0
|
||||
vnclipu.wi v23, v7, 0
|
||||
vse8.v v16, (a0)
|
||||
vse8.v v17, (t1)
|
||||
vse8.v v18, (t2)
|
||||
vse8.v v19, (t3)
|
||||
vse8.v v20, (t4)
|
||||
vse8.v v21, (t5)
|
||||
vse8.v v22, (t6)
|
||||
vse8.v v23, (a7)
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h264_idct8_add_16_rvv, zve32x, zba
|
||||
csrwi vxrm, 0
|
||||
.Lidct8_add_16_rvv:
|
||||
li a4, 8
|
||||
vsetivli a3, 8, e32, m1, ta, ma
|
||||
1:
|
||||
addi t1, a1, 1 * 8 * 4
|
||||
vle32.v v0, (a1)
|
||||
addi t2, a1, 2 * 8 * 4
|
||||
vle32.v v1, (t1)
|
||||
addi t3, a1, 3 * 8 * 4
|
||||
vle32.v v2, (t2)
|
||||
addi t4, a1, 4 * 8 * 4
|
||||
vle32.v v3, (t3)
|
||||
addi t5, a1, 5 * 8 * 4
|
||||
vle32.v v4, (t4)
|
||||
addi t6, a1, 6 * 8 * 4
|
||||
vle32.v v5, (t5)
|
||||
addi a7, a1, 7 * 8 * 4
|
||||
vle32.v v6, (t6)
|
||||
sub a4, a4, a3
|
||||
vle32.v v7, (a7)
|
||||
jal t0, ff_h264_idct8_rvv
|
||||
vse32.v v0, (a1)
|
||||
sh2add a1, a3, a1
|
||||
vse32.v v1, (t1)
|
||||
vse32.v v2, (t2)
|
||||
vse32.v v3, (t3)
|
||||
vse32.v v4, (t4)
|
||||
vse32.v v5, (t5)
|
||||
vse32.v v6, (t6)
|
||||
vse32.v v7, (a7)
|
||||
bnez a4, 1b
|
||||
|
||||
addi a1, a1, -8 * 4
|
||||
li a4, 8
|
||||
slli a6, a3, 3 + 2
|
||||
2:
|
||||
vsetvli zero, zero, e32, m1, ta, ma
|
||||
vlseg8e32.v v0, (a1)
|
||||
jal t0, ff_h264_idct8_rvv
|
||||
add t1, a0, a2
|
||||
vle16.v v16, (a0)
|
||||
add t2, t1, a2
|
||||
vle16.v v17, (t1)
|
||||
add t3, t2, a2
|
||||
vle16.v v18, (t2)
|
||||
add t4, t3, a2
|
||||
vle16.v v19, (t3)
|
||||
add t5, t4, a2
|
||||
vle16.v v20, (t4)
|
||||
add t6, t5, a2
|
||||
vle16.v v21, (t5)
|
||||
add a7, t6, a2
|
||||
vle16.v v22, (t6)
|
||||
sub a4, a4, a3
|
||||
vle16.v v23, (a7)
|
||||
.irp n,0,1,2,3,4,5,6,7
|
||||
vssra.vi v\n, v\n, 6
|
||||
.endr
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
vwaddu.wv v0, v0, v16
|
||||
add a1, a6, a1
|
||||
vwaddu.wv v1, v1, v17
|
||||
vwaddu.wv v2, v2, v18
|
||||
vwaddu.wv v3, v3, v19
|
||||
vwaddu.wv v4, v4, v20
|
||||
vwaddu.wv v5, v5, v21
|
||||
vwaddu.wv v6, v6, v22
|
||||
vwaddu.wv v7, v7, v23
|
||||
vsetvli zero, zero, e32, m1, ta, ma
|
||||
.irp n,0,1,2,3,4,5,6,7
|
||||
vmax.vx v\n, v\n, zero
|
||||
.endr
|
||||
.irp n,0,1,2,3,4,5,6,7
|
||||
vmin.vx v\n, v\n, a5
|
||||
.endr
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
vncvt.x.x.w v16, v0
|
||||
vncvt.x.x.w v17, v1
|
||||
vncvt.x.x.w v18, v2
|
||||
vncvt.x.x.w v19, v3
|
||||
vncvt.x.x.w v20, v4
|
||||
vncvt.x.x.w v21, v5
|
||||
vncvt.x.x.w v22, v6
|
||||
vncvt.x.x.w v23, v7
|
||||
vse16.v v16, (a0)
|
||||
sh1add a0, a3, a0
|
||||
vse16.v v17, (t1)
|
||||
vse16.v v18, (t2)
|
||||
vse16.v v19, (t3)
|
||||
vse16.v v20, (t4)
|
||||
vse16.v v21, (t5)
|
||||
vse16.v v22, (t6)
|
||||
vse16.v v23, (a7)
|
||||
bnez a4, 2b
|
||||
|
||||
.equ offset, 0
|
||||
.rept 2048 / __riscv_xlen
|
||||
sx zero, offset - 8 * 8 * 4(a1)
|
||||
.equ offset, offset + (__riscv_xlen / 8)
|
||||
.endr
|
||||
ret
|
||||
endfunc
|
||||
|
||||
.irp depth, 9, 10, 12, 14
|
||||
func ff_h264_idct_add_\depth\()_rvv, zve32x
|
||||
lpad 0
|
||||
li a5, (1 << \depth) - 1
|
||||
j ff_h264_idct_add_16_rvv
|
||||
endfunc
|
||||
|
||||
func ff_h264_idct8_add_\depth\()_rvv, zve32x
|
||||
lpad 0
|
||||
li a5, (1 << \depth) - 1
|
||||
j ff_h264_idct8_add_16_rvv
|
||||
endfunc
|
||||
.endr
|
||||
|
||||
.macro idct_dc_add8 width
|
||||
func ff_h264_idct\width\()_dc_add_8_rvv, zve64x, b
|
||||
lpad 0
|
||||
.if \width == 8
|
||||
vsetivli zero, \width, e8, mf2, ta, ma
|
||||
.else
|
||||
vsetivli zero, \width, e8, mf4, ta, ma
|
||||
.endif
|
||||
lh t0, 0(a1)
|
||||
li t1, 255
|
||||
addi t0, t0, 32
|
||||
srai t0, t0, 6
|
||||
sh zero, 0(a1)
|
||||
.if \width == 8
|
||||
li a6, \width * \width
|
||||
vlse64.v v24, (a0), a2
|
||||
vsetvli zero, a6, e8, m4, ta, ma
|
||||
.else
|
||||
vlse32.v v24, (a0), a2
|
||||
vsetivli zero, \width * \width, e8, m1, ta, ma
|
||||
.endif
|
||||
bgez t0, 1f
|
||||
|
||||
neg t0, t0
|
||||
minu t0, t0, t1
|
||||
vssubu.vx v24, v24, t0
|
||||
.if \width == 8
|
||||
vsetivli zero, \width, e8, mf2, ta, ma
|
||||
vsse64.v v24, (a0), a2
|
||||
.else
|
||||
vsetivli zero, \width, e8, mf4, ta, ma
|
||||
vsse32.v v24, (a0), a2
|
||||
.endif
|
||||
ret
|
||||
1:
|
||||
minu t0, t0, t1
|
||||
vsaddu.vx v24, v24, t0
|
||||
.if \width == 8
|
||||
vsetivli zero, \width, e8, mf2, ta, ma
|
||||
vsse64.v v24, (a0), a2
|
||||
.else
|
||||
vsetivli zero, \width, e8, mf4, ta, ma
|
||||
vsse32.v v24, (a0), a2
|
||||
.endif
|
||||
ret
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
idct_dc_add8 4
|
||||
idct_dc_add8 8
|
||||
|
||||
.macro idct_dc_add width
|
||||
func ff_h264_idct\width\()_dc_add_16_rvv, zve64x, zba
|
||||
.if \width == 8
|
||||
vsetivli zero, \width, e16, m1, ta, ma
|
||||
.else
|
||||
vsetivli zero, \width, e16, mf2, ta, ma
|
||||
.endif
|
||||
lw t0, 0(a1)
|
||||
addi t0, t0, 32
|
||||
srai t0, t0, 6
|
||||
sw zero, 0(a1)
|
||||
add t1, a0, a2
|
||||
sh1add t2, a2, a0
|
||||
sh1add t3, a2, t1
|
||||
.if \width == 8
|
||||
sh2add t4, a2, a0
|
||||
sh2add t5, a2, t1
|
||||
sh2add t6, a2, t2
|
||||
sh2add a7, a2, t3
|
||||
.endif
|
||||
vle16.v v0, (a0)
|
||||
vle16.v v1, (t1)
|
||||
vle16.v v2, (t2)
|
||||
vle16.v v3, (t3)
|
||||
.if \width == 8
|
||||
vle16.v v4, (t4)
|
||||
vle16.v v5, (t5)
|
||||
vle16.v v6, (t6)
|
||||
vle16.v v7, (a7)
|
||||
vsetvli a6, zero, e16, m8, ta, ma
|
||||
.else
|
||||
vsetvli a6, zero, e16, m4, ta, ma
|
||||
.endif
|
||||
vadd.vx v0, v0, t0
|
||||
vmax.vx v0, v0, zero
|
||||
vmin.vx v0, v0, a5
|
||||
.if \width == 8
|
||||
vsetivli zero, \width, e16, m1, ta, ma
|
||||
.else
|
||||
vsetivli zero, \width, e16, mf2, ta, ma
|
||||
.endif
|
||||
vse16.v v0, (a0)
|
||||
vse16.v v1, (t1)
|
||||
vse16.v v2, (t2)
|
||||
vse16.v v3, (t3)
|
||||
.if \width == 8
|
||||
vse16.v v4, (t4)
|
||||
vse16.v v5, (t5)
|
||||
vse16.v v6, (t6)
|
||||
vse16.v v7, (a7)
|
||||
.endif
|
||||
ret
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
idct_dc_add 4
|
||||
idct_dc_add 8
|
||||
|
||||
.irp depth,9,10,12,14
|
||||
func ff_h264_idct4_dc_add_\depth\()_rvv, zve64x
|
||||
lpad 0
|
||||
li a5, (1 << \depth) - 1
|
||||
j ff_h264_idct4_dc_add_16_rvv
|
||||
endfunc
|
||||
|
||||
func ff_h264_idct8_dc_add_\depth\()_rvv, zve64x
|
||||
lpad 0
|
||||
li a5, (1 << \depth) - 1
|
||||
j ff_h264_idct8_dc_add_16_rvv
|
||||
endfunc
|
||||
.endr
|
||||
|
||||
const ff_h264_scan8, align=0
|
||||
.byte 014, 015, 024, 025, 016, 017, 026, 027
|
||||
.byte 034, 035, 044, 045, 036, 037, 046, 047
|
||||
.byte 064, 065, 074, 075, 066, 067, 076, 077
|
||||
.byte 0104, 0105, 0114, 0115, 0106, 0107, 0116, 0117
|
||||
.byte 0134, 0135, 0144, 0145, 0136, 0137, 0146, 0147
|
||||
.byte 0154, 0155, 0164, 0165, 0156, 0157, 0166, 0167
|
||||
endconst
|
||||
|
||||
.macro idct4_add16 type, depth
|
||||
func ff_h264_idct_add\type\()_\depth\()_rvv, zve32x, b
|
||||
.if \depth == 8
|
||||
lpad 0
|
||||
.endif
|
||||
csrwi vxrm, 0
|
||||
lla t0, ff_h264_scan8
|
||||
vsetivli zero, 16, e8, m1, ta, ma
|
||||
.ifc \type, 16intra
|
||||
.Lidct4_add4_\depth\()_rvv:
|
||||
.endif
|
||||
li t1, 32 * (\depth / 8)
|
||||
vle8.v v8, (t0)
|
||||
.if \depth == 8
|
||||
vlse16.v v16, (a2), t1
|
||||
.else
|
||||
vlse32.v v16, (a2), t1
|
||||
.endif
|
||||
vluxei8.v v12, (a4), v8
|
||||
.if \depth == 8
|
||||
vsetvli zero, zero, e16, m2, ta, ma
|
||||
.else
|
||||
vsetvli zero, zero, e32, m4, ta, ma
|
||||
.endif
|
||||
vmsne.vi v1, v16, 0
|
||||
vsetvli zero, zero, e8, m1, ta, ma
|
||||
.ifc \type, 16
|
||||
vmseq.vi v2, v12, 1
|
||||
.endif
|
||||
vmsne.vi v0, v12, 0
|
||||
.ifc \type, 16
|
||||
vmand.mm v1, v1, v2
|
||||
.endif
|
||||
vsetvli zero, zero, e16, m2, ta, ma
|
||||
vmv.x.s a4, v0
|
||||
vmv.x.s a7, v1
|
||||
zext.h a4, a4
|
||||
slli a7, a7, 16
|
||||
mv t4, a0
|
||||
or a4, a4, a7
|
||||
mv t5, a1
|
||||
mv a1, a2
|
||||
mv a2, a3
|
||||
csrr a3, vl
|
||||
mv a7, ra
|
||||
1:
|
||||
andi t0, a4, 1
|
||||
addi a3, a3, -1
|
||||
.ifc \type, 16
|
||||
beqz t0, 3f # if (nnz)
|
||||
.endif
|
||||
lw t2, (t5) # block_offset[i]
|
||||
bexti t1, a4, 16
|
||||
add a0, t4, t2
|
||||
.ifc \type, 16
|
||||
bnez t1, 2f # if (nnz == 1 && block[i * 16])
|
||||
.else
|
||||
beqz t0, 2f # if (nnzc[scan8[i]])
|
||||
.endif
|
||||
jal .Lidct4_add_\depth\()_rvv
|
||||
j 3f
|
||||
2:
|
||||
.ifnc \type, 16
|
||||
beqz t1, 3f # if (block[i * 16])
|
||||
.endif
|
||||
jal ff_h264_idct4_dc_add_\depth\()_rvv
|
||||
3:
|
||||
srli a4, a4, 1
|
||||
addi t5, t5, 4
|
||||
addi a1, a1, 16 * 2 * (\depth / 8)
|
||||
bnez a3, 1b
|
||||
|
||||
mv ra, a7
|
||||
ret
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
.macro idct4_add8 type, depth
|
||||
#if (__riscv_xlen == 64)
|
||||
func ff_h264_idct4_add\type\()_\depth\()_rvv, zve32x
|
||||
.if \depth == 8
|
||||
lpad 0
|
||||
.endif
|
||||
csrwi vxrm, 0
|
||||
addi sp, sp, -32
|
||||
addi a2, a2, 16 * 16 * 2 * (\depth / 8) # &block[16 * 16]
|
||||
lla t0, ff_h264_scan8 + 16
|
||||
sd s0, 0(sp)
|
||||
sd ra, 8(sp)
|
||||
mv s0, sp
|
||||
sd a0, 16(sp)
|
||||
sd a4, 24(sp)
|
||||
ld a0, 0(a0) # dest[0]
|
||||
addi a1, a1, 16 * 4 # &block_offset[16]
|
||||
vsetivli zero, 4, e8, m1, ta, ma
|
||||
jal .Lidct4_add4_\depth\()_rvv
|
||||
|
||||
ld a4, 24(sp) # nnzc
|
||||
ld a0, 16(sp)
|
||||
mv a3, a2 # stride
|
||||
addi a2, a1, (16 - 4) * 16 * 2 * (\depth / 8) # &block[32 * 16]
|
||||
addi a1, t5, (16 - 4) * 4 # &block_offset[32]
|
||||
ld a0, 8(a0) # dest[1]
|
||||
lla t0, ff_h264_scan8 + 32
|
||||
.ifc \type, 8_422
|
||||
vsetivli zero, 4, e8, m1, ta, ma
|
||||
jal .Lidct4_add4_\depth\()_rvv
|
||||
|
||||
ld a4, 24(sp) # nnzc
|
||||
ld a0, 16(sp)
|
||||
mv a3, a2 # stride
|
||||
addi a2, a1, (-12- 4) * 16 * 2 * (\depth / 8) # &block[20 * 16]
|
||||
addi a1, t5, (-8 - 4) * 4 # &block_offset[24]
|
||||
ld a0, 0(a0) # dest[0]
|
||||
lla t0, ff_h264_scan8 + 24
|
||||
vsetivli zero, 4, e8, m1, ta, ma
|
||||
jal .Lidct4_add4_\depth\()_rvv
|
||||
|
||||
ld a4, 24(sp) # nnzc
|
||||
ld a0, 16(sp)
|
||||
mv a3, a2 # stride
|
||||
addi a2, a1, (16 - 4) * 16 * 2 * (\depth / 8) # &block[36 * 16]
|
||||
addi a1, t5, (16 - 4) * 4 # &block_offset[40]
|
||||
ld a0, 8(a0) # dest[1]
|
||||
lla t0, ff_h264_scan8 + 40
|
||||
.endif
|
||||
ld ra, 8(sp)
|
||||
ld s0, 0(sp)
|
||||
addi sp, sp, 32
|
||||
vsetivli zero, 4, e8, m1, ta, ma
|
||||
j .Lidct4_add4_\depth\()_rvv
|
||||
endfunc
|
||||
#endif
|
||||
.endm
|
||||
|
||||
.irp depth, 8, 16
|
||||
idct4_add16 16, \depth
|
||||
idct4_add16 16intra, \depth
|
||||
idct4_add8 8, \depth
|
||||
idct4_add8 8_422, \depth
|
||||
|
||||
#if (__riscv_xlen == 64)
|
||||
func ff_h264_idct8_add4_\depth\()_rvv, zve32x, b
|
||||
.if \depth == 8
|
||||
lpad 0
|
||||
.endif
|
||||
csrwi vxrm, 0
|
||||
addi sp, sp, -48
|
||||
lla t0, ff_h264_scan8
|
||||
sd s0, (sp)
|
||||
li t1, 4 * 32 * (\depth / 8)
|
||||
mv s0, sp
|
||||
li t2, 4
|
||||
sd ra, 8(sp)
|
||||
sd s1, 16(sp)
|
||||
sd s2, 24(sp)
|
||||
sd s4, 32(sp)
|
||||
sd s5, 40(sp)
|
||||
vsetivli zero, 4, e8, mf4, ta, ma
|
||||
vlse8.v v8, (t0), t2
|
||||
.if \depth == 8
|
||||
vlse16.v v16, (a2), t1
|
||||
.else
|
||||
vlse32.v v16, (a2), t1
|
||||
.endif
|
||||
vluxei8.v v12, (a4), v8
|
||||
.if \depth == 8
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
.else
|
||||
vsetvli zero, zero, e32, m1, ta, ma
|
||||
.endif
|
||||
vmsne.vi v1, v16, 0
|
||||
vsetvli zero, zero, e8, mf4, ta, ma
|
||||
vmseq.vi v2, v12, 1
|
||||
vmsne.vi v0, v12, 0
|
||||
vmand.mm v1, v1, v2
|
||||
vmv.x.s s2, v0
|
||||
vmv.x.s a7, v1
|
||||
zext.h s2, s2
|
||||
slli a7, a7, 16
|
||||
li s1, 4
|
||||
or s2, s2, a7
|
||||
mv s4, a0
|
||||
mv s5, a1
|
||||
mv a1, a2
|
||||
mv a2, a3
|
||||
1:
|
||||
andi t0, s2, 1
|
||||
addi s1, s1, -1
|
||||
beqz t0, 3f # if (nnz)
|
||||
lw t2, (s5) # block_offset[i]
|
||||
bexti t1, s2, 16
|
||||
add a0, s4, t2
|
||||
bnez t1, 2f # if (nnz == 1 && block[i * 16])
|
||||
jal .Lidct8_add_\depth\()_rvv
|
||||
.if \depth == 8
|
||||
j 3f
|
||||
.else
|
||||
j 4f # idct8_add_16 updates a1
|
||||
.endif
|
||||
2:
|
||||
jal ff_h264_idct8_dc_add_\depth\()_rvv
|
||||
3:
|
||||
addi a1, a1, 4 * 16 * 2 * (\depth / 8)
|
||||
4:
|
||||
srli s2, s2, 1
|
||||
addi s5, s5, 4 * 4
|
||||
bnez s1, 1b
|
||||
|
||||
ld s5, 40(sp)
|
||||
ld s4, 32(sp)
|
||||
ld s2, 24(sp)
|
||||
ld s1, 16(sp)
|
||||
ld ra, 8(sp)
|
||||
ld s0, 0(sp)
|
||||
addi sp, sp, 48
|
||||
ret
|
||||
endfunc
|
||||
#endif
|
||||
.endr
|
||||
|
||||
.irp depth, 9, 10, 12, 14
|
||||
func ff_h264_idct_add16_\depth\()_rvv, zve32x
|
||||
lpad 0
|
||||
li a5, (1 << \depth) - 1
|
||||
j ff_h264_idct_add16_16_rvv
|
||||
endfunc
|
||||
|
||||
func ff_h264_idct_add16intra_\depth\()_rvv, zve32x
|
||||
lpad 0
|
||||
li a5, (1 << \depth) - 1
|
||||
j ff_h264_idct_add16intra_16_rvv
|
||||
endfunc
|
||||
|
||||
#if (__riscv_xlen == 64)
|
||||
func ff_h264_idct8_add4_\depth\()_rvv, zve32x
|
||||
lpad 0
|
||||
li a5, (1 << \depth) - 1
|
||||
j ff_h264_idct8_add4_16_rvv
|
||||
endfunc
|
||||
|
||||
func ff_h264_idct4_add8_\depth\()_rvv, zve32x
|
||||
lpad 0
|
||||
li a5, (1 << \depth) - 1
|
||||
j ff_h264_idct4_add8_16_rvv
|
||||
endfunc
|
||||
|
||||
func ff_h264_idct4_add8_422_\depth\()_rvv, zve32x
|
||||
lpad 0
|
||||
li a5, (1 << \depth) - 1
|
||||
j ff_h264_idct4_add8_422_16_rvv
|
||||
endfunc
|
||||
#endif
|
||||
.endr
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* RISC-V optimised DSP functions
|
||||
* Copyright (c) 2024 Niklas Haas
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/h264qpel.h"
|
||||
|
||||
#define DECL_QPEL_OPS(OP, SIZE, EXT) \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc00_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc10_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc20_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc30_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc01_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc11_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc21_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc31_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc02_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc12_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc22_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc32_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc03_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc13_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc23_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \
|
||||
void ff_ ## OP ## _h264_qpel ## SIZE ## _mc33_ ## EXT(uint8_t *dst, const uint8_t *src, ptrdiff_t stride);
|
||||
|
||||
DECL_QPEL_OPS(put, 16, rvv256)
|
||||
DECL_QPEL_OPS(put, 8, rvv256)
|
||||
// DECL_QPEL_OPS(put, 4, rvv256)
|
||||
|
||||
DECL_QPEL_OPS(avg, 16, rvv256)
|
||||
DECL_QPEL_OPS(avg, 8, rvv256)
|
||||
// DECL_QPEL_OPS(avg, 4, rvv256)
|
||||
|
||||
DECL_QPEL_OPS(put, 16, rvv)
|
||||
DECL_QPEL_OPS(put, 8, rvv)
|
||||
DECL_QPEL_OPS(put, 4, rvv)
|
||||
|
||||
DECL_QPEL_OPS(avg, 16, rvv)
|
||||
DECL_QPEL_OPS(avg, 8, rvv)
|
||||
DECL_QPEL_OPS(avg, 4, rvv)
|
||||
|
||||
#define SET_QPEL_FNS(OP, IDX, SIZE, EXT) \
|
||||
do { \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][ 0] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc00_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][ 1] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc10_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][ 2] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc20_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][ 3] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc30_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][ 4] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc01_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][ 5] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc11_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][ 6] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc21_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][ 7] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc31_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][ 8] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc02_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][ 9] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc12_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][10] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc22_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][11] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc32_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][12] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc03_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][13] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc13_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][14] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc23_ ## EXT; \
|
||||
c->OP ## _h264_qpel_pixels_tab[IDX][15] = ff_ ## OP ## _h264_qpel ## SIZE ## _mc33_ ## EXT; \
|
||||
} while (0)
|
||||
|
||||
av_cold void ff_h264qpel_init_riscv(H264QpelContext *c, int bit_depth)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
if (flags & AV_CPU_FLAG_RVV_I32) {
|
||||
const int vlen = 8 * ff_get_rv_vlenb();
|
||||
|
||||
switch (bit_depth) {
|
||||
case 8:
|
||||
if (vlen >= 256) {
|
||||
SET_QPEL_FNS(put, 0, 16, rvv256);
|
||||
SET_QPEL_FNS(put, 1, 8, rvv256);
|
||||
SET_QPEL_FNS(put, 2, 4, rvv);
|
||||
|
||||
SET_QPEL_FNS(avg, 0, 16, rvv256);
|
||||
SET_QPEL_FNS(avg, 1, 8, rvv256);
|
||||
SET_QPEL_FNS(avg, 2, 4, rvv);
|
||||
} else if (vlen >= 128) {
|
||||
SET_QPEL_FNS(put, 0, 16, rvv);
|
||||
SET_QPEL_FNS(put, 1, 8, rvv);
|
||||
SET_QPEL_FNS(put, 2, 4, rvv);
|
||||
|
||||
SET_QPEL_FNS(avg, 0, 16, rvv);
|
||||
SET_QPEL_FNS(avg, 1, 8, rvv);
|
||||
SET_QPEL_FNS(avg, 2, 4, rvv);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,464 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2024 Niklas Haas
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "libavutil/riscv/asm.S"
|
||||
|
||||
.macro lx rd, addr
|
||||
#if (__riscv_xlen == 32)
|
||||
lw \rd, \addr
|
||||
#elif (__riscv_xlen == 64)
|
||||
ld \rd, \addr
|
||||
#else
|
||||
lq \rd, \addr
|
||||
#endif
|
||||
.endm
|
||||
|
||||
.macro sx rd, addr
|
||||
#if (__riscv_xlen == 32)
|
||||
sw \rd, \addr
|
||||
#elif (__riscv_xlen == 64)
|
||||
sd \rd, \addr
|
||||
#else
|
||||
sq \rd, \addr
|
||||
#endif
|
||||
.endm
|
||||
|
||||
/* output is unclipped; clobbers v26-v31 plus t0 and t02 */
|
||||
.macro lowpass_h vdst, src
|
||||
addi t4, \src, 3
|
||||
lbu t5, 2(\src)
|
||||
vle8.v v31, (t4)
|
||||
lbu t4, 1(\src)
|
||||
vslide1up.vx v30, v31, t5
|
||||
lbu t5, 0(\src)
|
||||
vslide1up.vx v29, v30, t4
|
||||
lbu t4, -1(\src)
|
||||
vslide1up.vx v28, v29, t5
|
||||
lbu t5, -2(\src)
|
||||
vslide1up.vx v27, v28, t4
|
||||
vslide1up.vx v26, v27, t5
|
||||
vwaddu.vv \vdst, v26, v31
|
||||
vwmaccu.vx \vdst, t6, v28
|
||||
vwmaccu.vx \vdst, t6, v29
|
||||
vwmaccsu.vx \vdst, a7, v27
|
||||
vwmaccsu.vx \vdst, a7, v30
|
||||
.endm
|
||||
|
||||
/* output is unclipped */
|
||||
.macro lowpass_v vdst, vsrc0, vsrc1, vsrc2, vsrc3, vsrc4, vsrc5, signed=0
|
||||
.if \signed
|
||||
vwadd.vv \vdst, \vsrc0, \vsrc5
|
||||
vwmacc.vx \vdst, t6, \vsrc2
|
||||
vwmacc.vx \vdst, t6, \vsrc3
|
||||
vwmacc.vx \vdst, a7, \vsrc1
|
||||
vwmacc.vx \vdst, a7, \vsrc4
|
||||
.else
|
||||
vwaddu.vv \vdst, \vsrc0, \vsrc5
|
||||
vwmaccu.vx \vdst, t6, \vsrc2
|
||||
vwmaccu.vx \vdst, t6, \vsrc3
|
||||
vwmaccsu.vx \vdst, a7, \vsrc1
|
||||
vwmaccsu.vx \vdst, a7, \vsrc4
|
||||
.endif
|
||||
.endm
|
||||
|
||||
.macro qpel_mc00 op, dst, src, stride, size
|
||||
func ff_\op\()_h264_qpel_pixels, zve32x
|
||||
1: add t1, a2, a1
|
||||
add t2, a2, t1
|
||||
add t3, a2, t2
|
||||
vle8.v v0, (a1)
|
||||
vle8.v v1, (t1)
|
||||
vle8.v v2, (t2)
|
||||
vle8.v v3, (t3)
|
||||
addi a4, a4, -4
|
||||
add a1, a2, t3
|
||||
add t1, a2, a0
|
||||
add t2, a2, t1
|
||||
add t3, a2, t2
|
||||
.ifc \op, avg
|
||||
vle8.v v4, (a0)
|
||||
vle8.v v5, (t1)
|
||||
vle8.v v6, (t2)
|
||||
vle8.v v7, (t3)
|
||||
vaaddu.vv v0, v0, v4
|
||||
vaaddu.vv v1, v1, v5
|
||||
vaaddu.vv v2, v2, v6
|
||||
vaaddu.vv v3, v3, v7
|
||||
.endif
|
||||
vse8.v v0, (a0)
|
||||
vse8.v v1, (t1)
|
||||
vse8.v v2, (t2)
|
||||
vse8.v v3, (t3)
|
||||
add a0, a2, t3
|
||||
bnez a4, 1b
|
||||
jr t0
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
qpel_mc00 put, a0, a1, a2, a4
|
||||
qpel_mc00 avg, a0, a1, a2, a4
|
||||
|
||||
.macro qpel_lowpass op, ext, lmul, lmul2
|
||||
func ff_\op\()_h264_qpel_h_lowpass_\lmul\ext, zve32x
|
||||
1: add t1, a3, a1
|
||||
add t2, a3, t1
|
||||
add t3, a3, t2
|
||||
lowpass_h v0, a1
|
||||
lowpass_h v2, t1
|
||||
lowpass_h v4, t2
|
||||
lowpass_h v6, t3
|
||||
add a1, a3, t3
|
||||
addi a4, a4, -4
|
||||
vsetvli zero, zero, e16, \lmul2, ta, ma
|
||||
vmax.vx v0, v0, zero
|
||||
vmax.vx v2, v2, zero
|
||||
vmax.vx v4, v4, zero
|
||||
vmax.vx v6, v6, zero
|
||||
vsetvli zero, zero, e8, \lmul, ta, ma
|
||||
vnclipu.wi v0, v0, 5
|
||||
vnclipu.wi v2, v2, 5
|
||||
vnclipu.wi v4, v4, 5
|
||||
vnclipu.wi v6, v6, 5
|
||||
.ifc \ext, _l2
|
||||
add t1, a6, a5
|
||||
add t2, a6, t1
|
||||
add t3, a6, t2
|
||||
vle8.v v8, (a5)
|
||||
vle8.v v10, (t1)
|
||||
vle8.v v12, (t2)
|
||||
vle8.v v14, (t3)
|
||||
add a5, a2, t3
|
||||
vaaddu.vv v0, v0, v8
|
||||
vaaddu.vv v2, v2, v10
|
||||
vaaddu.vv v4, v4, v12
|
||||
vaaddu.vv v6, v6, v14
|
||||
.endif
|
||||
add t1, a2, a0
|
||||
add t2, a2, t1
|
||||
add t3, a2, t2
|
||||
.ifc \op, avg
|
||||
vle8.v v1, (a0)
|
||||
vle8.v v3, (t1)
|
||||
vle8.v v5, (t2)
|
||||
vle8.v v7, (t3)
|
||||
vaaddu.vv v0, v0, v1
|
||||
vaaddu.vv v2, v2, v3
|
||||
vaaddu.vv v4, v4, v5
|
||||
vaaddu.vv v6, v6, v7
|
||||
.endif
|
||||
vse8.v v0, (a0)
|
||||
vse8.v v2, (t1)
|
||||
vse8.v v4, (t2)
|
||||
vse8.v v6, (t3)
|
||||
add a0, a2, t3
|
||||
bnez a4, 1b
|
||||
jr t0
|
||||
endfunc
|
||||
|
||||
func ff_\op\()_h264_qpel_v_lowpass_\lmul\ext, zve32x
|
||||
sub t1, a1, a3
|
||||
sub t2, t1, a3
|
||||
vle8.v v2, (a1)
|
||||
vle8.v v1, (t1)
|
||||
vle8.v v0, (t2)
|
||||
add t1, a1, a3
|
||||
add t2, t1, a3
|
||||
add a1, t2, a3
|
||||
vle8.v v3, (t1)
|
||||
vle8.v v4, (t2)
|
||||
1: add t1, a3, a1
|
||||
add t2, a3, t1
|
||||
add t3, a3, t2
|
||||
vle8.v v5, (a1)
|
||||
vle8.v v6, (t1)
|
||||
vle8.v v7, (t2)
|
||||
vle8.v v8, (t3)
|
||||
add a1, a3, t3
|
||||
lowpass_v v24, v0, v1, v2, v3, v4, v5
|
||||
lowpass_v v26, v1, v2, v3, v4, v5, v6
|
||||
lowpass_v v28, v2, v3, v4, v5, v6, v7
|
||||
lowpass_v v30, v3, v4, v5, v6, v7, v8
|
||||
addi a4, a4, -4
|
||||
vsetvli zero, zero, e16, \lmul2, ta, ma
|
||||
vmax.vx v24, v24, zero
|
||||
vmax.vx v26, v26, zero
|
||||
vmax.vx v28, v28, zero
|
||||
vmax.vx v30, v30, zero
|
||||
vsetvli zero, zero, e8, \lmul, ta, ma
|
||||
vnclipu.wi v24, v24, 5
|
||||
vnclipu.wi v26, v26, 5
|
||||
vnclipu.wi v28, v28, 5
|
||||
vnclipu.wi v30, v30, 5
|
||||
.ifc \ext, _l2
|
||||
add t1, a6, a5
|
||||
add t2, a6, t1
|
||||
add t3, a6, t2
|
||||
vle8.v v9, (a5)
|
||||
vle8.v v10, (t1)
|
||||
vle8.v v11, (t2)
|
||||
vle8.v v12, (t3)
|
||||
add a5, a6, t3
|
||||
vaaddu.vv v24, v24, v9
|
||||
vaaddu.vv v26, v26, v10
|
||||
vaaddu.vv v28, v28, v11
|
||||
vaaddu.vv v30, v30, v12
|
||||
.endif
|
||||
add t1, a2, a0
|
||||
add t2, a2, t1
|
||||
add t3, a2, t2
|
||||
.ifc \op, avg
|
||||
vle8.v v9, (a0)
|
||||
vle8.v v10, (t1)
|
||||
vle8.v v11, (t2)
|
||||
vle8.v v12, (t3)
|
||||
vaaddu.vv v24, v24, v9
|
||||
vaaddu.vv v26, v26, v10
|
||||
vaaddu.vv v28, v28, v11
|
||||
vaaddu.vv v30, v30, v12
|
||||
.endif
|
||||
vse8.v v24, (a0)
|
||||
vse8.v v26, (t1)
|
||||
vse8.v v28, (t2)
|
||||
vse8.v v30, (t3)
|
||||
add a0, a2, t3
|
||||
vmv.v.v v0, v4
|
||||
vmv.v.v v1, v5
|
||||
vmv.v.v v2, v6
|
||||
vmv.v.v v3, v7
|
||||
vmv.v.v v4, v8
|
||||
bnez a4, 1b
|
||||
jr t0
|
||||
endfunc
|
||||
|
||||
func ff_\op\()_h264_qpel_hv_lowpass_\lmul\ext, zve32x
|
||||
sub t1, a1, a3
|
||||
sub t2, t1, a3
|
||||
lowpass_h v4, a1
|
||||
lowpass_h v2, t1
|
||||
lowpass_h v0, t2
|
||||
add t1, a1, a3
|
||||
add t2, t1, a3
|
||||
add a1, t2, a3
|
||||
lowpass_h v6, t1
|
||||
lowpass_h v8, t2
|
||||
1: add t1, a3, a1
|
||||
add t2, a3, t1
|
||||
add t3, a3, t2
|
||||
lowpass_h v10, a1
|
||||
lowpass_h v12, t1
|
||||
lowpass_h v14, t2
|
||||
lowpass_h v16, t3
|
||||
vsetvli zero, zero, e16, \lmul2, ta, ma
|
||||
addi a4, a4, -4
|
||||
lowpass_v v20, v0, v2, v4, v6, v8, v10, signed=1
|
||||
lowpass_v v24, v2, v4, v6, v8, v10, v12, signed=1
|
||||
lowpass_v v28, v4, v6, v8, v10, v12, v14, signed=1
|
||||
vnclip.wi v0, v20, 10
|
||||
lowpass_v v20, v6, v8, v10, v12, v14, v16, signed=1
|
||||
vnclip.wi v2, v24, 10
|
||||
vnclip.wi v4, v28, 10
|
||||
vnclip.wi v6, v20, 10
|
||||
vmax.vx v18, v0, zero
|
||||
vmax.vx v20, v2, zero
|
||||
vmax.vx v22, v4, zero
|
||||
vmax.vx v24, v6, zero
|
||||
vmv.v.v v0, v8
|
||||
vmv.v.v v2, v10
|
||||
vmv.v.v v4, v12
|
||||
vmv.v.v v6, v14
|
||||
vmv.v.v v8, v16
|
||||
add a1, a3, t3
|
||||
vsetvli zero, zero, e8, \lmul, ta, ma
|
||||
vnclipu.wi v18, v18, 0
|
||||
vnclipu.wi v20, v20, 0
|
||||
vnclipu.wi v22, v22, 0
|
||||
vnclipu.wi v24, v24, 0
|
||||
.ifc \ext, _l2
|
||||
add t1, a6, a5
|
||||
add t2, a6, t1
|
||||
add t3, a6, t2
|
||||
vle8.v v26, (a5)
|
||||
vle8.v v27, (t1)
|
||||
vle8.v v28, (t2)
|
||||
vle8.v v29, (t3)
|
||||
add a5, a6, t3
|
||||
vaaddu.vv v18, v18, v26
|
||||
vaaddu.vv v20, v20, v27
|
||||
vaaddu.vv v22, v22, v28
|
||||
vaaddu.vv v24, v24, v29
|
||||
.endif
|
||||
add t1, a2, a0
|
||||
add t2, a2, t1
|
||||
add t3, a2, t2
|
||||
.ifc \op, avg
|
||||
vle8.v v26, (a0)
|
||||
vle8.v v27, (t1)
|
||||
vle8.v v28, (t2)
|
||||
vle8.v v29, (t3)
|
||||
vaaddu.vv v18, v18, v26
|
||||
vaaddu.vv v20, v20, v27
|
||||
vaaddu.vv v22, v22, v28
|
||||
vaaddu.vv v24, v24, v29
|
||||
.endif
|
||||
vse8.v v18, (a0)
|
||||
vse8.v v20, (t1)
|
||||
vse8.v v22, (t2)
|
||||
vse8.v v24, (t3)
|
||||
add a0, a2, t3
|
||||
bnez a4, 1b
|
||||
jr t0
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
/* Note: We could possibly specialize for the width 8 / width 4 cases by
|
||||
loading 32 bit integers, but this makes the convolutions more complicated
|
||||
to implement, so it's not necessarily any faster. */
|
||||
|
||||
.macro h264_qpel lmul, lmul2
|
||||
qpel_lowpass put, , \lmul, \lmul2
|
||||
qpel_lowpass put, _l2, \lmul, \lmul2
|
||||
qpel_lowpass avg, , \lmul, \lmul2
|
||||
qpel_lowpass avg, _l2, \lmul, \lmul2
|
||||
.endm
|
||||
|
||||
h264_qpel m1, m2
|
||||
h264_qpel mf2, m1
|
||||
h264_qpel mf4, mf2
|
||||
h264_qpel mf8, mf4
|
||||
|
||||
.macro h264_qpel_1pass op, case, lmul, size, ext=rvv, dir, offset
|
||||
func ff_\op\()_h264_qpel\size\()_\case\()_\ext, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, \size, e8, \lmul, ta, ma
|
||||
csrwi vxrm, 0
|
||||
li a4, \size
|
||||
li t6, 20
|
||||
li a7, -5
|
||||
mv a3, a2
|
||||
mv t0, ra
|
||||
.ifnb \offset
|
||||
.ifc \dir, v
|
||||
add a5, a1, \offset
|
||||
.else
|
||||
addi a5, a1, \offset
|
||||
.endif
|
||||
mv a6, a3
|
||||
j ff_\op\()_h264_qpel_\dir\()_lowpass_\lmul\()_l2
|
||||
.else
|
||||
j ff_\op\()_h264_qpel_\dir\()_lowpass_\lmul\()
|
||||
.endif
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
.macro h264_qpel_2pass op, case, lmul, size, ext=rvv, dir1, dir2, off1=0, off2
|
||||
func ff_\op\()_h264_qpel\size\()_\case\()_\ext, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, \size, e8, \lmul, ta, ma
|
||||
csrwi vxrm, 0
|
||||
addi sp, sp, (-(__riscv_xlen >> 2))
|
||||
li a4, \size
|
||||
li t6, 20
|
||||
li a7, -5
|
||||
sx a0, 0(sp)
|
||||
sx a1, (__riscv_xlen >> 3)(sp)
|
||||
.ifc \off1, a2
|
||||
add a1, a1, \off1
|
||||
.elseif \off1
|
||||
addi a1, a1, \off1
|
||||
.endif
|
||||
mv a3, a2
|
||||
.ifc \op, avg
|
||||
// Use temporary array on stack for the first pass
|
||||
addi a0, sp, -(\size * \size)
|
||||
li a2, \size
|
||||
.endif
|
||||
jal t0, ff_put_h264_qpel_\dir1\()_lowpass_\lmul
|
||||
lx a0, 0(sp)
|
||||
lx a1, (__riscv_xlen >> 3)(sp)
|
||||
.ifc \op, put
|
||||
// Directly reuse the first pass output buffer
|
||||
mv a5, a0
|
||||
mv a6, a2
|
||||
.else
|
||||
addi a5, sp, -(\size * \size)
|
||||
li a6, \size
|
||||
mv a2, a3
|
||||
.endif
|
||||
.ifnb \off2
|
||||
addi a1, a1, \off2
|
||||
.endif
|
||||
li a4, \size
|
||||
mv t0, ra
|
||||
addi sp, sp, 16
|
||||
j ff_\op\()_h264_qpel_\dir2\()_lowpass_\lmul\()_l2
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
.macro ff_h264_qpel_fns op, lmul, size, ext=rvv
|
||||
func ff_\op\()_h264_qpel\size\()_mc00_\ext, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, \size, e8, \lmul, ta, ma
|
||||
csrwi vxrm, 0
|
||||
li a4, \size
|
||||
mv t0, ra
|
||||
j ff_\op\()_h264_qpel_pixels
|
||||
endfunc
|
||||
|
||||
h264_qpel_1pass \op, mc20, \lmul, \size, \ext, h
|
||||
h264_qpel_1pass \op, mc02, \lmul, \size, \ext, v
|
||||
h264_qpel_1pass \op, mc10, \lmul, \size, \ext, h, 0
|
||||
h264_qpel_1pass \op, mc30, \lmul, \size, \ext, h, 1
|
||||
h264_qpel_1pass \op, mc01, \lmul, \size, \ext, v, zero
|
||||
h264_qpel_1pass \op, mc03, \lmul, \size, \ext, v, a2
|
||||
h264_qpel_1pass \op, mc22, \lmul, \size, \ext, hv
|
||||
|
||||
h264_qpel_2pass \op, mc11, \lmul, \size, \ext, h, v
|
||||
h264_qpel_2pass \op, mc21, \lmul, \size, \ext, h, hv
|
||||
h264_qpel_2pass \op, mc12, \lmul, \size, \ext, v, hv
|
||||
h264_qpel_2pass \op, mc31, \lmul, \size, \ext, h, v, off2=1
|
||||
h264_qpel_2pass \op, mc13, \lmul, \size, \ext, h, v, a2
|
||||
h264_qpel_2pass \op, mc33, \lmul, \size, \ext, h, v, a2, 1
|
||||
h264_qpel_2pass \op, mc23, \lmul, \size, \ext, h, hv, a2
|
||||
h264_qpel_2pass \op, mc32, \lmul, \size, \ext, v, hv, 1
|
||||
.endm
|
||||
|
||||
ff_h264_qpel_fns put, mf2, 16, rvv256
|
||||
ff_h264_qpel_fns put, mf4, 8, rvv256
|
||||
/* ff_h264_qpel_fns put, mf8, 4, rvv256 */
|
||||
|
||||
ff_h264_qpel_fns avg, mf2, 16, rvv256
|
||||
ff_h264_qpel_fns avg, mf4, 8, rvv256
|
||||
/* ff_h264_qpel_fns avg, mf8, 4, rvv256 */
|
||||
|
||||
ff_h264_qpel_fns put, m1, 16, rvv
|
||||
ff_h264_qpel_fns put, mf2, 8, rvv
|
||||
ff_h264_qpel_fns put, mf4, 4, rvv
|
||||
|
||||
ff_h264_qpel_fns avg, m1, 16, rvv
|
||||
ff_h264_qpel_fns avg, mf2, 8, rvv
|
||||
ff_h264_qpel_fns avg, mf4, 4, rvv
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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"
|
||||
|
||||
.macro vsetvlstatic w, vlen, en, mn1, mn2, mn3, mn4, mn5, mn6, vta=ta
|
||||
.if \w == 2 && \vlen == 128
|
||||
vsetivli zero, \w, \en, \mn1, \vta, ma
|
||||
.elseif \w <= 4 && \vlen == 128
|
||||
vsetivli zero, \w, \en, \mn2, \vta, ma
|
||||
.elseif \w <= 8 && \vlen == 128
|
||||
vsetivli zero, \w, \en, \mn3, \vta, ma
|
||||
.elseif \w <= 16 && \vlen == 128
|
||||
vsetivli zero, \w, \en, \mn4, \vta, ma
|
||||
.elseif \w <= 32 && \vlen == 128
|
||||
li t0, \w
|
||||
vsetvli zero, t0, \en, \mn5, \vta, ma
|
||||
.elseif \w <= 4 && \vlen == 256
|
||||
vsetivli zero, \w, \en, \mn1, \vta, ma
|
||||
.elseif \w <= 8 && \vlen == 256
|
||||
vsetivli zero, \w, \en, \mn2, \vta, ma
|
||||
.elseif \w <= 16 && \vlen == 256
|
||||
vsetivli zero, \w, \en, \mn3, \vta, ma
|
||||
.elseif \w <= 32 && \vlen == 256
|
||||
li t0, \w
|
||||
vsetvli zero, t0, \en, \mn4, \vta, ma
|
||||
.elseif \w <= 64 && \vlen == 256
|
||||
li t0, \w
|
||||
vsetvli zero, t0, \en, \mn5, \vta, ma
|
||||
.else
|
||||
li t0, \w
|
||||
vsetvli zero, t0, \en, \mn6, \vta, ma
|
||||
.endif
|
||||
.endm
|
||||
|
||||
.macro vsetvlstatic8 w, vlen, vta
|
||||
vsetvlstatic \w, \vlen, e8, mf8, mf4, mf2, m1, m2, m4, \vta
|
||||
.endm
|
||||
|
||||
.macro vsetvlstatic16 w, vlen, vta
|
||||
vsetvlstatic \w, \vlen, e16, mf4, mf2, m1, m2, m4, m8, \vta
|
||||
.endm
|
||||
|
||||
.macro vsetvlstatic32 w, vlen, vta
|
||||
vsetvlstatic \w, \vlen, e32, mf2, m1, m2, m4, m8, m8, \vta
|
||||
.endm
|
||||
|
||||
.macro POW2_JMP_TABLE id, vlen
|
||||
const jmp_table_\id\vlen
|
||||
.4byte \id\()2\vlen\()f - jmp_table_\id\vlen
|
||||
.4byte \id\()4\vlen\()f - jmp_table_\id\vlen
|
||||
.4byte \id\()8\vlen\()f - jmp_table_\id\vlen
|
||||
.4byte \id\()16\vlen\()f - jmp_table_\id\vlen
|
||||
.4byte \id\()32\vlen\()f - jmp_table_\id\vlen
|
||||
.4byte \id\()64\vlen\()f - jmp_table_\id\vlen
|
||||
.4byte \id\()128\vlen\()f - jmp_table_\id\vlen
|
||||
endconst
|
||||
.endm
|
||||
|
||||
.macro POW2_J vlen, id, w
|
||||
clz t1, \w
|
||||
neg t1, t1
|
||||
lla t5, jmp_table_\id\vlen
|
||||
sh2add t1, t1, t5
|
||||
lw t1, ((__riscv_xlen-2)<<2)(t1)
|
||||
add t1, t1, t5
|
||||
jr t1
|
||||
.endm
|
||||
|
||||
.macro put_pixels w, vlen, id, MAX_PB_SIZE
|
||||
\id\w\vlen:
|
||||
vsetvlstatic8 \w, \vlen
|
||||
li t2, 1<<6
|
||||
.if \w == 128 && \vlen == 128
|
||||
1:
|
||||
addi t0, a1, 64
|
||||
addi t1, a0, 64*2
|
||||
vle8.v v0, (a1)
|
||||
vle8.v v16, (t0)
|
||||
vwmulu.vx v8, v0, t2
|
||||
vwmulu.vx v24, v16, t2
|
||||
vse16.v v8, (a0)
|
||||
vse16.v v24, (t1)
|
||||
add a1, a1, a2
|
||||
addi a3, a3, -1
|
||||
addi a0, a0, 128*2
|
||||
bnez a3, 1b
|
||||
.else
|
||||
1:
|
||||
vle8.v v0, (a1)
|
||||
vwmulu.vx v8, v0, t2
|
||||
vse16.v v8, (a0)
|
||||
add a1, a1, a2
|
||||
addi a3, a3, -1
|
||||
addi a0, a0, \MAX_PB_SIZE<<1
|
||||
bnez a3, 1b
|
||||
.endif
|
||||
ret
|
||||
.endm
|
||||
|
||||
.macro func_put_pixels vlen, MAX_PB_SIZE, name
|
||||
func ff_\name\()_put_pixels_8_rvv_\vlen\(), zve32x, zbb, zba
|
||||
lpad 0
|
||||
POW2_JMP_TABLE 3, \vlen
|
||||
POW2_J \vlen, 3, a6
|
||||
.irp w,2,4,8,16,32,64,128
|
||||
put_pixels \w, \vlen, 3, \MAX_PB_SIZE
|
||||
.endr
|
||||
endfunc
|
||||
.endm
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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 "libavcodec/riscv/h26x/asm.S"
|
||||
|
||||
func_put_pixels 256, 64, h2656
|
||||
func_put_pixels 128, 64, h2656
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_RISCV_H26X_H2656DSP_H
|
||||
#define AVCODEC_RISCV_H26X_H2656DSP_H
|
||||
|
||||
void ff_h2656_put_pixels_8_rvv_256(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride, int height, intptr_t mx, intptr_t my, int width);
|
||||
void ff_h2656_put_pixels_8_rvv_128(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride, int height, intptr_t mx, intptr_t my, int width);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
|
||||
#include "libavcodec/hevc/dsp.h"
|
||||
#include "libavcodec/riscv/h26x/h2656dsp.h"
|
||||
|
||||
#define RVV_FNASSIGN(member, v, h, fn, ext) \
|
||||
member[1][v][h] = ff_h2656_put_pixels_##8_##ext; \
|
||||
member[3][v][h] = ff_h2656_put_pixels_##8_##ext; \
|
||||
member[5][v][h] = ff_h2656_put_pixels_##8_##ext; \
|
||||
member[7][v][h] = ff_h2656_put_pixels_##8_##ext; \
|
||||
member[9][v][h] = ff_h2656_put_pixels_##8_##ext;
|
||||
|
||||
void ff_hevc_dsp_init_riscv(HEVCDSPContext *c, const int bit_depth)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
const int flags = av_get_cpu_flags();
|
||||
int vlenb;
|
||||
|
||||
if (!(flags & AV_CPU_FLAG_RVV_I32) || !(flags & AV_CPU_FLAG_RVB))
|
||||
return;
|
||||
|
||||
vlenb = ff_get_rv_vlenb();
|
||||
if (vlenb >= 32) {
|
||||
switch (bit_depth) {
|
||||
case 8:
|
||||
RVV_FNASSIGN(c->put_hevc_qpel, 0, 0, pel_pixels, rvv_256);
|
||||
RVV_FNASSIGN(c->put_hevc_epel, 0, 0, pel_pixels, rvv_256);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (vlenb >= 16) {
|
||||
switch (bit_depth) {
|
||||
case 8:
|
||||
RVV_FNASSIGN(c->put_hevc_qpel, 0, 0, pel_pixels, rvv_128);
|
||||
RVV_FNASSIGN(c->put_hevc_epel, 0, 0, pel_pixels, rvv_128);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/huffyuvdsp.h"
|
||||
|
||||
void ff_add_int16_rvv(uint16_t *dst, const uint16_t *src, unsigned m, int w);
|
||||
void ff_add_hfyu_left_pred_bgr32_rvv(uint8_t *dst, const uint8_t *src,
|
||||
intptr_t w, uint8_t *left);
|
||||
|
||||
av_cold void ff_huffyuvdsp_init_riscv(HuffYUVDSPContext *c,
|
||||
enum AVPixelFormat pix_fmt)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
|
||||
c->add_int16 = ff_add_int16_rvv;
|
||||
c->add_hfyu_left_pred_bgr32 = ff_add_hfyu_left_pred_bgr32_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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_add_int16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a3, e16, m8, ta, ma
|
||||
vle16.v v16, (a0)
|
||||
sub a3, a3, t0
|
||||
vle16.v v24, (a1)
|
||||
sh1add a1, t0, a1
|
||||
vadd.vv v16, v16, v24
|
||||
vand.vx v16, v16, a2
|
||||
vse16.v v16, (a0)
|
||||
sh1add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_add_hfyu_left_pred_bgr32_rvv, zve32x, b
|
||||
lpad 0
|
||||
vtype_ivli t1, 4, e8, ta, ma
|
||||
li t0, 4
|
||||
vsetvl zero, t0, t1
|
||||
vle8.v v8, (a3)
|
||||
sh2add a2, a2, a1
|
||||
1:
|
||||
vle8.v v0, (a1)
|
||||
vadd.vv v8, v8, v0
|
||||
addi a1, a1, 4
|
||||
vse8.v v8, (a0)
|
||||
addi a0, a0, 4
|
||||
bne a2, a1, 1b
|
||||
|
||||
vse8.v v8, (a3)
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright © 2022 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 <stdint.h>
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavcodec/idctdsp.h"
|
||||
|
||||
void ff_put_pixels_clamped_rvv(const int16_t *block, uint8_t *pixels,
|
||||
ptrdiff_t stride);
|
||||
void ff_put_signed_pixels_clamped_rvv(const int16_t *block, uint8_t *pixels,
|
||||
ptrdiff_t stride);
|
||||
void ff_add_pixels_clamped_rvv(const int16_t *block, uint8_t *pixels,
|
||||
ptrdiff_t stride);
|
||||
|
||||
av_cold void ff_idctdsp_init_riscv(IDCTDSPContext *c, AVCodecContext *avctx,
|
||||
unsigned high_bit_depth)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I64) && ff_rv_vlen_least(128)) {
|
||||
c->put_pixels_clamped = ff_put_pixels_clamped_rvv;
|
||||
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_rvv;
|
||||
c->add_pixels_clamped = ff_add_pixels_clamped_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright © 2022 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_put_pixels_clamped_rvv, zve64x
|
||||
lpad 0
|
||||
li t0, 8 * 8
|
||||
vsetvli zero, t0, e16, m8, ta, ma
|
||||
vle16.v v24, (a0)
|
||||
/* RVV only has signed-signed and unsigned-unsigned clipping.
|
||||
* We need two steps for signed-to-unsigned clipping. */
|
||||
vmax.vx v24, v24, zero
|
||||
vsetvli zero, zero, e8, m4, ta, ma
|
||||
vnclipu.wi v16, v24, 0
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
vsse64.v v16, (a1), a2
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_put_signed_pixels_clamped_rvv, zve64x
|
||||
lpad 0
|
||||
li t0, 8 * 8
|
||||
vsetvli zero, t0, e8, m4, ta, ma
|
||||
vle16.v v24, (a0)
|
||||
li t1, 128
|
||||
vnclip.wi v16, v24, 0
|
||||
vadd.vx v16, v16, t1
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
vsse64.v v16, (a1), a2
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_add_pixels_clamped_rvv, zve64x
|
||||
lpad 0
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
li t0, 8 * 8
|
||||
vlse64.v v16, (a1), a2
|
||||
vsetvli zero, t0, e8, m4, ta, ma
|
||||
vle16.v v24, (a0)
|
||||
vwaddu.wv v24, v24, v16
|
||||
vsetvli zero, zero, e16, m8, ta, ma
|
||||
vmax.vx v24, v24, zero
|
||||
vsetvli zero, zero, e8, m4, ta, ma
|
||||
vnclipu.wi v16, v24, 0
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
vsse64.v v16, (a1), a2
|
||||
ret
|
||||
endfunc
|
||||
@@ -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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/jpeg2000dsp.h"
|
||||
|
||||
void ff_ict_float_rvv(void *src0, void *src1, void *src2, int csize);
|
||||
void ff_rct_int_rvv(void *src0, void *src1, void *src2, int csize);
|
||||
|
||||
av_cold void ff_jpeg2000dsp_init_riscv(Jpeg2000DSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
|
||||
if (flags & AV_CPU_FLAG_RVV_F32)
|
||||
c->mct_decode[FF_DWT97] = ff_ict_float_rvv;
|
||||
c->mct_decode[FF_DWT53] = ff_rct_int_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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_ict_float_rvv, zve32f, zba
|
||||
lpad 0
|
||||
lla t0, ff_jpeg2000_f_ict_params
|
||||
flw ft0, 0(t0)
|
||||
flw ft1, 4(t0)
|
||||
flw ft2, 8(t0)
|
||||
flw ft3, 12(t0)
|
||||
1:
|
||||
vsetvli t0, a3, e32, m8, ta, ma
|
||||
vle32.v v8, (a0)
|
||||
sub a3, a3, t0
|
||||
vle32.v v16, (a1)
|
||||
vle32.v v24, (a2)
|
||||
vfmul.vf v0, v16, ft1
|
||||
vfmadd.vf v16, ft3, v8
|
||||
vfsub.vv v0, v8, v0
|
||||
vfmacc.vf v8, ft0, v24
|
||||
vfnmsac.vf v0, ft2, v24
|
||||
vse32.v v8, (a0)
|
||||
sh2add a0, t0, a0
|
||||
vse32.v v0, (a1)
|
||||
sh2add a1, t0, a1
|
||||
vse32.v v16, (a2)
|
||||
sh2add a2, t0, a2
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_rct_int_rvv, zve32x, zba
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a3, e32, m8, ta, ma
|
||||
vle32.v v16, (a1)
|
||||
sub a3, a3, t0
|
||||
vle32.v v24, (a2)
|
||||
vle32.v v8, (a0)
|
||||
vadd.vv v0, v16, v24
|
||||
vsra.vi v0, v0, 2
|
||||
vsub.vv v0, v8, v0
|
||||
vadd.vv v8, v0, v24
|
||||
vadd.vv v24, v0, v16
|
||||
vse32.v v8, (a0)
|
||||
sh2add a0, t0, a0
|
||||
vse32.v v0, (a1)
|
||||
sh2add a1, t0, a1
|
||||
vse32.v v24, (a2)
|
||||
sh2add a2, t0, a2
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/lossless_audiodsp.h"
|
||||
|
||||
int32_t ff_scalarproduct_and_madd_int16_rvv(int16_t *v1, const int16_t *v2,
|
||||
const int16_t *v3, int len,
|
||||
int mul);
|
||||
int32_t ff_scalarproduct_and_madd_int32_rvv(int16_t *v1, const int32_t *v2,
|
||||
const int16_t *v3, int len,
|
||||
int mul);
|
||||
|
||||
av_cold void ff_llauddsp_init_riscv(LLAudDSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
|
||||
c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_rvv;
|
||||
c->scalarproduct_and_madd_int32 = ff_scalarproduct_and_madd_int32_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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_scalarproduct_and_madd_int16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
vsetvli t0, zero, e32, m8, ta, ma
|
||||
vmv.v.x v0, zero
|
||||
1:
|
||||
vsetvli t0, a3, e16, m4, tu, ma
|
||||
vle16.v v8, (a0)
|
||||
sub a3, a3, t0
|
||||
vle16.v v16, (a1)
|
||||
sh1add a1, t0, a1
|
||||
vwmacc.vv v0, v8, v16
|
||||
vle16.v v24, (a2)
|
||||
sh1add a2, t0, a2
|
||||
vmacc.vx v8, a4, v24
|
||||
vse16.v v8, (a0)
|
||||
sh1add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
vsetvli t0, zero, e32, m8, ta, ma
|
||||
vmv.s.x v8, zero
|
||||
vredsum.vs v0, v0, v8
|
||||
vmv.x.s a0, v0
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_scalarproduct_and_madd_int32_rvv, zve32x, zba
|
||||
lpad 0
|
||||
vsetvli t0, zero, e32, m8, ta, ma
|
||||
vmv.v.x v0, zero
|
||||
1:
|
||||
vsetvli t0, a3, e32, m8, tu, ma
|
||||
vle16.v v8, (a0)
|
||||
sub a3, a3, t0
|
||||
vsext.vf2 v24, v8
|
||||
vle32.v v16, (a1)
|
||||
sh2add a1, t0, a1
|
||||
vmacc.vv v0, v16, v24
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vle16.v v24, (a2)
|
||||
sh1add a2, t0, a2
|
||||
vmacc.vx v8, a4, v24
|
||||
vse16.v v8, (a0)
|
||||
sh1add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
vsetvli t0, zero, e32, m8, ta, ma
|
||||
vmv.s.x v8, zero
|
||||
vredsum.vs v0, v0, v8
|
||||
vmv.x.s a0, v0
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/lossless_videodsp.h"
|
||||
|
||||
void ff_llvid_add_bytes_rvv(uint8_t *, uint8_t *src, ptrdiff_t w);
|
||||
|
||||
av_cold void ff_llviddsp_init_riscv(LLVidDSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_I32) {
|
||||
c->add_bytes = ff_llvid_add_bytes_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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_llvid_add_bytes_rvv, zve32x
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a2, e8, m8, ta, ma
|
||||
vle8.v v0, (a1)
|
||||
sub a2, a2, t0
|
||||
vle8.v v8, (a0)
|
||||
add a1, t0, a1
|
||||
vadd.vv v8, v0, v8
|
||||
vse8.v v8, (a0)
|
||||
add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/lossless_videoencdsp.h"
|
||||
|
||||
void ff_llvidenc_diff_bytes_rvv(uint8_t *dst, const uint8_t *src1,
|
||||
const uint8_t *src2, intptr_t w);
|
||||
|
||||
av_cold void ff_llvidencdsp_init_riscv(LLVidEncDSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_I32) {
|
||||
c->diff_bytes = ff_llvidenc_diff_bytes_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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_llvidenc_diff_bytes_rvv, zve32x
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a3, e8, m8, ta, ma
|
||||
vle8.v v0, (a1)
|
||||
sub a3, a3, t0
|
||||
vle8.v v8, (a2)
|
||||
add a1, t0, a1
|
||||
vsub.vv v8, v0, v8
|
||||
add a2, t0, a2
|
||||
vse8.v v8, (a0)
|
||||
add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright © 2022 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/lpc.h"
|
||||
|
||||
void ff_lpc_apply_welch_window_rvv(const int32_t *, ptrdiff_t, double *);
|
||||
void ff_lpc_compute_autocorr_rvv(const double *, ptrdiff_t, int, double *);
|
||||
|
||||
av_cold void ff_lpc_init_riscv(LPCContext *c)
|
||||
{
|
||||
#if HAVE_RVV && (__riscv_xlen >= 64)
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_F64) && (flags & AV_CPU_FLAG_RVB)) {
|
||||
c->lpc_apply_welch_window = ff_lpc_apply_welch_window_rvv;
|
||||
|
||||
if (ff_get_rv_vlenb() > c->max_order)
|
||||
c->lpc_compute_autocorr = ff_lpc_compute_autocorr_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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"
|
||||
|
||||
#if __riscv_xlen >= 64
|
||||
func ff_lpc_apply_welch_window_rvv, zve64d, zba
|
||||
lpad 0
|
||||
vsetvli t0, zero, e64, m8, ta, ma
|
||||
vid.v v0
|
||||
addi t2, a1, -1
|
||||
vfcvt.f.xu.v v0, v0
|
||||
li t3, 2
|
||||
fcvt.d.l ft2, t2
|
||||
srai t1, a1, 1
|
||||
fcvt.d.l ft3, t3
|
||||
li t4, 1
|
||||
fdiv.d ft0, ft3, ft2 # ft0 = c = 2. / (len - 1)
|
||||
fcvt.d.l fa1, t4 # fa1 = 1.
|
||||
fsub.d ft1, ft0, fa1
|
||||
vfrsub.vf v0, v0, ft1 # v0[i] = c - i - 1.
|
||||
1:
|
||||
vsetvli t0, t1, e64, m8, ta, ma
|
||||
vfmul.vv v16, v0, v0 # no fused multipy-add as v0 is reused
|
||||
sub t1, t1, t0
|
||||
vle32.v v8, (a0)
|
||||
fcvt.d.l ft2, t0
|
||||
vfrsub.vf v16, v16, fa1 # v16 = 1. - w * w
|
||||
sh2add a0, t0, a0
|
||||
vsetvli zero, zero, e32, m4, ta, ma
|
||||
vfwcvt.f.x.v v24, v8
|
||||
vsetvli zero, zero, e64, m8, ta, ma
|
||||
vfsub.vf v0, v0, ft2 # v0 -= vl
|
||||
vfmul.vv v8, v24, v16
|
||||
vse64.v v8, (a2)
|
||||
sh3add a2, t0, a2
|
||||
bnez t1, 1b
|
||||
|
||||
andi t1, a1, 1
|
||||
beqz t1, 2f
|
||||
|
||||
sd zero, (a2)
|
||||
addi a0, a0, 4
|
||||
addi a2, a2, 8
|
||||
2:
|
||||
vsetvli t0, zero, e64, m8, ta, ma
|
||||
vid.v v0
|
||||
srai t1, a1, 1
|
||||
vfcvt.f.xu.v v0, v0
|
||||
fcvt.d.l ft1, t1
|
||||
fsub.d ft1, ft0, ft1 # ft1 = c - (len / 2)
|
||||
vfadd.vf v0, v0, ft1 # v0[i] = c - (len / 2) + i
|
||||
3:
|
||||
vsetvli t0, t1, e64, m8, ta, ma
|
||||
vfmul.vv v16, v0, v0
|
||||
sub t1, t1, t0
|
||||
vle32.v v8, (a0)
|
||||
fcvt.d.l ft2, t0
|
||||
vfrsub.vf v16, v16, fa1 # v16 = 1. - w * w
|
||||
sh2add a0, t0, a0
|
||||
vsetvli zero, zero, e32, m4, ta, ma
|
||||
vfwcvt.f.x.v v24, v8
|
||||
vsetvli zero, zero, e64, m8, ta, ma
|
||||
vfadd.vf v0, v0, ft2 # v0 += vl
|
||||
vfmul.vv v8, v24, v16
|
||||
vse64.v v8, (a2)
|
||||
sh3add a2, t0, a2
|
||||
bnez t1, 3b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_lpc_compute_autocorr_rvv, zve64d, b
|
||||
lpad 0
|
||||
vtype_vli t1, a2, t2, e64, ta, ma, 1
|
||||
addi a2, a2, 1
|
||||
li t0, 1
|
||||
vsetvl zero, a2, t1
|
||||
fcvt.d.l ft0, t0
|
||||
vle64.v v0, (a0)
|
||||
sh3add a0, a2, a0 # data += lag
|
||||
vfmv.v.f v16, ft0
|
||||
bge a2, a1, 2f
|
||||
1:
|
||||
vfmv.f.s ft0, v0
|
||||
fld ft1, (a0) # ft1 = data[lag + i]
|
||||
vfmacc.vf v16, ft0, v0 # v16[j] += data[i] * data[i + j]
|
||||
addi a1, a1, -1
|
||||
vfslide1down.vf v0, v0, ft1
|
||||
addi a0, a0, 8
|
||||
bgt a1, a2, 1b # while (len > lag);
|
||||
2:
|
||||
vfmv.f.s ft0, v0
|
||||
vsetvli zero, a1, e64, m8, tu, ma
|
||||
vfmacc.vf v16, ft0, v0
|
||||
addi a1, a1, -1
|
||||
vslide1down.vx v0, v0, zero
|
||||
bnez a1, 2b # while (len > 0);
|
||||
|
||||
vsetvli zero, a2, e64, m8, ta, ma
|
||||
vse64.v v16, (a3)
|
||||
ret
|
||||
endfunc
|
||||
#endif
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/me_cmp.h"
|
||||
#include "libavcodec/mpegvideoenc.h"
|
||||
|
||||
int ff_pix_abs16_rvv(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
|
||||
ptrdiff_t stride, int h);
|
||||
int ff_pix_abs8_rvv(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
|
||||
ptrdiff_t stride, int h);
|
||||
int ff_pix_abs16_x2_rvv(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
|
||||
ptrdiff_t stride, int h);
|
||||
int ff_pix_abs8_x2_rvv(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
|
||||
ptrdiff_t stride, int h);
|
||||
int ff_pix_abs16_y2_rvv(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
|
||||
ptrdiff_t stride, int h);
|
||||
int ff_pix_abs8_y2_rvv(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
|
||||
ptrdiff_t stride, int h);
|
||||
|
||||
int ff_sse16_rvv(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
|
||||
ptrdiff_t stride, int h);
|
||||
int ff_sse8_rvv(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
|
||||
ptrdiff_t stride, int h);
|
||||
int ff_sse4_rvv(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
|
||||
ptrdiff_t stride, int h);
|
||||
|
||||
int ff_vsse16_rvv(MPVEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h);
|
||||
int ff_vsse8_rvv(MPVEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h);
|
||||
int ff_vsse_intra16_rvv(MPVEncContext *c, const uint8_t *s, const uint8_t *dummy, ptrdiff_t stride, int h);
|
||||
int ff_vsse_intra8_rvv(MPVEncContext *c, const uint8_t *s, const uint8_t *dummy, ptrdiff_t stride, int h);
|
||||
int ff_vsad16_rvv(MPVEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h);
|
||||
int ff_vsad8_rvv(MPVEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h);
|
||||
int ff_vsad_intra16_rvv(MPVEncContext *c, const uint8_t *s, const uint8_t *dummy, ptrdiff_t stride, int h);
|
||||
int ff_vsad_intra8_rvv(MPVEncContext *c, const uint8_t *s, const uint8_t *dummy, ptrdiff_t stride, int h);
|
||||
int ff_nsse16_rvv(int multiplier, const uint8_t *s1, const uint8_t *s2,
|
||||
ptrdiff_t stride, int h);
|
||||
int ff_nsse8_rvv(int multiplier, const uint8_t *s1, const uint8_t *s2,
|
||||
ptrdiff_t stride, int h);
|
||||
|
||||
static int nsse16_rvv_wrapper(MPVEncContext *c, const uint8_t *s1, const uint8_t *s2,
|
||||
ptrdiff_t stride, int h)
|
||||
{
|
||||
if (c)
|
||||
return ff_nsse16_rvv(c->c.avctx->nsse_weight, s1, s2, stride, h);
|
||||
else
|
||||
return ff_nsse16_rvv(8, s1, s2, stride, h);
|
||||
}
|
||||
|
||||
static int nsse8_rvv_wrapper(MPVEncContext *c, const uint8_t *s1, const uint8_t *s2,
|
||||
ptrdiff_t stride, int h)
|
||||
{
|
||||
if (c)
|
||||
return ff_nsse8_rvv(c->c.avctx->nsse_weight, s1, s2, stride, h);
|
||||
else
|
||||
return ff_nsse8_rvv(8, s1, s2, stride, h);
|
||||
}
|
||||
|
||||
av_cold void ff_me_cmp_init_riscv(MECmpContext *c, AVCodecContext *avctx)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_I32 && ff_rv_vlen_least(128)) {
|
||||
c->pix_abs[0][0] = ff_pix_abs16_rvv;
|
||||
c->sad[0] = ff_pix_abs16_rvv;
|
||||
c->pix_abs[1][0] = ff_pix_abs8_rvv;
|
||||
c->sad[1] = ff_pix_abs8_rvv;
|
||||
c->pix_abs[0][1] = ff_pix_abs16_x2_rvv;
|
||||
c->pix_abs[1][1] = ff_pix_abs8_x2_rvv;
|
||||
c->pix_abs[0][2] = ff_pix_abs16_y2_rvv;
|
||||
c->pix_abs[1][2] = ff_pix_abs8_y2_rvv;
|
||||
|
||||
c->sse[0] = ff_sse16_rvv;
|
||||
c->sse[1] = ff_sse8_rvv;
|
||||
c->sse[2] = ff_sse4_rvv;
|
||||
|
||||
c->vsse[0] = ff_vsse16_rvv;
|
||||
c->vsse[1] = ff_vsse8_rvv;
|
||||
c->vsse[4] = ff_vsse_intra16_rvv;
|
||||
c->vsse[5] = ff_vsse_intra8_rvv;
|
||||
c->vsad[0] = ff_vsad16_rvv;
|
||||
c->vsad[1] = ff_vsad8_rvv;
|
||||
c->vsad[4] = ff_vsad_intra16_rvv;
|
||||
c->vsad[5] = ff_vsad_intra8_rvv;
|
||||
|
||||
c->nsse[0] = nsse16_rvv_wrapper;
|
||||
c->nsse[1] = nsse8_rvv_wrapper;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,544 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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"
|
||||
|
||||
.macro pix_abs_ret
|
||||
vsetivli zero, 1, e32, m1, ta, ma
|
||||
vmv.x.s a0, v0
|
||||
ret
|
||||
.endm
|
||||
|
||||
func ff_pix_abs16_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, 1, e32, m1, ta, ma
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetivli zero, 16, e8, m1, tu, ma
|
||||
vle8.v v4, (a1)
|
||||
vle8.v v12, (a2)
|
||||
addi a4, a4, -1
|
||||
vwsubu.vv v16, v4, v12
|
||||
add a1, a1, a3
|
||||
vwsubu.vv v20, v12, v4
|
||||
vsetvli zero, zero, e16, m2, tu, ma
|
||||
vmax.vv v16, v16, v20
|
||||
add a2, a2, a3
|
||||
vwredsum.vs v0, v16, v0
|
||||
bnez a4, 1b
|
||||
|
||||
pix_abs_ret
|
||||
endfunc
|
||||
|
||||
func ff_pix_abs8_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, 1, e32, m1, ta, ma
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetivli zero, 8, e8, mf2, tu, ma
|
||||
vle8.v v4, (a1)
|
||||
vle8.v v12, (a2)
|
||||
addi a4, a4, -1
|
||||
vwsubu.vv v16, v4, v12
|
||||
add a1, a1, a3
|
||||
vwsubu.vv v20, v12, v4
|
||||
vsetvli zero, zero, e16, m1, tu, ma
|
||||
vmax.vv v16, v16, v20
|
||||
add a2, a2, a3
|
||||
vwredsum.vs v0, v16, v0
|
||||
bnez a4, 1b
|
||||
|
||||
pix_abs_ret
|
||||
endfunc
|
||||
|
||||
func ff_pix_abs16_x2_rvv, zve32x
|
||||
lpad 0
|
||||
csrwi vxrm, 0
|
||||
vsetivli zero, 1, e32, m1, ta, ma
|
||||
li t5, 1
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetivli zero, 17, e8, m2, tu, ma
|
||||
vle8.v v12, (a2)
|
||||
addi a4, a4, -1
|
||||
vslide1down.vx v24, v12, t5
|
||||
vsetivli zero, 16, e8, m1, tu, ma
|
||||
vle8.v v4, (a1)
|
||||
vaaddu.vv v12, v12, v24
|
||||
vwsubu.vv v16, v4, v12
|
||||
add a1, a1, a3
|
||||
vwsubu.vv v20, v12, v4
|
||||
vsetvli zero, zero, e16, m2, tu, ma
|
||||
vmax.vv v16, v16, v20
|
||||
add a2, a2, a3
|
||||
vwredsum.vs v0, v16, v0
|
||||
bnez a4, 1b
|
||||
|
||||
pix_abs_ret
|
||||
endfunc
|
||||
|
||||
func ff_pix_abs8_x2_rvv, zve32x
|
||||
lpad 0
|
||||
csrwi vxrm, 0
|
||||
vsetivli zero, 1, e32, m1, ta, ma
|
||||
li t5, 1
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetivli zero, 9, e8, m1, tu, ma
|
||||
vle8.v v12, (a2)
|
||||
addi a4, a4, -1
|
||||
vslide1down.vx v24, v12, t5
|
||||
vsetivli zero, 8, e8, mf2, tu, ma
|
||||
vle8.v v4, (a1)
|
||||
vaaddu.vv v12, v12, v24
|
||||
vwsubu.vv v16, v4, v12
|
||||
add a1, a1, a3
|
||||
vwsubu.vv v20, v12, v4
|
||||
vsetvli zero, zero, e16, m1, tu, ma
|
||||
vmax.vv v16, v16, v20
|
||||
add a2, a2, a3
|
||||
vwredsum.vs v0, v16, v0
|
||||
bnez a4, 1b
|
||||
|
||||
pix_abs_ret
|
||||
endfunc
|
||||
|
||||
func ff_pix_abs16_y2_rvv, zve32x
|
||||
lpad 0
|
||||
csrwi vxrm, 0
|
||||
vsetivli zero, 1, e32, m1, ta, ma
|
||||
add t1, a2, a3
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetivli zero, 16, e8, m1, tu, ma
|
||||
vle8.v v12, (a2)
|
||||
vle8.v v24, (t1)
|
||||
addi a4, a4, -1
|
||||
vle8.v v4, (a1)
|
||||
vaaddu.vv v12, v12, v24
|
||||
vwsubu.vv v16, v4, v12
|
||||
vwsubu.vv v20, v12, v4
|
||||
add a1, a1, a3
|
||||
vsetvli zero, zero, e16, m2, tu, ma
|
||||
add a2, a2, a3
|
||||
vmax.vv v16, v16, v20
|
||||
add t1, t1, a3
|
||||
vwredsum.vs v0, v16, v0
|
||||
bnez a4, 1b
|
||||
|
||||
pix_abs_ret
|
||||
endfunc
|
||||
|
||||
func ff_pix_abs8_y2_rvv, zve32x
|
||||
lpad 0
|
||||
csrwi vxrm, 0
|
||||
vsetivli zero, 1, e32, m1, ta, ma
|
||||
add t1, a2, a3
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetivli zero, 8, e8, mf2, tu, ma
|
||||
vle8.v v12, (a2)
|
||||
vle8.v v24, (t1)
|
||||
addi a4, a4, -1
|
||||
vle8.v v4, (a1)
|
||||
vaaddu.vv v12, v12, v24
|
||||
vwsubu.vv v16, v4, v12
|
||||
vwsubu.vv v20, v12, v4
|
||||
add a1, a1, a3
|
||||
vsetvli zero, zero, e16, m1, tu, ma
|
||||
add a2, a2, a3
|
||||
vmax.vv v16, v16, v20
|
||||
add t1, t1, a3
|
||||
vwredsum.vs v0, v16, v0
|
||||
bnez a4, 1b
|
||||
|
||||
pix_abs_ret
|
||||
endfunc
|
||||
|
||||
func ff_sse16_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli t0, 16, e32, m4, ta, ma
|
||||
vmv.v.x v24, zero
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetvli zero, zero, e8, m1, tu, ma
|
||||
vle8.v v4, (a1)
|
||||
vle8.v v12, (a2)
|
||||
addi a4, a4, -1
|
||||
vwsubu.vv v16, v4, v12
|
||||
vsetvli zero, zero, e16, m2, tu, ma
|
||||
vwmacc.vv v24, v16, v16
|
||||
add a1, a1, a3
|
||||
add a2, a2, a3
|
||||
bnez a4, 1b
|
||||
|
||||
vsetvli zero, zero, e32, m4, tu, ma
|
||||
vredsum.vs v0, v24, v0
|
||||
vmv.x.s a0, v0
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_sse8_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli t0, 8, e32, m2, ta, ma
|
||||
vmv.v.x v24, zero
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetvli zero, zero, e8, mf2, tu, ma
|
||||
vle8.v v4, (a1)
|
||||
vle8.v v12, (a2)
|
||||
addi a4, a4, -1
|
||||
vwsubu.vv v16, v4, v12
|
||||
vsetvli zero, zero, e16, m1, tu, ma
|
||||
vwmacc.vv v24, v16, v16
|
||||
add a1, a1, a3
|
||||
add a2, a2, a3
|
||||
bnez a4, 1b
|
||||
|
||||
vsetvli zero, zero, e32, m2, tu, ma
|
||||
vredsum.vs v0, v24, v0
|
||||
vmv.x.s a0, v0
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_sse4_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli t0, 4, e32, m1, ta, ma
|
||||
vmv.v.x v24, zero
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetvli zero, zero, e8, mf4, tu, ma
|
||||
vle8.v v4, (a1)
|
||||
vle8.v v12, (a2)
|
||||
addi a4, a4, -1
|
||||
vwsubu.vv v16, v4, v12
|
||||
vsetvli zero, zero, e16, mf2, tu, ma
|
||||
vwmacc.vv v24, v16, v16
|
||||
add a1, a1, a3
|
||||
add a2, a2, a3
|
||||
bnez a4, 1b
|
||||
|
||||
vsetvli zero, zero, e32, m1, tu, ma
|
||||
vredsum.vs v0, v24, v0
|
||||
vmv.x.s a0, v0
|
||||
ret
|
||||
endfunc
|
||||
|
||||
.macro vabsaddu dst src tmp
|
||||
vneg.v \tmp, \src
|
||||
vmax.vv \tmp, \src, \tmp
|
||||
vwaddu.wv \dst, \dst, \tmp
|
||||
.endm
|
||||
|
||||
.macro vsad_vsse16 type
|
||||
lpad 0
|
||||
vsetivli t0, 16, e32, m4, ta, ma
|
||||
addi a4, a4, -1
|
||||
add t1, a1, a3
|
||||
add t2, a2, a3
|
||||
vmv.v.x v24, zero
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetvli zero, zero, e8, m1, tu, ma
|
||||
vle8.v v4, (a1)
|
||||
vle8.v v8, (t1)
|
||||
vle8.v v12, (a2)
|
||||
vle8.v v16, (t2)
|
||||
addi a4, a4, -1
|
||||
vwsubu.vv v28, v4, v12
|
||||
vwsubu.wv v12, v28, v8
|
||||
vwaddu.wv v28, v12, v16
|
||||
vsetvli zero, zero, e16, m2, tu, ma
|
||||
|
||||
.ifc \type,abs
|
||||
vabsaddu v24, v28, v12
|
||||
.endif
|
||||
.ifc \type,square
|
||||
vwmacc.vv v24, v28, v28
|
||||
.endif
|
||||
|
||||
add a1, a1, a3
|
||||
add a2, a2, a3
|
||||
add t1, t1, a3
|
||||
add t2, t2, a3
|
||||
bnez a4, 1b
|
||||
|
||||
vsetvli zero, zero, e32, m4, tu, ma
|
||||
vredsum.vs v0, v24, v0
|
||||
vmv.x.s a0, v0
|
||||
ret
|
||||
.endm
|
||||
|
||||
.macro vsad_vsse8 type
|
||||
lpad 0
|
||||
vsetivli t0, 8, e32, m2, ta, ma
|
||||
addi a4, a4, -1
|
||||
add t1, a1, a3
|
||||
add t2, a2, a3
|
||||
vmv.v.x v24, zero
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetvli zero, zero, e8, mf2, tu, ma
|
||||
vle8.v v4, (a1)
|
||||
vle8.v v8, (t1)
|
||||
vle8.v v12, (a2)
|
||||
vle8.v v16, (t2)
|
||||
addi a4, a4, -1
|
||||
vwsubu.vv v28, v4, v12
|
||||
vwsubu.wv v12, v28, v8
|
||||
vwaddu.wv v28, v12, v16
|
||||
vsetvli zero, zero, e16, m1, tu, ma
|
||||
|
||||
.ifc \type,abs
|
||||
vabsaddu v24, v28, v12
|
||||
.endif
|
||||
.ifc \type,square
|
||||
vwmacc.vv v24, v28, v28
|
||||
.endif
|
||||
|
||||
add a1, a1, a3
|
||||
add a2, a2, a3
|
||||
add t1, t1, a3
|
||||
add t2, t2, a3
|
||||
bnez a4, 1b
|
||||
|
||||
vsetvli zero, zero, e32, m2, tu, ma
|
||||
vredsum.vs v0, v24, v0
|
||||
vmv.x.s a0, v0
|
||||
ret
|
||||
.endm
|
||||
|
||||
.macro vsad_vsse_intra16 type
|
||||
lpad 0
|
||||
vsetivli t0, 16, e32, m4, ta, ma
|
||||
addi a4, a4, -1
|
||||
add t1, a1, a3
|
||||
vmv.v.x v24, zero
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetvli zero, zero, e8, m1, tu, ma
|
||||
vle8.v v4, (a1)
|
||||
vle8.v v12, (t1)
|
||||
addi a4, a4, -1
|
||||
vwsubu.vv v16, v4, v12
|
||||
vsetvli zero, zero, e16, m2, tu, ma
|
||||
|
||||
.ifc \type,abs
|
||||
vabsaddu v24, v16, v12
|
||||
.endif
|
||||
.ifc \type,square
|
||||
vwmacc.vv v24, v16, v16
|
||||
.endif
|
||||
|
||||
add a1, a1, a3
|
||||
add t1, t1, a3
|
||||
bnez a4, 1b
|
||||
|
||||
vsetvli zero, zero, e32, m4, tu, ma
|
||||
vredsum.vs v0, v24, v0
|
||||
vmv.x.s a0, v0
|
||||
ret
|
||||
.endm
|
||||
|
||||
.macro vsad_vsse_intra8 type
|
||||
lpad 0
|
||||
vsetivli t0, 8, e32, m2, ta, ma
|
||||
addi a4, a4, -1
|
||||
add t1, a1, a3
|
||||
vmv.v.x v24, zero
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetvli zero, zero, e8, mf2, tu, ma
|
||||
vle8.v v4, (a1)
|
||||
vle8.v v12, (t1)
|
||||
addi a4, a4, -1
|
||||
vwsubu.vv v16, v4, v12
|
||||
vsetvli zero, zero, e16, m1, tu, ma
|
||||
|
||||
.ifc \type,abs
|
||||
vabsaddu v24, v16, v12
|
||||
.endif
|
||||
.ifc \type,square
|
||||
vwmacc.vv v24, v16, v16
|
||||
.endif
|
||||
|
||||
add a1, a1, a3
|
||||
add t1, t1, a3
|
||||
bnez a4, 1b
|
||||
|
||||
vsetvli zero, zero, e32, m2, tu, ma
|
||||
vredsum.vs v0, v24, v0
|
||||
vmv.x.s a0, v0
|
||||
ret
|
||||
.endm
|
||||
|
||||
func ff_vsse16_rvv, zve32x
|
||||
vsad_vsse16 square
|
||||
endfunc
|
||||
|
||||
func ff_vsse8_rvv, zve32x
|
||||
vsad_vsse8 square
|
||||
endfunc
|
||||
|
||||
func ff_vsse_intra16_rvv, zve32x
|
||||
vsad_vsse_intra16 square
|
||||
endfunc
|
||||
|
||||
func ff_vsse_intra8_rvv, zve32x
|
||||
vsad_vsse_intra8 square
|
||||
endfunc
|
||||
|
||||
func ff_vsad16_rvv, zve32x
|
||||
vsad_vsse16 abs
|
||||
endfunc
|
||||
|
||||
func ff_vsad8_rvv, zve32x
|
||||
vsad_vsse8 abs
|
||||
endfunc
|
||||
|
||||
func ff_vsad_intra16_rvv, zve32x
|
||||
vsad_vsse_intra16 abs
|
||||
endfunc
|
||||
|
||||
func ff_vsad_intra8_rvv, zve32x
|
||||
vsad_vsse_intra8 abs
|
||||
endfunc
|
||||
|
||||
func ff_nsse16_rvv, zve32x
|
||||
lpad 0
|
||||
|
||||
.macro squarediff16
|
||||
vsetivli zero, 16, e8, m1, tu, ma
|
||||
vle8.v v4, (a1)
|
||||
vle8.v v12, (a2)
|
||||
vwsubu.vv v16, v4, v12
|
||||
vsetvli zero, zero, e16, m2, tu, ma
|
||||
vwmacc.vv v24, v16, v16
|
||||
.endm
|
||||
|
||||
.macro gradiff16 srcx srcv
|
||||
vsetivli zero, 16, e8, m1, tu, ma
|
||||
vle8.v v8, (\srcx)
|
||||
vslide1down.vx v0, \srcv, t5
|
||||
vslide1down.vx v16, v8, t5
|
||||
vwsubu.vv v20, \srcv, v0
|
||||
vwsubu.wv v0, v20, v8
|
||||
vwaddu.wv v20, v0, v16
|
||||
vsetivli zero, 15, e16, m2, tu, ma
|
||||
vneg.v v0, v20
|
||||
vmax.vv v0, v20, v0
|
||||
.endm
|
||||
|
||||
csrwi vxrm, 0
|
||||
vsetivli t0, 16, e32, m4, ta, ma
|
||||
addi a4, a4, -1
|
||||
li t5, 1
|
||||
vmv.v.x v24, zero
|
||||
vmv.v.x v28, zero
|
||||
1:
|
||||
add t1, a1, a3
|
||||
add t2, a2, a3
|
||||
addi a4, a4, -1
|
||||
squarediff16
|
||||
gradiff16 t1, v4
|
||||
vwaddu.wv v28, v28, v0
|
||||
gradiff16 t2, v12
|
||||
vwsubu.wv v28, v28, v0
|
||||
add a1, a1, a3
|
||||
add a2, a2, a3
|
||||
bnez a4, 1b
|
||||
|
||||
squarediff16
|
||||
vsetivli zero, 16, e32, m4, tu, ma
|
||||
vmv.s.x v0, zero
|
||||
vmv.s.x v4, zero
|
||||
vredsum.vs v0, v24, v0
|
||||
vredsum.vs v4, v28, v4
|
||||
vmv.x.s t1, v0
|
||||
vmv.x.s t2, v4
|
||||
srai t3, t2, 31
|
||||
xor t2, t3, t2
|
||||
sub t2, t2, t3
|
||||
mul t2, t2, a0
|
||||
add a0, t2, t1
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_nsse8_rvv, zve32x
|
||||
lpad 0
|
||||
|
||||
.macro squarediff8
|
||||
vsetivli zero, 8, e8, mf2, tu, ma
|
||||
vle8.v v4, (a1)
|
||||
vle8.v v12, (a2)
|
||||
vwsubu.vv v16, v4, v12
|
||||
vsetvli zero, zero, e16, m1, tu, ma
|
||||
vwmacc.vv v24, v16, v16
|
||||
.endm
|
||||
|
||||
.macro gradiff8 srcx srcv
|
||||
vsetivli zero, 8, e8, mf2, tu, ma
|
||||
vle8.v v8, (\srcx)
|
||||
vslide1down.vx v0, \srcv, t5
|
||||
vslide1down.vx v16, v8, t5
|
||||
vwsubu.vv v20, \srcv, v0
|
||||
vwsubu.wv v0, v20, v8
|
||||
vwaddu.wv v20, v0, v16
|
||||
vsetivli zero, 7, e16, m1, tu, ma
|
||||
vneg.v v0, v20
|
||||
vmax.vv v0, v20, v0
|
||||
.endm
|
||||
|
||||
csrwi vxrm, 0
|
||||
vsetivli t0, 8, e32, m2, ta, ma
|
||||
addi a4, a4, -1
|
||||
li t5, 1
|
||||
vmv.v.x v24, zero
|
||||
vmv.v.x v28, zero
|
||||
1:
|
||||
add t1, a1, a3
|
||||
add t2, a2, a3
|
||||
addi a4, a4, -1
|
||||
squarediff8
|
||||
gradiff8 t1, v4
|
||||
vwaddu.wv v28, v28, v0
|
||||
gradiff8 t2, v12
|
||||
vwsubu.wv v28, v28, v0
|
||||
add a1, a1, a3
|
||||
add a2, a2, a3
|
||||
bnez a4, 1b
|
||||
|
||||
squarediff8
|
||||
vsetivli zero, 8, e32, m2, tu, ma
|
||||
vmv.s.x v0, zero
|
||||
vmv.s.x v4, zero
|
||||
vredsum.vs v0, v24, v0
|
||||
vredsum.vs v4, v28, v4
|
||||
vmv.x.s t1, v0
|
||||
vmv.x.s t2, v4
|
||||
srai t3, t2, 31
|
||||
xor t2, t3, t2
|
||||
sub t2, t2, t3
|
||||
mul t2, t2, a0
|
||||
add a0, t2, t1
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright © 2024 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 <stdint.h>
|
||||
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/mpegvideoencdsp.h"
|
||||
|
||||
int ff_try_8x8basis_rvv(const int16_t rem[64], const int16_t weight[64],
|
||||
const int16_t basis[16], int scale);
|
||||
void ff_add_8x8basis_rvv(int16_t rem[64], const int16_t basis[16], int scale);
|
||||
int ff_pix_sum_rvv(const uint8_t *pix, ptrdiff_t line_size);
|
||||
int ff_pix_norm1_rvv(const uint8_t *pix, ptrdiff_t line_size);
|
||||
|
||||
av_cold void ff_mpegvideoencdsp_init_riscv(MpegvideoEncDSPContext *c,
|
||||
AVCodecContext *avctx)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_I32) {
|
||||
if (flags & AV_CPU_FLAG_RVB) {
|
||||
c->try_8x8basis = ff_try_8x8basis_rvv;
|
||||
c->add_8x8basis = ff_add_8x8basis_rvv;
|
||||
}
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_I64) {
|
||||
if ((flags & AV_CPU_FLAG_RVB) && ff_rv_vlen_least(128))
|
||||
c->pix_sum = ff_pix_sum_rvv;
|
||||
c->pix_norm1 = ff_pix_norm1_rvv;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright © 2024 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"
|
||||
|
||||
.equ BASIS_SHIFT, 16
|
||||
.equ RECON_SHIFT, 6
|
||||
|
||||
func ff_try_8x8basis_rvv, zve32x, b
|
||||
li t1, 64
|
||||
csrwi vxrm, 0
|
||||
vsetvli t0, t1, e32, m8, ta, ma
|
||||
vmv.v.x v24, zero
|
||||
vmv.s.x v1, zero
|
||||
1:
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vle16.v v4, (a2)
|
||||
sub t1, t1, t0
|
||||
vwmul.vx v16, v4, a3
|
||||
sh1add a2, t0, a2
|
||||
vle16.v v8, (a0)
|
||||
sh1add a0, t0, a0
|
||||
vnclip.wi v4, v16, BASIS_SHIFT - RECON_SHIFT
|
||||
vle16.v v12, (a1)
|
||||
sh1add a1, t0, a1
|
||||
vadd.vv v4, v8, v4
|
||||
vsra.vi v4, v4, RECON_SHIFT
|
||||
vwmul.vv v16, v12, v4
|
||||
vsetvli zero, zero, e32, m8, ta, ma
|
||||
vmul.vv v16, v16, v16
|
||||
vsra.vi v16, v16, 4
|
||||
vadd.vv v24, v24, v16
|
||||
bnez t1, 1b
|
||||
|
||||
vredsum.vs v1, v24, v1
|
||||
vmv.x.s a0, v1
|
||||
srai a0, a0, 2
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_add_8x8basis_rvv, zve32x, b
|
||||
li t1, 64
|
||||
csrwi vxrm, 0
|
||||
1:
|
||||
vsetvli t0, t1, e16, m4, ta, ma
|
||||
vle16.v v4, (a1)
|
||||
sub t1, t1, t0
|
||||
vwmul.vx v16, v4, a2
|
||||
sh1add a1, t0, a1
|
||||
vle16.v v8, (a0)
|
||||
vnclip.wi v4, v16, BASIS_SHIFT - RECON_SHIFT
|
||||
vadd.vv v4, v8, v4
|
||||
vse16.v v4, (a0)
|
||||
sh1add a0, t0, a0
|
||||
bnez t1, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_pix_sum_rvv, zve64x, b
|
||||
lpad 0
|
||||
vsetivli t0, 16, e16, m1, ta, ma
|
||||
slli t1, t0, 3
|
||||
vlsseg2e64.v v8, (a0), a1 # poor man's vlse128.v
|
||||
li t2, 16
|
||||
vmv.s.x v1, zero
|
||||
vsetvli zero, t1, e8, m4, ta, ma
|
||||
vwaddu.vv v16, v8, v12
|
||||
beq t0, t2, 2f # VLEN >= 256
|
||||
1:
|
||||
sh3add a0, a1, a0
|
||||
vsetivli zero, 8, e16, m1, ta, ma
|
||||
vlsseg2e64.v v8, (a0), a1
|
||||
vsetvli zero, t1, e8, m4, ta, ma
|
||||
vwaddu.wv v16, v16, v8
|
||||
vwaddu.wv v16, v16, v12
|
||||
2:
|
||||
vsetvli zero, zero, e16, m8, ta, ma
|
||||
vredsum.vs v1, v16, v1
|
||||
vmv.x.s a0, v1
|
||||
zext.h a0, a0
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_pix_norm1_rvv, zve64x
|
||||
lpad 0
|
||||
li t1, 16
|
||||
vsetvli t0, zero, e32, m8, ta, ma
|
||||
vmv.v.x v16, zero
|
||||
vmv.s.x v1, zero
|
||||
1:
|
||||
vsetvli t0, t1, e64, m2, ta, ma
|
||||
vlsseg2e64.v v8, (a0), a1
|
||||
slli t2, t0, 3
|
||||
vsetvli zero, t2, e8, m2, ta, ma
|
||||
vwmulu.vv v24, v8, v8
|
||||
sub t1, t1, t0
|
||||
vwmulu.vv v28, v10, v10
|
||||
mul t3, a1, t0
|
||||
vsetvli zero, zero, e16, m4, tu, ma
|
||||
vwaddu.wv v16, v16, v24
|
||||
add a0, t3, a0
|
||||
vwaddu.wv v16, v16, v28
|
||||
bnez t1, 1b
|
||||
|
||||
vsetvli zero, zero, e32, m8, ta, ma
|
||||
vredsum.vs v1, v16, v1
|
||||
vmv.x.s a0, v1
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright © 2022 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/opus/dsp.h"
|
||||
|
||||
void ff_opus_postfilter_rvv(float *data, int period, float *g, int len);
|
||||
|
||||
av_cold void ff_opus_dsp_init_riscv(OpusDSP *d)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_F32) && (flags & AV_CPU_FLAG_RVB))
|
||||
d->postfilter = ff_opus_postfilter_rvv;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright © 2022 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_opus_postfilter_rvv, zve32f, b
|
||||
lpad 0
|
||||
flw fa0, 0(a2) // g0
|
||||
slli t1, a1, 2
|
||||
flw fa1, 4(a2) // g1
|
||||
sub t0, a0, t1
|
||||
flw fa2, 8(a2) // g2
|
||||
addi t1, t0, -2 * 4 // data - (period + 2) = initial &x4
|
||||
vsetivli zero, 4, e32, m4, ta, ma
|
||||
addi t0, t0, 2 * 4 // data - (period - 2) = initial &x0
|
||||
vle32.v v16, (t1)
|
||||
addi t3, a1, -2 // maximum parallelism w/o stepping our tail
|
||||
1:
|
||||
vslidedown.vi v8, v16, 2
|
||||
min t1, a3, t3
|
||||
vslide1down.vx v12, v16, zero
|
||||
vsetvli t1, t1, e32, m4, ta, ma
|
||||
vle32.v v0, (t0) // x0
|
||||
sub a3, a3, t1
|
||||
vslide1down.vx v4, v8, zero
|
||||
sh2add t0, t1, t0
|
||||
vle32.v v28, (a0)
|
||||
addi t2, t1, -4
|
||||
vslideup.vi v4, v0, 1
|
||||
vslideup.vi v8, v4, 1
|
||||
vslideup.vi v12, v8, 1
|
||||
vslideup.vi v16, v12, 1
|
||||
vfadd.vv v20, v4, v12
|
||||
vfadd.vv v24, v0, v16
|
||||
vslidedown.vx v16, v0, t2
|
||||
vfmacc.vf v28, fa0, v8
|
||||
vfmacc.vf v28, fa1, v20
|
||||
vfmacc.vf v28, fa2, v24
|
||||
vse32.v v28, (a0)
|
||||
sh2add a0, t1, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright © 2022 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 <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/pixblockdsp.h"
|
||||
|
||||
void ff_get_pixels_8_rvi(int16_t *block, const uint8_t *pixels,
|
||||
ptrdiff_t stride);
|
||||
void ff_get_pixels_16_rvi(int16_t *block, const uint8_t *pixels,
|
||||
ptrdiff_t stride);
|
||||
|
||||
void ff_get_pixels_8_rvv(int16_t *block, const uint8_t *pixels,
|
||||
ptrdiff_t stride);
|
||||
void ff_get_pixels_unaligned_8_rvv(int16_t *block, const uint8_t *pixels,
|
||||
ptrdiff_t stride);
|
||||
void ff_diff_pixels_rvv(int16_t *block, const uint8_t *s1,
|
||||
const uint8_t *s2, ptrdiff_t stride);
|
||||
void ff_diff_pixels_unaligned_rvv(int16_t *block, const uint8_t *s1,
|
||||
const uint8_t *s2, ptrdiff_t stride);
|
||||
|
||||
av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c,
|
||||
unsigned high_bit_depth)
|
||||
{
|
||||
#if HAVE_RV
|
||||
int cpu_flags = av_get_cpu_flags();
|
||||
|
||||
#if __riscv_xlen >= 64
|
||||
if (cpu_flags & AV_CPU_FLAG_RVI) {
|
||||
if (high_bit_depth)
|
||||
c->get_pixels = ff_get_pixels_16_rvi;
|
||||
else
|
||||
c->get_pixels = ff_get_pixels_8_rvi;
|
||||
}
|
||||
|
||||
if (cpu_flags & AV_CPU_FLAG_RV_MISALIGNED) {
|
||||
if (high_bit_depth)
|
||||
c->get_pixels_unaligned = ff_get_pixels_16_rvi;
|
||||
else
|
||||
c->get_pixels_unaligned = ff_get_pixels_8_rvi;
|
||||
}
|
||||
#endif
|
||||
#if HAVE_RVV
|
||||
if ((cpu_flags & AV_CPU_FLAG_RVV_I32) && ff_rv_vlen_least(128)) {
|
||||
c->diff_pixels = ff_diff_pixels_unaligned_rvv;
|
||||
c->diff_pixels_unaligned = ff_diff_pixels_unaligned_rvv;
|
||||
}
|
||||
|
||||
if ((cpu_flags & AV_CPU_FLAG_RVV_I64) && ff_get_rv_vlenb() >= 16) {
|
||||
if (!high_bit_depth) {
|
||||
c->get_pixels = ff_get_pixels_8_rvv;
|
||||
c->get_pixels_unaligned = ff_get_pixels_unaligned_8_rvv;
|
||||
}
|
||||
|
||||
c->diff_pixels = ff_diff_pixels_rvv;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright © 2022 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"
|
||||
|
||||
#if __riscv_xlen >= 64
|
||||
func ff_get_pixels_8_rvi
|
||||
lpad 0
|
||||
.irp row, 0, 1, 2, 3, 4, 5, 6, 7
|
||||
ld t0, (a1)
|
||||
add a1, a1, a2
|
||||
sd zero, ((\row * 16) + 0)(a0)
|
||||
addi t6, t6, -1
|
||||
sd zero, ((\row * 16) + 8)(a0)
|
||||
srli t1, t0, 8
|
||||
sb t0, ((\row * 16) + 0)(a0)
|
||||
srli t2, t0, 16
|
||||
sb t1, ((\row * 16) + 2)(a0)
|
||||
srli t3, t0, 24
|
||||
sb t2, ((\row * 16) + 4)(a0)
|
||||
srli t4, t0, 32
|
||||
sb t3, ((\row * 16) + 6)(a0)
|
||||
srli t1, t0, 40
|
||||
sb t4, ((\row * 16) + 8)(a0)
|
||||
srli t2, t0, 48
|
||||
sb t1, ((\row * 16) + 10)(a0)
|
||||
srli t3, t0, 56
|
||||
sb t2, ((\row * 16) + 12)(a0)
|
||||
sb t3, ((\row * 16) + 14)(a0)
|
||||
.endr
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_get_pixels_16_rvi
|
||||
lpad 0
|
||||
.irp row, 0, 1, 2, 3, 4, 5, 6, 7
|
||||
ld t0, 0(a1)
|
||||
ld t1, 8(a1)
|
||||
add a1, a1, a2
|
||||
sd t0, ((\row * 16) + 0)(a0)
|
||||
sd t1, ((\row * 16) + 8)(a0)
|
||||
.endr
|
||||
ret
|
||||
endfunc
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright © 2022 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_get_pixels_8_rvv, zve64x
|
||||
lpad 0
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
li t0, 8 * 8
|
||||
1:
|
||||
vlse64.v v16, (a1), a2
|
||||
vsetvli zero, t0, e8, m4, ta, ma
|
||||
vwcvtu.x.x.v v8, v16
|
||||
vse16.v v8, (a0)
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_get_pixels_unaligned_8_rvv, zve64x
|
||||
lpad 0
|
||||
andi t1, a1, 7
|
||||
vsetivli zero, 8, e64, m4, ta, ma
|
||||
li t0, 8 * 8
|
||||
beqz t1, 1b
|
||||
andi a1, a1, -8
|
||||
slli t2, t1, 3
|
||||
addi t1, a1, 8
|
||||
sub t3, t0, t2
|
||||
vlse64.v v16, (a1), a2
|
||||
vlse64.v v24, (t1), a2
|
||||
vsrl.vx v16, v16, t2
|
||||
vsll.vx v24, v24, t3
|
||||
vor.vv v16, v16, v24
|
||||
vsetvli zero, t0, e8, m4, ta, ma
|
||||
vwcvtu.x.x.v v8, v16
|
||||
vse16.v v8, (a0)
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_diff_pixels_rvv, zve64x
|
||||
lpad 0
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
li t0, 8 * 8
|
||||
vlse64.v v16, (a1), a3
|
||||
vlse64.v v24, (a2), a3
|
||||
vsetvli zero, t0, e8, m4, ta, ma
|
||||
vwsubu.vv v8, v16, v24
|
||||
vse16.v v8, (a0)
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_diff_pixels_unaligned_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
vlsseg8e8.v v16, (a1), a3
|
||||
vlsseg8e8.v v24, (a2), a3
|
||||
vwsubu.vv v8, v16, v24
|
||||
vwsubu.vv v9, v17, v25
|
||||
vwsubu.vv v10, v18, v26
|
||||
vwsubu.vv v11, v19, v27
|
||||
vwsubu.vv v12, v20, v28
|
||||
vwsubu.vv v13, v21, v29
|
||||
vwsubu.vv v14, v22, v30
|
||||
vwsubu.vv v15, v23, v31
|
||||
vsseg8e16.v v8, (a0)
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/rv34dsp.h"
|
||||
|
||||
void ff_rv34_inv_transform_dc_rvv(int16_t *block);
|
||||
void ff_rv34_idct_dc_add_rvv(uint8_t *dst, ptrdiff_t stride, int dc);
|
||||
|
||||
av_cold void ff_rv34dsp_init_riscv(RV34DSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_I32 && ff_rv_vlen_least(128)) {
|
||||
c->rv34_inv_transform_dc = ff_rv34_inv_transform_dc_rvv;
|
||||
c->rv34_idct_dc_add = ff_rv34_idct_dc_add_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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_rv34_inv_transform_dc_rvv, zve32x
|
||||
lpad 0
|
||||
lh t1, 0(a0)
|
||||
li t0, 13 * 13 * 3
|
||||
mul t2, t0, t1
|
||||
srai t2, t2, 11
|
||||
vsetivli zero, 16, e16, m2, ta, ma
|
||||
vmv.v.x v8, t2
|
||||
vse16.v v8, (a0)
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_rv34_idct_dc_add_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, 4, e8, mf4, ta, ma
|
||||
vlse32.v v0, (a0), a1
|
||||
li t1, 169
|
||||
mul t1, t1, a2
|
||||
addi t1, t1, 512
|
||||
srai t1, t1, 10
|
||||
vsetivli zero, 4*4, e8, m2, ta, ma
|
||||
bgez t1, 1f
|
||||
|
||||
neg t1, t1
|
||||
vssubu.vx v0, v0, t1
|
||||
vsetivli zero, 4, e8, mf4, ta, ma
|
||||
vsse32.v v0, (a0), a1
|
||||
ret
|
||||
1:
|
||||
vsaddu.vx v0, v0, t1
|
||||
vsetivli zero, 4, e8, mf4, ta, ma
|
||||
vsse32.v v0, (a0), a1
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/rv34dsp.h"
|
||||
|
||||
void ff_put_rv40_chroma_mc8_rvv(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
|
||||
int h, int x, int y);
|
||||
void ff_put_rv40_chroma_mc4_rvv(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
|
||||
int h, int x, int y);
|
||||
|
||||
void ff_avg_rv40_chroma_mc8_rvv(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
|
||||
int h, int x, int y);
|
||||
void ff_avg_rv40_chroma_mc4_rvv(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
|
||||
int h, int x, int y);
|
||||
|
||||
av_cold void ff_rv40dsp_init_riscv(RV34DSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && ff_rv_vlen_least(128) &&
|
||||
(flags & AV_CPU_FLAG_RVB)) {
|
||||
c->put_chroma_pixels_tab[0] = ff_put_rv40_chroma_mc8_rvv;
|
||||
c->put_chroma_pixels_tab[1] = ff_put_rv40_chroma_mc4_rvv;
|
||||
c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_rvv;
|
||||
c->avg_chroma_pixels_tab[1] = ff_avg_rv40_chroma_mc4_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,415 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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"
|
||||
|
||||
const rv40_bias
|
||||
.byte 0, 16, 32, 16
|
||||
.byte 32, 28, 32, 28
|
||||
.byte 0, 32, 16, 32
|
||||
.byte 32, 28, 32, 28
|
||||
endconst
|
||||
|
||||
.macro do_chroma_mc type unroll
|
||||
csrwi vxrm, 0
|
||||
addi sp, sp, -16
|
||||
#if __riscv_xlen == 32
|
||||
sw s2, (sp)
|
||||
#elif __riscv_xlen == 64
|
||||
sd s2, (sp)
|
||||
#else
|
||||
sq s2, (sp)
|
||||
#endif
|
||||
lla t4, rv40_bias
|
||||
srli t5, a5, 1
|
||||
sh2add t4, t5, t4
|
||||
srli t5, a4, 1
|
||||
add t5, t4, t5
|
||||
slli t2, a5, 3
|
||||
lb s2, (t5)
|
||||
mul t1, a5, a4
|
||||
sh3add a5, a4, t2
|
||||
slli a4, a4, 3
|
||||
sub a5, t1, a5
|
||||
sub a7, a4, t1
|
||||
addi a6, a5, 64
|
||||
sub t0, t2, t1
|
||||
vsetvli t3, t6, e8, m1, ta, mu
|
||||
beqz t1, 2f
|
||||
blez a3, 8f
|
||||
li t4, 0
|
||||
li t2, 0
|
||||
li t5, 1
|
||||
addi a5, t3, 1
|
||||
slli t3, a2, (1 + \unroll)
|
||||
1: # if (xy != 0)
|
||||
add a4, a1, t4
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
.ifc \unroll,1
|
||||
addi t2, t2, 4
|
||||
.else
|
||||
addi t2, t2, 2
|
||||
.endif
|
||||
vle8.v v10, (a4)
|
||||
add a4, a4, a2
|
||||
vslide1down.vx v11, v10, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v8, v10, a6
|
||||
vwmaccu.vx v8, a7, v11
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vle8.v v12, (a4)
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
add a4, a4, a2
|
||||
vwmaccu.vx v8, t0, v12
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vslide1down.vx v13, v12, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v10, v12, a6
|
||||
vwmaccu.vx v8, t1, v13
|
||||
vwmaccu.vx v10, a7, v13
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vle8.v v14, (a4)
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
add a4, a4, a2
|
||||
vwmaccu.vx v10, t0, v14
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vslide1down.vx v15, v14, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v12, v14, a6
|
||||
vwmaccu.vx v10, t1, v15
|
||||
vwmaccu.vx v12, a7, v15
|
||||
vwaddu.wx v20, v8, s2
|
||||
vnsrl.wi v15, v20, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v9, (a0)
|
||||
vaaddu.vv v15, v15, v9
|
||||
.endif
|
||||
vse8.v v15, (a0)
|
||||
add a0, a0, a2
|
||||
vwaddu.wx v20, v10, s2
|
||||
vnsrl.wi v8, v20, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v9, (a0)
|
||||
vaaddu.vv v8, v8, v9
|
||||
.endif
|
||||
add t4, t4, t3
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
.ifc \unroll,1
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vle8.v v14, (a4)
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
add a4, a4, a2
|
||||
vwmaccu.vx v12, t0, v14
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vslide1down.vx v15, v14, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v16, v14, a6
|
||||
vwmaccu.vx v12, t1, v15
|
||||
vwmaccu.vx v16, a7, v15
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vle8.v v14, (a4)
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmaccu.vx v16, t0, v14
|
||||
vsetvli zero, a5, e8, m1, ta, ma
|
||||
vslide1down.vx v14, v14, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmaccu.vx v16, t1, v14
|
||||
vwaddu.wx v20, v12, s2
|
||||
vnsrl.wi v8, v20, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v9, (a0)
|
||||
vaaddu.vv v8, v8, v9
|
||||
.endif
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
vwaddu.wx v20, v16, s2
|
||||
vnsrl.wi v8, v20, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v9, (a0)
|
||||
vaaddu.vv v8, v8, v9
|
||||
.endif
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
.endif
|
||||
blt t2, a3, 1b
|
||||
j 8f
|
||||
2:
|
||||
bnez a4, 4f
|
||||
beqz t2, 4f
|
||||
blez a3, 8f
|
||||
li a4, 0
|
||||
li t1, 0
|
||||
slli a7, a2, (1 + \unroll)
|
||||
3: # if ((x8 - xy) == 0 && (y8 -xy) != 0)
|
||||
add a5, a1, a4
|
||||
vsetvli zero, zero, e8, m1, ta, ma
|
||||
.ifc \unroll,1
|
||||
addi t1, t1, 4
|
||||
.else
|
||||
addi t1, t1, 2
|
||||
.endif
|
||||
vle8.v v8, (a5)
|
||||
add a5, a5, a2
|
||||
add t2, a5, a2
|
||||
vwmulu.vx v10, v8, a6
|
||||
vle8.v v8, (a5)
|
||||
vwmulu.vx v12, v8, a6
|
||||
vle8.v v9, (t2)
|
||||
add t2, t2, a2
|
||||
add a5, t2, a2
|
||||
vwmaccu.vx v10, t0, v8
|
||||
add a4, a4, a7
|
||||
vwmaccu.vx v12, t0, v9
|
||||
vwaddu.wx v20, v10, s2
|
||||
vnsrl.wi v15, v20, 6
|
||||
vwmulu.vx v10, v9, a6
|
||||
vwaddu.wx v20, v12, s2
|
||||
vnsrl.wi v9, v20, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v16, (a0)
|
||||
vaaddu.vv v15, v15, v16
|
||||
.endif
|
||||
vse8.v v15, (a0)
|
||||
add a0, a0, a2
|
||||
.ifc \type,avg
|
||||
vle8.v v16, (a0)
|
||||
vaaddu.vv v9, v9, v16
|
||||
.endif
|
||||
vse8.v v9, (a0)
|
||||
add a0, a0, a2
|
||||
.ifc \unroll,1
|
||||
vle8.v v8, (t2)
|
||||
vle8.v v14, (a5)
|
||||
vwmaccu.vx v10, t0, v8
|
||||
vwmulu.vx v12, v8, a6
|
||||
vwaddu.wx v20, v10, s2
|
||||
vnsrl.wi v8, v20, 6
|
||||
vwmaccu.vx v12, t0, v14
|
||||
.ifc \type,avg
|
||||
vle8.v v16, (a0)
|
||||
vaaddu.vv v8, v8, v16
|
||||
.endif
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
vwaddu.wx v20, v12, s2
|
||||
vnsrl.wi v8, v20, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v16, (a0)
|
||||
vaaddu.vv v8, v8, v16
|
||||
.endif
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
.endif
|
||||
blt t1, a3, 3b
|
||||
j 8f
|
||||
4:
|
||||
beqz a4, 6f
|
||||
bnez t2, 6f
|
||||
blez a3, 8f
|
||||
li a4, 0
|
||||
li t2, 0
|
||||
addi t0, t3, 1
|
||||
slli t1, a2, (1 + \unroll)
|
||||
5: # if ((x8 - xy) != 0 && (y8 -xy) == 0)
|
||||
add a5, a1, a4
|
||||
vsetvli zero, t0, e8, m1, ta, ma
|
||||
.ifc \unroll,1
|
||||
addi t2, t2, 4
|
||||
.else
|
||||
addi t2, t2, 2
|
||||
.endif
|
||||
vle8.v v8, (a5)
|
||||
add a5, a5, a2
|
||||
vslide1down.vx v9, v8, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v10, v8, a6
|
||||
vwmaccu.vx v10, a7, v9
|
||||
vsetvli zero, t0, e8, m1, ta, ma
|
||||
vle8.v v8, (a5)
|
||||
add a5, a5, a2
|
||||
vslide1down.vx v9, v8, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v12, v8, a6
|
||||
vwmaccu.vx v12, a7, v9
|
||||
vwaddu.wx v20, v10, s2
|
||||
vnsrl.wi v16, v20, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a0)
|
||||
vaaddu.vv v16, v16, v18
|
||||
.endif
|
||||
vse8.v v16, (a0)
|
||||
add a0, a0, a2
|
||||
vwaddu.wx v20, v12, s2
|
||||
vnsrl.wi v10, v20, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a0)
|
||||
vaaddu.vv v10, v10, v18
|
||||
.endif
|
||||
add a4, a4, t1
|
||||
vse8.v v10, (a0)
|
||||
add a0, a0, a2
|
||||
.ifc \unroll,1
|
||||
vsetvli zero, t0, e8, m1, ta, ma
|
||||
vle8.v v8, (a5)
|
||||
add a5, a5, a2
|
||||
vslide1down.vx v9, v8, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v14, v8, a6
|
||||
vwmaccu.vx v14, a7, v9
|
||||
vsetvli zero, t0, e8, m1, ta, ma
|
||||
vle8.v v8, (a5)
|
||||
vslide1down.vx v9, v8, t5
|
||||
vsetvli zero, t6, e8, m1, ta, ma
|
||||
vwmulu.vx v12, v8, a6
|
||||
vwaddu.wx v20, v14, s2
|
||||
vnsrl.wi v8, v20, 6
|
||||
vwmaccu.vx v12, a7, v9
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a0)
|
||||
vaaddu.vv v8, v8, v18
|
||||
.endif
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
vwaddu.wx v20, v12, s2
|
||||
vnsrl.wi v8, v20, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a0)
|
||||
vaaddu.vv v8, v8, v18
|
||||
.endif
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
.endif
|
||||
blt t2, a3, 5b
|
||||
j 8f
|
||||
6:
|
||||
blez a3, 8f
|
||||
li a4, 0
|
||||
li t2, 0
|
||||
slli a7, a2, (1 + \unroll)
|
||||
7: # the final else, none of the above conditions are met
|
||||
add t0, a1, a4
|
||||
vsetvli zero, zero, e8, m1, ta, ma
|
||||
add a5, a0, a4
|
||||
add a4, a4, a7
|
||||
.ifc \unroll,1
|
||||
addi t2, t2, 4
|
||||
.else
|
||||
addi t2, t2, 2
|
||||
.endif
|
||||
vle8.v v8, (t0)
|
||||
add t0, t0, a2
|
||||
add t1, t0, a2
|
||||
vwmulu.vx v10, v8, a6
|
||||
vle8.v v8, (t0)
|
||||
add t0, t1, a2
|
||||
vwaddu.wx v20, v10, s2
|
||||
vnsrl.wi v13, v20, 6
|
||||
vwmulu.vx v10, v8, a6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a5)
|
||||
vaaddu.vv v13, v13, v18
|
||||
.endif
|
||||
vse8.v v13, (a5)
|
||||
add a5, a5, a2
|
||||
vwaddu.wx v20, v10, s2
|
||||
vnsrl.wi v8, v20, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a5)
|
||||
vaaddu.vv v8, v8, v18
|
||||
.endif
|
||||
vse8.v v8, (a5)
|
||||
add a5, a5, a2
|
||||
.ifc \unroll,1
|
||||
vle8.v v9, (t1)
|
||||
vle8.v v12, (t0)
|
||||
vwmulu.vx v10, v9, a6
|
||||
vwaddu.wx v20, v10, s2
|
||||
vnsrl.wi v8, v20, 6
|
||||
vwmulu.vx v10, v12, a6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a5)
|
||||
vaaddu.vv v8, v8, v18
|
||||
.endif
|
||||
vse8.v v8, (a5)
|
||||
add a5, a5, a2
|
||||
vwaddu.wx v20, v10, s2
|
||||
vnsrl.wi v8, v20, 6
|
||||
.ifc \type,avg
|
||||
vle8.v v18, (a5)
|
||||
vaaddu.vv v8, v8, v18
|
||||
.endif
|
||||
vse8.v v8, (a5)
|
||||
.endif
|
||||
blt t2, a3, 7b
|
||||
8:
|
||||
#if __riscv_xlen == 32
|
||||
lw s2, (sp)
|
||||
#elif __riscv_xlen == 64
|
||||
ld s2, (sp)
|
||||
#else
|
||||
lq s2, (sp)
|
||||
#endif
|
||||
addi sp, sp, 16
|
||||
|
||||
ret
|
||||
.endm
|
||||
|
||||
func ff_put_rv40_chroma_mc_rvv, zve32x, zba
|
||||
11:
|
||||
li a7, 3
|
||||
blt a3, a7, 12f
|
||||
do_chroma_mc put 1
|
||||
12:
|
||||
do_chroma_mc put 0
|
||||
endfunc
|
||||
|
||||
func ff_avg_rv40_chroma_mc_rvv, zve32x, zba
|
||||
21:
|
||||
li a7, 3
|
||||
blt a3, a7, 22f
|
||||
do_chroma_mc avg 1
|
||||
22:
|
||||
do_chroma_mc avg 0
|
||||
endfunc
|
||||
|
||||
func ff_put_rv40_chroma_mc8_rvv, zve32x
|
||||
lpad 0
|
||||
li t6, 8
|
||||
j 11b
|
||||
endfunc
|
||||
|
||||
func ff_put_rv40_chroma_mc4_rvv, zve32x
|
||||
lpad 0
|
||||
li t6, 4
|
||||
j 11b
|
||||
endfunc
|
||||
|
||||
func ff_avg_rv40_chroma_mc8_rvv, zve32x
|
||||
lpad 0
|
||||
li t6, 8
|
||||
j 21b
|
||||
endfunc
|
||||
|
||||
func ff_avg_rv40_chroma_mc4_rvv, zve32x
|
||||
lpad 0
|
||||
li t6, 4
|
||||
j 21b
|
||||
endfunc
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/sbrdsp.h"
|
||||
|
||||
void ff_sbr_sum64x5_rvv(float *z);
|
||||
float ff_sbr_sum_square_rvv(float (*x)[2], int n);
|
||||
void ff_sbr_autocorrelate_rvv(const float x[40][2], float phi[3][2][2]);
|
||||
void ff_sbr_hf_gen_rvv(float (*X_high)[2], const float (*X_low)[2],
|
||||
const float alpha0[2], const float alpha1[2],
|
||||
float bw, int start, int end);
|
||||
void ff_sbr_hf_g_filt_rvv(float (*Y)[2], const float (*X_high)[40][2],
|
||||
const float *g_filt, int m_max, intptr_t ixh);
|
||||
void ff_sbr_hf_apply_noise_0_rvv(float (*Y)[2], const float *s,
|
||||
const float *f, int n, int kx, int max);
|
||||
void ff_sbr_hf_apply_noise_1_rvv(float (*Y)[2], const float *s,
|
||||
const float *f, int n, int kx, int max);
|
||||
void ff_sbr_hf_apply_noise_2_rvv(float (*Y)[2], const float *s,
|
||||
const float *f, int n, int kx, int max);
|
||||
void ff_sbr_hf_apply_noise_3_rvv(float (*Y)[2], const float *s,
|
||||
const float *f, int n, int kx, int max);
|
||||
|
||||
av_cold void ff_sbrdsp_init_riscv(SBRDSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_F32) {
|
||||
if (flags & AV_CPU_FLAG_RVB) {
|
||||
c->sum64x5 = ff_sbr_sum64x5_rvv;
|
||||
c->sum_square = ff_sbr_sum_square_rvv;
|
||||
c->hf_gen = ff_sbr_hf_gen_rvv;
|
||||
c->hf_g_filt = ff_sbr_hf_g_filt_rvv;
|
||||
if (ff_get_rv_vlenb() <= 32) {
|
||||
c->hf_apply_noise[0] = ff_sbr_hf_apply_noise_0_rvv;
|
||||
c->hf_apply_noise[2] = ff_sbr_hf_apply_noise_2_rvv;
|
||||
c->hf_apply_noise[1] = ff_sbr_hf_apply_noise_1_rvv;
|
||||
c->hf_apply_noise[3] = ff_sbr_hf_apply_noise_3_rvv;
|
||||
}
|
||||
}
|
||||
c->autocorrelate = ff_sbr_autocorrelate_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
* 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_sbr_sum64x5_rvv, zve32f, zba
|
||||
lpad 0
|
||||
li a5, 64
|
||||
addi a1, a0, 64 * 4
|
||||
addi a2, a0, 128 * 4
|
||||
addi a3, a0, 192 * 4
|
||||
addi a4, a0, 256 * 4
|
||||
1:
|
||||
vsetvli t0, a5, e32, m8, ta, ma
|
||||
sub a5, a5, t0
|
||||
vle32.v v0, (a0)
|
||||
vle32.v v8, (a1)
|
||||
sh2add a1, t0, a1
|
||||
vle32.v v16, (a2)
|
||||
vfadd.vv v0, v0, v8
|
||||
sh2add a2, t0, a2
|
||||
vle32.v v24, (a3)
|
||||
vfadd.vv v0, v0, v16
|
||||
sh2add a3, t0, a3
|
||||
vle32.v v8, (a4)
|
||||
vfadd.vv v0, v0, v24
|
||||
sh2add a4, t0, a4
|
||||
vfadd.vv v0, v0, v8
|
||||
vse32.v v0, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a5, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_sbr_sum_square_rvv, zve32f, zba
|
||||
lpad 0
|
||||
vsetvli t0, zero, e32, m8, ta, ma
|
||||
slli a1, a1, 1
|
||||
vmv.v.x v8, zero
|
||||
vmv.s.x v0, zero
|
||||
1:
|
||||
vsetvli t0, a1, e32, m8, tu, ma
|
||||
vle32.v v16, (a0)
|
||||
sub a1, a1, t0
|
||||
vfmacc.vv v8, v16, v16
|
||||
sh2add a0, t0, a0
|
||||
bnez a1, 1b
|
||||
|
||||
vfredusum.vs v0, v8, v0
|
||||
vfmv.f.s fa0, v0
|
||||
NOHWF fmv.x.w a0, fa0
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_sbr_autocorrelate_rvv, zve32f
|
||||
lpad 0
|
||||
vsetvli t0, zero, e32, m4, ta, ma
|
||||
vmv.v.x v0, zero
|
||||
flw fa0, (a0)
|
||||
vmv.v.x v4, zero
|
||||
flw fa1, 4(a0)
|
||||
vmv.v.x v8, zero
|
||||
flw fa2, 8(a0)
|
||||
li a2, 37
|
||||
flw fa3, 12(a0)
|
||||
fmul.s ft10, fa0, fa0
|
||||
flw fa4, 16(a0)
|
||||
fmul.s ft6, fa0, fa2
|
||||
flw fa5, 20(a0)
|
||||
addi a0, a0, 38 * 8
|
||||
fmul.s ft7, fa0, fa3
|
||||
fmul.s ft2, fa0, fa4
|
||||
fmul.s ft3, fa0, fa5
|
||||
flw fa0, (a0)
|
||||
fmadd.s ft10, fa1, fa1, ft10
|
||||
fmadd.s ft6, fa1, fa3, ft6
|
||||
flw fa3, 12(a0)
|
||||
fnmsub.s ft7, fa1, fa2, ft7
|
||||
flw fa2, 8(a0)
|
||||
fmadd.s ft2, fa1, fa5, ft2
|
||||
fnmsub.s ft3, fa1, fa4, ft3
|
||||
flw fa1, 4(a0)
|
||||
fmul.s ft4, fa0, fa0
|
||||
fmul.s ft0, fa0, fa2
|
||||
fmul.s ft1, fa0, fa3
|
||||
fmadd.s ft4, fa1, fa1, ft4
|
||||
fmadd.s ft0, fa1, fa3, ft0
|
||||
fnmsub.s ft1, fa1, fa2, ft1
|
||||
1:
|
||||
vsetvli t0, a2, e32, m2, tu, ma
|
||||
slli t1, t0, 3
|
||||
sub a0, a0, t1
|
||||
vlseg2e32.v v16, (a0)
|
||||
sub a2, a2, t0
|
||||
vfmacc.vv v0, v16, v16
|
||||
vfslide1down.vf v20, v16, fa0
|
||||
vfmacc.vv v4, v16, v20
|
||||
vfslide1down.vf v22, v18, fa1
|
||||
vfmacc.vv v0, v18, v18
|
||||
vfslide1down.vf v24, v20, fa2
|
||||
vfmacc.vv v4, v18, v22
|
||||
vfslide1down.vf v26, v22, fa3
|
||||
vfmacc.vv v6, v16, v22
|
||||
vfmv.f.s fa0, v16
|
||||
vfmacc.vv v8, v16, v24
|
||||
vfmv.f.s fa1, v18
|
||||
vfmacc.vv v10, v16, v26
|
||||
vfmv.f.s fa2, v20
|
||||
vfnmsac.vv v6, v18, v20
|
||||
vfmv.f.s fa3, v22
|
||||
vfmacc.vv v8, v18, v26
|
||||
vfnmsac.vv v10, v18, v24
|
||||
bnez a2, 1b
|
||||
|
||||
vsetvli t0, zero, e32, m2, ta, ma
|
||||
vfredusum.vs v0, v0, v2
|
||||
vfredusum.vs v4, v4, v2
|
||||
vfmv.f.s fa0, v0
|
||||
vfredusum.vs v6, v6, v2
|
||||
vfmv.f.s fa2, v4
|
||||
fadd.s ft4, ft4, fa0
|
||||
vfredusum.vs v8, v8, v2
|
||||
vfmv.f.s fa3, v6
|
||||
fadd.s ft0, ft0, fa2
|
||||
vfredusum.vs v10, v10, v2
|
||||
vfmv.f.s fa4, v8
|
||||
fadd.s ft1, ft1, fa3
|
||||
vfmv.f.s fa5, v10
|
||||
fsw ft0, (a1)
|
||||
fadd.s ft2, ft2, fa4
|
||||
fsw ft1, 4(a1)
|
||||
fadd.s ft3, ft3, fa5
|
||||
fsw ft2, 8(a1)
|
||||
fadd.s ft6, ft6, fa2
|
||||
fsw ft3, 12(a1)
|
||||
fadd.s ft7, ft7, fa3
|
||||
fsw ft4, 16(a1)
|
||||
fadd.s ft10, ft10, fa0
|
||||
fsw ft6, 24(a1)
|
||||
fsw ft7, 28(a1)
|
||||
fsw ft10, 40(a1)
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_sbr_hf_gen_rvv, zve32f, zba
|
||||
lpad 0
|
||||
NOHWF fmv.w.x fa0, a4
|
||||
NOHWF mv a4, a5
|
||||
NOHWF mv a5, a6
|
||||
flw ft2, 0(a2)
|
||||
fmul.s fa1, fa0, fa0 // bw * bw
|
||||
sh3add a1, a5, a1
|
||||
flw ft3, 4(a2)
|
||||
fmul.s fa2, ft2, fa0 // alpha[2]
|
||||
sh3add a0, a5, a0
|
||||
flw ft0, 0(a3)
|
||||
fmul.s fa3, ft3, fa0 // alpha[3]
|
||||
sub a5, a5, a4
|
||||
flw ft1, 4(a3)
|
||||
fmul.s fa0, ft0, fa1 // alpha[0]
|
||||
flw ft0, -16(a1) // X_low[end - 2][0]
|
||||
fmul.s fa1, ft1, fa1 // alpha[1]
|
||||
flw ft1, -12(a1) // X_low[end - 2][1]
|
||||
flw ft2, -8(a1) // X_low[end - 1][0]
|
||||
flw ft3, -4(a1) // X_low[end - 1][1]
|
||||
addi a1, a1, -16
|
||||
1:
|
||||
vsetvli t0, a5, e32, m4, ta, ma
|
||||
slli t1, t0, 3
|
||||
sub a1, a1, t1
|
||||
vlseg2e32.v v0, (a1) // X_low[i - 2]
|
||||
sub a0, a0, t1
|
||||
vfslide1down.vf v8, v0, ft0 // X_low[i - 1][0]
|
||||
sub a5, a5, t0
|
||||
vfslide1down.vf v12, v4, ft1 // X_low[i - 1][1]
|
||||
vfslide1down.vf v16, v8, ft2 // X_low[i ][0]
|
||||
vfslide1down.vf v20, v12, ft3 // X_low[i ][1]
|
||||
vfmacc.vf v16, fa0, v0
|
||||
vfmacc.vf v20, fa0, v4
|
||||
vfmv.f.s ft0, v0
|
||||
vfnmsac.vf v16, fa1, v4
|
||||
vfmacc.vf v20, fa1, v0
|
||||
vfmv.f.s ft1, v4
|
||||
vfmacc.vf v16, fa2, v8
|
||||
vfmacc.vf v20, fa2, v12
|
||||
vfmv.f.s ft2, v8
|
||||
vfnmsac.vf v16, fa3, v12
|
||||
vfmacc.vf v20, fa3, v8
|
||||
vfmv.f.s ft3, v12
|
||||
vsseg2e32.v v16, (a0)
|
||||
bnez a5, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_sbr_hf_g_filt_rvv, zve32f, zba
|
||||
lpad 0
|
||||
li t1, 40 * 2 * 4
|
||||
sh3add a1, a4, a1
|
||||
1:
|
||||
vsetvli t0, a3, e32, m4, ta, ma
|
||||
vlsseg2e32.v v16, (a1), t1
|
||||
mul t2, t0, t1
|
||||
vle32.v v8, (a2)
|
||||
sub a3, a3, t0
|
||||
vfmul.vv v16, v16, v8
|
||||
add a1, t2, a1
|
||||
vfmul.vv v20, v20, v8
|
||||
sh2add a2, t0, a2
|
||||
vsseg2e32.v v16, (a0)
|
||||
sh3add a0, t0, a0
|
||||
bnez a3, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
.macro hf_apply_noise n
|
||||
lla a6, ff_sbr_noise_table + 8
|
||||
fmv.s.x ft0, zero
|
||||
1:
|
||||
.if \n & 1
|
||||
min t0, t0, a5 // preserve parity of t0 for v4 sign injector
|
||||
vsetvli zero, t0, e32, m4, ta, mu
|
||||
.else
|
||||
vsetvli t0, a5, e32, m4, ta, mu
|
||||
.endif
|
||||
sh3add t6, a3, a6
|
||||
vle32.v v8, (a1) // s_m
|
||||
sub a5, a5, t0
|
||||
vle32.v v12, (a2) // q_filt
|
||||
sh2add a1, t0, a1
|
||||
vmfeq.vf v0, v8, ft0 // s_m == 0.f
|
||||
vlseg2e32.v v24, (t6) // ff_sbr_noise_table
|
||||
sh2add a2, t0, a2
|
||||
.if \n == 2
|
||||
vfneg.v v8, v8
|
||||
.endif
|
||||
.if \n & 1
|
||||
vfsgnjx.vv v8, v8, v4 // could equivalent use vxor.vv
|
||||
.endif
|
||||
add a3, t0, a3
|
||||
vlseg2e32.v v16, (a0) // Y
|
||||
andi a3, a3, 0x1ff
|
||||
.if \n & 1
|
||||
vfmul.vv v28, v12, v28
|
||||
vfmacc.vv v16, v12, v24, v0.t
|
||||
vmerge.vvm v28, v8, v28, v0
|
||||
vfadd.vv v20, v20, v28
|
||||
.else
|
||||
vfmul.vv v24, v12, v24
|
||||
vfmacc.vv v20, v12, v28, v0.t
|
||||
vmerge.vvm v24, v8, v24, v0
|
||||
vfadd.vv v16, v16, v24
|
||||
.endif
|
||||
vsseg2e32.v v16, (a0)
|
||||
sh3add a0, t0, a0
|
||||
bnez a5, 1b
|
||||
|
||||
ret
|
||||
.endm
|
||||
|
||||
func ff_sbr_hf_apply_noise_0_rvv, zve32f, b
|
||||
lpad 0
|
||||
hf_apply_noise 0
|
||||
endfunc
|
||||
|
||||
func ff_sbr_hf_apply_noise_3_rvv, zve32f, b
|
||||
lpad 0
|
||||
not a4, a4 // invert parity of kx
|
||||
// fall through
|
||||
endfunc
|
||||
|
||||
func ff_sbr_hf_apply_noise_1_rvv, zve32f, b
|
||||
lpad 0
|
||||
vsetvli t0, zero, e32, m4, ta, ma
|
||||
vid.v v4
|
||||
vxor.vx v4, v4, a4
|
||||
vsll.vi v4, v4, 31 // v4[i] = (kx & 1) ? -0.f : +0.f
|
||||
hf_apply_noise 1
|
||||
endfunc
|
||||
|
||||
func ff_sbr_hf_apply_noise_2_rvv, zve32f, b
|
||||
lpad 0
|
||||
hf_apply_noise 2
|
||||
endfunc
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright © 2024 Rémi Denis-Courmont.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "libavutil/riscv/asm.S"
|
||||
|
||||
.macro lx rd, addr
|
||||
#if (__riscv_xlen == 32)
|
||||
lw \rd, \addr
|
||||
#elif (__riscv_xlen == 64)
|
||||
ld \rd, \addr
|
||||
#else
|
||||
lq \rd, \addr
|
||||
#endif
|
||||
.endm
|
||||
|
||||
func ff_startcode_find_candidate_rvb, zbb
|
||||
lpad 0
|
||||
add a1, a0, a1
|
||||
|
||||
// Potentially unaligned head
|
||||
andi t0, a0, -(__riscv_xlen / 8)
|
||||
beq a0, a1, 2f
|
||||
|
||||
andi t1, a0, (__riscv_xlen / 8) - 1
|
||||
lx t2, (t0)
|
||||
li t3, __riscv_xlen
|
||||
orc.b t2, t2
|
||||
slli t1, t1, 3
|
||||
not t2, t2
|
||||
sub t3, t3, t1
|
||||
srl t2, t2, t1
|
||||
addi t0, t0, __riscv_xlen / 8
|
||||
sll t2, t2, t1
|
||||
bnez t2, 4f
|
||||
|
||||
// Main loop (including potentially short tail)
|
||||
bge t0, a1, 2f
|
||||
li t3, -1
|
||||
1:
|
||||
lx t2, (t0)
|
||||
addi t0, t0, __riscv_xlen / 8
|
||||
orc.b t2, t2
|
||||
bne t2, t3, 3f // t2 != -1 iff (at least one) zero byte
|
||||
blt t0, a1, 1b
|
||||
|
||||
2: // No zero byte found
|
||||
sub a0, a1, a0
|
||||
ret
|
||||
|
||||
3: // Zero byte found in main loop
|
||||
not t2, t2
|
||||
4: // Zero byte found in head
|
||||
ctz t2, t2
|
||||
addi t0, t0, -(__riscv_xlen / 8) // back-track
|
||||
srl t2, t2, 3
|
||||
add t0, t0, t2
|
||||
// Uncomment the following line for exact POSIX C strnlen() semantics.
|
||||
//minu t0, t0, a1 // ignore zero byte in tail
|
||||
sub a0, t0, a0
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright © 2024 Rémi Denis-Courmont.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "libavutil/riscv/asm.S"
|
||||
|
||||
func ff_startcode_find_candidate_rvv, zve32x
|
||||
lpad 0
|
||||
mv t0, a0
|
||||
1:
|
||||
vsetvli t1, a1, e8, m8, ta, ma
|
||||
vle8.v v8, (t0)
|
||||
sub a1, a1, t1
|
||||
vmseq.vi v0, v8, 0
|
||||
vfirst.m t2, v0
|
||||
bgez t2, 2f
|
||||
add t0, t0, t1
|
||||
bnez a1, 1b
|
||||
|
||||
mv t2, zero
|
||||
2:
|
||||
add t0, t0, t2
|
||||
sub a0, t0, a0
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/svq1encdsp.h"
|
||||
|
||||
int ff_ssd_int8_vs_int16_rvv(const int8_t *pix1, const int16_t *pix2,
|
||||
intptr_t size);
|
||||
|
||||
av_cold void ff_svq1enc_init_riscv(SVQ1EncDSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_I32) {
|
||||
if (flags & AV_CPU_FLAG_RVB) {
|
||||
c->ssd_int8_vs_int16 = ff_ssd_int8_vs_int16_rvv;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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_ssd_int8_vs_int16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
vsetvli t0, zero, e32, m8, ta, ma
|
||||
vmv.v.x v24, zero
|
||||
1:
|
||||
vsetvli t0, a2, e8, m2, tu, ma
|
||||
vle16.v v8, (a1)
|
||||
sub a2, a2, t0
|
||||
vle8.v v0, (a0)
|
||||
vwsub.wv v16, v8, v0
|
||||
vsetvli zero, zero, e16, m4, tu, ma
|
||||
add a0, a0, t0
|
||||
vwmacc.vv v24, v16, v16
|
||||
sh1add a1, t0, a1
|
||||
bnez a2, 1b
|
||||
vsetvli zero, zero, e32, m8, ta, ma
|
||||
vmv.s.x v0, zero
|
||||
vredsum.vs v0, v24, v0
|
||||
vmv.x.s a0, v0
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/takdsp.h"
|
||||
|
||||
void ff_decorrelate_ls_rvv(const int32_t *p1, int32_t *p2, int length);
|
||||
void ff_decorrelate_sr_rvv(int32_t *p1, const int32_t *p2, int length);
|
||||
void ff_decorrelate_sm_rvv(int32_t *p1, int32_t *p2, int length);
|
||||
void ff_decorrelate_sf_rvv(int32_t *p1, const int32_t *p2, int len, int, int);
|
||||
|
||||
av_cold void ff_takdsp_init_riscv(TAKDSPContext *dsp)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
|
||||
dsp->decorrelate_ls = ff_decorrelate_ls_rvv;
|
||||
dsp->decorrelate_sr = ff_decorrelate_sr_rvv;
|
||||
dsp->decorrelate_sm = ff_decorrelate_sm_rvv;
|
||||
dsp->decorrelate_sf = ff_decorrelate_sf_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
* Copyright (c) 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_decorrelate_ls_rvv, zve32x, zba
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a2, e32, m8, ta, ma
|
||||
sub a2, a2, t0
|
||||
vle32.v v0, (a0)
|
||||
sh2add a0, t0, a0
|
||||
vle32.v v8, (a1)
|
||||
vadd.vv v16, v0, v8
|
||||
vse32.v v16, (a1)
|
||||
sh2add a1, t0, a1
|
||||
bnez a2, 1b
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_decorrelate_sr_rvv, zve32x, zba
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a2, e32, m8, ta, ma
|
||||
vle32.v v0, (a0)
|
||||
sub a2, a2, t0
|
||||
vle32.v v8, (a1)
|
||||
sh2add a1, t0, a1
|
||||
vsub.vv v16, v8, v0
|
||||
vse32.v v16, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_decorrelate_sm_rvv, zve32x, zba
|
||||
lpad 0
|
||||
1:
|
||||
vsetvli t0, a2, e32, m8, ta, ma
|
||||
vle32.v v8, (a1)
|
||||
sub a2, a2, t0
|
||||
vle32.v v0, (a0)
|
||||
vsra.vi v16, v8, 1
|
||||
vsub.vv v0, v0, v16
|
||||
vse32.v v0, (a0)
|
||||
sh2add a0, t0, a0
|
||||
vadd.vv v8, v0, v8
|
||||
vse32.v v8, (a1)
|
||||
sh2add a1, t0, a1
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_decorrelate_sf_rvv, zve32x, zba
|
||||
lpad 0
|
||||
csrwi vxrm, 0
|
||||
1:
|
||||
vsetvli t0, a2, e32, m8, ta, ma
|
||||
vle32.v v8, (a1)
|
||||
sub a2, a2, t0
|
||||
vsra.vx v8, v8, a3
|
||||
sh2add a1, t0, a1
|
||||
vle32.v v0, (a0)
|
||||
vmul.vx v8, v8, a4
|
||||
vssra.vi v8, v8, 8
|
||||
vsll.vx v8, v8, a3
|
||||
vsub.vv v0, v8, v0
|
||||
vse32.v v0, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/utvideodsp.h"
|
||||
|
||||
void ff_restore_rgb_planes_rvv(uint8_t *r, uint8_t *g, uint8_t *b,
|
||||
ptrdiff_t linesize_r, ptrdiff_t linesize_g,
|
||||
ptrdiff_t linesize_b, int width, int height);
|
||||
void ff_restore_rgb_planes10_rvv(uint16_t *r, uint16_t *g, uint16_t *b,
|
||||
ptrdiff_t linesize_r, ptrdiff_t linesize_g,
|
||||
ptrdiff_t linesize_b, int width, int height);
|
||||
|
||||
av_cold void ff_utvideodsp_init_riscv(UTVideoDSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_I32) {
|
||||
c->restore_rgb_planes = ff_restore_rgb_planes_rvv;
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVB)
|
||||
c->restore_rgb_planes10 = ff_restore_rgb_planes10_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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_restore_rgb_planes_rvv, zve32x, zba
|
||||
lpad 0
|
||||
li t1, -0x80
|
||||
sub a3, a3, a6
|
||||
sub a4, a4, a6
|
||||
sub a5, a5, a6
|
||||
1:
|
||||
mv t6, a6
|
||||
addi a7, a7, -1
|
||||
2:
|
||||
vsetvli t0, t6, e8, m8, ta, ma
|
||||
vle8.v v16, (a1)
|
||||
sub t6, t6, t0
|
||||
vle8.v v8, (a0)
|
||||
vadd.vx v16, v16, t1
|
||||
add a1, t0, a1
|
||||
vle8.v v24, (a2)
|
||||
vadd.vv v8, v8, v16
|
||||
vadd.vv v24, v24, v16
|
||||
vse8.v v8, (a0)
|
||||
add a0, t0, a0
|
||||
vse8.v v24, (a2)
|
||||
add a2, t0, a2
|
||||
bnez t6, 2b
|
||||
|
||||
add a0, a3, a0
|
||||
add a1, a4, a1
|
||||
add a2, a5, a2
|
||||
bnez a7, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_restore_rgb_planes10_rvv, zve32x, zba
|
||||
lpad 0
|
||||
li t1, -0x200
|
||||
li t2, 0x3FF
|
||||
sub a3, a3, a6
|
||||
sub a4, a4, a6
|
||||
sub a5, a5, a6
|
||||
1:
|
||||
mv t6, a6
|
||||
addi a7, a7, -1
|
||||
2:
|
||||
vsetvli t0, t6, e16, m8, ta, ma
|
||||
vle16.v v16, (a1)
|
||||
sub t6, t6, t0
|
||||
vle16.v v8, (a0)
|
||||
vadd.vx v16, v16, t1
|
||||
sh1add a1, t0, a1
|
||||
vle16.v v24, (a2)
|
||||
vadd.vv v8, v8, v16
|
||||
vadd.vv v24, v24, v16
|
||||
vand.vx v8, v8, t2
|
||||
vand.vx v24, v24, t2
|
||||
vse16.v v8, (a0)
|
||||
sh1add a0, t0, a0
|
||||
vse16.v v24, (a2)
|
||||
sh1add a2, t0, a2
|
||||
bnez t6, 2b
|
||||
|
||||
sh1add a0, a3, a0
|
||||
sh1add a1, a4, a1
|
||||
sh1add a2, a5, a2
|
||||
bnez a7, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/vc1.h"
|
||||
|
||||
void ff_vc1_inv_trans_8x8_dc_rvv(uint8_t *dest, ptrdiff_t stride, int16_t *block);
|
||||
void ff_vc1_inv_trans_8x8_rvv(int16_t block[64]);
|
||||
void ff_vc1_inv_trans_4x8_dc_rvv(uint8_t *dest, ptrdiff_t stride, int16_t *block);
|
||||
void ff_vc1_inv_trans_4x8_rvv(uint8_t *dest, ptrdiff_t stride, int16_t *block);
|
||||
void ff_vc1_inv_trans_8x4_dc_rvv(uint8_t *dest, ptrdiff_t stride, int16_t *block);
|
||||
void ff_vc1_inv_trans_8x4_rvv(uint8_t *dest, ptrdiff_t stride, int16_t *block);
|
||||
void ff_vc1_inv_trans_4x4_dc_rvv(uint8_t *dest, ptrdiff_t stride, int16_t *block);
|
||||
void ff_vc1_inv_trans_4x4_rvv(uint8_t *dest, ptrdiff_t stride, int16_t *block);
|
||||
void ff_put_pixels16x16_rvi(uint8_t *dst, const uint8_t *src, ptrdiff_t line_size, int rnd);
|
||||
void ff_put_pixels8x8_rvi(uint8_t *dst, const uint8_t *src, ptrdiff_t line_size, int rnd);
|
||||
void ff_avg_pixels16x16_rvv(uint8_t *dst, const uint8_t *src, ptrdiff_t line_size, int rnd);
|
||||
void ff_avg_pixels8x8_rvv(uint8_t *dst, const uint8_t *src, ptrdiff_t line_size, int rnd);
|
||||
int ff_startcode_find_candidate_rvb(const uint8_t *, int);
|
||||
int ff_startcode_find_candidate_rvv(const uint8_t *, int);
|
||||
int ff_vc1_unescape_buffer_rvv(const uint8_t *, int, uint8_t *);
|
||||
|
||||
av_cold void ff_vc1dsp_init_riscv(VC1DSPContext *dsp)
|
||||
{
|
||||
#if HAVE_RV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
# if __riscv_xlen >= 64
|
||||
if (flags & AV_CPU_FLAG_RVI) {
|
||||
dsp->put_vc1_mspel_pixels_tab[1][0] = ff_put_pixels8x8_rvi;
|
||||
dsp->put_vc1_mspel_pixels_tab[0][0] = ff_put_pixels16x16_rvi;
|
||||
}
|
||||
# endif
|
||||
if (flags & AV_CPU_FLAG_RVB_BASIC)
|
||||
dsp->startcode_find_candidate = ff_startcode_find_candidate_rvb;
|
||||
# if HAVE_RVV
|
||||
if (flags & AV_CPU_FLAG_RVV_I32) {
|
||||
if (ff_rv_vlen_least(128)) {
|
||||
dsp->vc1_inv_trans_8x8 = ff_vc1_inv_trans_8x8_rvv;
|
||||
dsp->vc1_inv_trans_8x4 = ff_vc1_inv_trans_8x4_rvv;
|
||||
dsp->vc1_inv_trans_4x8 = ff_vc1_inv_trans_4x8_rvv;
|
||||
dsp->vc1_inv_trans_4x4 = ff_vc1_inv_trans_4x4_rvv;
|
||||
dsp->vc1_inv_trans_4x8_dc = ff_vc1_inv_trans_4x8_dc_rvv;
|
||||
dsp->vc1_inv_trans_4x4_dc = ff_vc1_inv_trans_4x4_dc_rvv;
|
||||
dsp->avg_vc1_mspel_pixels_tab[0][0] = ff_avg_pixels16x16_rvv;
|
||||
dsp->avg_vc1_mspel_pixels_tab[1][0] = ff_avg_pixels8x8_rvv;
|
||||
if (flags & AV_CPU_FLAG_RVV_I64) {
|
||||
dsp->vc1_inv_trans_8x8_dc = ff_vc1_inv_trans_8x8_dc_rvv;
|
||||
dsp->vc1_inv_trans_8x4_dc = ff_vc1_inv_trans_8x4_dc_rvv;
|
||||
}
|
||||
}
|
||||
dsp->startcode_find_candidate = ff_startcode_find_candidate_rvv;
|
||||
dsp->vc1_unescape_buffer = ff_vc1_unescape_buffer_rvv;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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"
|
||||
|
||||
#if __riscv_xlen >= 64
|
||||
func ff_put_pixels8x8_rvi
|
||||
lpad 0
|
||||
.rept 8
|
||||
ld t0, (a1)
|
||||
sd t0, (a0)
|
||||
add a1, a1, a2
|
||||
add a0, a0, a2
|
||||
.endr
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_put_pixels16x16_rvi
|
||||
lpad 0
|
||||
.rept 16
|
||||
ld t0, (a1)
|
||||
ld t1, 8(a1)
|
||||
sd t0, (a0)
|
||||
sd t1, 8(a0)
|
||||
add a1, a1, a2
|
||||
add a0, a0, a2
|
||||
.endr
|
||||
|
||||
ret
|
||||
endfunc
|
||||
#endif
|
||||
@@ -0,0 +1,455 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
* Copyright (c) 2024 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"
|
||||
|
||||
.macro inv_trans_dc rows, cols, w, mat_lmul, row_lmul
|
||||
func ff_vc1_inv_trans_\cols\()x\rows\()_dc_rvv, zve64x, zba
|
||||
lpad 0
|
||||
lh t2, (a2)
|
||||
li a4, 22 - (5 * \cols) / 4
|
||||
mul t2, t2, a4
|
||||
vsetivli zero, \rows, e8, m\row_lmul, ta, ma
|
||||
vlse\w\().v v0, (a0), a1
|
||||
addi t2, t2, 4
|
||||
li a5, 22 - (5 * \rows) / 4
|
||||
srai t2, t2, 3
|
||||
mul t2, t2, a5
|
||||
.if \cols * \rows >= 32
|
||||
li t0, \cols * \rows
|
||||
.endif
|
||||
addi t2, t2, 64
|
||||
srai t2, t2, 7
|
||||
.if \rows * \cols >= 32
|
||||
vsetvli zero, t0, e8, m\mat_lmul, ta, ma
|
||||
.else
|
||||
vsetivli zero, \rows * \cols, e8, m\mat_lmul, ta, ma
|
||||
.endif
|
||||
bgez t2, 1f
|
||||
|
||||
neg t2, t2
|
||||
vssubu.vx v0, v0, t2
|
||||
vsetivli zero, \rows, e8, m\row_lmul, ta, ma
|
||||
vsse\w\().v v0, (a0), a1
|
||||
ret
|
||||
1:
|
||||
vsaddu.vx v0, v0, t2
|
||||
vsetivli zero, \rows, e8, m\row_lmul, ta, ma
|
||||
vsse\w\().v v0, (a0), a1
|
||||
ret
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
inv_trans_dc 8, 8, 64, 4, f2
|
||||
inv_trans_dc 4, 8, 64, 2, f4
|
||||
inv_trans_dc 8, 4, 32, 2, f2
|
||||
inv_trans_dc 4, 4, 32, 1, f4
|
||||
|
||||
.variant_cc ff_vc1_inv_trans_8_rvv
|
||||
func ff_vc1_inv_trans_8_rvv, zve32x
|
||||
li t4, 12
|
||||
vsll.vi v14, v6, 4
|
||||
li t2, 6
|
||||
vsll.vi v12, v2, 4
|
||||
li t5, 15
|
||||
vmul.vx v8, v0, t4
|
||||
li t3, 9
|
||||
# t[2..5] = [6 9 12 15]
|
||||
vmul.vx v10, v4, t4
|
||||
vmul.vx v16, v2, t2
|
||||
vmacc.vx v12, t2, v6 # t3
|
||||
vnmsac.vx v14, t2, v2 # -t4
|
||||
vadd.vv v24, v8, v10 # t1
|
||||
vsub.vv v25, v8, v10 # t2
|
||||
vadd.vv v28, v24, v12 # t5
|
||||
vsub.vv v31, v24, v12 # t8
|
||||
vsub.vv v29, v25, v14 # t6
|
||||
vadd.vv v30, v25, v14 # t7
|
||||
vsll.vi v20, v1, 4
|
||||
vsll.vi v22, v7, 2
|
||||
vmacc.vx v20, t5, v3
|
||||
vmacc.vx v22, t3, v5
|
||||
vsll.vi v21, v3, 2
|
||||
vsll.vi v23, v5, 4
|
||||
vadd.vv v24, v20, v22 # t1
|
||||
vnmsac.vx v21, t5, v1
|
||||
vmacc.vx v23, t3, v7
|
||||
vsll.vi v20, v3, 4
|
||||
vsll.vi v22, v5, 2
|
||||
vadd.vv v25, v21, v23 # -t2
|
||||
vnmsac.vx v20, t3, v1
|
||||
vmacc.vx v22, t5, v7
|
||||
vsll.vi v21, v1, 2
|
||||
vsll.vi v23, v7, 4
|
||||
vsub.vv v26, v22, v20 # t3
|
||||
vnmsac.vx v21, t3, v3
|
||||
vnmsac.vx v23, t5, v5
|
||||
srli t2, t1, 2
|
||||
vwadd.vv v8, v28, v24
|
||||
vwsub.vv v10, v29, v25
|
||||
vsub.vv v27, v21, v23 # t4
|
||||
vwadd.vv v12, v30, v26
|
||||
vwadd.vv v14, v31, v27
|
||||
beqz t2, 1f # faster than 4x add t2=zero
|
||||
.irp n,31,30,29,28
|
||||
vadd.vi v\n, v\n, 1
|
||||
.endr
|
||||
1:
|
||||
vwsub.vv v16, v31, v27
|
||||
vwsub.vv v18, v30, v26
|
||||
vwadd.vv v20, v29, v25
|
||||
vwsub.vv v22, v28, v24
|
||||
vnclip.wx v0, v8, t1
|
||||
vnclip.wx v1, v10, t1
|
||||
vnclip.wx v2, v12, t1
|
||||
vnclip.wx v3, v14, t1
|
||||
vnclip.wx v4, v16, t1
|
||||
vnclip.wx v5, v18, t1
|
||||
vnclip.wx v6, v20, t1
|
||||
vnclip.wx v7, v22, t1
|
||||
jr t0
|
||||
endfunc
|
||||
|
||||
.variant_cc ff_vc1_inv_trans_4_rvv
|
||||
func ff_vc1_inv_trans_4_rvv, zve32x
|
||||
li t3, 17
|
||||
vmul.vx v8, v0, t3
|
||||
li t4, 22
|
||||
vmul.vx v10, v2, t3
|
||||
li t2, 10
|
||||
vmul.vx v26, v1, t4
|
||||
vmul.vx v27, v3, t4
|
||||
vadd.vv v24, v8, v10 # t1
|
||||
vsub.vv v25, v8, v10 # t2
|
||||
vmacc.vx v26, t2, v3 # t3
|
||||
vnmsac.vx v27, t2, v1 # t4
|
||||
vwadd.vv v8, v24, v26
|
||||
vwsub.vv v10, v25, v27
|
||||
vwadd.vv v12, v25, v27
|
||||
vwsub.vv v14, v24, v26
|
||||
vnclip.wx v0, v8, t1
|
||||
vnclip.wx v1, v10, t1
|
||||
vnclip.wx v2, v12, t1
|
||||
vnclip.wx v3, v14, t1
|
||||
jr t0
|
||||
endfunc
|
||||
|
||||
func ff_vc1_inv_trans_8x8_rvv, zve32x
|
||||
lpad 0
|
||||
csrwi vxrm, 0
|
||||
vsetivli zero, 8, e16, m1, ta, ma
|
||||
addi a1, a0, 1 * 8 * 2
|
||||
vle16.v v0, (a0)
|
||||
addi a2, a0, 2 * 8 * 2
|
||||
vle16.v v1, (a1)
|
||||
addi a3, a0, 3 * 8 * 2
|
||||
vle16.v v2, (a2)
|
||||
addi a4, a0, 4 * 8 * 2
|
||||
vle16.v v3, (a3)
|
||||
addi a5, a0, 5 * 8 * 2
|
||||
vle16.v v4, (a4)
|
||||
addi a6, a0, 6 * 8 * 2
|
||||
vle16.v v5, (a5)
|
||||
addi a7, a0, 7 * 8 * 2
|
||||
vle16.v v6, (a6)
|
||||
vle16.v v7, (a7)
|
||||
li t1, 3
|
||||
jal t0, ff_vc1_inv_trans_8_rvv
|
||||
vsseg8e16.v v0, (a0)
|
||||
.irp n,0,1,2,3,4,5,6,7
|
||||
vle16.v v\n, (a\n)
|
||||
.endr
|
||||
li t1, 7
|
||||
jal t0, ff_vc1_inv_trans_8_rvv
|
||||
vse16.v v0, (a0)
|
||||
vse16.v v1, (a1)
|
||||
vse16.v v2, (a2)
|
||||
vse16.v v3, (a3)
|
||||
vse16.v v4, (a4)
|
||||
vse16.v v5, (a5)
|
||||
vse16.v v6, (a6)
|
||||
vse16.v v7, (a7)
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_vc1_inv_trans_8x4_rvv, zve32x
|
||||
lpad 0
|
||||
csrwi vxrm, 0
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
vlseg8e16.v v0, (a2)
|
||||
li t1, 3
|
||||
jal t0, ff_vc1_inv_trans_8_rvv
|
||||
vsseg8e16.v v0, (a2)
|
||||
addi a3, a2, 1 * 8 * 2
|
||||
vsetivli zero, 8, e16, m1, ta, ma
|
||||
vle16.v v0, (a2)
|
||||
addi a4, a2, 2 * 8 * 2
|
||||
vle16.v v1, (a3)
|
||||
addi a5, a2, 3 * 8 * 2
|
||||
vle16.v v2, (a4)
|
||||
vle16.v v3, (a5)
|
||||
li t1, 7
|
||||
jal t0, ff_vc1_inv_trans_4_rvv
|
||||
add a3, a1, a0
|
||||
vle8.v v8, (a0)
|
||||
add a4, a1, a3
|
||||
vle8.v v9, (a3)
|
||||
add a5, a1, a4
|
||||
vle8.v v10, (a4)
|
||||
vle8.v v11, (a5)
|
||||
vsetvli zero, zero, e8, mf2, ta, ma
|
||||
vwaddu.wv v0, v0, v8
|
||||
vwaddu.wv v1, v1, v9
|
||||
vwaddu.wv v2, v2, v10
|
||||
vwaddu.wv v3, v3, v11
|
||||
vsetvli zero, zero, e16, m1, ta, ma
|
||||
.irp n,0,1,2,3
|
||||
vmax.vx v\n, v\n, zero
|
||||
.endr
|
||||
vsetvli zero, zero, e8, mf2, ta, ma
|
||||
vnclipu.wi v8, v0, 0
|
||||
vnclipu.wi v9, v1, 0
|
||||
vse8.v v8, (a0)
|
||||
vnclipu.wi v10, v2, 0
|
||||
vse8.v v9, (a3)
|
||||
vnclipu.wi v11, v3, 0
|
||||
vse8.v v10, (a4)
|
||||
vse8.v v11, (a5)
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_vc1_inv_trans_4x8_rvv, zve32x
|
||||
lpad 0
|
||||
li a3, 8 * 2
|
||||
csrwi vxrm, 0
|
||||
vsetivli zero, 8, e16, m1, ta, ma
|
||||
vlsseg4e16.v v0, (a2), a3
|
||||
li t1, 3
|
||||
jal t0, ff_vc1_inv_trans_4_rvv
|
||||
vssseg4e16.v v0, (a2), a3
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
addi t1, a2, 1 * 8 * 2
|
||||
vle16.v v0, (a2)
|
||||
addi t2, a2, 2 * 8 * 2
|
||||
vle16.v v1, (t1)
|
||||
addi t3, a2, 3 * 8 * 2
|
||||
vle16.v v2, (t2)
|
||||
addi t4, a2, 4 * 8 * 2
|
||||
vle16.v v3, (t3)
|
||||
addi t5, a2, 5 * 8 * 2
|
||||
vle16.v v4, (t4)
|
||||
addi t6, a2, 6 * 8 * 2
|
||||
vle16.v v5, (t5)
|
||||
addi t1, a2, 7 * 8 * 2
|
||||
vle16.v v6, (t6)
|
||||
vle16.v v7, (t1)
|
||||
li t1, 7
|
||||
jal t0, ff_vc1_inv_trans_8_rvv
|
||||
add t0, a1, a0
|
||||
vle8.v v8, (a0)
|
||||
add t1, a1, t0
|
||||
vle8.v v9, (t0)
|
||||
add t2, a1, t1
|
||||
vle8.v v10, (t1)
|
||||
add t3, a1, t2
|
||||
vle8.v v11, (t2)
|
||||
add t4, a1, t3
|
||||
vle8.v v12, (t3)
|
||||
add t5, a1, t4
|
||||
vle8.v v13, (t4)
|
||||
add t6, a1, t5
|
||||
vle8.v v14, (t5)
|
||||
vle8.v v15, (t6)
|
||||
vsetvli zero, zero, e8, mf4, ta, ma
|
||||
vwaddu.wv v0, v0, v8
|
||||
vwaddu.wv v1, v1, v9
|
||||
vwaddu.wv v2, v2, v10
|
||||
vwaddu.wv v3, v3, v11
|
||||
vwaddu.wv v4, v4, v12
|
||||
vwaddu.wv v5, v5, v13
|
||||
vwaddu.wv v6, v6, v14
|
||||
vwaddu.wv v7, v7, v15
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
.irp n,0,1,2,3,4,5,6,7
|
||||
vmax.vx v\n, v\n, zero
|
||||
.endr
|
||||
vsetvli zero, zero, e8, mf4, ta, ma
|
||||
vnclipu.wi v8, v0, 0
|
||||
vnclipu.wi v9, v1, 0
|
||||
vse8.v v8, (a0)
|
||||
vnclipu.wi v10, v2, 0
|
||||
vse8.v v9, (t0)
|
||||
vnclipu.wi v11, v3, 0
|
||||
vse8.v v10, (t1)
|
||||
vnclipu.wi v12, v4, 0
|
||||
vse8.v v11, (t2)
|
||||
vnclipu.wi v13, v5, 0
|
||||
vse8.v v12, (t3)
|
||||
vnclipu.wi v14, v6, 0
|
||||
vse8.v v13, (t4)
|
||||
vnclipu.wi v15, v7, 0
|
||||
vse8.v v14, (t5)
|
||||
vse8.v v15, (t6)
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_vc1_inv_trans_4x4_rvv, zve32x
|
||||
lpad 0
|
||||
li a3, 8 * 2
|
||||
csrwi vxrm, 0
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
vlsseg4e16.v v0, (a2), a3
|
||||
li t1, 3
|
||||
jal t0, ff_vc1_inv_trans_4_rvv
|
||||
vssseg4e16.v v0, (a2), a3
|
||||
addi t1, a2, 2 * 4 * 2
|
||||
vle16.v v0, (a2)
|
||||
addi t2, a2, 4 * 4 * 2
|
||||
vle16.v v1, (t1)
|
||||
addi t3, a2, 6 * 4 * 2
|
||||
vle16.v v2, (t2)
|
||||
vle16.v v3, (t3)
|
||||
li t1, 7
|
||||
jal t0, ff_vc1_inv_trans_4_rvv
|
||||
add t1, a1, a0
|
||||
vle8.v v8, (a0)
|
||||
add t2, a1, t1
|
||||
vle8.v v9, (t1)
|
||||
add t3, a1, t2
|
||||
vle8.v v10, (t2)
|
||||
vle8.v v11, (t3)
|
||||
vsetvli zero, zero, e8, mf4, ta, ma
|
||||
vwaddu.wv v0, v0, v8
|
||||
vwaddu.wv v1, v1, v9
|
||||
vwaddu.wv v2, v2, v10
|
||||
vwaddu.wv v3, v3, v11
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
.irp n,0,1,2,3
|
||||
vmax.vx v\n, v\n, zero
|
||||
.endr
|
||||
vsetvli zero, zero, e8, mf4, ta, ma
|
||||
vnclipu.wi v8, v0, 0
|
||||
vnclipu.wi v9, v1, 0
|
||||
vse8.v v8, (a0)
|
||||
vnclipu.wi v10, v2, 0
|
||||
vse8.v v9, (t1)
|
||||
vnclipu.wi v11, v3, 0
|
||||
vse8.v v10, (t2)
|
||||
vse8.v v11, (t3)
|
||||
ret
|
||||
endfunc
|
||||
|
||||
.macro mspel_op op pos n1 n2
|
||||
add t1, \pos, a2
|
||||
v\op\()e8.v v\n1, (\pos)
|
||||
sh1add \pos, a2, \pos
|
||||
v\op\()e8.v v\n2, (t1)
|
||||
.endm
|
||||
|
||||
.macro mspel_op_all op pos a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16
|
||||
mspel_op \op \pos \a1 \a2
|
||||
mspel_op \op \pos \a3 \a4
|
||||
mspel_op \op \pos \a5 \a6
|
||||
mspel_op \op \pos \a7 \a8
|
||||
mspel_op \op \pos \a9 \a10
|
||||
mspel_op \op \pos \a11 \a12
|
||||
mspel_op \op \pos \a13 \a14
|
||||
mspel_op \op \pos \a15 \a16
|
||||
.endm
|
||||
|
||||
func ff_avg_pixels16x16_rvv, zve32x
|
||||
lpad 0
|
||||
li t0, 16
|
||||
vsetivli zero, 16, e8, m1, ta, ma
|
||||
j 1f
|
||||
endfunc
|
||||
|
||||
func ff_avg_pixels8x8_rvv, zve32x
|
||||
lpad 0
|
||||
li t0, 8
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
1:
|
||||
csrwi vxrm, 0
|
||||
2:
|
||||
vle8.v v16, (a1)
|
||||
addi t0, t0, -1
|
||||
vle8.v v8, (a0)
|
||||
add a1, a1, a2
|
||||
vaaddu.vv v16, v16, v8
|
||||
vse8.v v16, (a0)
|
||||
add a0, a0, a2
|
||||
bnez t0, 2b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_vc1_unescape_buffer_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, 2, e8, m1, ta, ma
|
||||
vmv.v.i v8, -1
|
||||
li t4, 1
|
||||
vmv.v.i v12, -1
|
||||
li t3, -1
|
||||
mv t5, a2
|
||||
blez a1, 3f
|
||||
1:
|
||||
vsetvli t0, a1, e8, m4, ta, ma
|
||||
vle8.v v16, (a0)
|
||||
vslideup.vi v8, v16, 2
|
||||
addi t0, t0, -1 # we cannot fully process the last element
|
||||
vslideup.vi v12, v16, 1
|
||||
vslide1down.vx v20, v16, t3
|
||||
vsetvli zero, t0, e8, m4, ta, ma
|
||||
vmseq.vi v0, v8, 0
|
||||
vmseq.vi v1, v12, 0
|
||||
vmseq.vi v2, v16, 3
|
||||
vmand.mm v0, v0, v1
|
||||
vmsltu.vi v3, v20, 4
|
||||
vmand.mm v0, v0, v2
|
||||
vmand.mm v0, v0, v3
|
||||
vfirst.m t2, v0
|
||||
bgez t2, 4f # found an escape byte?
|
||||
|
||||
vse8.v v16, (a2)
|
||||
addi t2, t0, -2
|
||||
add a2, a2, t0
|
||||
2:
|
||||
vslidedown.vx v8, v16, t2
|
||||
sub a1, a1, t0
|
||||
vslidedown.vi v12, v8, 1
|
||||
add a0, a0, t0
|
||||
bgtu a1, t4, 1b // size > 1
|
||||
|
||||
lb t0, (a0)
|
||||
sb t0, (a2) # copy last byte (cannot be escaped)
|
||||
addi a2, a2, 1
|
||||
3:
|
||||
sub a0, a2, t5
|
||||
ret
|
||||
4:
|
||||
vsetvli zero, t2, e8, m4, ta, ma
|
||||
vse8.v v16, (a2)
|
||||
addi t0, t2, 1
|
||||
add a2, a2, t2
|
||||
addi t2, t2, -1
|
||||
vsetvli zero, t0, e8, m4, ta, ma
|
||||
j 2b
|
||||
endfunc
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright © 2022 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 "libavutil/riscv/asm.S"
|
||||
|
||||
#if HAVE_RV_ZICBOP
|
||||
func ff_prefetch_rv_zicbop, zicbop
|
||||
1:
|
||||
addi a2, a2, -1
|
||||
prefetch.r 0(a0)
|
||||
add a0, a0, a1
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/videodsp.h"
|
||||
|
||||
void ff_prefetch_rv_zicbop(const uint8_t *mem, ptrdiff_t stride, int h);
|
||||
|
||||
av_cold void ff_videodsp_init_riscv(VideoDSPContext *ctx, int bpc)
|
||||
{
|
||||
#if HAVE_RV_ZICBOP
|
||||
/* TODO: Since we pay for the indirect function call anyway, we should
|
||||
* only set this if Cache-Block Operation Prefetch (Zicbop) is actually
|
||||
* supported and otherwise save a few cycles of NOPs.
|
||||
* But so far there are no means to detect Zicbop (in user mode).
|
||||
*/
|
||||
ctx->prefetch = ff_prefetch_rv_zicbop;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright © 2022 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavcodec/vorbisdsp.h"
|
||||
|
||||
void ff_vorbis_inverse_coupling_rvv(float *mag, float *ang,
|
||||
ptrdiff_t blocksize);
|
||||
|
||||
av_cold void ff_vorbisdsp_init_riscv(VorbisDSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB))
|
||||
c->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_rvv;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright © 2022 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_vorbis_inverse_coupling_rvv, zve32f, zba
|
||||
lpad 0
|
||||
fmv.w.x ft0, zero
|
||||
1:
|
||||
vsetvli t0, a2, e32, m4, ta, ma
|
||||
vle32.v v16, (a1)
|
||||
sub a2, a2, t0
|
||||
vle32.v v24, (a0)
|
||||
vfmax.vf v8, v16, ft0
|
||||
vfmin.vf v16, v16, ft0
|
||||
vfsgnj.vv v8, v8, v24
|
||||
vfsgnj.vv v16, v16, v24
|
||||
vfsub.vv v8, v24, v8
|
||||
vfsub.vv v24, v24, v16
|
||||
vse32.v v8, (a1)
|
||||
sh2add a1, t0, a1
|
||||
vse32.v v24, (a0)
|
||||
sh2add a0, t0, a0
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/vp8dsp.h"
|
||||
|
||||
void ff_vp7_luma_dc_wht_rvv(int16_t block[4][4][16], int16_t dc[16]);
|
||||
void ff_vp7_idct_add_rvv(uint8_t *dst, int16_t block[16], ptrdiff_t stride);
|
||||
void ff_vp78_idct_dc_add_rvv(uint8_t *, int16_t block[16], ptrdiff_t, int dc);
|
||||
void ff_vp7_idct_dc_add4y_rvv(uint8_t *dst, int16_t block[4][16], ptrdiff_t);
|
||||
void ff_vp7_idct_dc_add4uv_rvv(uint8_t *dst, int16_t block[4][16], ptrdiff_t);
|
||||
|
||||
static void ff_vp7_idct_dc_add_rvv(uint8_t *dst, int16_t block[16],
|
||||
ptrdiff_t stride)
|
||||
{
|
||||
int dc = (23170 * (23170 * block[0] >> 14) + 0x20000) >> 18;
|
||||
|
||||
ff_vp78_idct_dc_add_rvv(dst, block, stride, dc);
|
||||
}
|
||||
|
||||
av_cold void ff_vp7dsp_init_riscv(VP8DSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB) &&
|
||||
ff_rv_vlen_least(128)) {
|
||||
#if __riscv_xlen >= 64
|
||||
c->vp8_luma_dc_wht = ff_vp7_luma_dc_wht_rvv;
|
||||
c->vp8_idct_add = ff_vp7_idct_add_rvv;
|
||||
#endif
|
||||
c->vp8_idct_dc_add = ff_vp7_idct_dc_add_rvv;
|
||||
c->vp8_idct_dc_add4y = ff_vp7_idct_dc_add4y_rvv;
|
||||
if (flags & AV_CPU_FLAG_RVV_I64)
|
||||
c->vp8_idct_dc_add4uv = ff_vp7_idct_dc_add4uv_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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"
|
||||
|
||||
#if __riscv_xlen >= 64
|
||||
func ff_vp7_luma_dc_wht_rvv, zve32x, zba
|
||||
lpad 0
|
||||
li a2, 4 * 16 * 2
|
||||
li a7, 16 * 2
|
||||
jal t0, 1f
|
||||
vsse16.v v4, (a0), a7
|
||||
vsse16.v v5, (t1), a7
|
||||
vsse16.v v6, (t2), a7
|
||||
vsse16.v v7, (t3), a7
|
||||
ret
|
||||
1:
|
||||
csrwi vxrm, 0
|
||||
li t4, 12540
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
vlseg4e16.v v0, (a1)
|
||||
li t6, 30274
|
||||
vwmul.vx v8, v1, t4
|
||||
li t5, 23170
|
||||
vwmul.vx v9, v3, t6
|
||||
addi t1, sp, -12 * 2
|
||||
vwmul.vx v10, v1, t6
|
||||
addi t2, sp, -8 * 2
|
||||
vwmul.vx v11, v3, t4
|
||||
addi t3, sp, -4 * 2
|
||||
vwadd.vv v4, v0, v2
|
||||
addi sp, sp, -16 * 2
|
||||
vwsub.vv v5, v0, v2
|
||||
vsetvli zero, zero, e32, m1, ta, ma
|
||||
vadd.vv v7, v10, v11
|
||||
vmul.vx v4, v4, t5
|
||||
vsub.vv v6, v8, v9
|
||||
vmul.vx v5, v5, t5
|
||||
vadd.vv v0, v4, v7
|
||||
vsub.vv v3, v4, v7
|
||||
vadd.vv v1, v5, v6
|
||||
vsub.vv v2, v5, v6
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
vnsra.wi v4, v0, 14
|
||||
vnsra.wi v7, v3, 14
|
||||
vnsra.wi v5, v1, 14
|
||||
vnsra.wi v6, v2, 14
|
||||
vsseg4e16.v v4, (sp)
|
||||
vle16.v v0, (sp)
|
||||
vle16.v v1, (t1)
|
||||
vle16.v v2, (t2)
|
||||
vle16.v v3, (t3)
|
||||
vwmul.vx v8, v1, t4
|
||||
vwmul.vx v9, v3, t6
|
||||
add t1, a2, a0
|
||||
vwmul.vx v10, v1, t6
|
||||
sh1add t2, a2, a0
|
||||
vwmul.vx v11, v3, t4
|
||||
sh1add a2, a2, a2 # a2 *= 3
|
||||
vwadd.vv v4, v0, v2
|
||||
add t3, a2, a0
|
||||
vwsub.vv v5, v0, v2
|
||||
vsetvli zero, zero, e32, m1, ta, ma
|
||||
vmul.vx v4, v4, t5
|
||||
sd zero, (a1)
|
||||
vadd.vv v7, v10, v11
|
||||
sd zero, 8(a1)
|
||||
vmul.vx v5, v5, t5
|
||||
sd zero, 16(a1)
|
||||
vsub.vv v6, v8, v9
|
||||
sd zero, 24(a1)
|
||||
vadd.vv v0, v4, v7
|
||||
addi sp, sp, 16 * 2
|
||||
vsub.vv v3, v4, v7
|
||||
vadd.vv v1, v5, v6
|
||||
vsub.vv v2, v5, v6
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
vnclip.wi v4, v0, 18
|
||||
vnclip.wi v5, v1, 18
|
||||
vnclip.wi v6, v2, 18
|
||||
vnclip.wi v7, v3, 18
|
||||
jr t0
|
||||
endfunc
|
||||
|
||||
func ff_vp7_idct_add_rvv, zve32x
|
||||
lpad 0
|
||||
jal t0, 1b
|
||||
csrwi vxrm, 2
|
||||
vsetvli zero, zero, e8, mf4, ta, ma
|
||||
vle8.v v12, (a0)
|
||||
vle8.v v13, (t1)
|
||||
vwaddu.wv v4, v4, v12
|
||||
vle8.v v14, (t2)
|
||||
vwaddu.wv v5, v5, v13
|
||||
vle8.v v15, (t3)
|
||||
vwaddu.wv v6, v6, v14
|
||||
vwaddu.wv v7, v7, v15
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
vmax.vx v4, v4, zero
|
||||
vmax.vx v5, v5, zero
|
||||
vmax.vx v6, v6, zero
|
||||
vmax.vx v7, v7, zero
|
||||
vsetvli zero, zero, e8, mf4, ta, ma
|
||||
vnclipu.wi v0, v4, 0
|
||||
vnclipu.wi v1, v5, 0
|
||||
vse8.v v0, (a0)
|
||||
vnclipu.wi v2, v6, 0
|
||||
vse8.v v1, (t1)
|
||||
vnclipu.wi v3, v7, 0
|
||||
vse8.v v2, (t2)
|
||||
vse8.v v3, (t3)
|
||||
ret
|
||||
endfunc
|
||||
#endif
|
||||
|
||||
.irp type, y, uv
|
||||
func ff_vp7_idct_dc_add4\type\()_rvv, zve32x
|
||||
lpad 0
|
||||
li t0, 32
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
li t1, 23170
|
||||
vlse16.v v8, (a1), t0 # block[0..3][0]
|
||||
vwmul.vx v0, v8, t1
|
||||
li t2, 0x20000 - (128 << 18)
|
||||
vsetvli zero, zero, e32, m1, ta, ma
|
||||
vsra.vi v0, v0, 14
|
||||
vmul.vx v0, v0, t1
|
||||
vadd.vx v0, v0, t2
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
vnsra.wi v8, v0, 18 # 4x DC
|
||||
tail ff_vp78_idct_dc_add4\type\()_rvv
|
||||
endfunc
|
||||
.endr
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_RISCV_VP8DSP_H
|
||||
#define AVCODEC_RISCV_VP8DSP_H
|
||||
|
||||
#include "libavcodec/vp8dsp.h"
|
||||
|
||||
#define VP8_LF_Y(hv, inner, opt) \
|
||||
void ff_vp8_##hv##_loop_filter16##inner##_##opt(uint8_t *dst, \
|
||||
ptrdiff_t stride, \
|
||||
int flim_E, int flim_I, \
|
||||
int hev_thresh)
|
||||
|
||||
#define VP8_LF_UV(hv, inner, opt) \
|
||||
void ff_vp8_##hv##_loop_filter8uv##inner##_##opt(uint8_t *dstU, \
|
||||
uint8_t *dstV, \
|
||||
ptrdiff_t stride, \
|
||||
int flim_E, int flim_I, \
|
||||
int hev_thresh)
|
||||
|
||||
#define VP8_LF_SIMPLE(hv, opt) \
|
||||
void ff_vp8_##hv##_loop_filter16_simple_##opt(uint8_t *dst, \
|
||||
ptrdiff_t stride, \
|
||||
int flim)
|
||||
|
||||
#define VP8_LF_HV(inner, opt) \
|
||||
VP8_LF_Y(h, inner, opt); \
|
||||
VP8_LF_Y(v, inner, opt); \
|
||||
VP8_LF_UV(h, inner, opt); \
|
||||
VP8_LF_UV(v, inner, opt)
|
||||
|
||||
#define VP8_LF(opt) \
|
||||
VP8_LF_HV(, opt); \
|
||||
VP8_LF_HV(_inner, opt); \
|
||||
VP8_LF_SIMPLE(h, opt); \
|
||||
VP8_LF_SIMPLE(v, opt)
|
||||
|
||||
#define VP8_MC(n, opt) \
|
||||
void ff_put_vp8_##n##_##opt(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, ptrdiff_t srcstride,\
|
||||
int h, int x, int y)
|
||||
|
||||
#define VP8_EPEL(w, opt) \
|
||||
VP8_MC(pixels ## w, opt); \
|
||||
VP8_MC(epel ## w ## _h4, opt); \
|
||||
VP8_MC(epel ## w ## _h6, opt); \
|
||||
VP8_MC(epel ## w ## _v4, opt); \
|
||||
VP8_MC(epel ## w ## _h4v4, opt); \
|
||||
VP8_MC(epel ## w ## _h6v4, opt); \
|
||||
VP8_MC(epel ## w ## _v6, opt); \
|
||||
VP8_MC(epel ## w ## _h4v6, opt); \
|
||||
VP8_MC(epel ## w ## _h6v6, opt)
|
||||
|
||||
#define VP8_BILIN(w, opt) \
|
||||
VP8_MC(bilin ## w ## _h, opt); \
|
||||
VP8_MC(bilin ## w ## _v, opt); \
|
||||
VP8_MC(bilin ## w ## _hv, opt)
|
||||
|
||||
#endif /* AVCODEC_RISCV_VP8DSP_H */
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/vp8dsp.h"
|
||||
#include "vp8dsp.h"
|
||||
|
||||
void ff_vp8_luma_dc_wht_rvv(int16_t block[4][4][16], int16_t dc[16]);
|
||||
void ff_vp8_idct_add_rvv(uint8_t *dst, int16_t block[16], ptrdiff_t stride);
|
||||
void ff_vp8_idct_dc_add_rvv(uint8_t *dst, int16_t block[16], ptrdiff_t stride);
|
||||
void ff_vp8_idct_dc_add4y_rvv(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride);
|
||||
void ff_vp8_idct_dc_add4uv_rvv(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride);
|
||||
|
||||
VP8_EPEL(16, rvi);
|
||||
VP8_EPEL(8, rvi);
|
||||
VP8_EPEL(4, rvi);
|
||||
VP8_EPEL(16, rvv);
|
||||
VP8_EPEL(8, rvv);
|
||||
VP8_EPEL(4, rvv);
|
||||
|
||||
VP8_BILIN(16, rvv);
|
||||
VP8_BILIN(8, rvv);
|
||||
VP8_BILIN(4, rvv);
|
||||
|
||||
av_cold void ff_vp78dsp_init_riscv(VP8DSPContext *c)
|
||||
{
|
||||
#if HAVE_RV
|
||||
int flags = av_get_cpu_flags();
|
||||
if (flags & AV_CPU_FLAG_RV_MISALIGNED) {
|
||||
#if __riscv_xlen >= 64
|
||||
c->put_vp8_epel_pixels_tab[0][0][0] = ff_put_vp8_pixels16_rvi;
|
||||
c->put_vp8_epel_pixels_tab[1][0][0] = ff_put_vp8_pixels8_rvi;
|
||||
c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_rvi;
|
||||
c->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_rvi;
|
||||
#endif
|
||||
c->put_vp8_epel_pixels_tab[2][0][0] = ff_put_vp8_pixels4_rvi;
|
||||
c->put_vp8_bilinear_pixels_tab[2][0][0] = ff_put_vp8_pixels4_rvi;
|
||||
}
|
||||
#if HAVE_RVV
|
||||
if (flags & AV_CPU_FLAG_RVV_I32 && ff_rv_vlen_least(128)) {
|
||||
c->put_vp8_bilinear_pixels_tab[0][0][1] = ff_put_vp8_bilin16_h_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[0][0][2] = ff_put_vp8_bilin16_h_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[1][0][1] = ff_put_vp8_bilin8_h_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[1][0][2] = ff_put_vp8_bilin8_h_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[2][0][1] = ff_put_vp8_bilin4_h_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[2][0][2] = ff_put_vp8_bilin4_h_rvv;
|
||||
|
||||
c->put_vp8_bilinear_pixels_tab[0][1][0] = ff_put_vp8_bilin16_v_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[0][2][0] = ff_put_vp8_bilin16_v_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[1][1][0] = ff_put_vp8_bilin8_v_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[1][2][0] = ff_put_vp8_bilin8_v_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[2][1][0] = ff_put_vp8_bilin4_v_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[2][2][0] = ff_put_vp8_bilin4_v_rvv;
|
||||
|
||||
c->put_vp8_bilinear_pixels_tab[0][1][1] = ff_put_vp8_bilin16_hv_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[0][1][2] = ff_put_vp8_bilin16_hv_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[0][2][1] = ff_put_vp8_bilin16_hv_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[0][2][2] = ff_put_vp8_bilin16_hv_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[1][1][1] = ff_put_vp8_bilin8_hv_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[1][1][2] = ff_put_vp8_bilin8_hv_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[1][2][1] = ff_put_vp8_bilin8_hv_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[1][2][2] = ff_put_vp8_bilin8_hv_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[2][1][1] = ff_put_vp8_bilin4_hv_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[2][1][2] = ff_put_vp8_bilin4_hv_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[2][2][1] = ff_put_vp8_bilin4_hv_rvv;
|
||||
c->put_vp8_bilinear_pixels_tab[2][2][2] = ff_put_vp8_bilin4_hv_rvv;
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVB) {
|
||||
c->put_vp8_epel_pixels_tab[0][0][2] = ff_put_vp8_epel16_h6_rvv;
|
||||
c->put_vp8_epel_pixels_tab[1][0][2] = ff_put_vp8_epel8_h6_rvv;
|
||||
c->put_vp8_epel_pixels_tab[2][0][2] = ff_put_vp8_epel4_h6_rvv;
|
||||
c->put_vp8_epel_pixels_tab[0][0][1] = ff_put_vp8_epel16_h4_rvv;
|
||||
c->put_vp8_epel_pixels_tab[1][0][1] = ff_put_vp8_epel8_h4_rvv;
|
||||
c->put_vp8_epel_pixels_tab[2][0][1] = ff_put_vp8_epel4_h4_rvv;
|
||||
|
||||
c->put_vp8_epel_pixels_tab[0][2][0] = ff_put_vp8_epel16_v6_rvv;
|
||||
c->put_vp8_epel_pixels_tab[1][2][0] = ff_put_vp8_epel8_v6_rvv;
|
||||
c->put_vp8_epel_pixels_tab[2][2][0] = ff_put_vp8_epel4_v6_rvv;
|
||||
c->put_vp8_epel_pixels_tab[0][1][0] = ff_put_vp8_epel16_v4_rvv;
|
||||
c->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_rvv;
|
||||
c->put_vp8_epel_pixels_tab[2][1][0] = ff_put_vp8_epel4_v4_rvv;
|
||||
#if __riscv_xlen <= 64
|
||||
c->put_vp8_epel_pixels_tab[0][2][2] = ff_put_vp8_epel16_h6v6_rvv;
|
||||
c->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_rvv;
|
||||
c->put_vp8_epel_pixels_tab[2][2][2] = ff_put_vp8_epel4_h6v6_rvv;
|
||||
c->put_vp8_epel_pixels_tab[0][2][1] = ff_put_vp8_epel16_h4v6_rvv;
|
||||
c->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_rvv;
|
||||
c->put_vp8_epel_pixels_tab[2][2][1] = ff_put_vp8_epel4_h4v6_rvv;
|
||||
c->put_vp8_epel_pixels_tab[0][1][1] = ff_put_vp8_epel16_h4v4_rvv;
|
||||
c->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_rvv;
|
||||
c->put_vp8_epel_pixels_tab[2][1][1] = ff_put_vp8_epel4_h4v4_rvv;
|
||||
c->put_vp8_epel_pixels_tab[0][1][2] = ff_put_vp8_epel16_h6v4_rvv;
|
||||
c->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_rvv;
|
||||
c->put_vp8_epel_pixels_tab[2][1][2] = ff_put_vp8_epel4_h6v4_rvv;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
av_cold void ff_vp8dsp_init_riscv(VP8DSPContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_RVV_I32 && ff_rv_vlen_least(128)) {
|
||||
#if __riscv_xlen >= 64
|
||||
if (flags & AV_CPU_FLAG_RVV_I64)
|
||||
c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_rvv;
|
||||
c->vp8_idct_add = ff_vp8_idct_add_rvv;
|
||||
#endif
|
||||
c->vp8_idct_dc_add = ff_vp8_idct_dc_add_rvv;
|
||||
c->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_rvv;
|
||||
if (flags & AV_CPU_FLAG_RVV_I64)
|
||||
c->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_rvv;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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"
|
||||
|
||||
#if __riscv_xlen >= 64
|
||||
func ff_put_vp8_pixels16_rvi
|
||||
lpad 0
|
||||
1:
|
||||
addi a4, a4, -1
|
||||
ld t0, (a2)
|
||||
ld t1, 8(a2)
|
||||
sd t0, (a0)
|
||||
sd t1, 8(a0)
|
||||
add a2, a2, a3
|
||||
add a0, a0, a1
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_put_vp8_pixels8_rvi
|
||||
lpad 0
|
||||
1:
|
||||
addi a4, a4, -1
|
||||
ld t0, (a2)
|
||||
sd t0, (a0)
|
||||
add a2, a2, a3
|
||||
add a0, a0, a1
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
#endif
|
||||
|
||||
func ff_put_vp8_pixels4_rvi
|
||||
lpad 0
|
||||
1:
|
||||
addi a4, a4, -1
|
||||
lw t0, (a2)
|
||||
sw t0, (a0)
|
||||
add a2, a2, a3
|
||||
add a0, a0, a1
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,551 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
* Copyright © 2024 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"
|
||||
|
||||
.macro vsetvlstatic8 len
|
||||
.if \len <= 4
|
||||
vsetivli zero, \len, e8, mf4, ta, ma
|
||||
.elseif \len <= 8
|
||||
vsetivli zero, \len, e8, mf2, ta, ma
|
||||
.elseif \len <= 16
|
||||
vsetivli zero, \len, e8, m1, ta, ma
|
||||
.elseif \len <= 31
|
||||
vsetivli zero, \len, e8, m2, ta, ma
|
||||
.endif
|
||||
.endm
|
||||
|
||||
.macro vsetvlstatic16 len
|
||||
.if \len <= 4
|
||||
vsetivli zero, \len, e16, mf2, ta, ma
|
||||
.elseif \len <= 8
|
||||
vsetivli zero, \len, e16, m1, ta, ma
|
||||
.elseif \len <= 16
|
||||
vsetivli zero, \len, e16, m2, ta, ma
|
||||
.endif
|
||||
.endm
|
||||
|
||||
#if __riscv_xlen >= 64
|
||||
func ff_vp8_luma_dc_wht_rvv, zve64x
|
||||
lpad 0
|
||||
vsetivli zero, 1, e64, m1, ta, ma
|
||||
vlseg4e64.v v4, (a1)
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
vwadd.vv v1, v5, v6
|
||||
addi t1, sp, -48
|
||||
vwadd.vv v0, v4, v7
|
||||
addi t2, sp, -32
|
||||
vwsub.vv v2, v5, v6
|
||||
addi t3, sp, -16
|
||||
vwsub.vv v3, v4, v7
|
||||
addi sp, sp, -64
|
||||
vsetvli zero, zero, e32, m1, ta, ma
|
||||
vadd.vv v4, v0, v1
|
||||
vadd.vv v5, v3, v2
|
||||
vse32.v v4, (sp)
|
||||
vsub.vv v6, v0, v1
|
||||
vse32.v v5, (t1)
|
||||
vsub.vv v7, v3, v2
|
||||
vse32.v v6, (t2)
|
||||
vse32.v v7, (t3)
|
||||
vlseg4e32.v v4, (sp)
|
||||
vadd.vv v0, v4, v7
|
||||
sd zero, (a1)
|
||||
vadd.vv v1, v5, v6
|
||||
sd zero, 8(a1)
|
||||
vsub.vv v2, v5, v6
|
||||
sd zero, 16(a1)
|
||||
vsub.vv v3, v4, v7
|
||||
sd zero, 24(a1)
|
||||
vadd.vi v0, v0, 3 # rounding mode not supported, do it manually
|
||||
li t0, 4 * 16 * 2
|
||||
vadd.vi v3, v3, 3
|
||||
addi t1, a0, 16 * 2
|
||||
vadd.vv v4, v0, v1
|
||||
addi t2, a0, 16 * 2 * 2
|
||||
vadd.vv v5, v3, v2
|
||||
addi t3, a0, 16 * 2 * 3
|
||||
vsub.vv v6, v0, v1
|
||||
vsub.vv v7, v3, v2
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
vnsra.wi v0, v4, 3
|
||||
addi sp, sp, 64
|
||||
vnsra.wi v1, v5, 3
|
||||
vsse16.v v0, (a0), t0
|
||||
vnsra.wi v2, v6, 3
|
||||
vsse16.v v1, (t1), t0
|
||||
vnsra.wi v3, v7, 3
|
||||
vsse16.v v2, (t2), t0
|
||||
vsse16.v v3, (t3), t0
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_vp8_idct_add_rvv, zve32x
|
||||
lpad 0
|
||||
csrwi vxrm, 0
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
addi a3, a1, 1 * 4 * 2
|
||||
addi a4, a1, 2 * 4 * 2
|
||||
addi a5, a1, 3 * 4 * 2
|
||||
li t1, 20091
|
||||
li t2, 35468
|
||||
jal t0, 1f
|
||||
vsseg4e16.v v0, (a1)
|
||||
jal t0, 1f
|
||||
vlsseg4e8.v v4, (a0), a2
|
||||
vssra.vi v0, v0, 3
|
||||
sd zero, (a1)
|
||||
vssra.vi v1, v1, 3
|
||||
sd zero, 8(a1)
|
||||
vssra.vi v2, v2, 3
|
||||
sd zero, 16(a1)
|
||||
vssra.vi v3, v3, 3
|
||||
sd zero, 24(a1)
|
||||
vsetvli zero, zero, e8, mf4, ta, ma
|
||||
vwaddu.wv v0, v0, v4
|
||||
vwaddu.wv v1, v1, v5
|
||||
vwaddu.wv v2, v2, v6
|
||||
vwaddu.wv v3, v3, v7
|
||||
vsetvli zero, zero, e16, mf2, ta, ma
|
||||
vmax.vx v0, v0, zero
|
||||
vmax.vx v1, v1, zero
|
||||
vmax.vx v2, v2, zero
|
||||
vmax.vx v3, v3, zero
|
||||
vsetvli zero, zero, e8, mf4, ta, ma
|
||||
vnclipu.wi v4, v0, 0
|
||||
vnclipu.wi v5, v1, 0
|
||||
vnclipu.wi v6, v2, 0
|
||||
vnclipu.wi v7, v3, 0
|
||||
vssseg4e8.v v4, (a0), a2
|
||||
ret
|
||||
1:
|
||||
vle16.v v0, (a1)
|
||||
vle16.v v2, (a4)
|
||||
vle16.v v1, (a3)
|
||||
vle16.v v3, (a5)
|
||||
vadd.vv v4, v0, v2 # t0
|
||||
vsub.vv v5, v0, v2 # t1
|
||||
vmulhsu.vx v8, v3, t1
|
||||
vmulhsu.vx v6, v1, t2
|
||||
vadd.vv v8, v8, v3
|
||||
vmulhsu.vx v7, v1, t1
|
||||
vmulhsu.vx v9, v3, t2
|
||||
vadd.vv v7, v7, v1
|
||||
vsub.vv v6, v6, v8 # t2
|
||||
vadd.vv v7, v7, v9 # t3
|
||||
vadd.vv v1, v5, v6
|
||||
vsub.vv v2, v5, v6
|
||||
vadd.vv v0, v4, v7
|
||||
vsub.vv v3, v4, v7
|
||||
jr t0
|
||||
endfunc
|
||||
#endif
|
||||
|
||||
func ff_vp8_idct_dc_add_rvv, zve32x
|
||||
lpad 0
|
||||
lh a3, (a1)
|
||||
addi a3, a3, 4
|
||||
srai a3, a3, 3
|
||||
# fall through
|
||||
endfunc
|
||||
|
||||
# a3 = DC
|
||||
func ff_vp78_idct_dc_add_rvv, zve32x
|
||||
vsetivli zero, 4, e8, mf4, ta, ma
|
||||
sh zero, (a1)
|
||||
vlse32.v v8, (a0), a2
|
||||
vsetivli zero, 16, e8, m1, ta, ma
|
||||
bgez a3, 1f
|
||||
|
||||
# block[0] < 0
|
||||
neg a3, a3
|
||||
vssubu.vx v8, v8, a3
|
||||
vsetivli zero, 4, e8, mf4, ta, ma
|
||||
vsse32.v v8, (a0), a2
|
||||
ret
|
||||
|
||||
1: # block[0] >= 0
|
||||
vsaddu.vx v8, v8, a3
|
||||
vsetivli zero, 4, e8, mf4, ta, ma
|
||||
vsse32.v v8, (a0), a2
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_vp8_idct_dc_add4y_rvv, zve32x
|
||||
lpad 0
|
||||
li t0, 32
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
li t1, 4 - (128 << 3)
|
||||
vlse16.v v8, (a1), t0
|
||||
vadd.vx v8, v8, t1
|
||||
vsra.vi v8, v8, 3
|
||||
# fall through
|
||||
endfunc
|
||||
|
||||
.variant_cc ff_vp78_idct_dc_add4y_rvv
|
||||
# v8 = [dc0 - 128, dc1 - 128, dc2 - 128, dc3 - 128]
|
||||
func ff_vp78_idct_dc_add4y_rvv, zve32x
|
||||
vsetivli zero, 16, e16, m2, ta, ma
|
||||
vid.v v4
|
||||
li a4, 4
|
||||
vsrl.vi v4, v4, 2
|
||||
li t1, 128
|
||||
vrgather.vv v0, v8, v4 # replicate each DC four times
|
||||
vsetvli zero, zero, e8, m1, ta, ma
|
||||
1:
|
||||
vle8.v v8, (a0)
|
||||
addi a4, a4, -1
|
||||
vwaddu.wv v16, v0, v8
|
||||
sh zero, (a1)
|
||||
vnclip.wi v8, v16, 0
|
||||
addi a1, a1, 32
|
||||
vxor.vx v8, v8, t1
|
||||
vse8.v v8, (a0)
|
||||
add a0, a0, a2
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_vp8_idct_dc_add4uv_rvv, zve32x
|
||||
lpad 0
|
||||
li t0, 32
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
li t1, 4 - (128 << 3)
|
||||
vlse16.v v8, (a1), t0
|
||||
vadd.vx v8, v8, t1
|
||||
vsra.vi v8, v8, 3
|
||||
# fall through
|
||||
endfunc
|
||||
|
||||
.variant_cc ff_vp78_idct_dc_add4uv_rvv
|
||||
func ff_vp78_idct_dc_add4uv_rvv, zve64x
|
||||
vsetivli zero, 16, e16, m2, ta, ma
|
||||
vid.v v4
|
||||
li a4, 4
|
||||
vsrl.vi v4, v4, 2
|
||||
li t1, 128
|
||||
vrgather.vv v0, v8, v4 # replicate each DC four times
|
||||
slli t2, a2, 2
|
||||
vsetivli zero, 2, e64, m1, ta, ma
|
||||
1:
|
||||
vlse64.v v8, (a0), t2
|
||||
addi a4, a4, -1
|
||||
vsetivli zero, 16, e8, m1, ta, ma
|
||||
vwaddu.wv v16, v0, v8
|
||||
sh zero, (a1)
|
||||
vnclip.wi v8, v16, 0
|
||||
addi a1, a1, 32
|
||||
vxor.vx v8, v8, t1
|
||||
vsetivli zero, 2, e64, m1, ta, ma
|
||||
vsse64.v v8, (a0), t2
|
||||
add a0, a0, a2
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
.macro bilin_load_h dst mn
|
||||
addi t5, a2, 1
|
||||
vle8.v \dst, (a2)
|
||||
vle8.v v2, (t5)
|
||||
vwmulu.vx v28, \dst, t1
|
||||
vwmaccu.vx v28, \mn, v2
|
||||
vwaddu.wx v24, v28, t4
|
||||
vnsra.wi \dst, v24, 3
|
||||
.endm
|
||||
|
||||
.macro put_vp8_bilin_h_v type mn
|
||||
func ff_put_vp8_bilin4_\type\()_rvv, zve32x
|
||||
lpad 0
|
||||
vsetvlstatic8 4
|
||||
.Lbilin_\type:
|
||||
li t1, 8
|
||||
li t4, 4
|
||||
sub t1, t1, \mn
|
||||
1:
|
||||
add t0, a2, a3
|
||||
add t2, a0, a1
|
||||
addi a4, a4, -2
|
||||
.ifc \type,v
|
||||
add t3, t0, a3
|
||||
.else
|
||||
addi t5, a2, 1
|
||||
addi t3, t0, 1
|
||||
vle8.v v2, (t5)
|
||||
.endif
|
||||
vle8.v v0, (a2)
|
||||
vle8.v v4, (t0)
|
||||
vle8.v v6, (t3)
|
||||
vwmulu.vx v28, v0, t1
|
||||
vwmulu.vx v26, v4, t1
|
||||
.ifc \type,v
|
||||
vwmaccu.vx v28, \mn, v4
|
||||
.else
|
||||
vwmaccu.vx v28, \mn, v2
|
||||
.endif
|
||||
vwmaccu.vx v26, \mn, v6
|
||||
vwaddu.wx v24, v28, t4
|
||||
vwaddu.wx v22, v26, t4
|
||||
vnsra.wi v30, v24, 3
|
||||
vnsra.wi v0, v22, 3
|
||||
vse8.v v30, (a0)
|
||||
vse8.v v0, (t2)
|
||||
add a2, t0, a3
|
||||
add a0, t2, a1
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
put_vp8_bilin_h_v h a5
|
||||
put_vp8_bilin_h_v v a6
|
||||
|
||||
func ff_put_vp8_bilin4_hv_rvv, zve32x
|
||||
lpad 0
|
||||
vsetvlstatic8 4
|
||||
.Lbilin_hv:
|
||||
li t3, 8
|
||||
sub t1, t3, a5
|
||||
sub t2, t3, a6
|
||||
li t4, 4
|
||||
bilin_load_h v4, a5
|
||||
add a2, a2, a3
|
||||
1:
|
||||
addi a4, a4, -1
|
||||
vwmulu.vx v20, v4, t2
|
||||
bilin_load_h v4, a5
|
||||
vwmaccu.vx v20, a6, v4
|
||||
vwaddu.wx v24, v20, t4
|
||||
vnsra.wi v0, v24, 3
|
||||
vse8.v v0, (a0)
|
||||
add a2, a2, a3
|
||||
add a0, a0, a1
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
.irp len,16,8
|
||||
func ff_put_vp8_bilin\len\()_h_rvv, zve32x
|
||||
lpad 0
|
||||
vsetvlstatic8 \len
|
||||
j .Lbilin_h
|
||||
endfunc
|
||||
|
||||
func ff_put_vp8_bilin\len\()_v_rvv, zve32x
|
||||
lpad 0
|
||||
vsetvlstatic8 \len
|
||||
j .Lbilin_v
|
||||
endfunc
|
||||
|
||||
func ff_put_vp8_bilin\len\()_hv_rvv, zve32x
|
||||
lpad 0
|
||||
vsetvlstatic8 \len
|
||||
j .Lbilin_hv
|
||||
endfunc
|
||||
.endr
|
||||
|
||||
const subpel_filters, align=0
|
||||
.byte 0, -6, 123, 12, -1, 0
|
||||
.byte 2, -11, 108, 36, -8, 1
|
||||
.byte 0, -9, 93, 50, -6, 0
|
||||
.byte 3, -16, 77, 77, -16, 3
|
||||
.byte 0, -6, 50, 93, -9, 0
|
||||
.byte 1, -8, 36, 108, -11, 2
|
||||
.byte 0, -1, 12, 123, -6, 0
|
||||
endconst
|
||||
|
||||
.macro epel_filter size type regtype
|
||||
.ifc \type,v
|
||||
addi \regtype\()0, a6, -1
|
||||
.else
|
||||
addi \regtype\()0, a5, -1
|
||||
.endif
|
||||
lla \regtype\()2, subpel_filters
|
||||
sh1add \regtype\()0, \regtype\()0, \regtype\()0
|
||||
sh1add \regtype\()0, \regtype\()0, \regtype\()2
|
||||
.irp n,1,2,3,4
|
||||
lb \regtype\n, \n(\regtype\()0)
|
||||
.endr
|
||||
.ifc \size,6
|
||||
lb \regtype\()5, 5(\regtype\()0)
|
||||
lb \regtype\()0, (\regtype\()0)
|
||||
.endif
|
||||
.endm
|
||||
|
||||
.macro epel_load dst len size type from_mem regtype
|
||||
.ifc \type,v
|
||||
sub t6, a2, a3
|
||||
add a7, a2, a3
|
||||
.else
|
||||
addi t6, a2, -1
|
||||
addi a7, a2, 1
|
||||
.endif
|
||||
|
||||
.if \from_mem
|
||||
vle8.v v24, (a2)
|
||||
vle8.v v22, (t6)
|
||||
vle8.v v26, (a7)
|
||||
.ifc \type,v
|
||||
add a7, a7, a3
|
||||
.else
|
||||
addi a7, a7, 1
|
||||
.endif
|
||||
vle8.v v28, (a7)
|
||||
vwmulu.vx v16, v24, \regtype\()2
|
||||
vwmulu.vx v20, v26, \regtype\()3
|
||||
.ifc \size,6
|
||||
.ifc \type,v
|
||||
sub t6, t6, a3
|
||||
add a7, a7, a3
|
||||
.else
|
||||
addi t6, t6, -1
|
||||
addi a7, a7, 1
|
||||
.endif
|
||||
vle8.v v24, (t6)
|
||||
vle8.v v26, (a7)
|
||||
vwmaccu.vx v16, \regtype\()0, v24
|
||||
vwmaccu.vx v16, \regtype\()5, v26
|
||||
.endif
|
||||
vwmaccsu.vx v16, \regtype\()1, v22
|
||||
vwmaccsu.vx v16, \regtype\()4, v28
|
||||
.else
|
||||
vwmulu.vx v16, v4, \regtype\()2
|
||||
vwmulu.vx v20, v6, \regtype\()3
|
||||
.ifc \size,6
|
||||
vwmaccu.vx v16, \regtype\()0, v0
|
||||
vwmaccu.vx v16, \regtype\()5, v10
|
||||
.endif
|
||||
vwmaccsu.vx v16, \regtype\()1, v2
|
||||
vwmaccsu.vx v16, \regtype\()4, v8
|
||||
.endif
|
||||
li t6, 64
|
||||
vwadd.wx v16, v16, t6
|
||||
vsetvlstatic16 \len
|
||||
vwadd.vv v24, v16, v20
|
||||
vnsra.wi v24, v24, 7
|
||||
vmax.vx v24, v24, zero
|
||||
vsetvlstatic8 \len
|
||||
vnclipu.wi \dst, v24, 0
|
||||
.endm
|
||||
|
||||
.macro epel_load_inc dst len size type from_mem regtype
|
||||
epel_load \dst \len \size \type \from_mem \regtype
|
||||
add a2, a2, a3
|
||||
.endm
|
||||
|
||||
.macro epel len size type
|
||||
func ff_put_vp8_epel\len\()_\type\()\size\()_rvv, zve32x, zba
|
||||
lpad 0
|
||||
epel_filter \size \type t
|
||||
vsetvlstatic8 \len
|
||||
1:
|
||||
addi a4, a4, -1
|
||||
epel_load_inc v30 \len \size \type 1 t
|
||||
vse8.v v30, (a0)
|
||||
add a0, a0, a1
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
.macro epel_hv len hsize vsize
|
||||
func ff_put_vp8_epel\len\()_h\hsize\()v\vsize\()_rvv, zve32x, zba
|
||||
lpad 0
|
||||
#if __riscv_xlen == 64
|
||||
addi sp, sp, -48
|
||||
.irp n,0,1,2,3,4,5
|
||||
sd s\n, (\n * 8)(sp)
|
||||
.endr
|
||||
#else
|
||||
addi sp, sp, -32
|
||||
.irp n,0,1,2,3,4,5
|
||||
sw s\n, (\n * 4)(sp)
|
||||
.endr
|
||||
#endif
|
||||
sub a2, a2, a3
|
||||
epel_filter \hsize h t
|
||||
epel_filter \vsize v s
|
||||
vsetvlstatic8 \len
|
||||
.if \hsize == 6 || \vsize == 6
|
||||
sub a2, a2, a3
|
||||
epel_load_inc v0 \len \hsize h 1 t
|
||||
.endif
|
||||
epel_load_inc v2 \len \hsize h 1 t
|
||||
epel_load_inc v4 \len \hsize h 1 t
|
||||
epel_load_inc v6 \len \hsize h 1 t
|
||||
epel_load_inc v8 \len \hsize h 1 t
|
||||
.if \hsize == 6 || \vsize == 6
|
||||
epel_load_inc v10 \len \hsize h 1 t
|
||||
.endif
|
||||
addi a4, a4, -1
|
||||
1:
|
||||
addi a4, a4, -1
|
||||
epel_load v30 \len \vsize v 0 s
|
||||
vse8.v v30, (a0)
|
||||
.if \hsize == 6 || \vsize == 6
|
||||
vmv.v.v v0, v2
|
||||
.endif
|
||||
vmv.v.v v2, v4
|
||||
vmv.v.v v4, v6
|
||||
vmv.v.v v6, v8
|
||||
.if \hsize == 6 || \vsize == 6
|
||||
vmv.v.v v8, v10
|
||||
epel_load_inc v10 \len \hsize h 1 t
|
||||
.else
|
||||
epel_load_inc v8 \len 4 h 1 t
|
||||
.endif
|
||||
add a0, a0, a1
|
||||
bnez a4, 1b
|
||||
epel_load v30 \len \vsize v 0 s
|
||||
vse8.v v30, (a0)
|
||||
|
||||
#if __riscv_xlen == 64
|
||||
.irp n,0,1,2,3,4,5
|
||||
ld s\n, (\n * 8)(sp)
|
||||
.endr
|
||||
addi sp, sp, 48
|
||||
#else
|
||||
.irp n,0,1,2,3,4,5
|
||||
lw s\n, (\n * 4)(sp)
|
||||
.endr
|
||||
addi sp, sp, 32
|
||||
#endif
|
||||
|
||||
ret
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
.irp len,16,8,4
|
||||
epel \len 6 h
|
||||
epel \len 4 h
|
||||
epel \len 6 v
|
||||
epel \len 4 v
|
||||
#if __riscv_xlen <= 64
|
||||
epel_hv \len 6 6
|
||||
epel_hv \len 4 4
|
||||
epel_hv \len 6 4
|
||||
epel_hv \len 4 6
|
||||
#endif
|
||||
.endr
|
||||
@@ -0,0 +1,300 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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"
|
||||
|
||||
.macro avgdc size
|
||||
vwredsumu.vs v16, v8, v16
|
||||
vsetivli zero, 1, e16, m1, ta, ma
|
||||
vmv.x.s t1, v16
|
||||
addi t1, t1, 1 << (\size - 1)
|
||||
srai t1, t1, \size
|
||||
.endm
|
||||
|
||||
.macro getdc type size
|
||||
.ifc \type,top
|
||||
vmv.v.x v16, zero
|
||||
vle8.v v8, (a3)
|
||||
avgdc \size
|
||||
.else
|
||||
.ifc \type,left
|
||||
vmv.v.x v16, zero
|
||||
vle8.v v8, (a2)
|
||||
avgdc \size
|
||||
.else
|
||||
.ifc \type,dc
|
||||
vmv.v.x v16, zero
|
||||
vle8.v v8, (a2)
|
||||
vwredsumu.vs v16, v8, v16
|
||||
vle8.v v8, (a3)
|
||||
avgdc \size
|
||||
.else
|
||||
li t1, \type
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
.endm
|
||||
|
||||
.macro dc_e32 type size n restore
|
||||
.ifc \size,32
|
||||
li t0, 32
|
||||
vsetvli zero, t0, e8, m2, ta, ma
|
||||
.else
|
||||
vsetivli zero, 16, e8, m1, ta, ma
|
||||
.endif
|
||||
getdc \type \n
|
||||
|
||||
.if \restore == 1 && \size == 32
|
||||
vsetvli zero, t0, e8, m2, ta, ma
|
||||
.elseif \restore == 1 && \size == 16
|
||||
vsetivli zero, 16, e8, m1, ta, ma
|
||||
.endif
|
||||
vmv.v.x v0, t1
|
||||
|
||||
.rept \size
|
||||
vse8.v v0, (a0)
|
||||
add a0, a0, a1
|
||||
.endr
|
||||
|
||||
ret
|
||||
.endm
|
||||
|
||||
.macro dc_e64 type size n restore
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
getdc \type \n
|
||||
|
||||
li t0, 64
|
||||
vsetvli zero, t0, e8, m4, ta, ma
|
||||
vmv.v.x v0, t1
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
vsse64.v v0, (a0), a1
|
||||
|
||||
ret
|
||||
.endm
|
||||
|
||||
.macro func_dc name size type n restore ext
|
||||
func ff_\()\name\()_\()\size\()x\size\()_rvv, \ext
|
||||
lpad 0
|
||||
.if \size == 8
|
||||
dc_e64 \type \size \n \restore
|
||||
.else
|
||||
dc_e32 \type \size \n \restore
|
||||
.endif
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
func_dc dc_127 32 127 0 0 zve32x
|
||||
func_dc dc_127 16 127 0 0 zve32x
|
||||
func_dc dc_127 8 127 0 0 zve64x
|
||||
func_dc dc_128 32 128 0 0 zve32x
|
||||
func_dc dc_128 16 128 0 0 zve32x
|
||||
func_dc dc_128 8 128 0 0 zve64x
|
||||
func_dc dc_129 32 129 0 0 zve32x
|
||||
func_dc dc_129 16 129 0 0 zve32x
|
||||
func_dc dc_129 8 129 0 0 zve64x
|
||||
func_dc dc 32 dc 6 1 zve32x
|
||||
func_dc dc 16 dc 5 1 zve32x
|
||||
func_dc dc 8 dc 4 0 zve64x
|
||||
func_dc dc_left 32 left 5 1 zve32x
|
||||
func_dc dc_left 16 left 4 1 zve32x
|
||||
func_dc dc_left 8 left 3 0 zve64x
|
||||
func_dc dc_top 32 top 5 1 zve32x
|
||||
func_dc dc_top 16 top 4 1 zve32x
|
||||
func_dc dc_top 8 top 3 0 zve64x
|
||||
|
||||
func ff_h_32x32_rvv, zve32x
|
||||
lpad 0
|
||||
li t0, 32
|
||||
addi a2, a2, 31
|
||||
vsetvli zero, t0, e8, m2, ta, ma
|
||||
|
||||
.rept 2
|
||||
.irp n, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
|
||||
lbu t1, (a2)
|
||||
addi a2, a2, -1
|
||||
vmv.v.x v\n, t1
|
||||
.endr
|
||||
.irp n, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
|
||||
vse8.v v\n, (a0)
|
||||
add a0, a0, a1
|
||||
.endr
|
||||
.endr
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h_16x16_rvv, zve32x
|
||||
lpad 0
|
||||
addi a2, a2, 15
|
||||
vsetivli zero, 16, e8, m1, ta, ma
|
||||
|
||||
.irp n, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
|
||||
lbu t1, (a2)
|
||||
addi a2, a2, -1
|
||||
vmv.v.x v\n, t1
|
||||
.endr
|
||||
.irp n, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
|
||||
vse8.v v\n, (a0)
|
||||
add a0, a0, a1
|
||||
.endr
|
||||
vse8.v v23, (a0)
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_h_8x8_rvv, zve32x
|
||||
lpad 0
|
||||
addi a2, a2, 7
|
||||
vsetivli zero, 8, e8, mf2, ta, ma
|
||||
|
||||
.irp n, 8, 9, 10, 11, 12, 13, 14, 15
|
||||
lbu t1, (a2)
|
||||
addi a2, a2, -1
|
||||
vmv.v.x v\n, t1
|
||||
.endr
|
||||
.irp n, 8, 9, 10, 11, 12, 13, 14
|
||||
vse8.v v\n, (a0)
|
||||
add a0, a0, a1
|
||||
.endr
|
||||
vse8.v v15, (a0)
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
.macro tm_sum4 dst1, dst2, dst3, dst4, top, n1
|
||||
lbu t1, \n1(a2)
|
||||
lbu t2, (\n1-1)(a2)
|
||||
lbu t3, (\n1-2)(a2)
|
||||
lbu t4, (\n1-3)(a2)
|
||||
sub t1, t1, a4
|
||||
sub t2, t2, a4
|
||||
sub t3, t3, a4
|
||||
sub t4, t4, a4
|
||||
vadd.vx \dst1, \top, t1
|
||||
vadd.vx \dst2, \top, t2
|
||||
vadd.vx \dst3, \top, t3
|
||||
vadd.vx \dst4, \top, t4
|
||||
.endm
|
||||
|
||||
func ff_tm_32x32_rvv, zve32x
|
||||
lpad 0
|
||||
lbu a4, -1(a3)
|
||||
li t5, 32
|
||||
|
||||
.irp offset, 31, 23, 15, 7
|
||||
vsetvli zero, t5, e16, m4, ta, ma
|
||||
vle8.v v8, (a3)
|
||||
vzext.vf2 v28, v8
|
||||
|
||||
tm_sum4 v0, v4, v8, v12, v28, \offset
|
||||
tm_sum4 v16, v20, v24, v28, v28, (\offset-4)
|
||||
|
||||
.irp n, 0, 4, 8, 12, 16, 20, 24, 28
|
||||
vmax.vx v\n, v\n, zero
|
||||
.endr
|
||||
|
||||
vsetvli zero, zero, e8, m2, ta, ma
|
||||
.irp n, 0, 4, 8, 12, 16, 20, 24, 28
|
||||
vnclipu.wi v\n, v\n, 0
|
||||
vse8.v v\n, (a0)
|
||||
add a0, a0, a1
|
||||
.endr
|
||||
.endr
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_tm_16x16_rvv, zve32x
|
||||
vsetivli zero, 16, e16, m2, ta, ma
|
||||
vle8.v v8, (a3)
|
||||
vzext.vf2 v30, v8
|
||||
lbu a4, -1(a3)
|
||||
|
||||
tm_sum4 v0, v2, v4, v6, v30, 15
|
||||
tm_sum4 v8, v10, v12, v14, v30, 11
|
||||
tm_sum4 v16, v18, v20, v22, v30, 7
|
||||
tm_sum4 v24, v26, v28, v30, v30, 3
|
||||
|
||||
.irp n, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
|
||||
vmax.vx v\n, v\n, zero
|
||||
.endr
|
||||
|
||||
vsetvli zero, zero, e8, m1, ta, ma
|
||||
.irp n, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28
|
||||
vnclipu.wi v\n, v\n, 0
|
||||
vse8.v v\n, (a0)
|
||||
add a0, a0, a1
|
||||
.endr
|
||||
vnclipu.wi v30, v30, 0
|
||||
vse8.v v30, (a0)
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_tm_8x8_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, 8, e16, m1, ta, ma
|
||||
vle8.v v8, (a3)
|
||||
vzext.vf2 v28, v8
|
||||
lbu a4, -1(a3)
|
||||
|
||||
tm_sum4 v16, v17, v18, v19, v28, 7
|
||||
tm_sum4 v20, v21, v22, v23, v28, 3
|
||||
|
||||
.irp n, 16, 17, 18, 19, 20, 21, 22, 23
|
||||
vmax.vx v\n, v\n, zero
|
||||
.endr
|
||||
|
||||
vsetvli zero, zero, e8, mf2, ta, ma
|
||||
.irp n, 16, 17, 18, 19, 20, 21, 22
|
||||
vnclipu.wi v\n, v\n, 0
|
||||
vse8.v v\n, (a0)
|
||||
add a0, a0, a1
|
||||
.endr
|
||||
vnclipu.wi v24, v23, 0
|
||||
vse8.v v24, (a0)
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_tm_4x4_rvv, zve32x
|
||||
lpad 0
|
||||
vsetivli zero, 4, e16, mf2, ta, ma
|
||||
vle8.v v8, (a3)
|
||||
vzext.vf2 v28, v8
|
||||
lbu a4, -1(a3)
|
||||
|
||||
tm_sum4 v16, v17, v18, v19, v28, 3
|
||||
|
||||
.irp n, 16, 17, 18, 19
|
||||
vmax.vx v\n, v\n, zero
|
||||
.endr
|
||||
|
||||
vsetvli zero, zero, e8, mf4, ta, ma
|
||||
.irp n, 16, 17, 18
|
||||
vnclipu.wi v\n, v\n, 0
|
||||
vse8.v v\n, (a0)
|
||||
add a0, a0, a1
|
||||
.endr
|
||||
vnclipu.wi v24, v19, 0
|
||||
vse8.v v24, (a0)
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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"
|
||||
|
||||
#if __riscv_xlen >= 64
|
||||
func ff_copy64_rvi
|
||||
lpad 0
|
||||
1:
|
||||
addi a4, a4, -1
|
||||
ld t0, (a2)
|
||||
ld t1, 8(a2)
|
||||
ld t2, 16(a2)
|
||||
ld t3, 24(a2)
|
||||
ld t4, 32(a2)
|
||||
ld t5, 40(a2)
|
||||
ld t6, 48(a2)
|
||||
ld a7, 56(a2)
|
||||
sd t0, (a0)
|
||||
sd t1, 8(a0)
|
||||
sd t2, 16(a0)
|
||||
sd t3, 24(a0)
|
||||
sd t4, 32(a0)
|
||||
sd t5, 40(a0)
|
||||
sd t6, 48(a0)
|
||||
sd a7, 56(a0)
|
||||
add a2, a2, a3
|
||||
add a0, a0, a1
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_copy32_rvi
|
||||
lpad 0
|
||||
1:
|
||||
addi a4, a4, -1
|
||||
ld t0, (a2)
|
||||
ld t1, 8(a2)
|
||||
ld t2, 16(a2)
|
||||
ld t3, 24(a2)
|
||||
sd t0, (a0)
|
||||
sd t1, 8(a0)
|
||||
sd t2, 16(a0)
|
||||
sd t3, 24(a0)
|
||||
add a2, a2, a3
|
||||
add a0, a0, a1
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_copy16_rvi
|
||||
lpad 0
|
||||
1:
|
||||
addi a4, a4, -1
|
||||
ld t0, (a2)
|
||||
ld t1, 8(a2)
|
||||
sd t0, (a0)
|
||||
sd t1, 8(a0)
|
||||
add a2, a2, a3
|
||||
add a0, a0, a1
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_copy8_rvi
|
||||
lpad 0
|
||||
1:
|
||||
addi a4, a4, -1
|
||||
ld t0, (a2)
|
||||
sd t0, (a0)
|
||||
add a2, a2, a3
|
||||
add a0, a0, a1
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
#endif
|
||||
|
||||
func ff_copy4_rvi
|
||||
lpad 0
|
||||
1:
|
||||
addi a4, a4, -1
|
||||
lw t0, (a2)
|
||||
sw t0, (a0)
|
||||
add a2, a2, a3
|
||||
add a0, a0, a1
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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"
|
||||
|
||||
.macro vsetvlstatic8 len an maxlen mn=m4
|
||||
.if \len == 4
|
||||
vsetivli zero, \len, e8, mf4, ta, ma
|
||||
.elseif \len == 8
|
||||
vsetivli zero, \len, e8, mf2, ta, ma
|
||||
.elseif \len == 16
|
||||
vsetivli zero, \len, e8, m1, ta, ma
|
||||
.elseif \len == 32
|
||||
li \an, \len
|
||||
vsetvli zero, \an, e8, m2, ta, ma
|
||||
.elseif \len == 64
|
||||
li \an, \maxlen
|
||||
vsetvli zero, \an, e8, \mn, ta, ma
|
||||
.endif
|
||||
.endm
|
||||
|
||||
.macro copy_avg len
|
||||
func ff_vp9_avg\len\()_rvv, zve32x
|
||||
lpad 0
|
||||
csrwi vxrm, 0
|
||||
vsetvlstatic8 \len, t0, 64
|
||||
1:
|
||||
vle8.v v8, (a2)
|
||||
vle8.v v16, (a0)
|
||||
vaaddu.vv v8, v8, v16
|
||||
addi a4, a4, -1
|
||||
vse8.v v8, (a0)
|
||||
add a2, a2, a3
|
||||
add a0, a0, a1
|
||||
bnez a4, 1b
|
||||
ret
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
.macro bilin_load dst, mn, type
|
||||
.ifc \type,v
|
||||
add t4, a2, a3
|
||||
.else
|
||||
addi t4, a2, 1
|
||||
.endif
|
||||
vle8.v v4, (a2)
|
||||
vle8.v v0, (t4)
|
||||
vwmulu.vx v16, v0, \mn
|
||||
vwmaccsu.vx v16, t1, v4
|
||||
vwadd.wx v16, v16, t3
|
||||
vnsra.wi v16, v16, 4
|
||||
vadd.vv \dst, v16, v4
|
||||
add a2, a2, a3
|
||||
.endm
|
||||
|
||||
.macro bilin_h_v op, type, mn
|
||||
func ff_\op\()_vp9_bilin_64\type\()_rvv, zve32x
|
||||
lpad 0
|
||||
vsetvlstatic8 64, t0, 64
|
||||
.ifc \op,avg
|
||||
csrwi vxrm, 0
|
||||
.endif
|
||||
li t3, 8
|
||||
neg t1, \mn
|
||||
1:
|
||||
addi a4, a4, -1
|
||||
bilin_load v0, \mn, \type
|
||||
.ifc \op,avg
|
||||
vle8.v v16, (a0)
|
||||
vaaddu.vv v0, v0, v16
|
||||
.endif
|
||||
vse8.v v0, (a0)
|
||||
add a0, a0, a1
|
||||
bnez a4, 1b
|
||||
ret
|
||||
|
||||
.Lbilin_\type\op:
|
||||
.ifc \op,avg
|
||||
csrwi vxrm, 0
|
||||
.endif
|
||||
li t4, 8
|
||||
neg t1, \mn
|
||||
1:
|
||||
addi a4, a4, -2
|
||||
add t6, a0, a1
|
||||
add t0, a2, a3
|
||||
vle8.v v8, (a2)
|
||||
vle8.v v4, (t0)
|
||||
.ifc \type,v
|
||||
add t2, t0, a3
|
||||
vwmulu.vx v16, v4, \mn
|
||||
.else
|
||||
addi t3, a2, 1
|
||||
addi t2, t0, 1
|
||||
vle8.v v0, (t3)
|
||||
vwmulu.vx v16, v0, \mn
|
||||
.endif
|
||||
vle8.v v12, (t2)
|
||||
vwmulu.vx v20, v12, \mn
|
||||
vwmaccsu.vx v16, t1, v8
|
||||
vwmaccsu.vx v20, t1, v4
|
||||
vwadd.wx v16, v16, t4
|
||||
vwadd.wx v20, v20, t4
|
||||
vnsra.wi v16, v16, 4
|
||||
vnsra.wi v20, v20, 4
|
||||
vadd.vv v0, v16, v8
|
||||
vadd.vv v12, v20, v4
|
||||
.ifc \op,avg
|
||||
vle8.v v16, (a0)
|
||||
vle8.v v20, (t6)
|
||||
vaaddu.vv v0, v0, v16
|
||||
vaaddu.vv v12, v12, v20
|
||||
.endif
|
||||
vse8.v v0, (a0)
|
||||
vse8.v v12, (t6)
|
||||
add a2, t0, a3
|
||||
add a0, t6, a1
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
.macro bilin_hv op
|
||||
func ff_\op\()_vp9_bilin_64hv_rvv, zve32x
|
||||
lpad 0
|
||||
vsetvlstatic8 64, t0, 64
|
||||
.Lbilin_hv\op:
|
||||
.ifc \op,avg
|
||||
csrwi vxrm, 0
|
||||
.endif
|
||||
neg t1, a5
|
||||
neg t2, a6
|
||||
li t3, 8
|
||||
bilin_load v24, a5, h
|
||||
1:
|
||||
addi a4, a4, -2
|
||||
bilin_load v8, a5, h
|
||||
vwmulu.vx v16, v8, a6
|
||||
vwmaccsu.vx v16, t2, v24
|
||||
vwadd.wx v16, v16, t3
|
||||
vnsra.wi v16, v16, 4
|
||||
vadd.vv v12, v16, v24
|
||||
add t5, a0, a1
|
||||
bilin_load v24, a5, h
|
||||
vwmulu.vx v16, v24, a6
|
||||
vwmaccsu.vx v16, t2, v8
|
||||
vwadd.wx v16, v16, t3
|
||||
vnsra.wi v16, v16, 4
|
||||
vadd.vv v0, v16, v8
|
||||
.ifc \op,avg
|
||||
vle8.v v8, (a0)
|
||||
vle8.v v16, (t5)
|
||||
vaaddu.vv v12, v12, v8
|
||||
vaaddu.vv v0, v0, v16
|
||||
.endif
|
||||
vse8.v v12, (a0)
|
||||
vse8.v v0, (t5)
|
||||
add a0, t5, a1
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
.irp len, 64, 32, 16, 8, 4
|
||||
copy_avg \len
|
||||
.endr
|
||||
|
||||
bilin_h_v put, h, a5
|
||||
bilin_h_v avg, h, a5
|
||||
bilin_h_v put, v, a6
|
||||
bilin_h_v avg, v, a6
|
||||
bilin_hv put
|
||||
bilin_hv avg
|
||||
|
||||
.macro func_bilin_h_v len, op, type
|
||||
func ff_\op\()_vp9_bilin_\len\()\type\()_rvv, zve32x
|
||||
lpad 0
|
||||
vsetvlstatic8 \len, t0, 64
|
||||
j .Lbilin_\type\()\op
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
.irp len, 32, 16, 8, 4
|
||||
.irp op, put, avg
|
||||
.irp type, h, v, hv
|
||||
func_bilin_h_v \len, \op, \type
|
||||
.endr
|
||||
.endr
|
||||
.endr
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_RISCV_VP9DSP_H
|
||||
#define AVCODEC_RISCV_VP9DSP_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void ff_dc_32x32_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_16x16_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_8x8_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_top_32x32_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_top_16x16_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_top_8x8_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_left_32x32_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_left_16x16_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_left_8x8_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_127_32x32_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_127_16x16_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_127_8x8_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_128_32x32_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_128_16x16_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_128_8x8_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_129_32x32_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_129_16x16_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_dc_129_8x8_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_h_32x32_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_h_16x16_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_h_8x8_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_tm_32x32_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_tm_16x16_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_tm_8x8_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
void ff_tm_4x4_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l,
|
||||
const uint8_t *a);
|
||||
|
||||
#define VP9_8TAP_RISCV_RVV_FUNC(SIZE, type, type_idx) \
|
||||
void ff_put_8tap_##type##_##SIZE##h_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, \
|
||||
ptrdiff_t srcstride, \
|
||||
int h, int mx, int my); \
|
||||
\
|
||||
void ff_put_8tap_##type##_##SIZE##v_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, \
|
||||
ptrdiff_t srcstride, \
|
||||
int h, int mx, int my); \
|
||||
\
|
||||
void ff_put_8tap_##type##_##SIZE##hv_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, \
|
||||
ptrdiff_t srcstride, \
|
||||
int h, int mx, int my); \
|
||||
\
|
||||
void ff_avg_8tap_##type##_##SIZE##h_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, \
|
||||
ptrdiff_t srcstride, \
|
||||
int h, int mx, int my); \
|
||||
\
|
||||
void ff_avg_8tap_##type##_##SIZE##v_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, \
|
||||
ptrdiff_t srcstride, \
|
||||
int h, int mx, int my); \
|
||||
\
|
||||
void ff_avg_8tap_##type##_##SIZE##hv_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, \
|
||||
ptrdiff_t srcstride, \
|
||||
int h, int mx, int my);
|
||||
|
||||
#define VP9_BILINEAR_RISCV_RVV_FUNC(SIZE) \
|
||||
void ff_put_vp9_bilin_##SIZE##h_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, ptrdiff_t srcstride, \
|
||||
int h, int mx, int my); \
|
||||
\
|
||||
void ff_put_vp9_bilin_##SIZE##v_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, ptrdiff_t srcstride, \
|
||||
int h, int mx, int my); \
|
||||
\
|
||||
void ff_put_vp9_bilin_##SIZE##hv_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, ptrdiff_t srcstride, \
|
||||
int h, int mx, int my); \
|
||||
\
|
||||
void ff_avg_vp9_bilin_##SIZE##h_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, ptrdiff_t srcstride, \
|
||||
int h, int mx, int my); \
|
||||
\
|
||||
void ff_avg_vp9_bilin_##SIZE##v_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, ptrdiff_t srcstride, \
|
||||
int h, int mx, int my); \
|
||||
\
|
||||
void ff_avg_vp9_bilin_##SIZE##hv_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, ptrdiff_t srcstride, \
|
||||
int h, int mx, int my);
|
||||
|
||||
#define VP9_COPY_AVG_RISCV_RVV_FUNC(SIZE) \
|
||||
void ff_vp9_copy##SIZE##_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, ptrdiff_t srcstride, \
|
||||
int h, int mx, int my); \
|
||||
\
|
||||
void ff_vp9_avg##SIZE##_rvv(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, ptrdiff_t srcstride, \
|
||||
int h, int mx, int my);
|
||||
|
||||
VP9_8TAP_RISCV_RVV_FUNC(64, regular, FILTER_8TAP_REGULAR);
|
||||
VP9_8TAP_RISCV_RVV_FUNC(32, regular, FILTER_8TAP_REGULAR);
|
||||
VP9_8TAP_RISCV_RVV_FUNC(16, regular, FILTER_8TAP_REGULAR);
|
||||
VP9_8TAP_RISCV_RVV_FUNC(8, regular, FILTER_8TAP_REGULAR);
|
||||
VP9_8TAP_RISCV_RVV_FUNC(4, regular, FILTER_8TAP_REGULAR);
|
||||
|
||||
VP9_8TAP_RISCV_RVV_FUNC(64, sharp, FILTER_8TAP_SHARP);
|
||||
VP9_8TAP_RISCV_RVV_FUNC(32, sharp, FILTER_8TAP_SHARP);
|
||||
VP9_8TAP_RISCV_RVV_FUNC(16, sharp, FILTER_8TAP_SHARP);
|
||||
VP9_8TAP_RISCV_RVV_FUNC(8, sharp, FILTER_8TAP_SHARP);
|
||||
VP9_8TAP_RISCV_RVV_FUNC(4, sharp, FILTER_8TAP_SHARP);
|
||||
|
||||
VP9_8TAP_RISCV_RVV_FUNC(64, smooth, FILTER_8TAP_SMOOTH);
|
||||
VP9_8TAP_RISCV_RVV_FUNC(32, smooth, FILTER_8TAP_SMOOTH);
|
||||
VP9_8TAP_RISCV_RVV_FUNC(16, smooth, FILTER_8TAP_SMOOTH);
|
||||
VP9_8TAP_RISCV_RVV_FUNC(8, smooth, FILTER_8TAP_SMOOTH);
|
||||
VP9_8TAP_RISCV_RVV_FUNC(4, smooth, FILTER_8TAP_SMOOTH);
|
||||
|
||||
VP9_BILINEAR_RISCV_RVV_FUNC(64);
|
||||
VP9_BILINEAR_RISCV_RVV_FUNC(32);
|
||||
VP9_BILINEAR_RISCV_RVV_FUNC(16);
|
||||
VP9_BILINEAR_RISCV_RVV_FUNC(8);
|
||||
VP9_BILINEAR_RISCV_RVV_FUNC(4);
|
||||
|
||||
VP9_COPY_AVG_RISCV_RVV_FUNC(64);
|
||||
VP9_COPY_AVG_RISCV_RVV_FUNC(32);
|
||||
VP9_COPY_AVG_RISCV_RVV_FUNC(16);
|
||||
VP9_COPY_AVG_RISCV_RVV_FUNC(8);
|
||||
VP9_COPY_AVG_RISCV_RVV_FUNC(4);
|
||||
|
||||
#define VP9_COPY_RISCV_RVI_FUNC(SIZE) \
|
||||
void ff_copy##SIZE##_rvi(uint8_t *dst, ptrdiff_t dststride, \
|
||||
const uint8_t *src, ptrdiff_t srcstride, \
|
||||
int h, int mx, int my);
|
||||
|
||||
VP9_COPY_RISCV_RVI_FUNC(64);
|
||||
VP9_COPY_RISCV_RVI_FUNC(32);
|
||||
VP9_COPY_RISCV_RVI_FUNC(16);
|
||||
VP9_COPY_RISCV_RVI_FUNC(8);
|
||||
VP9_COPY_RISCV_RVI_FUNC(4);
|
||||
|
||||
#undef VP9_8TAP_RISCV_RVV_FUNC
|
||||
#undef VP9_BILINEAR_RISCV_RVV_FUNC
|
||||
#undef VP9_COPY_AVG_RISCV_RVV_FUNC
|
||||
|
||||
#endif // #ifndef AVCODEC_RISCV_VP9DSP_H
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lervvr 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
|
||||
* Lervvr General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lervvr 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/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/vp9dsp.h"
|
||||
#include "vp9dsp.h"
|
||||
|
||||
static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext *dsp, int bpp)
|
||||
{
|
||||
#if HAVE_RV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
# if __riscv_xlen >= 64
|
||||
if (bpp == 8 && (flags & AV_CPU_FLAG_RV_MISALIGNED)) {
|
||||
|
||||
#define init_fpel(idx1, sz) \
|
||||
dsp->mc[idx1][FILTER_8TAP_SMOOTH ][0][0][0] = ff_copy##sz##_rvi; \
|
||||
dsp->mc[idx1][FILTER_8TAP_REGULAR][0][0][0] = ff_copy##sz##_rvi; \
|
||||
dsp->mc[idx1][FILTER_8TAP_SHARP ][0][0][0] = ff_copy##sz##_rvi; \
|
||||
dsp->mc[idx1][FILTER_BILINEAR ][0][0][0] = ff_copy##sz##_rvi
|
||||
|
||||
init_fpel(0, 64);
|
||||
init_fpel(1, 32);
|
||||
init_fpel(2, 16);
|
||||
init_fpel(3, 8);
|
||||
init_fpel(4, 4);
|
||||
|
||||
#undef init_fpel
|
||||
}
|
||||
# endif
|
||||
|
||||
#if HAVE_RVV
|
||||
if (bpp == 8 && (flags & AV_CPU_FLAG_RVV_I32) && ff_rv_vlen_least(128)) {
|
||||
|
||||
#define init_fpel(idx1, sz) \
|
||||
dsp->mc[idx1][FILTER_8TAP_SMOOTH ][1][0][0] = ff_vp9_avg##sz##_rvv; \
|
||||
dsp->mc[idx1][FILTER_8TAP_REGULAR][1][0][0] = ff_vp9_avg##sz##_rvv; \
|
||||
dsp->mc[idx1][FILTER_8TAP_SHARP ][1][0][0] = ff_vp9_avg##sz##_rvv; \
|
||||
dsp->mc[idx1][FILTER_BILINEAR ][1][0][0] = ff_vp9_avg##sz##_rvv
|
||||
|
||||
init_fpel(0, 64);
|
||||
init_fpel(1, 32);
|
||||
init_fpel(2, 16);
|
||||
init_fpel(3, 8);
|
||||
init_fpel(4, 4);
|
||||
|
||||
dsp->mc[0][FILTER_BILINEAR ][0][0][1] = ff_put_vp9_bilin_64v_rvv;
|
||||
dsp->mc[0][FILTER_BILINEAR ][0][1][0] = ff_put_vp9_bilin_64h_rvv;
|
||||
dsp->mc[0][FILTER_BILINEAR ][1][0][1] = ff_avg_vp9_bilin_64v_rvv;
|
||||
dsp->mc[0][FILTER_BILINEAR ][1][1][0] = ff_avg_vp9_bilin_64h_rvv;
|
||||
dsp->mc[1][FILTER_BILINEAR ][0][0][1] = ff_put_vp9_bilin_32v_rvv;
|
||||
dsp->mc[1][FILTER_BILINEAR ][0][1][0] = ff_put_vp9_bilin_32h_rvv;
|
||||
dsp->mc[1][FILTER_BILINEAR ][1][0][1] = ff_avg_vp9_bilin_32v_rvv;
|
||||
dsp->mc[1][FILTER_BILINEAR ][1][1][0] = ff_avg_vp9_bilin_32h_rvv;
|
||||
dsp->mc[2][FILTER_BILINEAR ][0][0][1] = ff_put_vp9_bilin_16v_rvv;
|
||||
dsp->mc[2][FILTER_BILINEAR ][0][1][0] = ff_put_vp9_bilin_16h_rvv;
|
||||
dsp->mc[2][FILTER_BILINEAR ][1][0][1] = ff_avg_vp9_bilin_16v_rvv;
|
||||
dsp->mc[2][FILTER_BILINEAR ][1][1][0] = ff_avg_vp9_bilin_16h_rvv;
|
||||
dsp->mc[3][FILTER_BILINEAR ][0][0][1] = ff_put_vp9_bilin_8v_rvv;
|
||||
dsp->mc[3][FILTER_BILINEAR ][0][1][0] = ff_put_vp9_bilin_8h_rvv;
|
||||
dsp->mc[3][FILTER_BILINEAR ][1][0][1] = ff_avg_vp9_bilin_8v_rvv;
|
||||
dsp->mc[3][FILTER_BILINEAR ][1][1][0] = ff_avg_vp9_bilin_8h_rvv;
|
||||
dsp->mc[4][FILTER_BILINEAR ][0][0][1] = ff_put_vp9_bilin_4v_rvv;
|
||||
dsp->mc[4][FILTER_BILINEAR ][0][1][0] = ff_put_vp9_bilin_4h_rvv;
|
||||
dsp->mc[4][FILTER_BILINEAR ][1][0][1] = ff_avg_vp9_bilin_4v_rvv;
|
||||
dsp->mc[4][FILTER_BILINEAR ][1][1][0] = ff_avg_vp9_bilin_4h_rvv;
|
||||
dsp->mc[0][FILTER_BILINEAR ][0][1][1] = ff_put_vp9_bilin_64hv_rvv;
|
||||
dsp->mc[0][FILTER_BILINEAR ][1][1][1] = ff_avg_vp9_bilin_64hv_rvv;
|
||||
dsp->mc[1][FILTER_BILINEAR ][0][1][1] = ff_put_vp9_bilin_32hv_rvv;
|
||||
dsp->mc[1][FILTER_BILINEAR ][1][1][1] = ff_avg_vp9_bilin_32hv_rvv;
|
||||
dsp->mc[2][FILTER_BILINEAR ][0][1][1] = ff_put_vp9_bilin_16hv_rvv;
|
||||
dsp->mc[2][FILTER_BILINEAR ][1][1][1] = ff_avg_vp9_bilin_16hv_rvv;
|
||||
dsp->mc[3][FILTER_BILINEAR ][0][1][1] = ff_put_vp9_bilin_8hv_rvv;
|
||||
dsp->mc[3][FILTER_BILINEAR ][1][1][1] = ff_avg_vp9_bilin_8hv_rvv;
|
||||
dsp->mc[4][FILTER_BILINEAR ][0][1][1] = ff_put_vp9_bilin_4hv_rvv;
|
||||
dsp->mc[4][FILTER_BILINEAR ][1][1][1] = ff_avg_vp9_bilin_4hv_rvv;
|
||||
|
||||
#undef init_fpel
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static av_cold void vp9dsp_intrapred_init_riscv(VP9DSPContext *dsp, int bpp)
|
||||
{
|
||||
#if HAVE_RV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
#if HAVE_RVV
|
||||
if (bpp == 8 && flags & AV_CPU_FLAG_RVV_I64 && ff_rv_vlen_least(128)) {
|
||||
dsp->intra_pred[TX_8X8][DC_PRED] = ff_dc_8x8_rvv;
|
||||
dsp->intra_pred[TX_8X8][LEFT_DC_PRED] = ff_dc_left_8x8_rvv;
|
||||
dsp->intra_pred[TX_8X8][DC_127_PRED] = ff_dc_127_8x8_rvv;
|
||||
dsp->intra_pred[TX_8X8][DC_128_PRED] = ff_dc_128_8x8_rvv;
|
||||
dsp->intra_pred[TX_8X8][DC_129_PRED] = ff_dc_129_8x8_rvv;
|
||||
dsp->intra_pred[TX_8X8][TOP_DC_PRED] = ff_dc_top_8x8_rvv;
|
||||
}
|
||||
|
||||
if (bpp == 8 && flags & AV_CPU_FLAG_RVV_I32 && ff_rv_vlen_least(128)) {
|
||||
dsp->intra_pred[TX_32X32][DC_PRED] = ff_dc_32x32_rvv;
|
||||
dsp->intra_pred[TX_16X16][DC_PRED] = ff_dc_16x16_rvv;
|
||||
dsp->intra_pred[TX_32X32][LEFT_DC_PRED] = ff_dc_left_32x32_rvv;
|
||||
dsp->intra_pred[TX_16X16][LEFT_DC_PRED] = ff_dc_left_16x16_rvv;
|
||||
dsp->intra_pred[TX_32X32][DC_127_PRED] = ff_dc_127_32x32_rvv;
|
||||
dsp->intra_pred[TX_16X16][DC_127_PRED] = ff_dc_127_16x16_rvv;
|
||||
dsp->intra_pred[TX_32X32][DC_128_PRED] = ff_dc_128_32x32_rvv;
|
||||
dsp->intra_pred[TX_16X16][DC_128_PRED] = ff_dc_128_16x16_rvv;
|
||||
dsp->intra_pred[TX_32X32][DC_129_PRED] = ff_dc_129_32x32_rvv;
|
||||
dsp->intra_pred[TX_16X16][DC_129_PRED] = ff_dc_129_16x16_rvv;
|
||||
dsp->intra_pred[TX_32X32][TOP_DC_PRED] = ff_dc_top_32x32_rvv;
|
||||
dsp->intra_pred[TX_16X16][TOP_DC_PRED] = ff_dc_top_16x16_rvv;
|
||||
dsp->intra_pred[TX_32X32][HOR_PRED] = ff_h_32x32_rvv;
|
||||
dsp->intra_pred[TX_16X16][HOR_PRED] = ff_h_16x16_rvv;
|
||||
dsp->intra_pred[TX_8X8][HOR_PRED] = ff_h_8x8_rvv;
|
||||
dsp->intra_pred[TX_32X32][TM_VP8_PRED] = ff_tm_32x32_rvv;
|
||||
dsp->intra_pred[TX_16X16][TM_VP8_PRED] = ff_tm_16x16_rvv;
|
||||
dsp->intra_pred[TX_8X8][TM_VP8_PRED] = ff_tm_8x8_rvv;
|
||||
dsp->intra_pred[TX_4X4][TM_VP8_PRED] = ff_tm_4x4_rvv;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
av_cold void ff_vp9dsp_init_riscv(VP9DSPContext *dsp, int bpp, int bitexact)
|
||||
{
|
||||
vp9dsp_intrapred_init_riscv(dsp, bpp);
|
||||
vp9dsp_mc_init_riscv(dsp, bpp);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
OBJS-$(CONFIG_VVC_DECODER) += riscv/vvc/dsp_init.o
|
||||
RVV-OBJS-$(CONFIG_VVC_DECODER) += riscv/vvc/mc_rvv.o \
|
||||
riscv/vvc/sad_rvv.o
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
|
||||
*
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/riscv/cpu.h"
|
||||
#include "libavcodec/vvc/dsp.h"
|
||||
#include "libavcodec/vvc/dec.h"
|
||||
#include "libavcodec/riscv/h26x/h2656dsp.h"
|
||||
|
||||
#define bf(fn, bd, opt) fn##_##bd##_##opt
|
||||
|
||||
#define AVG_PROTOTYPES(bd, opt) \
|
||||
void bf(ff_vvc_avg, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, \
|
||||
const int16_t *src0, const int16_t *src1, int width, int height); \
|
||||
void bf(ff_vvc_w_avg, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, \
|
||||
const int16_t *src0, const int16_t *src1, int width, int height, \
|
||||
int denom, int w0, int w1, int o0, int o1);
|
||||
|
||||
AVG_PROTOTYPES(8, rvv_128)
|
||||
AVG_PROTOTYPES(8, rvv_256)
|
||||
|
||||
#define DMVR_PROTOTYPES(bd, opt) \
|
||||
void ff_vvc_dmvr_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \
|
||||
int height, intptr_t mx, intptr_t my, int width); \
|
||||
void ff_vvc_dmvr_h_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \
|
||||
int height, intptr_t mx, intptr_t my, int width); \
|
||||
void ff_vvc_dmvr_v_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \
|
||||
int height, intptr_t mx, intptr_t my, int width); \
|
||||
void ff_vvc_dmvr_hv_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \
|
||||
int height, intptr_t mx, intptr_t my, int width); \
|
||||
|
||||
DMVR_PROTOTYPES(8, rvv_128)
|
||||
DMVR_PROTOTYPES(8, rvv_256)
|
||||
|
||||
#define DMVR_INIT(bd, opt) do { \
|
||||
c->inter.dmvr[0][0] = ff_vvc_dmvr_##bd##_##opt; \
|
||||
c->inter.dmvr[0][1] = ff_vvc_dmvr_h_##bd##_##opt; \
|
||||
c->inter.dmvr[1][0] = ff_vvc_dmvr_v_##bd##_##opt; \
|
||||
c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_##bd##_##opt; \
|
||||
} while (0)
|
||||
|
||||
int ff_vvc_sad_rvv_128(const int16_t *src0, const int16_t *src1, int dx, int dy, int block_w, int block_h);
|
||||
int ff_vvc_sad_rvv_256(const int16_t *src0, const int16_t *src1, int dx, int dy, int block_w, int block_h);
|
||||
|
||||
#define PUT_PIXELS_PROTOTYPES2(bd, opt) \
|
||||
void bf(ff_vvc_put_pixels, bd, opt)(int16_t *dst, \
|
||||
const uint8_t *_src, const ptrdiff_t _src_stride, \
|
||||
const int height, const int8_t *hf, const int8_t *vf, const int width);
|
||||
|
||||
PUT_PIXELS_PROTOTYPES2(8, rvv_128)
|
||||
PUT_PIXELS_PROTOTYPES2(8, rvv_256)
|
||||
|
||||
#define PEL_FUNC(dst, C, idx1, idx2, a) \
|
||||
do { \
|
||||
for (int w = 1; w < 7; w++) \
|
||||
c->inter.dst[C][w][idx1][idx2] = a; \
|
||||
} while (0) \
|
||||
|
||||
#define FUNCS(C, opt) \
|
||||
PEL_FUNC(put, C, 0, 0, ff_vvc_put_pixels_8_##opt); \
|
||||
|
||||
void ff_vvc_dsp_init_riscv(VVCDSPContext *const c, const int bd)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
const int flags = av_get_cpu_flags();
|
||||
int vlenb;
|
||||
|
||||
if (!(flags & AV_CPU_FLAG_RVV_I32) || !(flags & AV_CPU_FLAG_RVB))
|
||||
return;
|
||||
|
||||
vlenb = ff_get_rv_vlenb();
|
||||
if (vlenb >= 32) {
|
||||
switch (bd) {
|
||||
case 8:
|
||||
c->inter.avg = ff_vvc_avg_8_rvv_256;
|
||||
# if (__riscv_xlen == 64)
|
||||
c->inter.w_avg = ff_vvc_w_avg_8_rvv_256;
|
||||
# endif
|
||||
DMVR_INIT(8, rvv_256);
|
||||
FUNCS(LUMA, rvv_256);
|
||||
FUNCS(CHROMA, rvv_256);
|
||||
break;
|
||||
case 10:
|
||||
c->inter.sad = ff_vvc_sad_rvv_256;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (vlenb >= 16) {
|
||||
switch (bd) {
|
||||
case 8:
|
||||
c->inter.avg = ff_vvc_avg_8_rvv_128;
|
||||
# if (__riscv_xlen == 64)
|
||||
c->inter.w_avg = ff_vvc_w_avg_8_rvv_128;
|
||||
# endif
|
||||
DMVR_INIT(8, rvv_128);
|
||||
FUNCS(LUMA, rvv_128);
|
||||
FUNCS(CHROMA, rvv_128);
|
||||
break;
|
||||
case 10:
|
||||
c->inter.sad = ff_vvc_sad_rvv_128;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user