From 840aa8db09ef1c7bffb2e91d99185e3e3ab45fc4 Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Sat, 2 May 2026 22:28:02 +0100 Subject: [PATCH 1/3] Skip quant limit heuristic for error blocks Avoid trying to read a block mode when compression failed and returned an error block. This is uncommon in normal use, but can be triggered by random colors that are difficult to compress. --- Source/astcenc_compress_symbolic.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/astcenc_compress_symbolic.cpp b/Source/astcenc_compress_symbolic.cpp index 789eac197..3a5d2dc22 100644 --- a/Source/astcenc_compress_symbolic.cpp +++ b/Source/astcenc_compress_symbolic.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- -// Copyright 2011-2025 Arm Limited +// Copyright 2011-2026 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy @@ -431,7 +431,6 @@ static float compress_symbolic_block_for_partition_1plane( // * Generate an optimized set of quantized weights // * Compute quantization errors for the mode - static const int8_t free_bits_for_partition_count[4] { 115 - 4, 111 - 4 - PARTITION_INDEX_BITS, 108 - 4 - PARTITION_INDEX_BITS, 105 - 4 - PARTITION_INDEX_BITS }; @@ -1304,8 +1303,11 @@ void compress_block( 1, 0, scb, tmpbuf, QUANT_32); // Record the quant level so we can use the filter later searches - const auto& bm = bsd.get_block_mode(scb.block_mode); - quant_limit = bm.get_weight_quant_mode(); + if (scb.block_type != SYM_BTYPE_ERROR) + { + const auto& bm = bsd.get_block_mode(scb.block_mode); + quant_limit = bm.get_weight_quant_mode(); + } best_errorvals_for_pcount[0] = astc::min(best_errorvals_for_pcount[0], errorval); if (errorval < (error_threshold * errorval_mult[i])) From 90cc95aace9ac9eafa2e8e540a25d199e43e22f3 Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Sat, 2 May 2026 23:13:12 +0100 Subject: [PATCH 2/3] Typo fix in astcenc.h --- Source/astcenc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/astcenc.h b/Source/astcenc.h index 1c931881a..0dd3443b8 100644 --- a/Source/astcenc.h +++ b/Source/astcenc.h @@ -121,7 +121,7 @@ * When using the normal map compression mode ASTC will store normals as a two component X+Y map. * Input images must contain unit-length normalized and should be passed in using a two component * swizzle. The astcenc command line tool defaults to an RRRG swizzle, but some developers prefer - * to use GGGR for compatability with BC5n which will work just as well. The Z component can be + * to use GGGR for compatibility with BC5n which will work just as well. The Z component can be * recovered programmatically in shader code, using knowledge that the vector is unit length and * that Z must be positive for a tangent-space normal map. * From f067380944687d46fc977c86e83e01993c8bc2ed Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Sat, 2 May 2026 23:13:56 +0100 Subject: [PATCH 3/3] Constrain fuzz_astc_decompress flags --- Source/Fuzzers/fuzz_astc_decompress.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Fuzzers/fuzz_astc_decompress.cpp b/Source/Fuzzers/fuzz_astc_decompress.cpp index 0739d2d78..fb2cd0fd1 100644 --- a/Source/Fuzzers/fuzz_astc_decompress.cpp +++ b/Source/Fuzzers/fuzz_astc_decompress.cpp @@ -44,14 +44,14 @@ extern "C" int LLVMFuzzerTestOneInput( // Randomize quality float quality = fdp.ConsumeFloatingPointInRange(ASTCENC_PRE_FASTEST, ASTCENC_PRE_EXHAUSTIVE); - // Randomize flags + // Randomize flags, but constrain to be safe with arbitrary input data unsigned int flags = fdp.ConsumeIntegralInRange(0, ASTCENC_ALL_FLAGS); + flags &= ~ASTCENC_FLG_SELF_DECOMPRESS_ONLY; - // Ensure we don't use flags incompatible with decompress-only if we were to use that, - // but here we are using a general context. astcenc_config config; astcenc_error status = astcenc_config_init(profile, block_x, block_y, block_z, quality, flags, &config); - if (status != ASTCENC_SUCCESS) { + if (status != ASTCENC_SUCCESS) + { return 0; }