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
16OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o16OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o
17RV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvb.o17RV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvb.o
18RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o18RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o
19RVVB-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvvb.o
19OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_init.o20OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_init.o
20RVV-OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_rvv.o21RVV-OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_rvv.o
21OBJS-$(CONFIG_FLAC_DECODER) += riscv/flacdsp_init.o22OBJS-$(CONFIG_FLAC_DECODER) += riscv/flacdsp_init.o
libavcodec/riscv/bswapdsp_init.c+10−3
@@ -27,6 +27,8 @@ · 26 unmodified lines
27 27
28void ff_bswap32_buf_rvb(uint32_t *dst, const uint32_t *src, int len);28void ff_bswap32_buf_rvb(uint32_t *dst, const uint32_t *src, int len);
29void ff_bswap16_buf_rvv(uint16_t *dst, const uint16_t *src, int len);29void ff_bswap16_buf_rvv(uint16_t *dst, const uint16_t *src, int len);
30void ff_bswap32_buf_rvvb(uint32_t *dst, const uint32_t *src, int len);
31void ff_bswap16_buf_rvvb(uint16_t *dst, const uint16_t *src, int len);
30 32
31av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c)33av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c)
32{34{
@@ -38,9 +40,14 @@ av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c) · 5 unmodified lines
38 c->bswap_buf = ff_bswap32_buf_rvb;40 c->bswap_buf = ff_bswap32_buf_rvb;
39#endif41#endif
40#if HAVE_RVV42#if HAVE_RVV
41 if (flags & AV_CPU_FLAG_RVB_ADDR) {43 if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
42 if (flags & AV_CPU_FLAG_RVV_I32)44 c->bswap16_buf = ff_bswap16_buf_rvv;
43 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
44 }51 }
45#endif52#endif
46#endif53#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
24func ff_bswap32_buf_rvvb, zve32x, zvbb, zba
25 lpad 0
261:
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
37endfunc
38
39func ff_bswap16_buf_rvvb, zve32x, zvbb, zba
40 lpad 0
411:
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
52endfunc

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