1/* Copyright 2013 Google Inc. All Rights Reserved.
2
3   Distributed under MIT license.
4   See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5*/
6
7/* Models the histograms of literals, commands and distance codes. */
8
9#ifndef BROTLI_ENC_HISTOGRAM_H_
10#define BROTLI_ENC_HISTOGRAM_H_
11
12#include <string.h>  /* memset */
13
14#include "../common/constants.h"
15#include <brotli/types.h>
16#include "./block_splitter.h"
17#include "./command.h"
18#include "./context.h"
19#include "./port.h"
20
21#if defined(__cplusplus) || defined(c_plusplus)
22extern "C" {
23#endif
24
25#define FN(X) X ## Literal
26#define DATA_SIZE BROTLI_NUM_LITERAL_SYMBOLS
27#define DataType uint8_t
28#include "./histogram_inc.h"  /* NOLINT(build/include) */
29#undef DataType
30#undef DATA_SIZE
31#undef FN
32
33#define FN(X) X ## Command
34#define DataType uint16_t
35#define DATA_SIZE BROTLI_NUM_COMMAND_SYMBOLS
36#include "./histogram_inc.h"  /* NOLINT(build/include) */
37#undef DATA_SIZE
38#undef FN
39
40#define FN(X) X ## Distance
41#define DATA_SIZE BROTLI_NUM_DISTANCE_SYMBOLS
42#include "./histogram_inc.h"  /* NOLINT(build/include) */
43#undef DataType
44#undef DATA_SIZE
45#undef FN
46
47BROTLI_INTERNAL void BrotliBuildHistogramsWithContext(
48    const Command* cmds, const size_t num_commands,
49    const BlockSplit* literal_split, const BlockSplit* insert_and_copy_split,
50    const BlockSplit* dist_split, const uint8_t* ringbuffer, size_t pos,
51    size_t mask, uint8_t prev_byte, uint8_t prev_byte2,
52    const ContextType* context_modes, HistogramLiteral* literal_histograms,
53    HistogramCommand* insert_and_copy_histograms,
54    HistogramDistance* copy_dist_histograms);
55
56#if defined(__cplusplus) || defined(c_plusplus)
57}  /* extern "C" */
58#endif
59
60#endif  /* BROTLI_ENC_HISTOGRAM_H_ */
61