mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-06 16:56:55 +08:00
Enable RVV if qemu is detected
- include a fix for jpeg unittests to do at least 1 iteration - include a fix for scale uv to only use linearup2 if filter is linear Tested on qemu with Intel host: [ RUN ] LibYUVBaseTest.TestCpuHas Cpu Flags 805306369 Has RISCV 268435456 Has RVV 536870912 Has RVVZVFH 0 Has X86 0 Bug: libyuv:956, libyuv:959, libyuv:960 Change-Id: I4a1b66f83d82ba127780f52526153d586db90111 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4429570 Commit-Queue: Frank Barchard <fbarchard@chromium.org> Reviewed-by: Randall Bosetti <rlb@google.com>
This commit is contained in:
parent
44396e6e9a
commit
c994782086
@ -196,9 +196,13 @@ LIBYUV_API SAFEBUFFERS int RiscvCpuCaps(const char* cpuinfo_name) {
|
|||||||
int flag = 0x0;
|
int flag = 0x0;
|
||||||
FILE* f = fopen(cpuinfo_name, "re");
|
FILE* f = fopen(cpuinfo_name, "re");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
// Assume nothing if /proc/cpuinfo is unavailable.
|
#if defined(__riscv_vector)
|
||||||
|
// Assume RVV if /proc/cpuinfo is unavailable.
|
||||||
// This will occur for Chrome sandbox for Pepper or Render process.
|
// This will occur for Chrome sandbox for Pepper or Render process.
|
||||||
|
return kCpuHasRVV;
|
||||||
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) {
|
while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) {
|
||||||
if (memcmp(cpuinfo_line, "isa", 3) == 0) {
|
if (memcmp(cpuinfo_line, "isa", 3) == 0) {
|
||||||
@ -243,6 +247,12 @@ LIBYUV_API SAFEBUFFERS int RiscvCpuCaps(const char* cpuinfo_name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(__riscv_vector)
|
||||||
|
else if ((memcmp(cpuinfo_line, "vendor_id\t: GenuineIntel", 24) == 0) ||
|
||||||
|
(memcmp(cpuinfo_line, "vendor_id\t: AuthenticAMD", 24) == 0)) {
|
||||||
|
flag |= kCpuHasRVV;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return flag;
|
return flag;
|
||||||
|
|||||||
@ -1039,7 +1039,7 @@ static void ScaleUV(const uint8_t* src,
|
|||||||
dst_stride, src, dst, x, y, dy, /*bpp=*/2, filtering);
|
dst_stride, src, dst, x, y, dy, /*bpp=*/2, filtering);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (filtering && (dst_width + 1) / 2 == src_width) {
|
if ((filtering == kFilterLinear) && ((dst_width + 1) / 2 == src_width)) {
|
||||||
ScaleUVLinearUp2(src_width, src_height, clip_width, clip_height, src_stride,
|
ScaleUVLinearUp2(src_width, src_height, clip_width, clip_height, src_stride,
|
||||||
dst_stride, src, dst);
|
dst_stride, src, dst);
|
||||||
return;
|
return;
|
||||||
@ -1139,7 +1139,7 @@ int UVScale_16(const uint16_t* src_uv,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (filtering && (dst_width + 1) / 2 == src_width) {
|
if ((filtering == kFilterLinear) && ((dst_width + 1) / 2 == src_width)) {
|
||||||
ScaleUVLinearUp2_16(src_width, src_height, dst_width, dst_height,
|
ScaleUVLinearUp2_16(src_width, src_height, dst_width, dst_height,
|
||||||
src_stride_uv, dst_stride_uv, src_uv, dst_uv);
|
src_stride_uv, dst_stride_uv, src_uv, dst_uv);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -2209,6 +2209,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToI420) {
|
|||||||
int half_height = (height + 1) / 2;
|
int half_height = (height + 1) / 2;
|
||||||
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
||||||
benchmark_height_ / (width * height);
|
benchmark_height_ / (width * height);
|
||||||
|
if (benchmark_iterations < 1) {
|
||||||
|
benchmark_iterations = 1;
|
||||||
|
}
|
||||||
|
|
||||||
align_buffer_page_end(dst_y, width * height);
|
align_buffer_page_end(dst_y, width * height);
|
||||||
align_buffer_page_end(dst_u, half_width * half_height);
|
align_buffer_page_end(dst_u, half_width * half_height);
|
||||||
@ -2243,6 +2246,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToI420_NV21) {
|
|||||||
int half_height = (height + 1) / 2;
|
int half_height = (height + 1) / 2;
|
||||||
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
||||||
benchmark_height_ / (width * height);
|
benchmark_height_ / (width * height);
|
||||||
|
if (benchmark_iterations < 1) {
|
||||||
|
benchmark_iterations = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Convert to NV21
|
// Convert to NV21
|
||||||
align_buffer_page_end(dst_y, width * height);
|
align_buffer_page_end(dst_y, width * height);
|
||||||
@ -2302,6 +2308,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToI420_NV12) {
|
|||||||
int half_height = (height + 1) / 2;
|
int half_height = (height + 1) / 2;
|
||||||
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
||||||
benchmark_height_ / (width * height);
|
benchmark_height_ / (width * height);
|
||||||
|
if (benchmark_iterations < 1) {
|
||||||
|
benchmark_iterations = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Convert to NV12
|
// Convert to NV12
|
||||||
align_buffer_page_end(dst_y, width * height);
|
align_buffer_page_end(dst_y, width * height);
|
||||||
@ -2361,6 +2370,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToNV21_420) {
|
|||||||
int half_height = (height + 1) / 2;
|
int half_height = (height + 1) / 2;
|
||||||
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
||||||
benchmark_height_ / (width * height);
|
benchmark_height_ / (width * height);
|
||||||
|
if (benchmark_iterations < 1) {
|
||||||
|
benchmark_iterations = 1;
|
||||||
|
}
|
||||||
|
|
||||||
align_buffer_page_end(dst_y, width * height);
|
align_buffer_page_end(dst_y, width * height);
|
||||||
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
||||||
@ -2391,6 +2403,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToNV12_420) {
|
|||||||
int half_height = (height + 1) / 2;
|
int half_height = (height + 1) / 2;
|
||||||
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
||||||
benchmark_height_ / (width * height);
|
benchmark_height_ / (width * height);
|
||||||
|
if (benchmark_iterations < 1) {
|
||||||
|
benchmark_iterations = 1;
|
||||||
|
}
|
||||||
|
|
||||||
align_buffer_page_end(dst_y, width * height);
|
align_buffer_page_end(dst_y, width * height);
|
||||||
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
||||||
@ -2426,6 +2441,9 @@ TEST_F(LibYUVConvertTest, DISABLED_TestMJPGToNV21_422) {
|
|||||||
int half_height = (height + 1) / 2;
|
int half_height = (height + 1) / 2;
|
||||||
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
||||||
benchmark_height_ / (width * height);
|
benchmark_height_ / (width * height);
|
||||||
|
if (benchmark_iterations < 1) {
|
||||||
|
benchmark_iterations = 1;
|
||||||
|
}
|
||||||
|
|
||||||
align_buffer_page_end(dst_y, width * height);
|
align_buffer_page_end(dst_y, width * height);
|
||||||
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
||||||
@ -2456,6 +2474,9 @@ TEST_F(LibYUVConvertTest, DISABLED_TestMJPGToNV12_422) {
|
|||||||
int half_height = (height + 1) / 2;
|
int half_height = (height + 1) / 2;
|
||||||
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
||||||
benchmark_height_ / (width * height);
|
benchmark_height_ / (width * height);
|
||||||
|
if (benchmark_iterations < 1) {
|
||||||
|
benchmark_iterations = 1;
|
||||||
|
}
|
||||||
|
|
||||||
align_buffer_page_end(dst_y, width * height);
|
align_buffer_page_end(dst_y, width * height);
|
||||||
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
||||||
@ -2490,6 +2511,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToNV21_400) {
|
|||||||
int half_height = (height + 1) / 2;
|
int half_height = (height + 1) / 2;
|
||||||
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
||||||
benchmark_height_ / (width * height);
|
benchmark_height_ / (width * height);
|
||||||
|
if (benchmark_iterations < 1) {
|
||||||
|
benchmark_iterations = 1;
|
||||||
|
}
|
||||||
|
|
||||||
align_buffer_page_end(dst_y, width * height);
|
align_buffer_page_end(dst_y, width * height);
|
||||||
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
||||||
@ -2520,6 +2544,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToNV12_400) {
|
|||||||
int half_height = (height + 1) / 2;
|
int half_height = (height + 1) / 2;
|
||||||
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
||||||
benchmark_height_ / (width * height);
|
benchmark_height_ / (width * height);
|
||||||
|
if (benchmark_iterations < 1) {
|
||||||
|
benchmark_iterations = 1;
|
||||||
|
}
|
||||||
|
|
||||||
align_buffer_page_end(dst_y, width * height);
|
align_buffer_page_end(dst_y, width * height);
|
||||||
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
||||||
@ -2554,6 +2581,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToNV21_444) {
|
|||||||
int half_height = (height + 1) / 2;
|
int half_height = (height + 1) / 2;
|
||||||
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
||||||
benchmark_height_ / (width * height);
|
benchmark_height_ / (width * height);
|
||||||
|
if (benchmark_iterations < 1) {
|
||||||
|
benchmark_iterations = 1;
|
||||||
|
}
|
||||||
|
|
||||||
align_buffer_page_end(dst_y, width * height);
|
align_buffer_page_end(dst_y, width * height);
|
||||||
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
||||||
@ -2584,6 +2614,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToNV12_444) {
|
|||||||
int half_height = (height + 1) / 2;
|
int half_height = (height + 1) / 2;
|
||||||
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
||||||
benchmark_height_ / (width * height);
|
benchmark_height_ / (width * height);
|
||||||
|
if (benchmark_iterations < 1) {
|
||||||
|
benchmark_iterations = 1;
|
||||||
|
}
|
||||||
|
|
||||||
align_buffer_page_end(dst_y, width * height);
|
align_buffer_page_end(dst_y, width * height);
|
||||||
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
align_buffer_page_end(dst_uv, half_width * half_height * 2);
|
||||||
@ -2616,6 +2649,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToARGB) {
|
|||||||
|
|
||||||
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
|
||||||
benchmark_height_ / (width * height);
|
benchmark_height_ / (width * height);
|
||||||
|
if (benchmark_iterations < 1) {
|
||||||
|
benchmark_iterations = 1;
|
||||||
|
}
|
||||||
|
|
||||||
align_buffer_page_end(dst_argb, width * height * 4);
|
align_buffer_page_end(dst_argb, width * height * 4);
|
||||||
for (int times = 0; times < benchmark_iterations; ++times) {
|
for (int times = 0; times < benchmark_iterations; ++times) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user