[FFmpeg-cvslog] lavc/ac3dsp: R-V V float_to_fixed24
sunyuechi
git at videolan.org
Wed Dec 6 20:12:44 EET 2023
ffmpeg | branch: master | sunyuechi <sunyuechi at iscas.ac.cn> | Wed Nov 22 14:57:29 2023 +0800| [8bdb6630627a5c304e61f5b81be3af6da77c4a67] | committer: Rémi Denis-Courmont
lavc/ac3dsp: R-V V float_to_fixed24
c910
float_to_fixed24_c: 2207.2
float_to_fixed24_rvv_f32: 696.2
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8bdb6630627a5c304e61f5b81be3af6da77c4a67
---
libavcodec/riscv/Makefile | 1 +
libavcodec/riscv/ac3dsp_init.c | 4 ++++
libavcodec/riscv/ac3dsp_rvv.S | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+)
diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
index 2d0e6c19c8..29a7fec455 100644
--- a/libavcodec/riscv/Makefile
+++ b/libavcodec/riscv/Makefile
@@ -2,6 +2,7 @@ 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_AC3DSP) += riscv/ac3dsp_init.o \
riscv/ac3dsp_rvb.o
+RVV-OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_rvv.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 \
diff --git a/libavcodec/riscv/ac3dsp_init.c b/libavcodec/riscv/ac3dsp_init.c
index 20f294f1de..118b2955ca 100644
--- a/libavcodec/riscv/ac3dsp_init.c
+++ b/libavcodec/riscv/ac3dsp_init.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stddef.h>
#include <stdint.h>
#include "config.h"
@@ -26,6 +27,7 @@
#include "libavcodec/ac3dsp.h"
void ff_extract_exponents_rvb(uint8_t *exp, int32_t *coef, int nb_coefs);
+void ff_float_to_fixed24_rvv(int32_t *dst, const float *src, size_t len);
av_cold void ff_ac3dsp_init_riscv(AC3DSPContext *c)
{
@@ -34,5 +36,7 @@ av_cold void ff_ac3dsp_init_riscv(AC3DSPContext *c)
if (flags & AV_CPU_FLAG_RVB_ADDR) {
if (flags & AV_CPU_FLAG_RVB_BASIC)
c->extract_exponents = ff_extract_exponents_rvb;
+ if (flags & AV_CPU_FLAG_RVV_F32)
+ c->float_to_fixed24 = ff_float_to_fixed24_rvv;
}
}
diff --git a/libavcodec/riscv/ac3dsp_rvv.S b/libavcodec/riscv/ac3dsp_rvv.S
new file mode 100644
index 0000000000..b8d32c4677
--- /dev/null
+++ b/libavcodec/riscv/ac3dsp_rvv.S
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2023 Institue 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/riscv/asm.S"
+
+func ff_float_to_fixed24_rvv, zve32f
+ 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
More information about the ffmpeg-cvslog
mailing list