Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] lavc/llauddsp: R-V V scalarproduct_and_madd_int16
@ 2023-11-12 20:14 Rémi Denis-Courmont
  2023-11-12 20:14 ` [FFmpeg-devel] [PATCH 2/2] lavc/llauddsp: R-V V scalarproduct_and_madd_int32 Rémi Denis-Courmont
  0 siblings, 1 reply; 2+ messages in thread
From: Rémi Denis-Courmont @ 2023-11-12 20:14 UTC (permalink / raw)
  To: ffmpeg-devel

scalarproduct_and_madd_int16_c:      10355.7
scalarproduct_and_madd_int16_rvv_i32: 1480.0
---
 libavcodec/lossless_audiodsp.c   |  2 ++
 libavcodec/lossless_audiodsp.h   |  1 +
 libavcodec/riscv/Makefile        |  2 ++
 libavcodec/riscv/llauddsp_init.c | 40 ++++++++++++++++++++++++++++
 libavcodec/riscv/llauddsp_rvv.S  | 45 ++++++++++++++++++++++++++++++++
 5 files changed, 90 insertions(+)
 create mode 100644 libavcodec/riscv/llauddsp_init.c
 create mode 100644 libavcodec/riscv/llauddsp_rvv.S

diff --git a/libavcodec/lossless_audiodsp.c b/libavcodec/lossless_audiodsp.c
index 1daf2e4c12..b0d64cf5b3 100644
--- a/libavcodec/lossless_audiodsp.c
+++ b/libavcodec/lossless_audiodsp.c
@@ -63,6 +63,8 @@ av_cold void ff_llauddsp_init(LLAudDSPContext *c)
     ff_llauddsp_init_arm(c);
 #elif ARCH_PPC
     ff_llauddsp_init_ppc(c);
+#elif ARCH_RISCV
+    ff_llauddsp_init_riscv(c);
 #elif ARCH_X86
     ff_llauddsp_init_x86(c);
 #endif
diff --git a/libavcodec/lossless_audiodsp.h b/libavcodec/lossless_audiodsp.h
index eea5d49fa9..cf2d43d7c9 100644
--- a/libavcodec/lossless_audiodsp.h
+++ b/libavcodec/lossless_audiodsp.h
@@ -46,6 +46,7 @@ typedef struct LLAudDSPContext {
 void ff_llauddsp_init(LLAudDSPContext *c);
 void ff_llauddsp_init_arm(LLAudDSPContext *c);
 void ff_llauddsp_init_ppc(LLAudDSPContext *c);
+void ff_llauddsp_init_riscv(LLAudDSPContext *c);
 void ff_llauddsp_init_x86(LLAudDSPContext *c);
 
 #endif /* AVCODEC_LOSSLESS_AUDIODSP_H */
diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
index 2c9af16782..57c1708dbb 100644
--- a/libavcodec/riscv/Makefile
+++ b/libavcodec/riscv/Makefile
@@ -24,6 +24,8 @@ 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_OPUS_DECODER) += riscv/opusdsp_init.o
 RVV-OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_rvv.o
 OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o \
diff --git a/libavcodec/riscv/llauddsp_init.c b/libavcodec/riscv/llauddsp_init.c
new file mode 100644
index 0000000000..ea023f73e6
--- /dev/null
+++ b/libavcodec/riscv/llauddsp_init.c
@@ -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/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);
+
+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_ADDR)) {
+        c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_rvv;
+    }
+#endif
+}
diff --git a/libavcodec/riscv/llauddsp_rvv.S b/libavcodec/riscv/llauddsp_rvv.S
new file mode 100644
index 0000000000..74adb338a9
--- /dev/null
+++ b/libavcodec/riscv/llauddsp_rvv.S
@@ -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 "libavutil/riscv/asm.S"
+
+func ff_scalarproduct_and_madd_int16_rvv, zve32x
+        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
-- 
2.42.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] lavc/llauddsp: R-V V scalarproduct_and_madd_int32
  2023-11-12 20:14 [FFmpeg-devel] [PATCH 1/2] lavc/llauddsp: R-V V scalarproduct_and_madd_int16 Rémi Denis-Courmont
@ 2023-11-12 20:14 ` Rémi Denis-Courmont
  0 siblings, 0 replies; 2+ messages in thread
From: Rémi Denis-Courmont @ 2023-11-12 20:14 UTC (permalink / raw)
  To: ffmpeg-devel

scalarproduct_and_madd_int32_c:      10899.7
scalarproduct_and_madd_int32_rvv_i32: 1749.0
---
 libavcodec/riscv/llauddsp_init.c |  4 ++++
 libavcodec/riscv/llauddsp_rvv.S  | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/libavcodec/riscv/llauddsp_init.c b/libavcodec/riscv/llauddsp_init.c
index ea023f73e6..1924b36821 100644
--- a/libavcodec/riscv/llauddsp_init.c
+++ b/libavcodec/riscv/llauddsp_init.c
@@ -27,6 +27,9 @@
 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)
 {
@@ -35,6 +38,7 @@ av_cold void ff_llauddsp_init_riscv(LLAudDSPContext *c)
 
     if ((flags & AV_CPU_FLAG_RVV_I32)  && (flags & AV_CPU_FLAG_RVB_ADDR)) {
         c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_rvv;
+        c->scalarproduct_and_madd_int32 = ff_scalarproduct_and_madd_int32_rvv;
     }
 #endif
 }
diff --git a/libavcodec/riscv/llauddsp_rvv.S b/libavcodec/riscv/llauddsp_rvv.S
index 74adb338a9..5569864832 100644
--- a/libavcodec/riscv/llauddsp_rvv.S
+++ b/libavcodec/riscv/llauddsp_rvv.S
@@ -43,3 +43,29 @@ func ff_scalarproduct_and_madd_int16_rvv, zve32x
         vmv.x.s a0, v0
         ret
 endfunc
+
+func ff_scalarproduct_and_madd_int32_rvv, zve32x
+        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
-- 
2.42.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-12 20:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-12 20:14 [FFmpeg-devel] [PATCH 1/2] lavc/llauddsp: R-V V scalarproduct_and_madd_int16 Rémi Denis-Courmont
2023-11-12 20:14 ` [FFmpeg-devel] [PATCH 2/2] lavc/llauddsp: R-V V scalarproduct_and_madd_int32 Rémi Denis-Courmont

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