126fa459cSmrg/* Copyright 2013 Google Inc. All Rights Reserved.
226fa459cSmrg
326fa459cSmrg   Distributed under MIT license.
426fa459cSmrg   See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
526fa459cSmrg*/
626fa459cSmrg
726fa459cSmrg/* Class to model the static dictionary. */
826fa459cSmrg
926fa459cSmrg#ifndef BROTLI_ENC_STATIC_DICT_H_
1026fa459cSmrg#define BROTLI_ENC_STATIC_DICT_H_
1126fa459cSmrg
1226fa459cSmrg#include "../common/dictionary.h"
1326fa459cSmrg#include "../common/platform.h"
1426fa459cSmrg#include <brotli/types.h>
1526fa459cSmrg#include "./encoder_dict.h"
1626fa459cSmrg
1726fa459cSmrg#if defined(__cplusplus) || defined(c_plusplus)
1826fa459cSmrgextern "C" {
1926fa459cSmrg#endif
2026fa459cSmrg
2126fa459cSmrg#define BROTLI_MAX_STATIC_DICTIONARY_MATCH_LEN 37
2226fa459cSmrgstatic const uint32_t kInvalidMatch = 0xFFFFFFF;
2326fa459cSmrg
2426fa459cSmrg/* Matches data against static dictionary words, and for each length l,
2526fa459cSmrg   for which a match is found, updates matches[l] to be the minimum possible
2626fa459cSmrg     (distance << 5) + len_code.
2726fa459cSmrg   Returns 1 if matches have been found, otherwise 0.
2826fa459cSmrg   Prerequisites:
2926fa459cSmrg     matches array is at least BROTLI_MAX_STATIC_DICTIONARY_MATCH_LEN + 1 long
3026fa459cSmrg     all elements are initialized to kInvalidMatch */
3126fa459cSmrgBROTLI_INTERNAL BROTLI_BOOL BrotliFindAllStaticDictionaryMatches(
3226fa459cSmrg    const BrotliEncoderDictionary* dictionary,
3326fa459cSmrg    const uint8_t* data, size_t min_length, size_t max_length,
3426fa459cSmrg    uint32_t* matches);
3526fa459cSmrg
3626fa459cSmrg#if defined(__cplusplus) || defined(c_plusplus)
3726fa459cSmrg}  /* extern "C" */
3826fa459cSmrg#endif
3926fa459cSmrg
4026fa459cSmrg#endif  /* BROTLI_ENC_STATIC_DICT_H_ */
41