diff options
Diffstat (limited to 'thirdparty/astcenc/astcenc_symbolic_physical.cpp')
-rw-r--r-- | thirdparty/astcenc/astcenc_symbolic_physical.cpp | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/thirdparty/astcenc/astcenc_symbolic_physical.cpp b/thirdparty/astcenc/astcenc_symbolic_physical.cpp index 80221a6013..49a8a1504b 100644 --- a/thirdparty/astcenc/astcenc_symbolic_physical.cpp +++ b/thirdparty/astcenc/astcenc_symbolic_physical.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- -// Copyright 2011-2021 Arm Limited +// 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 @@ -24,36 +24,21 @@ #include <cassert> /** - * @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. + * @brief Reverse bits in a byte. * - * @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. + * @param p The value to reverse. + * + * @return The reversed result. */ -static inline void write_bits( - int value, - int bitcount, - int bitoffset, - uint8_t* ptr -) { - int mask = (1 << bitcount) - 1; - value &= mask; - ptr += bitoffset >> 3; - bitoffset &= 7; - value <<= bitoffset; - mask <<= bitoffset; - mask = ~mask; - - ptr[0] &= mask; - ptr[0] |= value; - ptr[1] &= mask >> 8; - ptr[1] |= value >> 8; +static inline int bitrev8(int p) +{ + p = ((p & 0x0F) << 4) | ((p >> 4) & 0x0F); + p = ((p & 0x33) << 2) | ((p >> 2) & 0x33); + p = ((p & 0x55) << 1) | ((p >> 1) & 0x55); + return p; } + /** * @brief Read up to 8 bits at an arbitrary bit offset. * @@ -80,19 +65,37 @@ static inline int read_bits( return value; } +#if !defined(ASTCENC_DECOMPRESS_ONLY) + /** - * @brief Reverse bits in a byte. + * @brief Write up to 8 bits at an arbitrary bit offset. * - * @param p The value to reverse. - * - * @return The reversed result. + * 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 int bitrev8(int p) -{ - p = ((p & 0x0F) << 4) | ((p >> 4) & 0x0F); - p = ((p & 0x33) << 2) | ((p >> 2) & 0x33); - p = ((p & 0x55) << 1) | ((p >> 1) & 0x55); - return p; +static inline void write_bits( + int value, + int bitcount, + int bitoffset, + uint8_t* ptr +) { + int mask = (1 << bitcount) - 1; + value &= mask; + ptr += bitoffset >> 3; + bitoffset &= 7; + value <<= bitoffset; + mask <<= bitoffset; + mask = ~mask; + + ptr[0] &= mask; + ptr[0] |= value; + ptr[1] &= mask >> 8; + ptr[1] |= value >> 8; } /* See header for documentation. */ @@ -282,6 +285,8 @@ void symbolic_to_physical( scb.partition_count == 1 ? 17 : 19 + PARTITION_INDEX_BITS); } +#endif + /* See header for documentation. */ void physical_to_symbolic( const block_size_descriptor& bsd, |