From: Peiting Shen <shenpeiting@eswincomputing.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Shen Peiting <shenpeiting@eswincomputing.com>
Subject: [FFmpeg-devel] [PATCH 1/6] lavc/ac3dsp: RISC-V V ac3_exponent_min
Date: Thu, 15 Jun 2023 10:36:40 +0000
Message-ID: <20230615103645.25778-2-shenpeiting@eswincomputing.com> (raw)
In-Reply-To: <20230615103645.25778-1-shenpeiting@eswincomputing.com>
From: Shen Peiting <shenpeiting@eswincomputing.com>
Find scalar minium optimized by using RVV instructions
Benchmarks on Spike(cycles):
*exp=1280*4;num_reuse_blocks=5;nb_coefs=16
ac3_exponent_min_c: 1993
ac3_exponent_min_rvv: 258
*exp=1280*4;num_reuse_blocks=19;nb_coefs=255
ac3_exponent_min_c: 99010
ac3_exponent_min_rvv: 3843
The optimization performance is more obvious with the increase of number of
reuse blocks and number of coefs.
Co-Authored by: Yang Xiaojun <yangxiaojun@eswincomputing.com>
Co-Authored by: Huang Xing <huangxing1@eswincomputing.com>
Co-Authored by: Zeng Fanchen <zengfanchen@eswincomputing.com>
Signed-off-by: Shen Peiting <shenpeiting@eswincomputing.com>
---
libavcodec/ac3dsp.c | 2 ++
libavcodec/ac3dsp.h | 1 +
libavcodec/riscv/Makefile | 2 ++
libavcodec/riscv/ac3dsp_init.c | 37 +++++++++++++++++++++++++++
libavcodec/riscv/ac3dsp_rvv.S | 46 ++++++++++++++++++++++++++++++++++
5 files changed, 88 insertions(+)
create mode 100644 libavcodec/riscv/ac3dsp_init.c
create mode 100644 libavcodec/riscv/ac3dsp_rvv.S
diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c
index 22cb5f242e..302b786b15 100644
--- a/libavcodec/ac3dsp.c
+++ b/libavcodec/ac3dsp.c
@@ -395,5 +395,7 @@ av_cold void ff_ac3dsp_init(AC3DSPContext *c)
ff_ac3dsp_init_x86(c);
#elif ARCH_MIPS
ff_ac3dsp_init_mips(c);
+#elif ARCH_RISCV
+ ff_ac3dsp_init_riscv(c);
#endif
}
diff --git a/libavcodec/ac3dsp.h b/libavcodec/ac3dsp.h
index 33e51e202e..a01bff3d11 100644
--- a/libavcodec/ac3dsp.h
+++ b/libavcodec/ac3dsp.h
@@ -109,6 +109,7 @@ void ff_ac3dsp_init (AC3DSPContext *c);
void ff_ac3dsp_init_arm(AC3DSPContext *c);
void ff_ac3dsp_init_x86(AC3DSPContext *c);
void ff_ac3dsp_init_mips(AC3DSPContext *c);
+void ff_ac3dsp_init_riscv(AC3DSPContext *c);
void ff_ac3dsp_downmix(AC3DSPContext *c, float **samples, float **matrix,
int out_ch, int in_ch, int len);
diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
index ee17a521fd..a627924cac 100644
--- a/libavcodec/riscv/Makefile
+++ b/libavcodec/riscv/Makefile
@@ -1,5 +1,7 @@
OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_init.o
RVV-OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_rvv.o
+OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_init.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
new file mode 100644
index 0000000000..bb67d86998
--- /dev/null
+++ b/libavcodec/riscv/ac3dsp_init.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2023 Beijing ESWIN Computing Technology Co., Ltd.
+ *
+ * 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 "libavcodec/ac3dsp.h"
+#include "libavutil/cpu.h"
+#include "config.h"
+
+void ff_ac3_exponent_min_rvv(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
+
+av_cold void ff_ac3dsp_init_riscv(AC3DSPContext *c)
+{
+ int flags = av_get_cpu_flags();
+#if HAVE_RVV
+ if (flags & AV_CPU_FLAG_RVV_I32)
+ c->ac3_exponent_min = ff_ac3_exponent_min_rvv;
+#endif
+}
+
diff --git a/libavcodec/riscv/ac3dsp_rvv.S b/libavcodec/riscv/ac3dsp_rvv.S
new file mode 100644
index 0000000000..879123f4a7
--- /dev/null
+++ b/libavcodec/riscv/ac3dsp_rvv.S
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2023 Beijing ESWIN Computing Technology Co., Ltd.
+ *
+ * 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
+ beq a1, x0, 3f
+ li t0, 256
+ addi a1, a1, 1
+1:
+ mv t2, a0
+ mv t3, a1
+ lb t4, (t2)
+2:
+ vsetvli t1, t3, e8, m8
+ vlse8.v v0, (t2), t0
+ vmv.s.x v8, t4
+ sub t3, t3, t1
+ vredminu.vs v8, v0, v8
+ vmv.x.s t4, v8
+ bnez t3, 2b
+ vsetivli t1, 1, e8
+ vse8.v v8, (a0)
+ addi a0, a0, 1
+ addi a2, a2, -1
+ bnez a2, 1b
+3:
+ ret
+endfunc
--
2.17.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-06-15 10:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-15 10:36 [FFmpeg-devel] [PATCH 0/6] RISC-V initial ac3dsp Peiting Shen
2023-06-15 10:36 ` Peiting Shen [this message]
2023-06-15 18:02 ` [FFmpeg-devel] [PATCH 1/6] lavc/ac3dsp: RISC-V V ac3_exponent_min Rémi Denis-Courmont
2023-06-15 10:36 ` [FFmpeg-devel] [PATCH 2/6] lavc/ac3dsp: RISC-V V float_to_fixed24 Peiting Shen
2023-06-15 18:06 ` Rémi Denis-Courmont
2023-06-15 10:36 ` [FFmpeg-devel] [PATCH 3/6] lavc/ac3dsp: RISC-V V ac3_sum_square_butterfly_int32 Peiting Shen
2023-06-15 19:25 ` Rémi Denis-Courmont
2023-06-16 10:15 ` 沈佩婷
2023-06-15 10:36 ` [FFmpeg-devel] [PATCH 4/6] lavc/ac3dsp: RISC-V V ac3_sum_square_butterfly_float Peiting Shen
2023-06-15 10:36 ` [FFmpeg-devel] [PATCH 5/6] lavc/ac3dsp: RISC-V V ac3_compute_mantissa_size Peiting Shen
2023-06-15 10:36 ` [FFmpeg-devel] [PATCH 6/6] lavc/ac3dsp: RISC-V B ac3_extract_exponents Peiting Shen
2023-06-15 19:18 ` Rémi Denis-Courmont
2023-06-15 13:57 ` [FFmpeg-devel] [PATCH 0/6] RISC-V initial ac3dsp Lynne
2023-06-15 19:10 ` Rémi Denis-Courmont
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230615103645.25778-2-shenpeiting@eswincomputing.com \
--to=shenpeiting@eswincomputing.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git