[FFmpeg-cvslog] sws/input: R-V V 32-bit RGB to UV

Rémi Denis-Courmont git at videolan.org
Sun Jun 9 18:20:39 EEST 2024


ffmpeg | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jun  6 18:12:50 2024 +0300| [e2f069905e7664e37e0ad54ddd3ffbfcdbb268c0] | committer: Rémi Denis-Courmont

sws/input: R-V V 32-bit RGB to UV

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e2f069905e7664e37e0ad54ddd3ffbfcdbb268c0
---

 libswscale/riscv/input_rvv.S | 52 ++++++++++++++++++++++++++++++++++++++++++++
 libswscale/riscv/swscale.c   |  8 +++++++
 2 files changed, 60 insertions(+)

diff --git a/libswscale/riscv/input_rvv.S b/libswscale/riscv/input_rvv.S
index 8dfd012a9d..2d00a5a225 100644
--- a/libswscale/riscv/input_rvv.S
+++ b/libswscale/riscv/input_rvv.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;
         }
     }



More information about the ffmpeg-cvslog mailing list