[vlc-commits] [Git][videolan/vlc][master] 2 commits: orient: allow SIMD replacements for plane functions
Rémi Denis-Courmont (@Courmisch)
gitlab at videolan.org
Thu Feb 24 19:43:26 UTC 2022
Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC
Commits:
95a9c8d2 by Rémi Denis-Courmont at 2022-02-24T20:53:03+02:00
orient: allow SIMD replacements for plane functions
- - - - -
a7d611f2 by Rémi Denis-Courmont at 2022-02-24T20:53:03+02:00
RISC-V V video transform optimisations
- - - - -
4 changed files:
- modules/isa/riscv/Makefile.am
- + modules/isa/riscv/rvv_transform.S
- + modules/isa/riscv/transform.c
- modules/video_chroma/orient.c
Changes:
=====================================
modules/isa/riscv/Makefile.am
=====================================
@@ -1,9 +1,13 @@
riscvdir = $(pluginsdir)/riscv
+libtransform_rvv_plugin_la_SOURCES = \
+ isa/riscv/transform.c isa/riscv/rvv_transform.S
+
libvolume_rvv_plugin_la_SOURCES = isa/riscv/mixer.c isa/riscv/rvv_amplify.S
libvolume_rvv_plugin_la_LIBADD = $(AM_LIBADD) $(LIBM)
if HAVE_RVV
riscv_LTLIBRARIES = \
+ libtransform_rvv_plugin.la \
libvolume_rvv_plugin.la
endif
=====================================
modules/isa/riscv/rvv_transform.S
=====================================
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * rvv_transform.S: rectangular transforms using RISC-V Vector Extension
+ ******************************************************************************
+ * Copyright (C) 2022 Rémi Denis-Courmont
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+ .option arch, +v
+ .text
+ .align 2
+
+ .macro transforms, bits, order
+ .if \bits - (8 << \order)
+ .error "Mismatched parameters"
+ .endif
+
+ .globl rvv_hflip_\bits
+ .type rvv_hflip_\bits, %function
+ // a0:out_base, a1:out_stride, a2:in_base, a3:in_stride
+ // a4:width, a5:height
+rvv_hflip_\bits :
+ .if \order
+ slli t4, a4, \order
+ add a2, a2, t4
+ .else
+ add a2, a2, a4
+ .endif
+ li t6, -(1 << \order)
+ add a2, a2, t6
+
+1: mv t0, a0
+ mv t2, a2
+ mv t4, a4
+2: vsetvli t5, t4, e\bits, m8, ta, ma
+ sub t4, t4, t5
+ vlse\bits\().v v0, (t2), t6
+ .if \order
+ slli t5, t5, \order
+ .endif
+ sub t2, t2, t5
+ vse\bits\().v v0, (t0)
+ add t0, t0, t5
+ bnez t5, 2b
+
+ add a5, a5, -1
+ add a0, a0, a1
+ add a2, a2, a3
+ bnez a5, 1b
+ ret
+ .size rvv_hflip_\bits, . - rvv_hflip_\bits
+
+ .globl rvv_transpose_\bits
+ .type rvv_transpose_\bits, %function
+ // a0:out_base, a1:out_stride, a2:in_base, a3:in_stride
+ // a4:in_width/out_height, a5:in_height/out_width
+rvv_transpose_\bits :
+1: mv t0, a0
+ mv t2, a2
+ mv t4, a4
+ /* For the sake of locality, the inner loop transposes VL rows at once
+ * rather than one column. */
+2: vsetvli t5, a5, e\bits, m8, ta, ma
+ vlse\bits\().v v0, (t2), a3
+ addi t2, t2, (1 << \order)
+ vse\bits\().v v0, (t0)
+ addi t4, t4, -1
+ add t0, t0, a1
+ bnez t4, 2b
+
+ sub a5, a5, t5
+ .if \order
+ slli t5, t5, \order
+ .endif
+ mul t3, a3, t5 // compute bytes in VL rows
+ add a0, a0, t5 // VL output columns done
+ add a2, a2, t3 // VL input rows done
+ bnez a5, 1b
+ ret
+ .size rvv_transpose_\bits, . - rvv_transpose_\bits
+
+ .endm // transforms
+
+ transforms 8, 0
+ transforms 16, 1
+ transforms 32, 2
+ transforms 64, 3
=====================================
modules/isa/riscv/transform.c
=====================================
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * transform.c: RISC-V V video transforms
+ *****************************************************************************
+ * Copyright (C) 2022 Rémi Denis-Courmont
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_cpu.h>
+#include <vlc_plugin.h>
+#include "../../video_chroma/orient.h"
+
+void rvv_hflip_8(void *, ptrdiff_t, const void *, ptrdiff_t, int, int);
+void rvv_hflip_16(void *, ptrdiff_t, const void *, ptrdiff_t, int, int);
+void rvv_hflip_32(void *, ptrdiff_t, const void *, ptrdiff_t, int, int);
+void rvv_hflip_64(void *, ptrdiff_t, const void *, ptrdiff_t, int, int);
+void rvv_transpose_8(void *, ptrdiff_t, const void *, ptrdiff_t, int, int);
+void rvv_transpose_16(void *, ptrdiff_t, const void *, ptrdiff_t, int, int);
+void rvv_transpose_32(void *, ptrdiff_t, const void *, ptrdiff_t, int, int);
+void rvv_transpose_64(void *, ptrdiff_t, const void *, ptrdiff_t, int, int);
+
+static void Probe(void *data)
+{
+ if (vlc_CPU_RV_V()) {
+ struct plane_transforms *const transforms = data;
+
+ transforms->hflip[0] = rvv_hflip_8;
+ transforms->hflip[1] = rvv_hflip_16;
+ transforms->hflip[2] = rvv_hflip_32;
+ transforms->hflip[3] = rvv_hflip_64;
+ transforms->transpose[0] = rvv_transpose_8;
+ transforms->transpose[1] = rvv_transpose_16;
+ transforms->transpose[2] = rvv_transpose_32;
+ transforms->transpose[3] = rvv_transpose_64;
+ }
+}
+
+vlc_module_begin()
+ set_subcategory(SUBCAT_VIDEO_VFILTER)
+ set_description("RISC-V V optimisation for video transform")
+ set_cpu_funcs("video transform", Probe, 10)
+vlc_module_end()
=====================================
modules/video_chroma/orient.c
=====================================
@@ -29,6 +29,7 @@
#include <limits.h>
#include <vlc_common.h>
+#include <vlc_cpu.h>
#include <vlc_plugin.h>
#include <vlc_filter.h>
#include <vlc_mouse.h>
@@ -80,7 +81,7 @@ TRANSFORMS(16)
TRANSFORMS(32)
TRANSFORMS(64)
-static const struct plane_transforms transforms = {
+static struct plane_transforms transforms = {
{ hflip_8, hflip_16, hflip_32, hflip_64, },
{ transpose_8, transpose_16, transpose_32, transpose_64, },
};
@@ -295,6 +296,8 @@ static int Open(filter_t *filter)
!= chroma->p[i].h.num * chroma->p[i].w.den)
return VLC_ENOTSUP;
+ vlc_CPU_functions_init_once("video transform", &transforms);
+
switch (chroma->pixel_size) {
case 1:
case 2:
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b13555433ef826b8f3cdbd0d6a7e2fe9b892e39c...a7d611f241a1cc9d35a9a6968f2b9cb5181fbdc6
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b13555433ef826b8f3cdbd0d6a7e2fe9b892e39c...a7d611f241a1cc9d35a9a6968f2b9cb5181fbdc6
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list