summaryrefslogtreecommitdiff
path: root/lib/jxl/enc_ans.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/jxl/enc_ans.cc')
-rw-r--r--lib/jxl/enc_ans.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/jxl/enc_ans.cc b/lib/jxl/enc_ans.cc
index 81ff836..6b2f8b3 100644
--- a/lib/jxl/enc_ans.cc
+++ b/lib/jxl/enc_ans.cc
@@ -18,21 +18,24 @@
#include <vector>
#include "lib/jxl/ans_common.h"
-#include "lib/jxl/aux_out.h"
-#include "lib/jxl/aux_out_fwd.h"
#include "lib/jxl/base/bits.h"
+#include "lib/jxl/base/fast_math-inl.h"
#include "lib/jxl/dec_ans.h"
+#include "lib/jxl/enc_aux_out.h"
#include "lib/jxl/enc_cluster.h"
#include "lib/jxl/enc_context_map.h"
+#include "lib/jxl/enc_fields.h"
#include "lib/jxl/enc_huffman.h"
-#include "lib/jxl/fast_math-inl.h"
#include "lib/jxl/fields.h"
namespace jxl {
namespace {
-bool ans_fuzzer_friendly_ = false;
+#if !JXL_IS_DEBUG_BUILD
+constexpr
+#endif
+ bool ans_fuzzer_friendly_ = false;
static const int kMaxNumSymbolsForSmallCode = 4;
@@ -78,6 +81,8 @@ float EstimateDataBits(const ANSHistBin* histogram, const ANSHistBin* counts,
}
}
if (total_histogram > 0) {
+ // Used only in assert.
+ (void)total_counts;
JXL_ASSERT(total_counts == ANS_TAB_SIZE);
}
return sum;
@@ -448,7 +453,7 @@ size_t BuildAndStoreANSEncodingData(
&tmp_writer, 8 * alphabet_size + 8); // safe upper bound
BuildAndStoreHuffmanTree(histo.data(), alphabet_size, depths.data(),
bits.data(), &tmp_writer);
- ReclaimAndCharge(&tmp_writer, &allotment, 0, /*aux_out=*/nullptr);
+ allotment.ReclaimAndCharge(&tmp_writer, 0, /*aux_out=*/nullptr);
cost = tmp_writer.BitsWritten();
} else {
size_t start = writer->BitsWritten();
@@ -785,7 +790,7 @@ class HistogramBuilder {
num_symbol, log_alpha_size, use_prefix_code,
codes->encoding_info.back().data(), writer);
allotment.FinishedHistogram(writer);
- ReclaimAndCharge(writer, &allotment, layer, aux_out);
+ allotment.ReclaimAndCharge(writer, layer, aux_out);
}
return cost;
}
@@ -1461,7 +1466,7 @@ void ApplyLZ77(const HistogramParams& params, size_t num_contexts,
} else if (params.lz77_method == HistogramParams::LZ77Method::kOptimal) {
ApplyLZ77_Optimal(params, num_contexts, tokens, lz77, tokens_lz77);
} else {
- JXL_ABORT("Not implemented");
+ JXL_UNREACHABLE("Not implemented");
}
}
} // namespace
@@ -1572,7 +1577,7 @@ size_t BuildAndEncodeHistograms(const HistogramParams& params,
context_map, use_prefix_code,
writer, layer, aux_out);
allotment.FinishedHistogram(writer);
- ReclaimAndCharge(writer, &allotment, layer, aux_out);
+ allotment.ReclaimAndCharge(writer, layer, aux_out);
if (aux_out != nullptr) {
aux_out->layers[layer].num_clustered_histograms +=
@@ -1672,7 +1677,7 @@ void WriteTokens(const std::vector<Token>& tokens,
size_t layer, AuxOut* aux_out) {
BitWriter::Allotment allotment(writer, 32 * tokens.size() + 32 * 1024 * 4);
size_t num_extra_bits = WriteTokens(tokens, codes, context_map, writer);
- ReclaimAndCharge(writer, &allotment, layer, aux_out);
+ allotment.ReclaimAndCharge(writer, layer, aux_out);
if (aux_out != nullptr) {
aux_out->layers[layer].extra_bits += num_extra_bits;
}