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/flacdsp: R-V V packed decorrelate_{l, r}s
@ 2023-11-13 20:00 Rémi Denis-Courmont
  2023-11-13 20:00 ` [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: R-V V decorrelate_ms packed Rémi Denis-Courmont
  0 siblings, 1 reply; 2+ messages in thread
From: Rémi Denis-Courmont @ 2023-11-13 20:00 UTC (permalink / raw)
  To: ffmpeg-devel

flac_decorrelate_ms_16_c:       457.2
flac_decorrelate_ms_16_rvv_i32: 203.0
flac_decorrelate_ms_32_c:       457.2
flac_decorrelate_ms_32_rvv_i32: 203.5
flac_decorrelate_rs_16_c:       456.2
flac_decorrelate_rs_16_rvv_i32: 207.0
flac_decorrelate_rs_32_c:       456.2
flac_decorrelate_rs_32_rvv_i32: 210.5
---
 libavcodec/flacdsp.c            |   2 +
 libavcodec/flacdsp.h            |   1 +
 libavcodec/riscv/Makefile       |   2 +
 libavcodec/riscv/flacdsp_init.c |  55 ++++++++++++++++
 libavcodec/riscv/flacdsp_rvv.S  | 113 ++++++++++++++++++++++++++++++++
 5 files changed, 173 insertions(+)
 create mode 100644 libavcodec/riscv/flacdsp_init.c
 create mode 100644 libavcodec/riscv/flacdsp_rvv.S

diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
index 42e231db53..71b4ac44aa 100644
--- a/libavcodec/flacdsp.c
+++ b/libavcodec/flacdsp.c
@@ -121,6 +121,8 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int cha
 
 #if ARCH_ARM
     ff_flacdsp_init_arm(c, fmt, channels);
+#elif ARCH_RISCV
+    ff_flacdsp_init_riscv(c, fmt, channels);
 #elif ARCH_X86
     ff_flacdsp_init_x86(c, fmt, channels);
 #endif
diff --git a/libavcodec/flacdsp.h b/libavcodec/flacdsp.h
index 9f8ed38b66..15149c026e 100644
--- a/libavcodec/flacdsp.h
+++ b/libavcodec/flacdsp.h
@@ -38,6 +38,7 @@ typedef struct FLACDSPContext {
 
 void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
 void ff_flacdsp_init_arm(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
+void ff_flacdsp_init_riscv(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
 void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
 
 #endif /* AVCODEC_FLACDSP_H */
diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
index 57c1708dbb..d34dc77458 100644
--- a/libavcodec/riscv/Makefile
+++ b/libavcodec/riscv/Makefile
@@ -12,6 +12,8 @@ OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o \
 RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.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
diff --git a/libavcodec/riscv/flacdsp_init.c b/libavcodec/riscv/flacdsp_init.c
new file mode 100644
index 0000000000..a3415d6d55
--- /dev/null
+++ b/libavcodec/riscv/flacdsp_init.c
@@ -0,0 +1,55 @@
+/*
+ * 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/flacdsp.h"
+
+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_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);
+
+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_ADDR)) {
+        switch (fmt) {
+        case AV_SAMPLE_FMT_S16:
+            c->decorrelate[1] = ff_flac_decorrelate_ls_16_rvv;
+            c->decorrelate[2] = ff_flac_decorrelate_rs_16_rvv;
+            break;
+        case AV_SAMPLE_FMT_S32:
+            c->decorrelate[1] = ff_flac_decorrelate_ls_32_rvv;
+            c->decorrelate[2] = ff_flac_decorrelate_rs_32_rvv;
+            break;
+        }
+    }
+#endif
+}
diff --git a/libavcodec/riscv/flacdsp_rvv.S b/libavcodec/riscv/flacdsp_rvv.S
new file mode 100644
index 0000000000..c70ad8fcb0
--- /dev/null
+++ b/libavcodec/riscv/flacdsp_rvv.S
@@ -0,0 +1,113 @@
+/*
+ * 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_flac_decorrelate_ls_16_rvv, zve32x
+        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
+        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_ls_32_rvv, zve32x
+        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
+        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
+#endif
-- 
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/flacdsp: R-V V decorrelate_ms packed
  2023-11-13 20:00 [FFmpeg-devel] [PATCH 1/2] lavc/flacdsp: R-V V packed decorrelate_{l, r}s Rémi Denis-Courmont
@ 2023-11-13 20:00 ` Rémi Denis-Courmont
  0 siblings, 0 replies; 2+ messages in thread
From: Rémi Denis-Courmont @ 2023-11-13 20:00 UTC (permalink / raw)
  To: ffmpeg-devel

flac_decorrelate_ms_16_c:       585.5
flac_decorrelate_ms_16_rvv_i32: 263.0
flac_decorrelate_ms_32_c:       584.7
flac_decorrelate_ms_32_rvv_i32: 250.0
---
 libavcodec/riscv/flacdsp_init.c |  6 ++++
 libavcodec/riscv/flacdsp_rvv.S  | 49 +++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/libavcodec/riscv/flacdsp_init.c b/libavcodec/riscv/flacdsp_init.c
index a3415d6d55..0e7be25d98 100644
--- a/libavcodec/riscv/flacdsp_init.c
+++ b/libavcodec/riscv/flacdsp_init.c
@@ -28,10 +28,14 @@ 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_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)
@@ -44,10 +48,12 @@ av_cold void ff_flacdsp_init_riscv(FLACDSPContext *c, enum AVSampleFormat fmt,
         case AV_SAMPLE_FMT_S16:
             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:
             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;
         }
     }
diff --git a/libavcodec/riscv/flacdsp_rvv.S b/libavcodec/riscv/flacdsp_rvv.S
index c70ad8fcb0..616565ed7e 100644
--- a/libavcodec/riscv/flacdsp_rvv.S
+++ b/libavcodec/riscv/flacdsp_rvv.S
@@ -69,6 +69,32 @@ func ff_flac_decorrelate_rs_16_rvv, zve32x
         ret
 endfunc
 
+func ff_flac_decorrelate_ms_16_rvv, zve32x
+        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_ls_32_rvv, zve32x
         ld      a0,  (a0)
         ld      a2, 8(a1)
@@ -110,4 +136,27 @@ func ff_flac_decorrelate_rs_32_rvv, zve32x
 
         ret
 endfunc
+
+func ff_flac_decorrelate_ms_32_rvv, zve32x
+        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
-- 
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-13 20:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13 20:00 [FFmpeg-devel] [PATCH 1/2] lavc/flacdsp: R-V V packed decorrelate_{l, r}s Rémi Denis-Courmont
2023-11-13 20:00 ` [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: R-V V decorrelate_ms packed 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