...
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
OBJS += riscv/rgb2rgb.o \
|
||||
riscv/swscale.o
|
||||
RV-OBJS += riscv/rgb2rgb_rvb.o
|
||||
RVV-OBJS += riscv/input_rvv.o \
|
||||
riscv/range_rvv.o \
|
||||
riscv/rgb2rgb_rvv.o
|
||||
|
||||
SHLIBOBJS += riscv/cpu_common.o
|
||||
@@ -0,0 +1 @@
|
||||
#include "libavutil/riscv/cpu_common.c"
|
||||
@@ -0,0 +1,321 @@
|
||||
/*
|
||||
* Copyright © 2024 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_bgr24ToY_rvv, zve32x
|
||||
lpad 0
|
||||
lw t1, 8(a5) # BY
|
||||
lw t3, 0(a5) # RY
|
||||
j 1f
|
||||
endfunc
|
||||
|
||||
func ff_rgb24ToY_rvv, zve32x, zba
|
||||
lpad 0
|
||||
lw t1, 0(a5) # RY
|
||||
lw t3, 8(a5) # BY
|
||||
1:
|
||||
lw t2, 4(a5) # GY
|
||||
li t4, (32 << (15 - 1)) + (1 << (15 - 7))
|
||||
2:
|
||||
vsetvli t0, a4, e32, m8, ta, ma
|
||||
vlseg3e8.v v0, (a1)
|
||||
sub a4, a4, t0
|
||||
vzext.vf4 v8, v0
|
||||
sh1add t5, t0, t0 # t1 = 3 * t0
|
||||
vzext.vf4 v16, v2
|
||||
vzext.vf4 v24, v4
|
||||
add a1, t5, a1
|
||||
vmul.vx v8, v8, t1
|
||||
vmacc.vx v8, t2, v16
|
||||
vmacc.vx v8, t3, v24
|
||||
vadd.vx v8, v8, t4
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vnsra.wi v0, v8, 15 - 6
|
||||
vse16.v v0, (a0)
|
||||
sh1add a0, t0, a0
|
||||
bnez a4, 2b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_bgr24ToUV_rvv, zve32x
|
||||
lpad 0
|
||||
lw t1, 20(a6) # BU
|
||||
lw t4, 32(a6) # BV
|
||||
lw t3, 12(a6) # RU
|
||||
lw t6, 24(a6) # RV
|
||||
j 1f
|
||||
endfunc
|
||||
|
||||
func ff_rgb24ToUV_rvv, zve32x, zba
|
||||
lpad 0
|
||||
lw t1, 12(a6) # RU
|
||||
lw t4, 24(a6) # RV
|
||||
lw t3, 20(a6) # BU
|
||||
lw t6, 32(a6) # BV
|
||||
1:
|
||||
lw t2, 16(a6) # GU
|
||||
lw t5, 28(a6) # GV
|
||||
li a7, (256 << (15 - 1)) + (1 << (15 - 7))
|
||||
2:
|
||||
vsetvli t0, a5, e32, m8, ta, ma
|
||||
vlseg3e8.v v0, (a3)
|
||||
sub a5, a5, t0
|
||||
vzext.vf4 v16, v0
|
||||
sh1add a6, t0, t0
|
||||
vzext.vf4 v24, v2
|
||||
vmul.vx v8, v16, t1
|
||||
add a3, a6, a3
|
||||
vmul.vx v16, v16, t4
|
||||
vmacc.vx v8, t2, v24
|
||||
vmacc.vx v16, t5, v24
|
||||
vzext.vf4 v24, v4
|
||||
vadd.vx v8, v8, a7
|
||||
vadd.vx v16, v16, a7
|
||||
vmacc.vx v8, t3, v24
|
||||
vmacc.vx v16, t6, v24
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vnsra.wi v0, v8, 15 - 6
|
||||
vnsra.wi v4, v16, 15 - 6
|
||||
vse16.v v0, (a0)
|
||||
sh1add a0, t0, a0
|
||||
vse16.v v4, (a1)
|
||||
sh1add a1, t0, a1
|
||||
bnez a5, 2b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_bgr24ToUV_half_rvv, zve32x
|
||||
lpad 0
|
||||
lw t1, 20(a6) # BU
|
||||
lw t4, 32(a6) # BV
|
||||
lw t3, 12(a6) # RU
|
||||
lw t6, 24(a6) # RV
|
||||
j 1f
|
||||
endfunc
|
||||
|
||||
func ff_rgb24ToUV_half_rvv, zve32x, zba
|
||||
lpad 0
|
||||
lw t1, 12(a6) # RU
|
||||
lw t4, 24(a6) # RV
|
||||
lw t3, 20(a6) # BU
|
||||
lw t6, 32(a6) # BV
|
||||
1:
|
||||
lw t2, 16(a6) # GU
|
||||
lw t5, 28(a6) # GV
|
||||
li a7, (256 << 15) + (1 << (15 - 6))
|
||||
2:
|
||||
vsetvli t0, a5, e8, m1, ta, ma
|
||||
vlseg6e8.v v0, (a3)
|
||||
sh1add a6, t0, t0
|
||||
vwaddu.vv v8, v0, v3
|
||||
sub a5, a5, t0
|
||||
vwaddu.vv v10, v1, v4
|
||||
sh1add a3, a6, a3
|
||||
vwaddu.vv v12, v2, v5
|
||||
vsetvli zero, zero, e32, m4, ta, ma
|
||||
vzext.vf2 v20, v8
|
||||
vzext.vf2 v24, v10
|
||||
vzext.vf2 v28, v12
|
||||
vmul.vx v0, v20, t1
|
||||
vmul.vx v4, v20, t4
|
||||
vmacc.vx v0, t2, v24
|
||||
vmacc.vx v4, t5, v24
|
||||
vmacc.vx v0, t3, v28
|
||||
vmacc.vx v4, t6, v28
|
||||
vadd.vx v0, v0, a7
|
||||
vadd.vx v4, v4, a7
|
||||
vsetvli zero, zero, e16, m2, ta, ma
|
||||
vnsra.wi v0, v0, 15 - 5
|
||||
vnsra.wi v2, v4, 15 - 5
|
||||
vse16.v v0, (a0)
|
||||
sh1add a0, t0, a0
|
||||
vse16.v v2, (a1)
|
||||
sh1add a1, t0, a1
|
||||
bnez a5, 2b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
.macro rgba_input chr0, chr1, high
|
||||
func ff_\chr1\()ToY_rvv, zve32x
|
||||
lpad 0
|
||||
lw t1, 8(a5) # BY
|
||||
lw t3, 0(a5) # RY
|
||||
j 1f
|
||||
endfunc
|
||||
|
||||
func ff_\chr0\()ToY_rvv, zve32x, zba
|
||||
lpad 0
|
||||
lw t1, 0(a5) # RY
|
||||
lw t3, 8(a5) # BY
|
||||
1:
|
||||
lw t2, 4(a5) # GY
|
||||
li t4, (32 << (15 - 1)) + (1 << (15 - 7))
|
||||
li t5, 0xff
|
||||
2:
|
||||
vsetvli t0, a4, e32, m8, ta, ma
|
||||
vle32.v v0, (a1)
|
||||
sub a4, a4, t0
|
||||
.if \high
|
||||
vsrl.vi v8, v0, 24
|
||||
.else
|
||||
vand.vx v8, v0, t5
|
||||
.endif
|
||||
sh2add a1, t0, a1
|
||||
vsrl.vi v16, v0, 8 * (1 + \high)
|
||||
vmul.vx v24, v8, t1
|
||||
vand.vx v16, v16, t5
|
||||
vsrl.vi v8, v0, 8 * (2 - \high)
|
||||
vmacc.vx v24, t2, v16
|
||||
vand.vx v8, v8, t5
|
||||
vadd.vx v24, v24, t4
|
||||
vmacc.vx v24, t3, v8
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vnsra.wi v0, v24, 15 - 6
|
||||
vse16.v v0, (a0)
|
||||
sh1add a0, t0, a0
|
||||
bnez a4, 2b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_\chr1\()ToUV_rvv, zve32x
|
||||
lpad 0
|
||||
lw t1, 20(a6) # BU
|
||||
lw t4, 32(a6) # BV
|
||||
lw t3, 12(a6) # RU
|
||||
lw t6, 24(a6) # RV
|
||||
j 1f
|
||||
endfunc
|
||||
|
||||
func ff_\chr0\()ToUV_rvv, zve32x, zba
|
||||
lpad 0
|
||||
lw t1, 12(a6) # RU
|
||||
lw t4, 24(a6) # RV
|
||||
lw t3, 20(a6) # BU
|
||||
lw t6, 32(a6) # BV
|
||||
1:
|
||||
lw t2, 16(a6) # GU
|
||||
lw t5, 28(a6) # GV
|
||||
li a6, 0xff
|
||||
li a7, (256 << (15 - 1)) + (1 << (15 - 7))
|
||||
2:
|
||||
vsetvli t0, a5, e32, m8, ta, ma
|
||||
vle32.v v0, (a3)
|
||||
sub a5, a5, t0
|
||||
.if \high
|
||||
vsrl.vi v24, v0, 24
|
||||
.else
|
||||
vand.vx v24, v0, a6
|
||||
.endif
|
||||
sh2add a3, t0, a3
|
||||
vsrl.vi v8, v0, 8 * (1 + \high)
|
||||
vmul.vx v16, v24, t1
|
||||
vand.vx v8, v8, a6
|
||||
vmul.vx v24, v24, t4
|
||||
vmacc.vx v16, t2, v8
|
||||
vsrl.vi v0, v0, 8 * (2 - \high)
|
||||
vmacc.vx v24, t5, v8
|
||||
vand.vx v0, v0, a6
|
||||
vadd.vx v16, v16, a7
|
||||
vadd.vx v24, v24, a7
|
||||
vmacc.vx v16, t3, v0
|
||||
vmacc.vx v24, t6, v0
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vnsra.wi v0, v16, 15 - 6
|
||||
vnsra.wi v4, v24, 15 - 6
|
||||
vse16.v v0, (a0)
|
||||
sh1add a0, t0, a0
|
||||
vse16.v v4, (a1)
|
||||
sh1add a1, t0, a1
|
||||
bnez a5, 2b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_\chr1\()ToUV_half_rvv, zve32x
|
||||
lpad 0
|
||||
lw t1, 20(a6) # BU
|
||||
lw t4, 32(a6) # BV
|
||||
lw t3, 12(a6) # RU
|
||||
lw t6, 24(a6) # RV
|
||||
j 1f
|
||||
endfunc
|
||||
|
||||
func ff_\chr0\()ToUV_half_rvv, zve32x, zba
|
||||
lpad 0
|
||||
lw t1, 12(a6) # RU
|
||||
lw t4, 24(a6) # RV
|
||||
lw t3, 20(a6) # BU
|
||||
lw t6, 32(a6) # BV
|
||||
1:
|
||||
lw t2, 16(a6) # GU
|
||||
lw t5, 28(a6) # GV
|
||||
li a6, 0xff
|
||||
li a7, (256 << 15) + (1 << (15 - 6))
|
||||
2:
|
||||
vsetvli t0, a5, e32, m4, ta, ma
|
||||
vlseg2e32.v v0, (a3)
|
||||
sub a5, a5, t0
|
||||
.if \high
|
||||
vsrl.vi v8, v0, 24
|
||||
vsrl.vi v12, v4, 24
|
||||
.else
|
||||
vand.vx v8, v0, a6
|
||||
vand.vx v12, v4, a6
|
||||
.endif
|
||||
sh3add a3, t0, a3
|
||||
vsrl.vi v16, v0, 8 * (1 + \high)
|
||||
vsrl.vi v20, v4, 8 * (1 + \high)
|
||||
vsrl.vi v24, v0, 8 * (2 - \high)
|
||||
vsrl.vi v28, v4, 8 * (2 - \high)
|
||||
vand.vx v16, v16, a6
|
||||
vand.vx v20, v20, a6
|
||||
vand.vx v24, v24, a6
|
||||
vand.vx v28, v28, a6
|
||||
vadd.vv v8, v8, v12
|
||||
vadd.vv v16, v16, v20
|
||||
vadd.vv v24, v24, v28
|
||||
vmul.vx v0, v8, t1
|
||||
vmul.vx v4, v8, t4
|
||||
vmacc.vx v0, t2, v16
|
||||
vmacc.vx v4, t5, v16
|
||||
vmacc.vx v0, t3, v24
|
||||
vmacc.vx v4, t6, v24
|
||||
vadd.vx v0, v0, a7
|
||||
vadd.vx v4, v4, a7
|
||||
vsetvli zero, zero, e16, m2, ta, ma
|
||||
vnsra.wi v0, v0, 15 - 5
|
||||
vnsra.wi v2, v4, 15 - 5
|
||||
vse16.v v0, (a0)
|
||||
sh1add a0, t0, a0
|
||||
vse16.v v2, (a1)
|
||||
sh1add a1, t0, a1
|
||||
bnez a5, 2b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
.endm
|
||||
|
||||
rgba_input rgba32, bgra32, 0
|
||||
rgba_input abgr32, argb32, 1
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright © 2024 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_range_lum_to_jpeg_16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
li t1, 30189
|
||||
li t2, 19077
|
||||
li t3, -39057361
|
||||
1:
|
||||
vsetvli t0, a1, e16, m4, ta, ma
|
||||
vle16.v v0, (a0)
|
||||
sub a1, a1, t0
|
||||
vmin.vx v0, v0, t1
|
||||
vwmul.vx v8, v0, t2
|
||||
vsetvli zero, zero, e32, m8, ta, ma
|
||||
vadd.vx v8, v8, t3
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vnsra.wi v0, v8, 14
|
||||
vse16.v v0, (a0)
|
||||
sh1add a0, t0, a0
|
||||
bnez a1, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_range_lum_from_jpeg_16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
li t1, 14071
|
||||
li t2, 33561947
|
||||
1:
|
||||
vsetvli t0, a1, e16, m4, ta, ma
|
||||
vle16.v v0, (a0)
|
||||
sub a1, a1, t0
|
||||
vwmul.vx v8, v0, t1
|
||||
vsetvli zero, zero, e32, m8, ta, ma
|
||||
vadd.vx v8, v8, t2
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vnsra.wi v0, v8, 14
|
||||
vse16.v v0, (a0)
|
||||
sh1add a0, t0, a0
|
||||
bnez a1, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_range_chr_to_jpeg_16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
li t1, 30775
|
||||
li t2, 4663
|
||||
li t3, -9289992
|
||||
1:
|
||||
vsetvli t0, a2, e16, m4, ta, ma
|
||||
vle16.v v0, (a0)
|
||||
sub a2, a2, t0
|
||||
vle16.v v4, (a1)
|
||||
vmin.vx v0, v0, t1
|
||||
vmin.vx v4, v4, t1
|
||||
vwmul.vx v8, v0, t2
|
||||
vwmul.vx v16, v4, t2
|
||||
vsetvli zero, zero, e32, m8, ta, ma
|
||||
vadd.vx v8, v8, t3
|
||||
vadd.vx v16, v16, t3
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vnsra.wi v0, v8, 12
|
||||
vnsra.wi v4, v16, 12
|
||||
vse16.v v0, (a0)
|
||||
sh1add a0, t0, a0
|
||||
vse16.v v4, (a1)
|
||||
sh1add a1, t0, a1
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_range_chr_from_jpeg_16_rvv, zve32x, zba
|
||||
lpad 0
|
||||
li t1, 1799
|
||||
li t2, 4081085
|
||||
1:
|
||||
vsetvli t0, a2, e16, m4, ta, ma
|
||||
vle16.v v0, (a0)
|
||||
sub a2, a2, t0
|
||||
vle16.v v4, (a1)
|
||||
vwmul.vx v8, v0, t1
|
||||
vwmul.vx v16, v4, t1
|
||||
vsetvli zero, zero, e32, m8, ta, ma
|
||||
vadd.vx v8, v8, t2
|
||||
vadd.vx v16, v16, t2
|
||||
vsetvli zero, zero, e16, m4, ta, ma
|
||||
vnsra.wi v0, v8, 11
|
||||
vnsra.wi v4, v16, 11
|
||||
vse16.v v0, (a0)
|
||||
sh1add a0, t0, a0
|
||||
vse16.v v4, (a1)
|
||||
sh1add a1, t0, a1
|
||||
bnez a2, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright © 2022 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 <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libswscale/rgb2rgb.h"
|
||||
|
||||
void ff_shuffle_bytes_0321_rvv(const uint8_t *src, uint8_t *dst, int src_len);
|
||||
void ff_shuffle_bytes_2103_rvv(const uint8_t *src, uint8_t *dst, int src_len);
|
||||
void ff_shuffle_bytes_1230_rvv(const uint8_t *src, uint8_t *dst, int src_len);
|
||||
void ff_shuffle_bytes_3012_rvv(const uint8_t *src, uint8_t *dst, int src_len);
|
||||
void ff_shuffle_bytes_3210_rvb(const uint8_t *src, uint8_t *dst, int src_len);
|
||||
void ff_interleave_bytes_rvv(const uint8_t *src1, const uint8_t *src2,
|
||||
uint8_t *dst, int width, int height, int s1stride,
|
||||
int s2stride, int dstride);
|
||||
void ff_deinterleave_bytes_rvv(const uint8_t *src, uint8_t *dst1,
|
||||
uint8_t *dst2, int width, int height,
|
||||
int srcStride, int dst1Stride, int dst2Stride);
|
||||
void ff_uyvytoyuv422_rvv(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
|
||||
const uint8_t *src, int width, int height,
|
||||
int ystride, int uvstride, int src_stride);
|
||||
void ff_yuyvtoyuv422_rvv(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
|
||||
const uint8_t *src, int width, int height,
|
||||
int ystride, int uvstride, int src_stride);
|
||||
|
||||
av_cold void rgb2rgb_init_riscv(void)
|
||||
{
|
||||
#if HAVE_RV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
#if (__riscv_xlen == 64)
|
||||
if (flags & AV_CPU_FLAG_RVB_BASIC)
|
||||
shuffle_bytes_3210 = ff_shuffle_bytes_3210_rvb;
|
||||
#endif
|
||||
#if HAVE_RVV
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
|
||||
shuffle_bytes_0321 = ff_shuffle_bytes_0321_rvv;
|
||||
shuffle_bytes_2103 = ff_shuffle_bytes_2103_rvv;
|
||||
shuffle_bytes_1230 = ff_shuffle_bytes_1230_rvv;
|
||||
shuffle_bytes_3012 = ff_shuffle_bytes_3012_rvv;
|
||||
interleaveBytes = ff_interleave_bytes_rvv;
|
||||
deinterleaveBytes = ff_deinterleave_bytes_rvv;
|
||||
uyvytoyuv422 = ff_uyvytoyuv422_rvv;
|
||||
yuyvtoyuv422 = ff_yuyvtoyuv422_rvv;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright © 2022 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"
|
||||
#include "libavutil/riscv/bswap_rvb.S"
|
||||
|
||||
#if (__riscv_xlen >= 64)
|
||||
func ff_shuffle_bytes_3210_rvb, zbb
|
||||
lpad 0
|
||||
bswap32_rvb a1, a0, a2
|
||||
endfunc
|
||||
#endif
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright © 2022 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_shuffle_bytes_0321_rvv, zve32x
|
||||
lpad 0
|
||||
li t1, 0x00ff00ff
|
||||
j 1f
|
||||
endfunc
|
||||
|
||||
func ff_shuffle_bytes_2103_rvv, zve32x, zba
|
||||
lpad 0
|
||||
li t1, ~0x00ff00ff
|
||||
1:
|
||||
not t2, t1
|
||||
srai a2, a2, 2
|
||||
2:
|
||||
vsetvli t0, a2, e32, m8, ta, ma
|
||||
vle32.v v8, (a0)
|
||||
sub a2, a2, t0
|
||||
vand.vx v16, v8, t2
|
||||
sh2add a0, t0, a0
|
||||
vand.vx v8, v8, t1
|
||||
vsrl.vi v24, v16, 16
|
||||
vsll.vi v16, v16, 16
|
||||
vor.vv v8, v8, v24
|
||||
vor.vv v8, v16, v8
|
||||
vse32.v v8, (a1)
|
||||
sh2add a1, t0, a1
|
||||
bnez a2, 2b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_shuffle_bytes_1230_rvv, zve32x
|
||||
lpad 0
|
||||
li t1, 24
|
||||
li t2, 8
|
||||
j 3f
|
||||
endfunc
|
||||
|
||||
func ff_shuffle_bytes_3012_rvv, zve32x, zba
|
||||
lpad 0
|
||||
li t1, 8
|
||||
li t2, 24
|
||||
3:
|
||||
srai a2, a2, 2
|
||||
4:
|
||||
vsetvli t0, a2, e32, m8, ta, ma
|
||||
vle32.v v8, (a0)
|
||||
sub a2, a2, t0
|
||||
vsll.vx v16, v8, t1
|
||||
sh2add a0, t0, a0
|
||||
vsrl.vx v8, v8, t2
|
||||
vor.vv v16, v16, v8
|
||||
vse32.v v16, (a1)
|
||||
sh2add a1, t0, a1
|
||||
bnez a2, 4b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_interleave_bytes_rvv, zve32x, zba
|
||||
lpad 0
|
||||
1:
|
||||
mv t0, a0
|
||||
mv t1, a1
|
||||
mv t2, a2
|
||||
mv t3, a3
|
||||
addi a4, a4, -1
|
||||
2:
|
||||
vsetvli t4, t3, e8, m4, ta, ma
|
||||
sub t3, t3, t4
|
||||
vle8.v v8, (t0)
|
||||
add t0, t4, t0
|
||||
vle8.v v12, (t1)
|
||||
add t1, t4, t1
|
||||
vsseg2e8.v v8, (t2)
|
||||
sh1add t2, t4, t2
|
||||
bnez t3, 2b
|
||||
|
||||
add a0, a0, a5
|
||||
add a1, a1, a6
|
||||
add a2, a2, a7
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
func ff_deinterleave_bytes_rvv, zve32x, zba
|
||||
lpad 0
|
||||
1:
|
||||
mv t0, a0
|
||||
mv t1, a1
|
||||
mv t2, a2
|
||||
mv t3, a3
|
||||
addi a4, a4, -1
|
||||
2:
|
||||
vsetvli t4, t3, e8, m4, ta, ma
|
||||
sub t3, t3, t4
|
||||
vlseg2e8.v v8, (t0)
|
||||
sh1add t0, t4, t0
|
||||
vse8.v v8, (t1)
|
||||
add t1, t4, t1
|
||||
vse8.v v12, (t2)
|
||||
add t2, t4, t2
|
||||
bnez t3, 2b
|
||||
|
||||
add a0, a0, a5
|
||||
add a1, a1, a6
|
||||
add a2, a2, a7
|
||||
bnez a4, 1b
|
||||
|
||||
ret
|
||||
endfunc
|
||||
|
||||
.macro yuy2_to_i422p luma, chroma
|
||||
lpad 0
|
||||
srai t4, a4, 1 // pixel width -> chroma width
|
||||
lw t6, (sp)
|
||||
slli t5, a4, 1 // pixel width -> (source) byte width
|
||||
sub a6, a6, a4
|
||||
sub a7, a7, t4
|
||||
sub t6, t6, t5
|
||||
vsetvli t2, zero, e8, m4, ta, ma
|
||||
1:
|
||||
mv t4, a4
|
||||
addi a5, a5, -1
|
||||
2:
|
||||
min t0, t2, t4 // ensure even VL on penultimate iteration
|
||||
vsetvli t0, t0, e8, m4, ta, ma
|
||||
vlseg2e8.v v16, (a3)
|
||||
srli t1, t0, 1
|
||||
vsetvli zero, t1, e8, m2, ta, ma
|
||||
vnsrl.wi v24, \chroma, 0 // U
|
||||
sub t4, t4, t0
|
||||
vnsrl.wi v28, \chroma, 8 // V
|
||||
sh1add a3, t0, a3
|
||||
vse8.v v24, (a1)
|
||||
add a1, t1, a1
|
||||
vse8.v v28, (a2)
|
||||
add a2, t1, a2
|
||||
vsetvli zero, t0, e8, m4, ta, ma
|
||||
vse8.v \luma, (a0)
|
||||
add a0, t0, a0
|
||||
bnez t4, 2b
|
||||
|
||||
add a3, a3, t6
|
||||
add a0, a0, a6
|
||||
add a1, a1, a7
|
||||
add a2, a2, a7
|
||||
bnez a5, 1b
|
||||
|
||||
ret
|
||||
.endm
|
||||
|
||||
func ff_uyvytoyuv422_rvv, zve32x, b
|
||||
yuy2_to_i422p v20, v16
|
||||
endfunc
|
||||
|
||||
func ff_yuyvtoyuv422_rvv, zve32x, b
|
||||
yuy2_to_i422p v16, v20
|
||||
endfunc
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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/riscv/cpu.h"
|
||||
#include "libswscale/swscale_internal.h"
|
||||
|
||||
void ff_range_lum_to_jpeg_16_rvv(int16_t *, int);
|
||||
void ff_range_chr_to_jpeg_16_rvv(int16_t *, int16_t *, int);
|
||||
void ff_range_lum_from_jpeg_16_rvv(int16_t *, int);
|
||||
void ff_range_chr_from_jpeg_16_rvv(int16_t *, int16_t *, int);
|
||||
|
||||
av_cold void ff_sws_init_range_convert_riscv(SwsInternal *c)
|
||||
{
|
||||
/* This code is currently disabled because of changes in the base
|
||||
* implementation of these functions. This code should be enabled
|
||||
* again once those changes are ported to this architecture. */
|
||||
#if 0
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
static const struct {
|
||||
void (*lum)(int16_t *, int);
|
||||
void (*chr)(int16_t *, int16_t *, int);
|
||||
} convs[2] = {
|
||||
{ ff_range_lum_to_jpeg_16_rvv, ff_range_chr_to_jpeg_16_rvv },
|
||||
{ ff_range_lum_from_jpeg_16_rvv, ff_range_chr_from_jpeg_16_rvv },
|
||||
};
|
||||
|
||||
if (c->dstBpc <= 14 &&
|
||||
(flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
|
||||
bool from = c->opts.src_range != 0;
|
||||
|
||||
c->lumConvertRange = convs[from].lum;
|
||||
c->chrConvertRange = convs[from].chr;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#define RVV_INPUT(name) \
|
||||
void ff_##name##ToY_rvv(uint8_t *dst, const uint8_t *src, const uint8_t *, \
|
||||
const uint8_t *, int w, uint32_t *coeffs, void *); \
|
||||
void ff_##name##ToUV_rvv(uint8_t *, uint8_t *, const uint8_t *, \
|
||||
const uint8_t *, const uint8_t *, int w, \
|
||||
uint32_t *coeffs, void *); \
|
||||
void ff_##name##ToUV_half_rvv(uint8_t *, uint8_t *, const uint8_t *, \
|
||||
const uint8_t *, const uint8_t *, int w, \
|
||||
uint32_t *coeffs, void *)
|
||||
|
||||
RVV_INPUT(abgr32);
|
||||
RVV_INPUT(argb32);
|
||||
RVV_INPUT(bgr24);
|
||||
RVV_INPUT(bgra32);
|
||||
RVV_INPUT(rgb24);
|
||||
RVV_INPUT(rgba32);
|
||||
|
||||
av_cold void ff_sws_init_swscale_riscv(SwsInternal *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
|
||||
switch (c->opts.src_format) {
|
||||
case AV_PIX_FMT_ABGR:
|
||||
c->lumToYV12 = ff_abgr32ToY_rvv;
|
||||
if (c->chrSrcHSubSample)
|
||||
c->chrToYV12 = ff_abgr32ToUV_half_rvv;
|
||||
else
|
||||
c->chrToYV12 = ff_abgr32ToUV_rvv;
|
||||
break;
|
||||
|
||||
case AV_PIX_FMT_ARGB:
|
||||
c->lumToYV12 = ff_argb32ToY_rvv;
|
||||
if (c->chrSrcHSubSample)
|
||||
c->chrToYV12 = ff_argb32ToUV_half_rvv;
|
||||
else
|
||||
c->chrToYV12 = ff_argb32ToUV_rvv;
|
||||
break;
|
||||
|
||||
case AV_PIX_FMT_BGR24:
|
||||
c->lumToYV12 = ff_bgr24ToY_rvv;
|
||||
if (c->chrSrcHSubSample)
|
||||
c->chrToYV12 = ff_bgr24ToUV_half_rvv;
|
||||
else
|
||||
c->chrToYV12 = ff_bgr24ToUV_rvv;
|
||||
break;
|
||||
|
||||
case AV_PIX_FMT_BGRA:
|
||||
c->lumToYV12 = ff_bgra32ToY_rvv;
|
||||
if (c->chrSrcHSubSample)
|
||||
c->chrToYV12 = ff_bgra32ToUV_half_rvv;
|
||||
else
|
||||
c->chrToYV12 = ff_bgra32ToUV_rvv;
|
||||
break;
|
||||
|
||||
case AV_PIX_FMT_RGB24:
|
||||
c->lumToYV12 = ff_rgb24ToY_rvv;
|
||||
if (c->chrSrcHSubSample)
|
||||
c->chrToYV12 = ff_rgb24ToUV_half_rvv;
|
||||
else
|
||||
c->chrToYV12 = ff_rgb24ToUV_rvv;
|
||||
break;
|
||||
|
||||
case AV_PIX_FMT_RGBA:
|
||||
c->lumToYV12 = ff_rgba32ToY_rvv;
|
||||
if (c->chrSrcHSubSample)
|
||||
c->chrToYV12 = ff_rgba32ToUV_half_rvv;
|
||||
else
|
||||
c->chrToYV12 = ff_rgba32ToUV_rvv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user