diff options
author | Frank Barchard <fbarchard@google.com> | 2023-04-18 12:01:59 -0700 |
---|---|---|
committer | libyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-04-18 20:29:04 +0000 |
commit | c99478208686d9f5adbabffd346ddaf899a9ddc7 (patch) | |
tree | 008663be9e03f4e198bdc89eaf72cfb0dd5320a4 | |
parent | 44396e6e9aad554283c8f1fbe981ac122c40dfc7 (diff) | |
download | libyuv-c99478208686d9f5adbabffd346ddaf899a9ddc7.tar.gz |
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>
-rw-r--r-- | source/cpu_id.cc | 12 | ||||
-rw-r--r-- | source/scale_uv.cc | 4 | ||||
-rw-r--r-- | unit_test/convert_test.cc | 36 |
3 files changed, 49 insertions, 3 deletions
diff --git a/source/cpu_id.cc b/source/cpu_id.cc index efad1b36..d5202c8d 100644 --- a/source/cpu_id.cc +++ b/source/cpu_id.cc @@ -196,9 +196,13 @@ LIBYUV_API SAFEBUFFERS int RiscvCpuCaps(const char* cpuinfo_name) { int flag = 0x0; FILE* f = fopen(cpuinfo_name, "re"); 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. + return kCpuHasRVV; +#else return 0; +#endif } while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) { 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); return flag; diff --git a/source/scale_uv.cc b/source/scale_uv.cc index 50daa566..65f986e9 100644 --- a/source/scale_uv.cc +++ b/source/scale_uv.cc @@ -1039,7 +1039,7 @@ static void ScaleUV(const uint8_t* src, dst_stride, src, dst, x, y, dy, /*bpp=*/2, filtering); 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, dst_stride, src, dst); return; @@ -1139,7 +1139,7 @@ int UVScale_16(const uint16_t* src_uv, } #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, src_stride_uv, dst_stride_uv, src_uv, dst_uv); return 0; diff --git a/unit_test/convert_test.cc b/unit_test/convert_test.cc index f94a7d31..1dd6be36 100644 --- a/unit_test/convert_test.cc +++ b/unit_test/convert_test.cc @@ -2209,6 +2209,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToI420) { int half_height = (height + 1) / 2; int benchmark_iterations = benchmark_iterations_ * benchmark_width_ * benchmark_height_ / (width * height); + if (benchmark_iterations < 1) { + benchmark_iterations = 1; + } align_buffer_page_end(dst_y, width * 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 benchmark_iterations = benchmark_iterations_ * benchmark_width_ * benchmark_height_ / (width * height); + if (benchmark_iterations < 1) { + benchmark_iterations = 1; + } // Convert to NV21 align_buffer_page_end(dst_y, width * height); @@ -2302,6 +2308,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToI420_NV12) { int half_height = (height + 1) / 2; int benchmark_iterations = benchmark_iterations_ * benchmark_width_ * benchmark_height_ / (width * height); + if (benchmark_iterations < 1) { + benchmark_iterations = 1; + } // Convert to NV12 align_buffer_page_end(dst_y, width * height); @@ -2361,6 +2370,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToNV21_420) { int half_height = (height + 1) / 2; int benchmark_iterations = benchmark_iterations_ * benchmark_width_ * benchmark_height_ / (width * height); + if (benchmark_iterations < 1) { + benchmark_iterations = 1; + } align_buffer_page_end(dst_y, width * height); 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 benchmark_iterations = benchmark_iterations_ * benchmark_width_ * benchmark_height_ / (width * height); + if (benchmark_iterations < 1) { + benchmark_iterations = 1; + } align_buffer_page_end(dst_y, width * height); 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 benchmark_iterations = benchmark_iterations_ * benchmark_width_ * benchmark_height_ / (width * height); + if (benchmark_iterations < 1) { + benchmark_iterations = 1; + } align_buffer_page_end(dst_y, width * height); 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 benchmark_iterations = benchmark_iterations_ * benchmark_width_ * benchmark_height_ / (width * height); + if (benchmark_iterations < 1) { + benchmark_iterations = 1; + } align_buffer_page_end(dst_y, width * height); 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 benchmark_iterations = benchmark_iterations_ * benchmark_width_ * benchmark_height_ / (width * height); + if (benchmark_iterations < 1) { + benchmark_iterations = 1; + } align_buffer_page_end(dst_y, width * height); 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 benchmark_iterations = benchmark_iterations_ * benchmark_width_ * benchmark_height_ / (width * height); + if (benchmark_iterations < 1) { + benchmark_iterations = 1; + } align_buffer_page_end(dst_y, width * height); 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 benchmark_iterations = benchmark_iterations_ * benchmark_width_ * benchmark_height_ / (width * height); + if (benchmark_iterations < 1) { + benchmark_iterations = 1; + } align_buffer_page_end(dst_y, width * height); 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 benchmark_iterations = benchmark_iterations_ * benchmark_width_ * benchmark_height_ / (width * height); + if (benchmark_iterations < 1) { + benchmark_iterations = 1; + } align_buffer_page_end(dst_y, width * height); 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_ * benchmark_height_ / (width * height); + if (benchmark_iterations < 1) { + benchmark_iterations = 1; + } align_buffer_page_end(dst_argb, width * height * 4); for (int times = 0; times < benchmark_iterations; ++times) { |