diff options
author | Darren Hsieh <darren.hsieh@sifive.com> | 2023-04-01 07:28:00 -0700 |
---|---|---|
committer | libyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-04-07 18:45:08 +0000 |
commit | e8af6cb2e4e6f2c3a1936cdee2e97f4e39f416f6 (patch) | |
tree | 1bf6553274637af3ced4e16b4bf6f7740ebd0a7e /source/row_rvv.cc | |
parent | 0b3ac31e4d7440a4419c8fa88bb31f9b9dd61a9c (diff) | |
download | libyuv-e8af6cb2e4e6f2c3a1936cdee2e97f4e39f416f6.tar.gz |
Add RAWToARGBRow_RVV,RAWToRGBARow_RVV,RAWToRGB24Row_RVV
* Run on SiFive internal FPGA:
RAWToARGB_Opt (~2x vs scalar)
RAWToRGBA_Opt (~2x vs scalar)
RAWToRGB24_Opt (~1.5x vs scalar)
LIBYUV_WIDTH=1280 LIBYUV_HEIGHT=720 LIBYUV_REPEAT=10
Change-Id: I21a13d646589ea2aa3822cb9225f5191068c285b
Signed-off-by: Darren Hsieh <darren.hsieh@sifive.com>
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4408357
Reviewed-by: Frank Barchard <fbarchard@chromium.org>
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Diffstat (limited to 'source/row_rvv.cc')
-rw-r--r-- | source/row_rvv.cc | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/source/row_rvv.cc b/source/row_rvv.cc new file mode 100644 index 00000000..0f264d34 --- /dev/null +++ b/source/row_rvv.cc @@ -0,0 +1,75 @@ +/* + * Copyright 2023 The LibYuv Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +/* + * Copyright (c) 2023 SiFive, Inc. All rights reserved. + * + * Contributed by Darren Hsieh <darren.hsieh@sifive.com> + * + */ + +#include <assert.h> + +#include "libyuv/row.h" + +#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv) +#include <riscv_vector.h> + +#ifdef __cplusplus +namespace libyuv { +extern "C" { +#endif + +void RAWToARGBRow_RVV(const uint8_t* src_raw, uint8_t* dst_argb, int width) { + size_t vl = __riscv_vsetvl_e8m2(width); + vuint8m2_t v_a = __riscv_vmv_v_x_u8m2(255u, vl); + while (width > 0) { + vuint8m2_t v_b, v_g, v_r; + vl = __riscv_vsetvl_e8m2(width); + __riscv_vlseg3e8_v_u8m2(&v_r, &v_g, &v_b, src_raw, vl); + __riscv_vsseg4e8_v_u8m2(dst_argb, v_b, v_g, v_r, v_a, vl); + width -= vl; + src_raw += (3 * vl); + dst_argb += (4 * vl); + } +} + +void RAWToRGBARow_RVV(const uint8_t* src_raw, uint8_t* dst_rgba, int width) { + size_t vl = __riscv_vsetvl_e8m2(width); + vuint8m2_t v_a = __riscv_vmv_v_x_u8m2(255u, vl); + while (width > 0) { + vuint8m2_t v_b, v_g, v_r; + vl = __riscv_vsetvl_e8m2(width); + __riscv_vlseg3e8_v_u8m2(&v_r, &v_g, &v_b, src_raw, vl); + __riscv_vsseg4e8_v_u8m2(dst_rgba, v_a, v_b, v_g, v_r, vl); + width -= vl; + src_raw += (3 * vl); + dst_rgba += (4 * vl); + } +} + +void RAWToRGB24Row_RVV(const uint8_t* src_raw, uint8_t* dst_rgb24, int width) { + while (width > 0) { + vuint8m2_t v_b, v_g, v_r; + size_t vl = __riscv_vsetvl_e8m2(width); + __riscv_vlseg3e8_v_u8m2(&v_b, &v_g, &v_r, src_raw, vl); + __riscv_vsseg3e8_v_u8m2(dst_rgb24, v_r, v_g, v_b, vl); + width -= vl; + src_raw += (3 * vl); + dst_rgb24 += (3 * vl); + } +} + +#ifdef __cplusplus +} // extern "C" +} // namespace libyuv +#endif + +#endif // !defined(LIBYUV_DISABLE_RVV) && defined(__riscv) |