Path: blob/master/thirdparty/brotli/common/transform.h
21345 views
/* transforms is a part of ABI, but not API.12It means that there are some functions that are supposed to be in "common"3library, but header itself is not placed into include/brotli. This way,4aforementioned functions will be available only to brotli internals.5*/67#ifndef BROTLI_COMMON_TRANSFORM_H_8#define BROTLI_COMMON_TRANSFORM_H_910#include "platform.h"1112#if defined(__cplusplus) || defined(c_plusplus)13extern "C" {14#endif1516enum BrotliWordTransformType {17BROTLI_TRANSFORM_IDENTITY = 0,18BROTLI_TRANSFORM_OMIT_LAST_1 = 1,19BROTLI_TRANSFORM_OMIT_LAST_2 = 2,20BROTLI_TRANSFORM_OMIT_LAST_3 = 3,21BROTLI_TRANSFORM_OMIT_LAST_4 = 4,22BROTLI_TRANSFORM_OMIT_LAST_5 = 5,23BROTLI_TRANSFORM_OMIT_LAST_6 = 6,24BROTLI_TRANSFORM_OMIT_LAST_7 = 7,25BROTLI_TRANSFORM_OMIT_LAST_8 = 8,26BROTLI_TRANSFORM_OMIT_LAST_9 = 9,27BROTLI_TRANSFORM_UPPERCASE_FIRST = 10,28BROTLI_TRANSFORM_UPPERCASE_ALL = 11,29BROTLI_TRANSFORM_OMIT_FIRST_1 = 12,30BROTLI_TRANSFORM_OMIT_FIRST_2 = 13,31BROTLI_TRANSFORM_OMIT_FIRST_3 = 14,32BROTLI_TRANSFORM_OMIT_FIRST_4 = 15,33BROTLI_TRANSFORM_OMIT_FIRST_5 = 16,34BROTLI_TRANSFORM_OMIT_FIRST_6 = 17,35BROTLI_TRANSFORM_OMIT_FIRST_7 = 18,36BROTLI_TRANSFORM_OMIT_FIRST_8 = 19,37BROTLI_TRANSFORM_OMIT_FIRST_9 = 20,38BROTLI_TRANSFORM_SHIFT_FIRST = 21,39BROTLI_TRANSFORM_SHIFT_ALL = 22,40BROTLI_NUM_TRANSFORM_TYPES /* Counts transforms, not a transform itself. */41};4243#define BROTLI_TRANSFORMS_MAX_CUT_OFF BROTLI_TRANSFORM_OMIT_LAST_94445typedef struct BrotliTransforms {46uint16_t prefix_suffix_size;47/* Last character must be null, so prefix_suffix_size must be at least 1. */48const uint8_t* prefix_suffix;49const uint16_t* prefix_suffix_map;50uint32_t num_transforms;51/* Each entry is a [prefix_id, transform, suffix_id] triplet. */52const uint8_t* transforms;53/* Shift for BROTLI_TRANSFORM_SHIFT_FIRST and BROTLI_TRANSFORM_SHIFT_ALL,54must be NULL if and only if no such transforms are present. */55const uint8_t* params;56/* Indices of transforms like ["", BROTLI_TRANSFORM_OMIT_LAST_#, ""].570-th element corresponds to ["", BROTLI_TRANSFORM_IDENTITY, ""].58-1, if cut-off transform does not exist. */59int16_t cutOffTransforms[BROTLI_TRANSFORMS_MAX_CUT_OFF + 1];60} BrotliTransforms;6162/* T is BrotliTransforms*; result is uint8_t. */63#define BROTLI_TRANSFORM_PREFIX_ID(T, I) ((T)->transforms[((I) * 3) + 0])64#define BROTLI_TRANSFORM_TYPE(T, I) ((T)->transforms[((I) * 3) + 1])65#define BROTLI_TRANSFORM_SUFFIX_ID(T, I) ((T)->transforms[((I) * 3) + 2])6667/* T is BrotliTransforms*; result is const uint8_t*. */68#define BROTLI_TRANSFORM_PREFIX(T, I) (&(T)->prefix_suffix[ \69(T)->prefix_suffix_map[BROTLI_TRANSFORM_PREFIX_ID(T, I)]])70#define BROTLI_TRANSFORM_SUFFIX(T, I) (&(T)->prefix_suffix[ \71(T)->prefix_suffix_map[BROTLI_TRANSFORM_SUFFIX_ID(T, I)]])7273BROTLI_COMMON_API const BrotliTransforms* BrotliGetTransforms(void);7475BROTLI_COMMON_API int BrotliTransformDictionaryWord(76uint8_t* dst, const uint8_t* word, int len,77const BrotliTransforms* transforms, int transform_idx);7879#if defined(__cplusplus) || defined(c_plusplus)80} /* extern "C" */81#endif8283#endif /* BROTLI_COMMON_TRANSFORM_H_ */848586