// 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 converting between symbolic and physical encodings. */ #include "astcenc_internal.h" #include <cassert> /** * @brief Reverse bits in a byte. * * @param p The value to reverse. * * @return The reversed result. */ static inline int bitrev8(int p) { … } /** * @brief Read up to 8 bits at an arbitrary bit offset. * * The stored value is at most 8 bits, but can be stored at an offset of between 0 and 7 bits so may * span two separate bytes in memory. * * @param bitcount The number of bits to read. * @param bitoffset The bit offset to read from, between 0 and 7. * @param[in,out] ptr The data pointer to read from. * * @return The read value. */ static inline int read_bits( int bitcount, int bitoffset, const uint8_t* ptr ) { … } #if !defined(ASTCENC_DECOMPRESS_ONLY) /** * @brief Write up to 8 bits at an arbitrary bit offset. * * The stored value is at most 8 bits, but can be stored at an offset of between 0 and 7 bits so * may span two separate bytes in memory. * * @param value The value to write. * @param bitcount The number of bits to write, starting from LSB. * @param bitoffset The bit offset to store at, between 0 and 7. * @param[in,out] ptr The data pointer to write to. */ static inline void write_bits( int value, int bitcount, int bitoffset, uint8_t* ptr ) { … } /* See header for documentation. */ void symbolic_to_physical( const block_size_descriptor& bsd, const symbolic_compressed_block& scb, uint8_t pcb[16] ) { … } #endif /* See header for documentation. */ void physical_to_symbolic( const block_size_descriptor& bsd, const uint8_t pcb[16], symbolic_compressed_block& scb ) { … }