avifrgbtoyuvtest: skip if no libsharpyuv
Fix https://github.com/AOMediaCodec/libavif/issues/1164.
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index b328048..099457d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -116,6 +116,10 @@
target_link_libraries(avify4mtest aviftest_helpers ${GTEST_BOTH_LIBRARIES})
target_include_directories(avify4mtest PRIVATE ${GTEST_INCLUDE_DIRS})
add_test(NAME avify4mtest COMMAND avify4mtest)
+
+ if(NOT libsharpyuv_FOUND)
+ message(STATUS "Some tests are skipped because libsharpyuv is unavailable.")
+ endif()
else()
message(STATUS "Most tests are disabled because AVIF_ENABLE_GTEST is OFF.")
endif()
diff --git a/tests/gtest/avifrgbtoyuvtest.cc b/tests/gtest/avifrgbtoyuvtest.cc
index 81b5675..b9f8013 100644
--- a/tests/gtest/avifrgbtoyuvtest.cc
+++ b/tests/gtest/avifrgbtoyuvtest.cc
@@ -203,7 +203,13 @@
ModifyImageChannel(&src_rgb, offsets.b, kBlueNoise);
}
- ASSERT_EQ(avifImageRGBToYUV(yuv.get(), &src_rgb), AVIF_RESULT_OK);
+ const avifResult result = avifImageRGBToYUV(yuv.get(), &src_rgb);
+ if (result == AVIF_RESULT_NOT_IMPLEMENTED &&
+ src_rgb.chromaDownsampling ==
+ AVIF_CHROMA_DOWNSAMPLING_SHARP_YUV) {
+ GTEST_SKIP() << "libsharpyuv unavailable, skip test.";
+ }
+ ASSERT_EQ(result, AVIF_RESULT_OK);
ASSERT_EQ(avifImageYUVToRGB(yuv.get(), &dst_rgb), AVIF_RESULT_OK);
GetDiffSumAndSqDiffSum(src_rgb, dst_rgb, &diff_sum, &abs_diff_sum,
&sq_diff_sum, &max_abs_diff);
@@ -290,7 +296,12 @@
testutil::FillImageChannel(&src_rgb, offsets.a, rgb_max);
}
- ASSERT_EQ(avifImageRGBToYUV(yuv.get(), &src_rgb), AVIF_RESULT_OK);
+ const avifResult result = avifImageRGBToYUV(yuv.get(), &src_rgb);
+ if (result == AVIF_RESULT_NOT_IMPLEMENTED &&
+ src_rgb.chromaDownsampling == AVIF_CHROMA_DOWNSAMPLING_SHARP_YUV) {
+ GTEST_SKIP() << "libsharpyuv unavailable, skip test.";
+ }
+ ASSERT_EQ(result, AVIF_RESULT_OK);
ASSERT_EQ(avifImageYUVToRGB(yuv.get(), &dst_rgb), AVIF_RESULT_OK);
GetDiffSumAndSqDiffSum(src_rgb, dst_rgb, &diff_sum, &abs_diff_sum,
&sq_diff_sum, &max_abs_diff);