History

lavc/bswapdsp: add RV Zvbb bswap16 and bswap32

Rémi Denis-Courmont committed 2 years ago

Commit 952b4261 parent f4daf633 files · +63 −3Browse files

Unified · Split

3 files
  1. libavcodec/riscv/Makefile +1 −0
  2. libavcodec/riscv/bswapdsp_init.c +10 −3
  3. libavcodec/riscv/bswapdsp_rvvb.S +52 −0
libavcodec/riscv/Makefile+1−0
@@ -16,6 +16,7 @@ RVV-OBJS-$(CONFIG_BLOCKDSP) += riscv/blockdsp_rvv.o · 15 unmodified lines
1616 OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o
1717 RV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvb.o
1818 RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o
19+RVVB-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvvb.o
1920 OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_init.o
2021 RVV-OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_rvv.o
2122 OBJS-$(CONFIG_FLAC_DECODER) += riscv/flacdsp_init.o
libavcodec/riscv/bswapdsp_init.c+10−3
@@ -27,6 +27,8 @@ · 26 unmodified lines
2727
2828 void ff_bswap32_buf_rvb(uint32_t *dst, const uint32_t *src, int len);
2929 void ff_bswap16_buf_rvv(uint16_t *dst, const uint16_t *src, int len);
30+void ff_bswap32_buf_rvvb(uint32_t *dst, const uint32_t *src, int len);
31+void ff_bswap16_buf_rvvb(uint16_t *dst, const uint16_t *src, int len);
3032
3133 av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c)
3234 {
@@ -38,9 +40,14 @@ av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c) · 5 unmodified lines
3840 c->bswap_buf = ff_bswap32_buf_rvb;
3941 #endif
4042 #if HAVE_RVV
41− if (flags & AV_CPU_FLAG_RVB_ADDR) {
42− if (flags & AV_CPU_FLAG_RVV_I32)
43− c->bswap16_buf = ff_bswap16_buf_rvv;
43+ if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
44+ c->bswap16_buf = ff_bswap16_buf_rvv;
45+#if HAVE_RV_ZVBB
46+ if (flags & AV_CPU_FLAG_RV_ZVBB) {
47+ c->bswap_buf = ff_bswap32_buf_rvvb;
48+ c->bswap16_buf = ff_bswap16_buf_rvvb;
49+ }
50+#endif
4451 }
4552 #endif
4653 #endif
libavcodec/riscv/bswapdsp_rvvb.S+52−0
@@ -0,0 +1,52 @@
1+/*
2+ * Copyright © 2024 Rémi Denis-Courmont.
3+ *
4+ * This file is part of FFmpeg.
5+ *
6+ * FFmpeg is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * FFmpeg is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with FFmpeg; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+ */
20+
21+#include "config.h"
22+#include "libavutil/riscv/asm.S"
23+
24+func ff_bswap32_buf_rvvb, zve32x, zvbb, zba
25+ lpad 0
26+1:
27+ vsetvli t0, a2, e32, m8, ta, ma
28+ vle32.v v8, (a1)
29+ sub a2, a2, t0
30+ vrev8.v v8, v8
31+ sh2add a1, t0, a1
32+ vse32.v v8, (a0)
33+ sh2add a0, t0, a0
34+ bnez a2, 1b
35+
36+ ret
37+endfunc
38+
39+func ff_bswap16_buf_rvvb, zve32x, zvbb, zba
40+ lpad 0
41+1:
42+ vsetvli t0, a2, e16, m8, ta, ma
43+ vle16.v v8, (a1)
44+ sub a2, a2, t0
45+ vrev8.v v8, v8
46+ sh1add a1, t0, a1
47+ vse16.v v8, (a0)
48+ sh1add a0, t0, a0
49+ bnez a2, 1b
50+
51+ ret
52+endfunc

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t