summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jxl/dec_ans.h
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl/dec_ans.h')
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_ans.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/dec_ans.h b/third_party/jpeg-xl/lib/jxl/dec_ans.h
index 57faad25a7..cbff1deebe 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_ans.h
+++ b/third_party/jpeg-xl/lib/jxl/dec_ans.h
@@ -9,6 +9,7 @@
// Library to decode the ANS population counts from the bit-stream and build a
// decoding table from them.
+#include <jxl/types.h>
#include <stddef.h>
#include <stdint.h>
@@ -133,6 +134,11 @@ static constexpr int8_t kSpecialDistances[kNumSpecialDistances][2] = {
{8, 0}, {4, 7}, {-4, 7}, {7, 4}, {-7, 4}, {8, 1}, {8, 2}, {6, 6},
{-6, 6}, {8, 3}, {5, 7}, {-5, 7}, {7, 5}, {-7, 5}, {8, 4}, {6, 7},
{-6, 7}, {7, 6}, {-7, 6}, {8, 5}, {7, 7}, {-7, 7}, {8, 6}, {8, 7}};
+static JXL_INLINE int SpecialDistance(size_t index, int multiplier) {
+ int dist = kSpecialDistances[index][0] +
+ static_cast<int>(multiplier) * kSpecialDistances[index][1];
+ return (dist > 1) ? dist : 1;
+}
struct ANSCode {
CacheAlignedUniquePtr alias_tables;
@@ -179,10 +185,7 @@ class ANSSymbolReader {
num_special_distances_ =
distance_multiplier == 0 ? 0 : kNumSpecialDistances;
for (size_t i = 0; i < num_special_distances_; i++) {
- int dist = kSpecialDistances[i][0];
- dist += static_cast<int>(distance_multiplier) * kSpecialDistances[i][1];
- if (dist < 1) dist = 1;
- special_distances_[i] = dist;
+ special_distances_[i] = SpecialDistance(i, distance_multiplier);
}
}
@@ -196,7 +199,7 @@ class ANSSymbolReader {
AliasTable::Lookup(table, res, log_entry_size_, entry_size_minus_1_);
state_ = symbol.freq * (state_ >> ANS_LOG_TAB_SIZE) + symbol.offset;
-#if 1
+#if JXL_TRUE
// Branchless version is about equally fast on SKX.
const uint32_t new_state =
(state_ << 16u) | static_cast<uint32_t>(br->PeekFixedBits<16>());