forked from FFmpeg/FFmpeg
lavu/riscv: count bytes rather than words for bswap32
This removes the dependency on Zba at essentially zero cost.
This commit is contained in:
parent
5171baa228
commit
bd0c3edb13
5 changed files with 13 additions and 13 deletions
|
@ -33,15 +33,15 @@ av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c)
|
||||||
#if HAVE_RV
|
#if HAVE_RV
|
||||||
int flags = av_get_cpu_flags();
|
int flags = av_get_cpu_flags();
|
||||||
|
|
||||||
if (flags & AV_CPU_FLAG_RVB_ADDR) {
|
|
||||||
#if (__riscv_xlen >= 64)
|
#if (__riscv_xlen >= 64)
|
||||||
if (flags & AV_CPU_FLAG_RVB_BASIC)
|
if (flags & AV_CPU_FLAG_RVB_BASIC)
|
||||||
c->bswap_buf = ff_bswap32_buf_rvb;
|
c->bswap_buf = ff_bswap32_buf_rvb;
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_RVV
|
#if HAVE_RVV
|
||||||
|
if (flags & AV_CPU_FLAG_RVB_ADDR) {
|
||||||
if (flags & AV_CPU_FLAG_RVV_I32)
|
if (flags & AV_CPU_FLAG_RVV_I32)
|
||||||
c->bswap16_buf = ff_bswap16_buf_rvv;
|
c->bswap16_buf = ff_bswap16_buf_rvv;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,9 @@
|
||||||
#include "libavutil/riscv/bswap_rvb.S"
|
#include "libavutil/riscv/bswap_rvb.S"
|
||||||
|
|
||||||
#if (__riscv_xlen >= 64)
|
#if (__riscv_xlen >= 64)
|
||||||
func ff_bswap32_buf_rvb, zba, zbb
|
func ff_bswap32_buf_rvb, zbb
|
||||||
lpad 0
|
lpad 0
|
||||||
|
slli a2, a2, 2
|
||||||
bswap32_rvb a0, a1, a2
|
bswap32_rvb a0, a1, a2
|
||||||
endfunc
|
endfunc
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,21 +20,21 @@
|
||||||
|
|
||||||
#if (__riscv_xlen >= 64)
|
#if (__riscv_xlen >= 64)
|
||||||
.macro bswap32_rvb out, in, count
|
.macro bswap32_rvb out, in, count
|
||||||
andi t0, \count, 4
|
andi t0, \count, 1
|
||||||
beqz t0, 1f
|
beqz t0, 1f
|
||||||
/* Align input to 64-bit */
|
/* Align input to 64-bit */
|
||||||
lwu t0, (\in)
|
lwu t0, (\in)
|
||||||
addi \out, \out, 4
|
addi \out, \out, 4
|
||||||
rev8 t0, t0
|
rev8 t0, t0
|
||||||
addi \count, \count, -1
|
addi \count, \count, -4
|
||||||
srli t0, t0, __riscv_xlen - 32
|
srli t0, t0, __riscv_xlen - 32
|
||||||
addi \in, \in, 4
|
addi \in, \in, 4
|
||||||
sw t0, -4(\out)
|
sw t0, -4(\out)
|
||||||
1:
|
1:
|
||||||
andi t3, \count, -2
|
andi t3, \count, -8
|
||||||
sh2add \count, \count, \out
|
add \count, \count, \out
|
||||||
beqz t3, 3f
|
beqz t3, 3f
|
||||||
sh2add t3, t3, \out
|
add t3, t3, \out
|
||||||
2: /* 2 elements (64 bits) at a time on a 64-bit boundary */
|
2: /* 2 elements (64 bits) at a time on a 64-bit boundary */
|
||||||
ld t0, (\in)
|
ld t0, (\in)
|
||||||
addi \out, \out, 8
|
addi \out, \out, 8
|
||||||
|
|
|
@ -46,7 +46,7 @@ av_cold void rgb2rgb_init_riscv(void)
|
||||||
int flags = av_get_cpu_flags();
|
int flags = av_get_cpu_flags();
|
||||||
|
|
||||||
#if (__riscv_xlen == 64)
|
#if (__riscv_xlen == 64)
|
||||||
if ((flags & AV_CPU_FLAG_RVB_BASIC) && (flags & AV_CPU_FLAG_RVB_ADDR))
|
if (flags & AV_CPU_FLAG_RVB_BASIC)
|
||||||
shuffle_bytes_3210 = ff_shuffle_bytes_3210_rvb;
|
shuffle_bytes_3210 = ff_shuffle_bytes_3210_rvb;
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_RVV
|
#if HAVE_RVV
|
||||||
|
|
|
@ -23,9 +23,8 @@
|
||||||
#include "libavutil/riscv/bswap_rvb.S"
|
#include "libavutil/riscv/bswap_rvb.S"
|
||||||
|
|
||||||
#if (__riscv_xlen >= 64)
|
#if (__riscv_xlen >= 64)
|
||||||
func ff_shuffle_bytes_3210_rvb, zba, zbb
|
func ff_shuffle_bytes_3210_rvb, zbb
|
||||||
lpad 0
|
lpad 0
|
||||||
srli a2, a2, 2
|
|
||||||
bswap32_rvb a1, a0, a2
|
bswap32_rvb a1, a0, a2
|
||||||
endfunc
|
endfunc
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue