diff --git a/source/cpu_id.cc b/source/cpu_id.cc index efad1b361..d5202c8d0 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 50daa5666..65f986e93 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 f94a7d31c..1dd6be36e 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) {