* [FFmpeg-devel] [PATCH 1/3] sws/input: R-V V 32-bit RGB to Y
@ 2024-06-06 18:26 Rémi Denis-Courmont
2024-06-06 18:26 ` [FFmpeg-devel] [PATCH 2/3] sws/input: R-V V 32-bit RGB to UV Rémi Denis-Courmont
2024-06-06 18:26 ` [FFmpeg-devel] [PATCH 3/3] sws/input: R-V V 32-bit RGB to halved UV Rémi Denis-Courmont
0 siblings, 2 replies; 3+ messages in thread
From: Rémi Denis-Courmont @ 2024-06-06 18:26 UTC (permalink / raw)
To: ffmpeg-devel
T-Head C908:
abgr_to_y_8_c: 2.5
abgr_to_y_8_rvv_i32: 2.2
abgr_to_y_128_c: 37.0
abgr_to_y_128_rvv_i32: 8.5
abgr_to_y_1080_c: 327.0
abgr_to_y_1080_rvv_i32: 69.5
abgr_to_y_1920_c: 552.0
abgr_to_y_1920_rvv_i32: 122.2
bgra_to_y_8_c: 2.5
bgra_to_y_8_rvv_i32: 2.2
bgra_to_y_128_c: 37.2
bgra_to_y_128_rvv_i32: 8.5
bgra_to_y_1080_c: 310.2
bgra_to_y_1080_rvv_i32: 69.5
bgra_to_y_1920_c: 568.2
bgra_to_y_1920_rvv_i32: 122.5
SpacemiT X60:
abgr_to_y_8_c: 2.5
abgr_to_y_8_rvv_i32: 2.0
abgr_to_y_128_c: 33.0
abgr_to_y_128_rvv_i32: 3.7
abgr_to_y_1080_c: 276.0
abgr_to_y_1080_rvv_i32: 31.5
abgr_to_y_1920_c: 493.7
abgr_to_y_1920_rvv_i32: 55.5
bgra_to_y_8_c: 2.2
bgra_to_y_8_rvv_i32: 2.0
bgra_to_y_128_c: 33.0
bgra_to_y_128_rvv_i32: 3.7
bgra_to_y_1080_c: 276.0
bgra_to_y_1080_rvv_i32: 31.5
bgra_to_y_1920_c: 490.7
bgra_to_y_1920_rvv_i32: 55.5
---
libswscale/riscv/input.S | 45 +++++++++++++++++++++++++++++++++++++
libswscale/riscv/swscale.c | 46 ++++++++++++++++++++++++++------------
2 files changed, 77 insertions(+), 14 deletions(-)
diff --git a/libswscale/riscv/input.S b/libswscale/riscv/input.S
index f84f79899b..8dfd012a9d 100644
--- a/libswscale/riscv/input.S
+++ b/libswscale/riscv/input.S
@@ -149,3 +149,48 @@ func ff_rgb24ToUV_half_rvv, zve32x
ret
endfunc
+
+ .macro rgba_input chr0, chr1, high
+func ff_\chr1\()ToY_rvv, zve32x
+ lw t1, 8(a5) # BY
+ lw t3, 0(a5) # RY
+ j 1f
+endfunc
+
+func ff_\chr0\()ToY_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))
+ 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
+ .endm
+
+rgba_input rgba32, bgra32, 0
+rgba_input abgr32, argb32, 1
diff --git a/libswscale/riscv/swscale.c b/libswscale/riscv/swscale.c
index bae626f64a..fcb338b295 100644
--- a/libswscale/riscv/swscale.c
+++ b/libswscale/riscv/swscale.c
@@ -21,20 +21,22 @@
#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_bgr24ToUV_rvv(uint8_t *, uint8_t *, const uint8_t *, const uint8_t *,
- const uint8_t *, int width, uint32_t *coeffs, void *);
-void ff_bgr24ToUV_half_rvv(uint8_t *, uint8_t *, const uint8_t *,
- 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 *);
-void ff_rgb24ToUV_rvv(uint8_t *, uint8_t *, const uint8_t *, const uint8_t *,
- const uint8_t *, int width, uint32_t *coeffs, void *);
-void ff_rgb24ToUV_half_rvv(uint8_t *, uint8_t *, const uint8_t *,
- const uint8_t *, const uint8_t *, int width,
- uint32_t *coeffs, void *);
+#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(SwsContext *c)
{
@@ -43,6 +45,14 @@ av_cold void ff_sws_init_swscale_riscv(SwsContext *c)
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) {
switch (c->srcFormat) {
+ case AV_PIX_FMT_ABGR:
+ c->lumToYV12 = ff_abgr32ToY_rvv;
+ break;
+
+ case AV_PIX_FMT_ARGB:
+ c->lumToYV12 = ff_argb32ToY_rvv;
+ break;
+
case AV_PIX_FMT_BGR24:
c->lumToYV12 = ff_bgr24ToY_rvv;
if (c->chrSrcHSubSample)
@@ -51,6 +61,10 @@ av_cold void ff_sws_init_swscale_riscv(SwsContext *c)
c->chrToYV12 = ff_bgr24ToUV_rvv;
break;
+ case AV_PIX_FMT_BGRA:
+ c->lumToYV12 = ff_bgra32ToY_rvv;
+ break;
+
case AV_PIX_FMT_RGB24:
c->lumToYV12 = ff_rgb24ToY_rvv;
if (c->chrSrcHSubSample)
@@ -58,6 +72,10 @@ av_cold void ff_sws_init_swscale_riscv(SwsContext *c)
else
c->chrToYV12 = ff_rgb24ToUV_rvv;
break;
+
+ case AV_PIX_FMT_RGBA:
+ c->lumToYV12 = ff_rgba32ToY_rvv;
+ break;
}
}
#endif
--
2.45.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
* [FFmpeg-devel] [PATCH 2/3] sws/input: R-V V 32-bit RGB to UV
2024-06-06 18:26 [FFmpeg-devel] [PATCH 1/3] sws/input: R-V V 32-bit RGB to Y Rémi Denis-Courmont
@ 2024-06-06 18:26 ` Rémi Denis-Courmont
2024-06-06 18:26 ` [FFmpeg-devel] [PATCH 3/3] sws/input: R-V V 32-bit RGB to halved UV Rémi Denis-Courmont
1 sibling, 0 replies; 3+ messages in thread
From: Rémi Denis-Courmont @ 2024-06-06 18:26 UTC (permalink / raw)
To: ffmpeg-devel
---
libswscale/riscv/input.S | 52 ++++++++++++++++++++++++++++++++++++++
libswscale/riscv/swscale.c | 8 ++++++
2 files changed, 60 insertions(+)
diff --git a/libswscale/riscv/input.S b/libswscale/riscv/input.S
index 8dfd012a9d..2d00a5a225 100644
--- a/libswscale/riscv/input.S
+++ b/libswscale/riscv/input.S
@@ -190,6 +190,58 @@ func ff_\chr0\()ToY_rvv, zve32x
ret
endfunc
+
+func ff_\chr1\()ToUV_rvv, zve32x
+ 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
+ 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
.endm
rgba_input rgba32, bgra32, 0
diff --git a/libswscale/riscv/swscale.c b/libswscale/riscv/swscale.c
index fcb338b295..76fbf2ca08 100644
--- a/libswscale/riscv/swscale.c
+++ b/libswscale/riscv/swscale.c
@@ -47,10 +47,14 @@ av_cold void ff_sws_init_swscale_riscv(SwsContext *c)
switch (c->srcFormat) {
case AV_PIX_FMT_ABGR:
c->lumToYV12 = ff_abgr32ToY_rvv;
+ if (!c->chrSrcHSubSample)
+ c->chrToYV12 = ff_abgr32ToUV_rvv;
break;
case AV_PIX_FMT_ARGB:
c->lumToYV12 = ff_argb32ToY_rvv;
+ if (!c->chrSrcHSubSample)
+ c->chrToYV12 = ff_argb32ToUV_rvv;
break;
case AV_PIX_FMT_BGR24:
@@ -63,6 +67,8 @@ av_cold void ff_sws_init_swscale_riscv(SwsContext *c)
case AV_PIX_FMT_BGRA:
c->lumToYV12 = ff_bgra32ToY_rvv;
+ if (!c->chrSrcHSubSample)
+ c->chrToYV12 = ff_bgra32ToUV_rvv;
break;
case AV_PIX_FMT_RGB24:
@@ -75,6 +81,8 @@ av_cold void ff_sws_init_swscale_riscv(SwsContext *c)
case AV_PIX_FMT_RGBA:
c->lumToYV12 = ff_rgba32ToY_rvv;
+ if (!c->chrSrcHSubSample)
+ c->chrToYV12 = ff_rgba32ToUV_rvv;
break;
}
}
--
2.45.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
* [FFmpeg-devel] [PATCH 3/3] sws/input: R-V V 32-bit RGB to halved UV
2024-06-06 18:26 [FFmpeg-devel] [PATCH 1/3] sws/input: R-V V 32-bit RGB to Y Rémi Denis-Courmont
2024-06-06 18:26 ` [FFmpeg-devel] [PATCH 2/3] sws/input: R-V V 32-bit RGB to UV Rémi Denis-Courmont
@ 2024-06-06 18:26 ` Rémi Denis-Courmont
1 sibling, 0 replies; 3+ messages in thread
From: Rémi Denis-Courmont @ 2024-06-06 18:26 UTC (permalink / raw)
To: ffmpeg-devel
T-Head C908:
abgr_to_uv_half_8_c: 2.2
abgr_to_uv_half_8_rvv_i32: 3.5
abgr_to_uv_half_128_c: 44.0
abgr_to_uv_half_128_rvv_i32: 13.0
abgr_to_uv_half_1080_c: 245.0
abgr_to_uv_half_1080_rvv_i32: 107.2
abgr_to_uv_half_1920_c: 406.2
abgr_to_uv_half_1920_rvv_i32: 188.7
bgra_to_uv_half_8_c: 2.2
bgra_to_uv_half_8_rvv_i32: 3.5
bgra_to_uv_half_128_c: 26.5
bgra_to_uv_half_128_rvv_i32: 13.0
bgra_to_uv_half_1080_c: 219.7
bgra_to_uv_half_1080_rvv_i32: 107.0
bgra_to_uv_half_1920_c: 406.7
bgra_to_uv_half_1920_rvv_i32: 188.7
SpacemiT X60:
abgr_to_uv_half_8_c: 2.2
abgr_to_uv_half_8_rvv_i32: 3.0
abgr_to_uv_half_128_c: 28.2
abgr_to_uv_half_128_rvv_i32: 5.7
abgr_to_uv_half_1080_c: 235.5
abgr_to_uv_half_1080_rvv_i32: 47.7
abgr_to_uv_half_1920_c: 418.2
abgr_to_uv_half_1920_rvv_i32: 84.0
bgra_to_uv_half_8_c: 2.0
bgra_to_uv_half_8_rvv_i32: 3.0
bgra_to_uv_half_128_c: 23.7
bgra_to_uv_half_128_rvv_i32: 5.7
bgra_to_uv_half_1080_c: 195.5
bgra_to_uv_half_1080_rvv_i32: 47.7
bgra_to_uv_half_1920_c: 346.5
bgra_to_uv_half_1920_rvv_i32: 84.0
---
libswscale/riscv/input.S | 61 ++++++++++++++++++++++++++++++++++++++
libswscale/riscv/swscale.c | 16 +++++++---
2 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/libswscale/riscv/input.S b/libswscale/riscv/input.S
index 2d00a5a225..1d7de59c66 100644
--- a/libswscale/riscv/input.S
+++ b/libswscale/riscv/input.S
@@ -242,6 +242,67 @@ func ff_\chr0\()ToUV_rvv, zve32x
ret
endfunc
+
+func ff_\chr1\()ToUV_half_rvv, zve32x
+ 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
+ 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
diff --git a/libswscale/riscv/swscale.c b/libswscale/riscv/swscale.c
index 76fbf2ca08..ffeb7876bf 100644
--- a/libswscale/riscv/swscale.c
+++ b/libswscale/riscv/swscale.c
@@ -47,13 +47,17 @@ av_cold void ff_sws_init_swscale_riscv(SwsContext *c)
switch (c->srcFormat) {
case AV_PIX_FMT_ABGR:
c->lumToYV12 = ff_abgr32ToY_rvv;
- if (!c->chrSrcHSubSample)
+ 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)
+ if (c->chrSrcHSubSample)
+ c->chrToYV12 = ff_argb32ToUV_half_rvv;
+ else
c->chrToYV12 = ff_argb32ToUV_rvv;
break;
@@ -67,7 +71,9 @@ av_cold void ff_sws_init_swscale_riscv(SwsContext *c)
case AV_PIX_FMT_BGRA:
c->lumToYV12 = ff_bgra32ToY_rvv;
- if (!c->chrSrcHSubSample)
+ if (c->chrSrcHSubSample)
+ c->chrToYV12 = ff_bgra32ToUV_half_rvv;
+ else
c->chrToYV12 = ff_bgra32ToUV_rvv;
break;
@@ -81,7 +87,9 @@ av_cold void ff_sws_init_swscale_riscv(SwsContext *c)
case AV_PIX_FMT_RGBA:
c->lumToYV12 = ff_rgba32ToY_rvv;
- if (!c->chrSrcHSubSample)
+ if (c->chrSrcHSubSample)
+ c->chrToYV12 = ff_rgba32ToUV_half_rvv;
+ else
c->chrToYV12 = ff_rgba32ToUV_rvv;
break;
}
--
2.45.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-06 18:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-06 18:26 [FFmpeg-devel] [PATCH 1/3] sws/input: R-V V 32-bit RGB to Y Rémi Denis-Courmont
2024-06-06 18:26 ` [FFmpeg-devel] [PATCH 2/3] sws/input: R-V V 32-bit RGB to UV Rémi Denis-Courmont
2024-06-06 18:26 ` [FFmpeg-devel] [PATCH 3/3] sws/input: R-V V 32-bit RGB to halved UV Rémi Denis-Courmont
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git