sws/input: R-V V rgb24ToY & bgr24ToY
T-Head C908: rgb24_to_y_8_c: 2.0 rgb24_to_y_8_rvv_i32: 2.7 rgb24_to_y_128_c: 26.2 rgb24_to_y_128_rvv_i32: 9.2 rgb24_to_y_1080_c: 219.5 rgb24_to_y_1080_rvv_i32: 76.2 rgb24_to_y_1280_c: 276.2 rgb24_to_y_1280_rvv_i32: 89.7 rgb24_to_y_1920_c: 389.7 rgb24_to_y_1920_rvv_i32: 134.2 SpacemiT X60: rgb24_to_y_8_c: 1.7 rgb24_to_y_8_rvv_i32: 2.2 rgb24_to_y_128_c: 23.2 rgb24_to_y_128_rvv_i32: 4.2 rgb24_to_y_1080_c: 195.0 rgb24_to_y_1080_rvv_i32: 33.7 rgb24_to_y_1280_c: 231.0 rgb24_to_y_1280_rvv_i32: 40.0 rgb24_to_y_1920_c: 346.2 rgb24_to_y_1920_rvv_i32: 59.7
This commit is contained in:
parent
7560db937d
commit
79dfdac4db
@ -1,3 +1,5 @@
|
||||
OBJS += riscv/rgb2rgb.o
|
||||
OBJS += riscv/rgb2rgb.o \
|
||||
riscv/swscale.o
|
||||
RV-OBJS += riscv/rgb2rgb_rvb.o
|
||||
RVV-OBJS += riscv/rgb2rgb_rvv.o
|
||||
RVV-OBJS += riscv/input_rvv.o \
|
||||
riscv/rgb2rgb_rvv.o
|
||||
|
55
libswscale/riscv/input_rvv.S
Normal file
55
libswscale/riscv/input_rvv.S
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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
|
||||
lw t1, 8(a5) # BY
|
||||
lw t3, 0(a5) # RY
|
||||
j 1f
|
||||
endfunc
|
||||
|
||||
func ff_rgb24ToY_rvv, zve32x
|
||||
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
|
46
libswscale/riscv/swscale.c
Normal file
46
libswscale/riscv/swscale.c
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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_bgr24ToY_rvv(uint8_t *dst, const uint8_t *src, const uint8_t *,
|
||||
const uint8_t *, int width, uint32_t *coeffs, void *);
|
||||
void ff_rgb24ToY_rvv(uint8_t *dst, const uint8_t *src, const uint8_t *,
|
||||
const uint8_t *, int width, uint32_t *coeffs, void *);
|
||||
|
||||
av_cold void ff_sws_init_swscale_riscv(SwsContext *c)
|
||||
{
|
||||
#if HAVE_RVV
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) {
|
||||
switch (c->srcFormat) {
|
||||
case AV_PIX_FMT_BGR24:
|
||||
c->lumToYV12 = ff_bgr24ToY_rvv;
|
||||
break;
|
||||
|
||||
case AV_PIX_FMT_RGB24:
|
||||
c->lumToYV12 = ff_rgb24ToY_rvv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
@ -602,6 +602,8 @@ void ff_sws_init_scale(SwsContext *c)
|
||||
ff_sws_init_swscale_arm(c);
|
||||
#elif ARCH_LOONGARCH64
|
||||
ff_sws_init_swscale_loongarch(c);
|
||||
#elif ARCH_RISCV
|
||||
ff_sws_init_swscale_riscv(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -988,6 +988,7 @@ void ff_sws_init_swscale_x86(SwsContext *c);
|
||||
void ff_sws_init_swscale_aarch64(SwsContext *c);
|
||||
void ff_sws_init_swscale_arm(SwsContext *c);
|
||||
void ff_sws_init_swscale_loongarch(SwsContext *c);
|
||||
void ff_sws_init_swscale_riscv(SwsContext *c);
|
||||
|
||||
void ff_hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth,
|
||||
const uint8_t *src, int srcW, int xInc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user