mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-06 16:56:55 +08:00
[AArch64] Add SVE2 implementation of P210ToARGBRow
Observed reduction in runtime compared to the existing Neon code: Cortex-A510: -32.8% Cortex-A520: +8.7% (!) Cortex-A715: -18.9% Cortex-A720: -18.9% Cortex-X2: -7.9% Cortex-X3: -8.8% Cortex-X4: +1.0% (!) Cortex-X925: -8.6% Bug: b/42280942 Change-Id: Ibe557500c3788b4fb39372c92b2f42ba216e6fea Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5975320 Reviewed-by: Frank Barchard <fbarchard@chromium.org> Reviewed-by: Justin Green <greenjustin@google.com>
This commit is contained in:
parent
721ad4aa18
commit
b753822d47
@ -562,6 +562,7 @@ extern "C" {
|
|||||||
#define HAS_I444TOARGBROW_SVE2
|
#define HAS_I444TOARGBROW_SVE2
|
||||||
#define HAS_NV12TOARGBROW_SVE2
|
#define HAS_NV12TOARGBROW_SVE2
|
||||||
#define HAS_NV21TOARGBROW_SVE2
|
#define HAS_NV21TOARGBROW_SVE2
|
||||||
|
#define HAS_P210TOARGBROW_SVE2
|
||||||
#define HAS_RAWTOARGBROW_SVE2
|
#define HAS_RAWTOARGBROW_SVE2
|
||||||
#define HAS_RAWTORGB24ROW_SVE2
|
#define HAS_RAWTORGB24ROW_SVE2
|
||||||
#define HAS_RAWTORGBAROW_SVE2
|
#define HAS_RAWTORGBAROW_SVE2
|
||||||
@ -5376,6 +5377,11 @@ void P210ToARGBRow_NEON(const uint16_t* y_buf,
|
|||||||
uint8_t* dst_argb,
|
uint8_t* dst_argb,
|
||||||
const struct YuvConstants* yuvconstants,
|
const struct YuvConstants* yuvconstants,
|
||||||
int width);
|
int width);
|
||||||
|
void P210ToARGBRow_SVE2(const uint16_t* y_buf,
|
||||||
|
const uint16_t* uv_buf,
|
||||||
|
uint8_t* dst_argb,
|
||||||
|
const struct YuvConstants* yuvconstants,
|
||||||
|
int width);
|
||||||
void P410ToARGBRow_NEON(const uint16_t* y_buf,
|
void P410ToARGBRow_NEON(const uint16_t* y_buf,
|
||||||
const uint16_t* uv_buf,
|
const uint16_t* uv_buf,
|
||||||
uint8_t* dst_argb,
|
uint8_t* dst_argb,
|
||||||
|
|||||||
@ -1914,6 +1914,11 @@ int P010ToARGBMatrix(const uint16_t* src_y,
|
|||||||
P210ToARGBRow = P210ToARGBRow_NEON;
|
P210ToARGBRow = P210ToARGBRow_NEON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if defined(HAS_P210TOARGBROW_SVE2)
|
||||||
|
if (TestCpuFlag(kCpuHasSVE2)) {
|
||||||
|
P210ToARGBRow = P210ToARGBRow_SVE2;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
for (y = 0; y < height; ++y) {
|
for (y = 0; y < height; ++y) {
|
||||||
P210ToARGBRow(src_y, src_uv, dst_argb, yuvconstants, width);
|
P210ToARGBRow(src_y, src_uv, dst_argb, yuvconstants, width);
|
||||||
@ -1973,6 +1978,11 @@ int P210ToARGBMatrix(const uint16_t* src_y,
|
|||||||
P210ToARGBRow = P210ToARGBRow_NEON;
|
P210ToARGBRow = P210ToARGBRow_NEON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if defined(HAS_P210TOARGBROW_SVE2)
|
||||||
|
if (TestCpuFlag(kCpuHasSVE2)) {
|
||||||
|
P210ToARGBRow = P210ToARGBRow_SVE2;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
for (y = 0; y < height; ++y) {
|
for (y = 0; y < height; ++y) {
|
||||||
P210ToARGBRow(src_y, src_uv, dst_argb, yuvconstants, width);
|
P210ToARGBRow(src_y, src_uv, dst_argb, yuvconstants, width);
|
||||||
|
|||||||
@ -78,6 +78,15 @@ extern "C" {
|
|||||||
"trn1 z0.b, z0.b, z0.b \n" /* YYYY */ \
|
"trn1 z0.b, z0.b, z0.b \n" /* YYYY */ \
|
||||||
"tbl z1.b, {z1.b}, z22.b \n" /* UVUV */
|
"tbl z1.b, {z1.b}, z22.b \n" /* UVUV */
|
||||||
|
|
||||||
|
#define READP210_SVE \
|
||||||
|
"ld1h {z0.h}, p1/z, [%[src_y]] \n" \
|
||||||
|
"ld1h {z1.h}, p2/z, [%[src_uv]] \n" \
|
||||||
|
"incb %[src_y] \n" \
|
||||||
|
"incb %[src_uv] \n" \
|
||||||
|
"prfm pldl1keep, [%[src_y], 448] \n" \
|
||||||
|
"prfm pldl1keep, [%[src_uv], 256] \n" \
|
||||||
|
"tbl z1.b, {z1.b}, z22.b \n"
|
||||||
|
|
||||||
#define READYUY2_SVE \
|
#define READYUY2_SVE \
|
||||||
"ld1w {z0.s}, p2/z, [%[src_yuy2]] \n" /* YUYV */ \
|
"ld1w {z0.s}, p2/z, [%[src_yuy2]] \n" /* YUYV */ \
|
||||||
"incb %[src_yuy2] \n" \
|
"incb %[src_yuy2] \n" \
|
||||||
@ -1789,6 +1798,62 @@ void HalfFloat1Row_SVE2(const uint16_t* src,
|
|||||||
: "cc", "memory", "z0", "z1", "p0", "p1");
|
: "cc", "memory", "z0", "z1", "p0", "p1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// P210 has 10 bits in msb of 16 bit NV12 style layout.
|
||||||
|
void P210ToARGBRow_SVE2(const uint16_t* src_y,
|
||||||
|
const uint16_t* src_uv,
|
||||||
|
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;
|
||||||
|
int width_last_uv = width_last_y + (width_last_y & 1);
|
||||||
|
uint32_t nv_uv_start = 0x03010301U;
|
||||||
|
uint32_t nv_uv_step = 0x04040404U;
|
||||||
|
asm volatile(
|
||||||
|
"ptrue p0.b \n" YUVTORGB_SVE_SETUP
|
||||||
|
"index z22.s, %w[nv_uv_start], %w[nv_uv_step] \n"
|
||||||
|
"dup z19.b, #255 \n" // A
|
||||||
|
"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"
|
||||||
|
"ptrue p2.h \n"
|
||||||
|
"1: \n" //
|
||||||
|
READP210_SVE NVTORGB_SVE RGBTOARGB8_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"
|
||||||
|
"whilelt p2.h, wzr, %w[width_last_uv] \n" //
|
||||||
|
READP210_SVE NVTORGB_SVE RGBTOARGB8_SVE
|
||||||
|
"st2h {z16.h, z17.h}, p1, [%[dst_argb]] \n"
|
||||||
|
|
||||||
|
"99: \n"
|
||||||
|
: [src_y] "+r"(src_y), // %[src_y]
|
||||||
|
[src_uv] "+r"(src_uv), // %[src_uv]
|
||||||
|
[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]
|
||||||
|
[nv_uv_start] "r"(nv_uv_start), // %[nv_uv_start]
|
||||||
|
[nv_uv_step] "r"(nv_uv_step), // %[nv_uv_step]
|
||||||
|
[width_last_y] "r"(width_last_y), // %[width_last_y]
|
||||||
|
[width_last_uv] "r"(width_last_uv) // %[width_last_uv]
|
||||||
|
: "cc", "memory", YUVTORGB_SVE_REGS);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // !defined(LIBYUV_DISABLE_SVE) && defined(__aarch64__)
|
#endif // !defined(LIBYUV_DISABLE_SVE) && defined(__aarch64__)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user