diff --git a/include/libyuv/row.h b/include/libyuv/row.h index 4f5e582d4..945b32458 100644 --- a/include/libyuv/row.h +++ b/include/libyuv/row.h @@ -559,6 +559,7 @@ extern "C" { #define HAS_I212TOAR30ROW_SVE2 #define HAS_I212TOARGBROW_SVE2 #define HAS_I400TOARGBROW_SVE2 +#define HAS_I410ALPHATOARGBROW_SVE2 #define HAS_I410TOARGBROW_SVE2 #define HAS_I422ALPHATOARGBROW_SVE2 #define HAS_I422TOARGB1555ROW_SVE2 @@ -1083,6 +1084,13 @@ void I410AlphaToARGBRow_NEON(const uint16_t* src_y, uint8_t* rgb_buf, const struct YuvConstants* yuvconstants, int width); +void I410AlphaToARGBRow_SVE2(const uint16_t* src_y, + const uint16_t* src_u, + const uint16_t* src_v, + const uint16_t* src_a, + uint8_t* rgb_buf, + const struct YuvConstants* yuvconstants, + int width); void I444ToARGBRow_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 dfcd4a7ce..599dcc313 100644 --- a/source/convert_argb.cc +++ b/source/convert_argb.cc @@ -2986,6 +2986,11 @@ int I410AlphaToARGBMatrix(const uint16_t* src_y, } } #endif +#if defined(HAS_I410ALPHATOARGBROW_SVE2) + if (TestCpuFlag(kCpuHasSVE2)) { + I410AlphaToARGBRow = I410AlphaToARGBRow_SVE2; + } +#endif #if defined(HAS_I410ALPHATOARGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { I410AlphaToARGBRow = I410AlphaToARGBRow_Any_SSSE3; @@ -7799,6 +7804,11 @@ static int I010AlphaToARGBMatrixBilinear( } } #endif +#if defined(HAS_I410ALPHATOARGBROW_SVE2) + if (TestCpuFlag(kCpuHasSVE2)) { + I410AlphaToARGBRow = I410AlphaToARGBRow_SVE2; + } +#endif #if defined(HAS_I410ALPHATOARGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { I410AlphaToARGBRow = I410AlphaToARGBRow_Any_SSSE3; @@ -7975,6 +7985,11 @@ static int I210AlphaToARGBMatrixLinear(const uint16_t* src_y, } } #endif +#if defined(HAS_I410ALPHATOARGBROW_SVE2) + if (TestCpuFlag(kCpuHasSVE2)) { + I410AlphaToARGBRow = I410AlphaToARGBRow_SVE2; + } +#endif #if defined(HAS_I410ALPHATOARGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { I410AlphaToARGBRow = I410AlphaToARGBRow_Any_SSSE3; diff --git a/source/row_sve.cc b/source/row_sve.cc index dac1d753d..f91e2175c 100644 --- a/source/row_sve.cc +++ b/source/row_sve.cc @@ -2183,6 +2183,58 @@ void I410ToARGBRow_SVE2(const uint16_t* src_y, : "cc", "memory", YUVTORGB_SVE_REGS); } +void I410AlphaToARGBRow_SVE2(const uint16_t* src_y, + const uint16_t* src_u, + const uint16_t* src_v, + const uint16_t* src_a, + uint8_t* dst_argb, + 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; + asm volatile( + "ptrue p0.b \n" YUVTORGB_SVE_SETUP + "cmp %w[width], %w[vl] \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" READI410_SVE + "ld1h {z19.h}, p1/z, [%[src_a]] \n" I4XXTORGB_SVE + "incb %[src_a] \n" RGBATOARGB8_SVE + "subs %w[width], %w[width], %w[vl] \n" + "st2h {z16.h, z17.h}, p1, [%[dst_argb]] \n" + "add %[dst_argb], %[dst_argb], %[vl], lsl #2 \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" READI410_SVE + "ld1h {z19.h}, p1/z, [%[src_a]] \n" // + I4XXTORGB_SVE RGBATOARGB8_SVE + "st2h {z16.h, z17.h}, p1, [%[dst_argb]] \n" + + "99: \n" + : [src_y] "+r"(src_y), // %[src_y] + [src_u] "+r"(src_u), // %[src_u] + [src_v] "+r"(src_v), // %[src_v] + [src_a] "+r"(src_a), // %[src_a] + [dst_argb] "+r"(dst_argb), // %[dst_argb] + [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] + : "cc", "memory", YUVTORGB_SVE_REGS); +} + void P410ToARGBRow_SVE2(const uint16_t* src_y, const uint16_t* src_uv, uint8_t* dst_argb,