9#ifndef BROTLI_ENC_ENTROPY_ENCODE_H_
10#define BROTLI_ENC_ENTROPY_ENCODE_H_
14#include "../common/platform.h"
16#if defined(__cplusplus) || defined(c_plusplus)
22 uint32_t total_count_;
24 int16_t index_right_or_value_;
27static BROTLI_INLINE
void InitHuffmanTree(
HuffmanTree* self, uint32_t count,
28 int16_t left, int16_t right) {
29 self->total_count_ = count;
30 self->index_left_ = left;
31 self->index_right_or_value_ = right;
36 int p,
HuffmanTree* pool, uint8_t* depth,
int max_depth);
50BROTLI_INTERNAL
void BrotliCreateHuffmanTree(
const uint32_t* data,
63BROTLI_INTERNAL
void BrotliOptimizeHuffmanCountsForRle(
64 size_t length, uint32_t* counts, uint8_t* good_for_rle);
69BROTLI_INTERNAL
void BrotliWriteHuffmanTree(
const uint8_t* depth,
73 uint8_t* extra_bits_data);
76BROTLI_INTERNAL
void BrotliConvertBitDepthsToSymbols(
const uint8_t* depth,
80BROTLI_INTERNAL
extern const size_t kBrotliShellGaps[6];
84static BROTLI_INLINE
void SortHuffmanTreeItems(
HuffmanTree* items,
85 const size_t n, HuffmanTreeComparator comparator) {
89 for (i = 1; i < n; ++i) {
93 while (comparator(&tmp, &items[j])) {
103 int g = n < 57 ? 2 : 0;
105 size_t gap = kBrotliShellGaps[g];
107 for (i = gap; i < n; ++i) {
110 for (; j >= gap && comparator(&tmp, &items[j - gap]); j -= gap) {
111 items[j] = items[j - gap];
119#if defined(__cplusplus) || defined(c_plusplus)
Definition: entropy_encode.h:21
Common types used in decoder and encoder API.
#define BROTLI_BOOL
A portable bool replacement.
Definition: types.h:49