aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Lai <bruce.lai@sifive.com>2023-06-16 00:12:24 -0700
committerlibyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-06-17 15:41:45 +0000
commit7939e039e76072bc687128fc5c1f10fe04f7858c (patch)
tree9d9098e86c44ac9edb3fc0dc1b45c69040b11396
parenta366ad714a37e6fd435914fd4df0ffa36b244cba (diff)
downloadlibyuv-7939e039e76072bc687128fc5c1f10fe04f7858c.tar.gz
[RVV] Fix compile warning in row_rvv
1. Fix compile warning in row_rvv.cc 2. Avoid compile row_rvv.cc/scale_rvv.cc when using GCC There is no RVV segment load & store on GCC. Hence, avoid compiling rvv code on GCC temporarily. 3. Add several compile options to cmake build flow -Wno-sign-compare -Wno-unused-function -Wunused-variable -Wuninitialized Bug: libyuv:956 Change-Id: I9577f98190fc9b28fb6fde65d82d0c67ce54f9ee Signed-off-by: Bruce Lai <bruce.lai@sifive.com> Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4615441 Commit-Queue: Frank Barchard <fbarchard@chromium.org> Reviewed-by: Frank Barchard <fbarchard@chromium.org>
-rw-r--r--CMakeLists.txt6
-rw-r--r--source/row_rvv.cc47
-rw-r--r--source/scale_rvv.cc15
3 files changed, 36 insertions, 32 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a4a1994..6f372949 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,6 +29,12 @@ endif()
# this creates the static library (.a)
ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} )
+target_compile_options(${ly_lib_static} PRIVATE
+ -Wno-sign-compare
+ -Wno-unused-function
+ -Wunused-variable
+ -Wuninitialized)
+
# this creates the shared library (.so)
ADD_LIBRARY ( ${ly_lib_shared} SHARED ${ly_source_files} )
SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" )
diff --git a/source/row_rvv.cc b/source/row_rvv.cc
index a79560c7..29422574 100644
--- a/source/row_rvv.cc
+++ b/source/row_rvv.cc
@@ -17,7 +17,8 @@
#include "libyuv/row.h"
-#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector)
+// This module is for clang rvv. GCC hasn't supported segment load & store.
+#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector) && defined(__clang__)
#include <assert.h>
#include <riscv_vector.h>
@@ -29,17 +30,17 @@ extern "C" {
// Fill YUV -> RGB conversion constants into vectors
// NOTE: To match behavior on other platforms, vxrm (fixed-point rounding mode
// register) is set to round-to-nearest-up mode(0).
-#define YUVTORGB_SETUP(vl, yuvconst, ub, vr, ug, vg, yg, bb, bg, br) \
- { \
- asm volatile("csrwi vxrm, 0"); \
- ub = yuvconst->kUVCoeff[0]; \
- vr = yuvconst->kUVCoeff[1]; \
- ug = yuvconst->kUVCoeff[2]; \
- vg = yuvconst->kUVCoeff[3]; \
- yg = yuvconst->kRGBCoeffBias[0]; \
- bb = yuvconst->kRGBCoeffBias[1] + 32; \
- bg = yuvconst->kRGBCoeffBias[2] - 32; \
- br = yuvconst->kRGBCoeffBias[3] + 32; \
+#define YUVTORGB_SETUP(yuvconst, ub, vr, ug, vg, yg, bb, bg, br) \
+ { \
+ asm volatile("csrwi vxrm, 0"); \
+ ub = yuvconst->kUVCoeff[0]; \
+ vr = yuvconst->kUVCoeff[1]; \
+ ug = yuvconst->kUVCoeff[2]; \
+ vg = yuvconst->kUVCoeff[3]; \
+ yg = yuvconst->kRGBCoeffBias[0]; \
+ bb = yuvconst->kRGBCoeffBias[1] + 32; \
+ bg = yuvconst->kRGBCoeffBias[2] - 32; \
+ br = yuvconst->kRGBCoeffBias[3] + 32; \
}
// Read [VLEN/8] Y, [VLEN/(8 * 2)] U and [VLEN/(8 * 2)] V from 422
@@ -266,14 +267,14 @@ void I444ToARGBRow_RVV(const uint8_t* src_y,
uint8_t* dst_argb,
const struct YuvConstants* yuvconstants,
int width) {
- size_t vl;
size_t w = (size_t)width;
+ size_t vl = __riscv_vsetvl_e8m2(w);
uint8_t ub, vr, ug, vg;
int16_t yg, bb, bg, br;
vuint8m2_t v_u, v_v;
vuint8m2_t v_b, v_g, v_r, v_a;
vuint16m4_t v_y_16, v_g_16, v_b_16, v_r_16;
- YUVTORGB_SETUP(vl, yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
+ YUVTORGB_SETUP(yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
v_a = __riscv_vmv_v_x_u8m2(255u, vl);
do {
READYUV444(vl, v_u, v_v, v_y_16);
@@ -303,7 +304,7 @@ void I444AlphaToARGBRow_RVV(const uint8_t* src_y,
vuint8m2_t v_u, v_v;
vuint8m2_t v_b, v_g, v_r, v_a;
vuint16m4_t v_y_16, v_g_16, v_b_16, v_r_16;
- YUVTORGB_SETUP(vl, yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
+ YUVTORGB_SETUP(yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
do {
READYUV444(vl, v_u, v_v, v_y_16);
v_a = __riscv_vle8_v_u8m2(src_a, vl);
@@ -333,7 +334,7 @@ void I444ToRGB24Row_RVV(const uint8_t* src_y,
vuint8m2_t v_u, v_v;
vuint8m2_t v_b, v_g, v_r;
vuint16m4_t v_y_16, v_g_16, v_b_16, v_r_16;
- YUVTORGB_SETUP(vl, yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
+ YUVTORGB_SETUP(yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
do {
READYUV444(vl, v_u, v_v, v_y_16);
YUVTORGB(vl, v_u, v_v, ub, vr, ug, vg, yg, bb, bg, br, v_y_16, v_g_16,
@@ -354,14 +355,14 @@ void I422ToARGBRow_RVV(const uint8_t* src_y,
uint8_t* dst_argb,
const struct YuvConstants* yuvconstants,
int width) {
- size_t vl;
size_t w = (size_t)width;
+ size_t vl = __riscv_vsetvl_e8m2(w);
uint8_t ub, vr, ug, vg;
int16_t yg, bb, bg, br;
vuint8m2_t v_u, v_v;
vuint8m2_t v_b, v_g, v_r, v_a;
vuint16m4_t v_y_16, v_g_16, v_b_16, v_r_16;
- YUVTORGB_SETUP(vl, yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
+ YUVTORGB_SETUP(yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
v_a = __riscv_vmv_v_x_u8m2(255u, vl);
do {
READYUV422(vl, v_u, v_v, v_y_16);
@@ -391,7 +392,7 @@ void I422AlphaToARGBRow_RVV(const uint8_t* src_y,
vuint8m2_t v_u, v_v;
vuint8m2_t v_b, v_g, v_r, v_a;
vuint16m4_t v_y_16, v_g_16, v_b_16, v_r_16;
- YUVTORGB_SETUP(vl, yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
+ YUVTORGB_SETUP(yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
do {
READYUV422(vl, v_u, v_v, v_y_16);
v_a = __riscv_vle8_v_u8m2(src_a, vl);
@@ -414,14 +415,14 @@ void I422ToRGBARow_RVV(const uint8_t* src_y,
uint8_t* dst_rgba,
const struct YuvConstants* yuvconstants,
int width) {
- size_t vl;
size_t w = (size_t)width;
+ size_t vl = __riscv_vsetvl_e8m2(w);
uint8_t ub, vr, ug, vg;
int16_t yg, bb, bg, br;
vuint8m2_t v_u, v_v;
vuint8m2_t v_b, v_g, v_r, v_a;
vuint16m4_t v_y_16, v_g_16, v_b_16, v_r_16;
- YUVTORGB_SETUP(vl, yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
+ YUVTORGB_SETUP(yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
v_a = __riscv_vmv_v_x_u8m2(255u, vl);
do {
READYUV422(vl, v_u, v_v, v_y_16);
@@ -450,7 +451,7 @@ void I422ToRGB24Row_RVV(const uint8_t* src_y,
vuint8m2_t v_u, v_v;
vuint8m2_t v_b, v_g, v_r;
vuint16m4_t v_y_16, v_g_16, v_b_16, v_r_16;
- YUVTORGB_SETUP(vl, yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
+ YUVTORGB_SETUP(yuvconstants, ub, vr, ug, vg, yg, bb, bg, br);
do {
READYUV422(vl, v_u, v_v, v_y_16);
YUVTORGB(vl, v_u, v_v, ub, vr, ug, vg, yg, bb, bg, br, v_y_16, v_g_16,
@@ -982,4 +983,4 @@ void ARGBCopyYToAlphaRow_RVV(const uint8_t* src, uint8_t* dst, int width) {
} // namespace libyuv
#endif
-#endif // !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector)
+#endif // !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector) && defined(__clang__)
diff --git a/source/scale_rvv.cc b/source/scale_rvv.cc
index 749deccd..137da77e 100644
--- a/source/scale_rvv.cc
+++ b/source/scale_rvv.cc
@@ -18,8 +18,8 @@
#include "libyuv/row.h"
#include "libyuv/scale_row.h"
-// This module is for gcc/clang rvv.
-#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector)
+// This module is for clang rvv. GCC hasn't supported segment load & store.
+#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector) && defined(__clang__)
#include <riscv_vector.h>
#ifdef __cplusplus
@@ -51,11 +51,9 @@ void ScaleARGBRowDown2_RVV(const uint8_t* src_argb,
const uint64_t* src = (const uint64_t*)(src_argb);
uint32_t* dst = (uint32_t*)(dst_argb);
do {
- vuint64m8_t v_data;
- vuint32m4_t v_dst;
size_t vl = __riscv_vsetvl_e64m8(w);
- v_data = __riscv_vle64_v_u64m8(src, vl);
- v_dst = __riscv_vnsrl_wx_u32m4(v_data, 32, vl);
+ vuint64m8_t v_data = __riscv_vle64_v_u64m8(src, vl);
+ vuint32m4_t v_dst = __riscv_vnsrl_wx_u32m4(v_data, 32, vl);
__riscv_vse32_v_u32m4(dst, v_dst, vl);
w -= vl;
src += vl;
@@ -133,9 +131,8 @@ void ScaleARGBRowDownEven_RVV(const uint8_t* src_argb,
uint32_t* dst = (uint32_t*)(dst_argb);
const int stride_byte = src_stepx * 4;
do {
- vuint32m8_t v_row;
size_t vl = __riscv_vsetvl_e32m8(w);
- v_row = __riscv_vlse32_v_u32m8(src, stride_byte, vl);
+ vuint32m8_t v_row = __riscv_vlse32_v_u32m8(src, stride_byte, vl);
__riscv_vse32_v_u32m8(dst, v_row, vl);
w -= vl;
src += vl * src_stepx;
@@ -602,4 +599,4 @@ void ScaleUVRowDownEven_RVV(const uint8_t* src_uv,
} // namespace libyuv
#endif
-#endif // !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector)
+#endif // !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector) && defined(__clang__)