diff --git a/include/libyuv/row.h b/include/libyuv/row.h index 87d079eeb..63b659332 100644 --- a/include/libyuv/row.h +++ b/include/libyuv/row.h @@ -554,6 +554,7 @@ extern "C" { #define HAS_DIVIDEROW_16_SVE2 #define HAS_HALFFLOATROW_SVE2 #define HAS_I210TOARGBROW_SVE2 +#define HAS_I212TOAR30ROW_SVE2 #define HAS_I212TOARGBROW_SVE2 #define HAS_I400TOARGBROW_SVE2 #define HAS_I422ALPHATOARGBROW_SVE2 @@ -1144,6 +1145,12 @@ void I212ToAR30Row_NEON(const uint16_t* src_y, uint8_t* rgb_buf, const struct YuvConstants* yuvconstants, int width); +void I212ToAR30Row_SVE2(const uint16_t* src_y, + const uint16_t* src_u, + const uint16_t* src_v, + uint8_t* rgb_buf, + const struct YuvConstants* yuvconstants, + int width); void I422ToARGBRow_NEON(const uint8_t* src_y, const uint8_t* src_u, const uint8_t* src_v, diff --git a/source/convert_argb.cc b/source/convert_argb.cc index 0bcdce5b2..4afb5c218 100644 --- a/source/convert_argb.cc +++ b/source/convert_argb.cc @@ -1160,6 +1160,11 @@ int I012ToAR30Matrix(const uint16_t* src_y, I212ToAR30Row = I212ToAR30Row_NEON; } } +#endif +#if defined(HAS_I212TOAR30ROW_SVE2) + if (TestCpuFlag(kCpuHasSVE2)) { + I212ToAR30Row = I212ToAR30Row_SVE2; + } #endif for (y = 0; y < height; ++y) { I212ToAR30Row(src_y, src_u, src_v, dst_ar30, yuvconstants, width); diff --git a/source/row_sve.cc b/source/row_sve.cc index 110555e2b..449ba02e7 100644 --- a/source/row_sve.cc +++ b/source/row_sve.cc @@ -2117,6 +2117,53 @@ void P410ToAR30Row_SVE2(const uint16_t* src_y, : "cc", "memory", YUVTORGB_SVE_REGS); } +void I212ToAR30Row_SVE2(const uint16_t* src_y, + const uint16_t* src_u, + const uint16_t* src_v, + uint8_t* dst_ar30, + const struct YuvConstants* yuvconstants, + int width) { + uint64_t vl; + asm("cnth %0" : "=r"(vl)); + int width_last_y = width & (vl - 1); + width_last_y = width_last_y == 0 ? vl : width_last_y; + uint16_t limit = 0x3ff0; + asm volatile( + "ptrue p0.b \n" YUVTORGB_SVE_SETUP + "dup z23.h, %w[limit] \n" + "subs %w[width], %w[width], %w[vl] \n" + "b.lt 2f \n" + + // Run bulk of computation with an all-true predicate to avoid predicate + // generation overhead. + "ptrue p1.h \n" + "1: \n" // + READI212_SVE I4XXTORGB_SVE STOREAR30_SVE + "subs %w[width], %w[width], %w[vl] \n" + "b.ge 1b \n" + + "2: \n" + "adds %w[width], %w[width], %w[vl] \n" + "b.eq 99f \n" + + // Calculate a predicate for the final iteration to deal with the tail. + "whilelt p1.h, wzr, %w[width_last_y] \n" // + READI212_SVE I4XXTORGB_SVE STOREAR30_SVE + + "99: \n" + : [src_y] "+r"(src_y), // %[src_y] + [src_u] "+r"(src_u), // %[src_u] + [src_v] "+r"(src_v), // %[src_v] + [dst_ar30] "+r"(dst_ar30), // %[dst_ar30] + [width] "+r"(width) // %[width] + : [vl] "r"(vl), // %[vl] + [kUVCoeff] "r"(&yuvconstants->kUVCoeff), // %[kUVCoeff] + [kRGBCoeffBias] "r"(&yuvconstants->kRGBCoeffBias), // %[kRGBCoeffBias] + [width_last_y] "r"(width_last_y), // %[width_last_y] + [limit] "r"(limit) // %[limit] + : "cc", "memory", YUVTORGB_SVE_REGS); +} + void I212ToARGBRow_SVE2(const uint16_t* src_y, const uint16_t* src_u, const uint16_t* src_v,