11cb0ef41Sopenharmony_ci/* Copyright 2013 Google Inc. All Rights Reserved.
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci   Distributed under MIT license.
41cb0ef41Sopenharmony_ci   See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
51cb0ef41Sopenharmony_ci*/
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci/* Models the histograms of literals, commands and distance codes. */
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci#ifndef BROTLI_ENC_HISTOGRAM_H_
101cb0ef41Sopenharmony_ci#define BROTLI_ENC_HISTOGRAM_H_
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci#include <string.h>  /* memset */
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci#include "../common/constants.h"
151cb0ef41Sopenharmony_ci#include "../common/context.h"
161cb0ef41Sopenharmony_ci#include "../common/platform.h"
171cb0ef41Sopenharmony_ci#include <brotli/types.h>
181cb0ef41Sopenharmony_ci#include "./block_splitter.h"
191cb0ef41Sopenharmony_ci#include "./command.h"
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci#if defined(__cplusplus) || defined(c_plusplus)
221cb0ef41Sopenharmony_ciextern "C" {
231cb0ef41Sopenharmony_ci#endif
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci/* The distance symbols effectively used by "Large Window Brotli" (32-bit). */
261cb0ef41Sopenharmony_ci#define BROTLI_NUM_HISTOGRAM_DISTANCE_SYMBOLS 544
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci#define FN(X) X ## Literal
291cb0ef41Sopenharmony_ci#define DATA_SIZE BROTLI_NUM_LITERAL_SYMBOLS
301cb0ef41Sopenharmony_ci#define DataType uint8_t
311cb0ef41Sopenharmony_ci#include "./histogram_inc.h"  /* NOLINT(build/include) */
321cb0ef41Sopenharmony_ci#undef DataType
331cb0ef41Sopenharmony_ci#undef DATA_SIZE
341cb0ef41Sopenharmony_ci#undef FN
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci#define FN(X) X ## Command
371cb0ef41Sopenharmony_ci#define DataType uint16_t
381cb0ef41Sopenharmony_ci#define DATA_SIZE BROTLI_NUM_COMMAND_SYMBOLS
391cb0ef41Sopenharmony_ci#include "./histogram_inc.h"  /* NOLINT(build/include) */
401cb0ef41Sopenharmony_ci#undef DATA_SIZE
411cb0ef41Sopenharmony_ci#undef FN
421cb0ef41Sopenharmony_ci
431cb0ef41Sopenharmony_ci#define FN(X) X ## Distance
441cb0ef41Sopenharmony_ci#define DATA_SIZE BROTLI_NUM_HISTOGRAM_DISTANCE_SYMBOLS
451cb0ef41Sopenharmony_ci#include "./histogram_inc.h"  /* NOLINT(build/include) */
461cb0ef41Sopenharmony_ci#undef DataType
471cb0ef41Sopenharmony_ci#undef DATA_SIZE
481cb0ef41Sopenharmony_ci#undef FN
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ciBROTLI_INTERNAL void BrotliBuildHistogramsWithContext(
511cb0ef41Sopenharmony_ci    const Command* cmds, const size_t num_commands,
521cb0ef41Sopenharmony_ci    const BlockSplit* literal_split, const BlockSplit* insert_and_copy_split,
531cb0ef41Sopenharmony_ci    const BlockSplit* dist_split, const uint8_t* ringbuffer, size_t pos,
541cb0ef41Sopenharmony_ci    size_t mask, uint8_t prev_byte, uint8_t prev_byte2,
551cb0ef41Sopenharmony_ci    const ContextType* context_modes, HistogramLiteral* literal_histograms,
561cb0ef41Sopenharmony_ci    HistogramCommand* insert_and_copy_histograms,
571cb0ef41Sopenharmony_ci    HistogramDistance* copy_dist_histograms);
581cb0ef41Sopenharmony_ci
591cb0ef41Sopenharmony_ci#if defined(__cplusplus) || defined(c_plusplus)
601cb0ef41Sopenharmony_ci}  /* extern "C" */
611cb0ef41Sopenharmony_ci#endif
621cb0ef41Sopenharmony_ci
631cb0ef41Sopenharmony_ci#endif  /* BROTLI_ENC_HISTOGRAM_H_ */
64