// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2023 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 // of the License at: // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations // under the License. // ---------------------------------------------------------------------------- /** * @brief Functions for finding dominant direction of a set of colors. */ #if !defined(ASTCENC_DECOMPRESS_ONLY) #include "astcenc_internal.h" #include <cassert> /** * @brief Compute the average RGB color of each partition. * * The algorithm here uses a vectorized sequential scan and per-partition * color accumulators, using select() to mask texel lanes in other partitions. * * We only accumulate sums for N-1 partitions during the scan; the value for * the last partition can be computed given that we know the block-wide average * already. * * Because of this we could reduce the loop iteration count so it "just" spans * the max texel index needed for the N-1 partitions, which could need fewer * iterations than the full block texel count. However, this makes the loop * count erratic and causes more branch mispredictions so is a net loss. * * @param pi The partitioning to use. * @param blk The block data to process. * @param[out] averages The output averages. Unused partition indices will * not be initialized, and lane<3> will be zero. */ static void compute_partition_averages_rgb( const partition_info& pi, const image_block& blk, vfloat4 averages[BLOCK_MAX_PARTITIONS] ) { … } /** * @brief Compute the average RGBA color of each partition. * * The algorithm here uses a vectorized sequential scan and per-partition * color accumulators, using select() to mask texel lanes in other partitions. * * We only accumulate sums for N-1 partitions during the scan; the value for * the last partition can be computed given that we know the block-wide average * already. * * Because of this we could reduce the loop iteration count so it "just" spans * the max texel index needed for the N-1 partitions, which could need fewer * iterations than the full block texel count. However, this makes the loop * count erratic and causes more branch mispredictions so is a net loss. * * @param pi The partitioning to use. * @param blk The block data to process. * @param[out] averages The output averages. Unused partition indices will * not be initialized. */ static void compute_partition_averages_rgba( const partition_info& pi, const image_block& blk, vfloat4 averages[BLOCK_MAX_PARTITIONS] ) { … } /* See header for documentation. */ void compute_avgs_and_dirs_4_comp( const partition_info& pi, const image_block& blk, partition_metrics pm[BLOCK_MAX_PARTITIONS] ) { … } /* See header for documentation. */ void compute_avgs_and_dirs_3_comp( const partition_info& pi, const image_block& blk, unsigned int omitted_component, partition_metrics pm[BLOCK_MAX_PARTITIONS] ) { … } /* See header for documentation. */ void compute_avgs_and_dirs_3_comp_rgb( const partition_info& pi, const image_block& blk, partition_metrics pm[BLOCK_MAX_PARTITIONS] ) { … } /* See header for documentation. */ void compute_avgs_and_dirs_2_comp( const partition_info& pt, const image_block& blk, unsigned int component1, unsigned int component2, partition_metrics pm[BLOCK_MAX_PARTITIONS] ) { … } /* See header for documentation. */ void compute_error_squared_rgba( const partition_info& pi, const image_block& blk, const processed_line4 uncor_plines[BLOCK_MAX_PARTITIONS], const processed_line4 samec_plines[BLOCK_MAX_PARTITIONS], float line_lengths[BLOCK_MAX_PARTITIONS], float& uncor_error, float& samec_error ) { … } /* See header for documentation. */ void compute_error_squared_rgb( const partition_info& pi, const image_block& blk, partition_lines3 plines[BLOCK_MAX_PARTITIONS], float& uncor_error, float& samec_error ) { … } #endif