summaryrefslogtreecommitdiff
path: root/thirdparty/astcenc/astcenc_symbolic_physical.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-05-11 14:28:49 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-05-12 12:31:24 +0200
commit30b1c7fc1fa0ccb82d9c0a3dbafce9aa466f28c8 (patch)
tree41d45dcf373e87de3b0c48fcafaecf4d5c06efbb /thirdparty/astcenc/astcenc_symbolic_physical.cpp
parenta227de0898c914e8ef163e1dfc47dc0adba50fb5 (diff)
astcenc: Update to 4.4.0
> The 4.4.0 release is a minor release with image quality improvements, > a small performance boost, a few new quality-of-life features, and a > few minor fixes for uncommon build configurations. https://github.com/ARM-software/astc-encoder/releases/tag/4.4.0 (cherry picked from commit 5a3f955e05f98b36faaab2192c8a3caae757f60e)
Diffstat (limited to 'thirdparty/astcenc/astcenc_symbolic_physical.cpp')
-rw-r--r--thirdparty/astcenc/astcenc_symbolic_physical.cpp79
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,