From 68960585b30a98ce7b631ddb416b06b2cb191224 Mon Sep 17 00:00:00 2001 From: pdknsk Date: Fri, 25 May 2018 05:29:04 +0200 Subject: [PATCH] [qcms] pre-cache skipping (#1443) --- projects/qcms/fuzz.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/projects/qcms/fuzz.cc b/projects/qcms/fuzz.cc index 76ed7fc66..752dae6ad 100644 --- a/projects/qcms/fuzz.cc +++ b/projects/qcms/fuzz.cc @@ -3,23 +3,26 @@ #include "qcms.h" static void transform(qcms_profile* src_profile, qcms_profile* dst_profile, - int alpha) { + size_t size) { // qcms supports GRAY and RGB profiles as input, and RGB as output. uint32_t src_color_space = qcms_profile_get_color_space(src_profile); - qcms_data_type src_type = alpha & 1 ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8; + qcms_data_type src_type = size & 1 ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8; if (src_color_space == icSigGrayData) - src_type = alpha & 1 ? QCMS_DATA_GRAYA_8 : QCMS_DATA_GRAY_8; + src_type = size & 1 ? QCMS_DATA_GRAYA_8 : QCMS_DATA_GRAY_8; else if (src_color_space != icSigRgbData) return; uint32_t dst_color_space = qcms_profile_get_color_space(dst_profile); if (dst_color_space != icSigRgbData) return; - qcms_data_type dst_type = alpha & 2 ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8; + qcms_data_type dst_type = size & 2 ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8; qcms_intent intent = qcms_profile_get_rendering_intent(src_profile); - qcms_profile_precache_output_transform(dst_profile); + // Firefox calls this on the display profile to increase performance. + // Skip with low probability to increase coverage. + if (size % 0x10) + qcms_profile_precache_output_transform(dst_profile); qcms_transform* transform = qcms_transform_create( src_profile, src_type, dst_profile, dst_type, intent); @@ -61,8 +64,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { return 0; } - transform(profile, srgb_profile, size & 3); - transform(srgb_profile, profile, size & 3); + transform(profile, srgb_profile, size); + transform(srgb_profile, profile, size); qcms_profile_release(profile); qcms_profile_release(srgb_profile);