| 1 | /* Copyright 2010 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 | /* A (forgetful) hash table to the data seen by the compressor, to |
| 8 | help create backward references to previous data. */ |
| 9 | |
| 10 | #ifndef BROTLI_ENC_HASH_H_ |
| 11 | #define BROTLI_ENC_HASH_H_cxx . . $ `c/enc/hash.h:11:9`! |
| 12 | |
| 13 | #include "../common/constants.h"cxx . . $ `<file>/c/common/constants.h`/ |
| 14 | #include "../common/dictionary.h"cxx . . $ `<file>/c/common/dictionary.h`/ |
| 15 | #include "../common/platform.h"cxx . . $ `<file>/c/common/platform.h`/ |
| 16 | #include "compound_dictionary.h"cxx . . $ `<file>/c/enc/compound_dictionary.h`/ |
| 17 | #include "encoder_dict.h"cxx . . $ `<file>/c/enc/encoder_dict.h`/ |
| 18 | #include "fast_log.h"cxx . . $ `<file>/c/enc/fast_log.h`/ |
| 19 | #include "find_match_length.h"cxx . . $ `<file>/c/enc/find_match_length.h`/ |
| 20 | #include "hash_base.h"cxx . . $ `<file>/c/enc/hash_base.h`/ |
| 21 | #include "matching_tag_mask.h"cxx . . $ `<file>/c/enc/matching_tag_mask.h`/ |
| 22 | #include "memory.h"cxx . . $ `<file>/c/enc/memory.h`/ |
| 23 | #include "params.h"cxx . . $ `<file>/c/enc/params.h`/ |
| 24 | #include "quality.h"cxx . . $ `<file>/c/enc/quality.h`/ |
| 25 | #include "static_dict.h"cxx . . $ `<file>/c/enc/static_dict.h`/ |
| 26 | |
| 27 | #if defined(__cplusplus) || defined(c_plusplus) |
| 28 | extern "C" { |
| 29 | #endif |
| 30 | |
| 31 | typedef structcxx . . $ $anonymous_type_5b62deaf4afff4b7_0# { |
| 32 | /** |
| 33 | * Dynamically allocated areas; regular hasher uses one or two allocations; |
| 34 | * "composite" hasher uses up to 4 allocations. |
| 35 | */ |
| 36 | void* extracxx . . $ $anonymous_type_5b62deaf4afff4b7_0#extra.[4]; |
| 37 | |
| 38 | /** |
| 39 | * False before the first invocation of HasherSetup (where "extra" memory) |
| 40 | * is allocated. |
| 41 | */ |
| 42 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_setup_cxx . . $ $anonymous_type_5b62deaf4afff4b7_0#is_setup_.; |
| 43 | |
| 44 | size_tcxx . . $ size_t# dict_num_lookupscxx . . $ $anonymous_type_5b62deaf4afff4b7_0#dict_num_lookups.; |
| 45 | size_tcxx . . $ size_t# dict_num_matchescxx . . $ $anonymous_type_5b62deaf4afff4b7_0#dict_num_matches.; |
| 46 | |
| 47 | BrotliHasherParamscxx . . $ BrotliHasherParams# paramscxx . . $ $anonymous_type_5b62deaf4afff4b7_0#params.; |
| 48 | |
| 49 | /** |
| 50 | * False if hasher needs to be "prepared" before use (before the first |
| 51 | * invocation of HasherSetup or after HasherReset). "preparation" is hasher |
| 52 | * data initialization (using input ringbuffer). |
| 53 | */ |
| 54 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_prepared_cxx . . $ $anonymous_type_5b62deaf4afff4b7_0#is_prepared_.; |
| 55 | } HasherCommoncxx . . $ HasherCommon#; |
| 56 | |
| 57 | #define score_tcxx . . $ `c/enc/hash.h:57:9`! size_t |
| 58 | |
| 59 | static const uint32_tcxx . . $ uint32_t# kCutoffTransformsCountcxx . . $ kCutoffTransformsCount. = 10; |
| 60 | /* 0, 12, 27, 23, 42, 63, 56, 48, 59, 64 */ |
| 61 | /* 0+0, 4+8, 8+19, 12+11, 16+26, 20+43, 24+32, 28+20, 32+27, 36+28 */ |
| 62 | static const uint64_tcxx . . $ uint64_t# kCutoffTransformscxx . . $ kCutoffTransforms. = |
| 63 | BROTLI_MAKE_UINT64_Tcxx . . $ uint64_t#(0x071B520A, 0xDA2D3200); |
| 64 | |
| 65 | typedef struct HasherSearchResultcxx . . $ HasherSearchResult# { |
| 66 | size_tcxx . . $ size_t# lencxx . . $ HasherSearchResult#len.; |
| 67 | size_tcxx . . $ size_t# distancecxx . . $ HasherSearchResult#distance.; |
| 68 | score_tcxx . . $ size_t# scorecxx . . $ HasherSearchResult#score.; |
| 69 | int len_code_deltacxx . . $ HasherSearchResult#len_code_delta.; /* == len_code - len */ |
| 70 | } HasherSearchResultcxx . . $ HasherSearchResult#; |
| 71 | |
| 72 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void PrepareDistanceCachecxx . . $ PrepareDistanceCache(621ccea12ecf5b06).( |
| 73 | int* BROTLI_RESTRICTcxx . . $ `c/common/platform.h:82:9`! distance_cache, const int num_distances) { |
| 74 | if (num_distances > 4) { |
| 75 | int last_distance = distance_cache[0]; |
| 76 | distance_cache[4] = last_distance - 1; |
| 77 | distance_cache[5] = last_distance + 1; |
| 78 | distance_cache[6] = last_distance - 2; |
| 79 | distance_cache[7] = last_distance + 2; |
| 80 | distance_cache[8] = last_distance - 3; |
| 81 | distance_cache[9] = last_distance + 3; |
| 82 | if (num_distances > 10) { |
| 83 | int next_last_distance = distance_cache[1]; |
| 84 | distance_cache[10] = next_last_distance - 1; |
| 85 | distance_cache[11] = next_last_distance + 1; |
| 86 | distance_cache[12] = next_last_distance - 2; |
| 87 | distance_cache[13] = next_last_distance + 2; |
| 88 | distance_cache[14] = next_last_distance - 3; |
| 89 | distance_cache[15] = next_last_distance + 3; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | #define BROTLI_LITERAL_BYTE_SCOREcxx . . $ `c/enc/hash.h:94:9`! 135 |
| 95 | #define BROTLI_DISTANCE_BIT_PENALTYcxx . . $ `c/enc/hash.h:95:9`! 30 |
| 96 | /* Score must be positive after applying maximal penalty. */ |
| 97 | #define BROTLI_SCORE_BASEcxx . . $ `c/enc/hash.h:97:9`! (BROTLI_DISTANCE_BIT_PENALTYcxx . . $ `c/enc/hash.h:95:9`! * 8 * sizeof(size_t)) |
| 98 | |
| 99 | /* Usually, we always choose the longest backward reference. This function |
| 100 | allows for the exception of that rule. |
| 101 | |
| 102 | If we choose a backward reference that is further away, it will |
| 103 | usually be coded with more bits. We approximate this by assuming |
| 104 | log2(distance). If the distance can be expressed in terms of the |
| 105 | last four distances, we use some heuristic constants to estimate |
| 106 | the bits cost. For the first up to four literals we use the bit |
| 107 | cost of the literals from the literal cost model, after that we |
| 108 | use the average bit cost of the cost model. |
| 109 | |
| 110 | This function is used to sometimes discard a longer backward reference |
| 111 | when it is not much longer and the bit cost for encoding it is more |
| 112 | than the saved literals. |
| 113 | |
| 114 | backward_reference_offset MUST be positive. */ |
| 115 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! score_tcxx . . $ size_t# BackwardReferenceScorecxx . . $ BackwardReferenceScore(80bad76eed2d2579).( |
| 116 | size_tcxx . . $ size_t# copy_length, size_tcxx . . $ size_t# backward_reference_offset) { |
| 117 | return BROTLI_SCORE_BASEcxx . . $ `c/enc/hash.h:97:9`! + BROTLI_LITERAL_BYTE_SCOREcxx . . $ `c/enc/hash.h:94:9`! * (score_tcxx . . $ `c/enc/hash.h:57:9`!)copy_length - |
| 118 | BROTLI_DISTANCE_BIT_PENALTYcxx . . $ `c/enc/hash.h:95:9`! * Log2FloorNonZerocxx . . $ Log2FloorNonZero(ea88b852781e8a38).(backward_reference_offset); |
| 119 | } |
| 120 | |
| 121 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! score_tcxx . . $ `c/enc/hash.h:57:9`! BackwardReferenceScoreUsingLastDistancecxx . . $ BackwardReferenceScoreUsingLastDistance(ecdaa1632f49f591).( |
| 122 | size_tcxx . . $ size_t# copy_length) { |
| 123 | return BROTLI_LITERAL_BYTE_SCOREcxx . . $ `c/enc/hash.h:94:9`! * (score_tcxx . . $ `c/enc/hash.h:57:9`!)copy_length + |
| 124 | BROTLI_SCORE_BASEcxx . . $ `c/enc/hash.h:97:9`! + 15; |
| 125 | } |
| 126 | |
| 127 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! score_tcxx . . $ size_t# BackwardReferencePenaltyUsingLastDistancecxx . . $ BackwardReferencePenaltyUsingLastDistance(ecdaa1632f49f591).( |
| 128 | size_tcxx . . $ size_t# distance_short_code) { |
| 129 | return (score_tcxx . . $ size_t#)39 + ((0x1CA10 >> (distance_short_code & 0xE)) & 0xE); |
| 130 | } |
| 131 | |
| 132 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! TestStaticDictionaryItemcxx . . $ TestStaticDictionaryItem(1b697295e4bdc8e3).( |
| 133 | const BrotliEncoderDictionarycxx . . $ BrotliEncoderDictionary#* dictionary, size_tcxx . . $ size_t# len, size_tcxx . . $ size_t# word_idx, |
| 134 | const uint8_tcxx . . $ uint8_t#* data, size_tcxx . . $ size_t# max_length, size_tcxx . . $ size_t# max_backward, |
| 135 | size_tcxx . . $ size_t# max_distance, HasherSearchResultcxx . . $ HasherSearchResult#* out) { |
| 136 | size_tcxx . . $ size_t# offset; |
| 137 | size_tcxx . . $ size_t# matchlen; |
| 138 | size_tcxx . . $ size_t# backward; |
| 139 | score_tcxx . . $ size_t# score; |
| 140 | offset = dictionary->wordscxx . . $ BrotliEncoderDictionary#words.->offsets_by_lengthcxx . . $ BrotliDictionary#offsets_by_length.[len] + len * word_idx; |
| 141 | if (len > max_length) { |
| 142 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 143 | } |
| 144 | |
| 145 | matchlen = |
| 146 | FindMatchLengthWithLimitcxx . . $ FindMatchLengthWithLimit(c2ccccc71581acc8).(data, &dictionary->wordscxx . . $ BrotliEncoderDictionary#words.->datacxx . . $ BrotliDictionary#data.[offset], len); |
| 147 | if (matchlen + dictionary->cutoffTransformsCountcxx . . $ BrotliEncoderDictionary#cutoffTransformsCount. <= len || matchlen == 0) { |
| 148 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 149 | } |
| 150 | { |
| 151 | size_tcxx . . $ size_t# cut = len - matchlen; |
| 152 | size_tcxx . . $ size_t# transform_id = (cut << 2) + |
| 153 | (size_tcxx . . $ size_t#)((dictionary->cutoffTransformscxx . . $ BrotliEncoderDictionary#cutoffTransforms. >> (cut * 6)) & 0x3F); |
| 154 | backward = max_backward + 1 + word_idx + |
| 155 | (transform_id << dictionary->wordscxx . . $ BrotliEncoderDictionary#words.->size_bits_by_lengthcxx . . $ BrotliDictionary#size_bits_by_length.[len]); |
| 156 | } |
| 157 | if (backward > max_distance) { |
| 158 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 159 | } |
| 160 | score = BackwardReferenceScorecxx . . $ BackwardReferenceScore(80bad76eed2d2579).(matchlen, backward); |
| 161 | if (score < out->scorecxx . . $ HasherSearchResult#score.) { |
| 162 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 163 | } |
| 164 | out->lencxx . . $ HasherSearchResult#len. = matchlen; |
| 165 | out->len_code_deltacxx . . $ HasherSearchResult#len_code_delta. = (int)len - (int)matchlen; |
| 166 | out->distancecxx . . $ HasherSearchResult#distance. = backward; |
| 167 | out->scorecxx . . $ HasherSearchResult#score. = score; |
| 168 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 169 | } |
| 170 | |
| 171 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void SearchInStaticDictionarycxx . . $ SearchInStaticDictionary(e21d390e7ad53fe0).( |
| 172 | const BrotliEncoderDictionarycxx . . $ BrotliEncoderDictionary#* dictionary, |
| 173 | HasherCommoncxx . . $ HasherCommon#* common, const uint8_tcxx . . $ uint8_t#* data, size_tcxx . . $ size_t# max_length, |
| 174 | size_tcxx . . $ size_t# max_backward, size_tcxx . . $ size_t# max_distance, |
| 175 | HasherSearchResultcxx . . $ HasherSearchResult#* out, BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! shallow) { |
| 176 | size_tcxx . . $ size_t# key; |
| 177 | size_tcxx . . $ size_t# i; |
| 178 | if (common->dict_num_matchescxx . . $ $anonymous_type_5b62deaf4afff4b7_0#dict_num_matches. < (common->dict_num_lookupscxx . . $ $anonymous_type_5b62deaf4afff4b7_0#dict_num_lookups. >> 7)) { |
| 179 | return; |
| 180 | } |
| 181 | key = Hash14cxx . . $ Hash14(ca1608e2c87725e2).(data) << 1; |
| 182 | for (i = 0; i < (shallow ? 1u : 2u); ++i, ++key) { |
| 183 | common->dict_num_lookupscxx . . $ $anonymous_type_5b62deaf4afff4b7_0#dict_num_lookups.++; |
| 184 | if (dictionary->hash_table_lengthscxx . . $ BrotliEncoderDictionary#hash_table_lengths.[key] != 0) { |
| 185 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! item_matches = TestStaticDictionaryItemcxx . . $ TestStaticDictionaryItem(1b697295e4bdc8e3).( |
| 186 | dictionary, dictionary->hash_table_lengthscxx . . $ BrotliEncoderDictionary#hash_table_lengths.[key], |
| 187 | dictionary->hash_table_wordscxx . . $ BrotliEncoderDictionary#hash_table_words.[key], data, |
| 188 | max_length, max_backward, max_distance, out); |
| 189 | if (item_matches) { |
| 190 | common->dict_num_matchescxx . . $ $anonymous_type_5b62deaf4afff4b7_0#dict_num_matches.++; |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | typedef struct BackwardMatchcxx . . $ BackwardMatch# { |
| 197 | uint32_tcxx . . $ uint32_t# distancecxx . . $ BackwardMatch#distance.; |
| 198 | uint32_tcxx . . $ uint32_t# length_and_codecxx . . $ BackwardMatch#length_and_code.; |
| 199 | } BackwardMatchcxx . . $ BackwardMatch#; |
| 200 | |
| 201 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void InitBackwardMatchcxx . . $ InitBackwardMatch(1ab56fcc6d89d1f4).(BackwardMatchcxx . . $ BackwardMatch#* self, |
| 202 | size_tcxx . . $ size_t# dist, size_tcxx . . $ size_t# len) { |
| 203 | self->distancecxx . . $ BackwardMatch#distance. = (uint32_tcxx . . $ uint32_t#)dist; |
| 204 | self->length_and_codecxx . . $ BackwardMatch#length_and_code. = (uint32_tcxx . . $ uint32_t#)(len << 5); |
| 205 | } |
| 206 | |
| 207 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void InitDictionaryBackwardMatchcxx . . $ InitDictionaryBackwardMatch(a65a9796ced115b8).(BackwardMatchcxx . . $ BackwardMatch#* self, |
| 208 | size_tcxx . . $ size_t# dist, size_tcxx . . $ size_t# len, size_tcxx . . $ size_t# len_code) { |
| 209 | self->distancecxx . . $ BackwardMatch#distance. = (uint32_tcxx . . $ uint32_t#)dist; |
| 210 | self->length_and_codecxx . . $ BackwardMatch#length_and_code. = |
| 211 | (uint32_tcxx . . $ uint32_t#)((len << 5) | (len == len_code ? 0 : len_code)); |
| 212 | } |
| 213 | |
| 214 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! size_tcxx . . $ size_t# BackwardMatchLengthcxx . . $ BackwardMatchLength(a1892b62ee829aa2).(const BackwardMatchcxx . . $ BackwardMatch#* self) { |
| 215 | return self->length_and_codecxx . . $ BackwardMatch#length_and_code. >> 5; |
| 216 | } |
| 217 | |
| 218 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! size_tcxx . . $ size_t# BackwardMatchLengthCodecxx . . $ BackwardMatchLengthCode(a1892b62ee829aa2).(const BackwardMatchcxx . . $ BackwardMatch#* self) { |
| 219 | size_tcxx . . $ size_t# code = self->length_and_codecxx . . $ BackwardMatch#length_and_code. & 31; |
| 220 | return code ? code : BackwardMatchLengthcxx . . $ BackwardMatchLength(a1892b62ee829aa2).(self); |
| 221 | } |
| 222 | |
| 223 | #define EXPAND_CATcxx . . $ `c/enc/hash.h:223:9`!(a, b) CATcxx . . $ `c/enc/hash.h:224:9`!(a, b) |
| 224 | #define CATcxx . . $ `c/enc/hash.h:224:9`!(a, b) a ## b |
| 225 | #define FNcxx . . $ `c/enc/hash.h:225:9`!(X) EXPAND_CATcxx . . $ `c/enc/hash.h:223:9`!(X, HASHERcxx . . $ `c/enc/hash.h:227:9`!()) |
| 226 | |
| 227 | #define HASHERcxx . . $ `c/enc/hash.h:227:9`!() H10 |
| 228 | #define BUCKET_BITScxx . . $ `c/enc/hash.h:228:9`! 17 |
| 229 | #define MAX_TREE_SEARCH_DEPTHcxx . . $ `c/enc/hash.h:229:9`! 64 |
| 230 | #define MAX_TREE_COMP_LENGTHcxx . . $ `c/enc/hash.h:230:9`! 128 |
| 231 | #include "hash_to_binary_tree_inc.h"cxx . . $ `<file>/c/enc/hash_to_binary_tree_inc.h`/ /* NOLINT(build/include) */ |
| 232 | #undef MAX_TREE_SEARCH_DEPTHcxx . . $ `c/enc/hash.h:229:9`! |
| 233 | #undef MAX_TREE_COMP_LENGTHcxx . . $ `c/enc/hash.h:230:9`! |
| 234 | #undef BUCKET_BITScxx . . $ `c/enc/hash.h:228:9`! |
| 235 | #undef HASHERcxx . . $ `c/enc/hash.h:227:9`! |
| 236 | /* MAX_NUM_MATCHES == 64 + MAX_TREE_SEARCH_DEPTH */ |
| 237 | #define MAX_NUM_MATCHES_H10cxx . . $ `c/enc/hash.h:237:9`! 128 |
| 238 | |
| 239 | /* For BUCKET_SWEEP_BITS == 0, enabling the dictionary lookup makes compression |
| 240 | a little faster (0.5% - 1%) and it compresses 0.15% better on small text |
| 241 | and HTML inputs. */ |
| 242 | |
| 243 | #define HASHERcxx . . $ `c/enc/hash.h:243:9`!() H2 |
| 244 | #define BUCKET_BITScxx . . $ `c/enc/hash.h:244:9`! 16 |
| 245 | #define BUCKET_SWEEP_BITScxx . . $ `c/enc/hash.h:245:9`! 0 |
| 246 | #define HASH_LENcxx . . $ `c/enc/hash.h:246:9`! 5 |
| 247 | #define USE_DICTIONARYcxx . . $ `c/enc/hash.h:247:9`! 1 |
| 248 | #include "hash_longest_match_quickly_inc.h"cxx . . $ `<file>/c/enc/hash_longest_match_quickly_inc.h`/ /* NOLINT(build/include) */ |
| 249 | #undef BUCKET_SWEEP_BITScxx . . $ `c/enc/hash.h:245:9`! |
| 250 | #undef USE_DICTIONARYcxx . . $ `c/enc/hash.h:247:9`! |
| 251 | #undef HASHERcxx . . $ `c/enc/hash.h:243:9`! |
| 252 | |
| 253 | #define HASHERcxx . . $ `c/enc/hash.h:253:9`!() H3 |
| 254 | #define BUCKET_SWEEP_BITScxx . . $ `c/enc/hash.h:254:9`! 1 |
| 255 | #define USE_DICTIONARYcxx . . $ `c/enc/hash.h:255:9`! 0 |
| 256 | #include "hash_longest_match_quickly_inc.h"cxx . . $ `<file>/c/enc/hash_longest_match_quickly_inc.h`/ /* NOLINT(build/include) */ |
| 257 | #undef USE_DICTIONARYcxx . . $ `c/enc/hash.h:255:9`! |
| 258 | #undef BUCKET_SWEEP_BITScxx . . $ `c/enc/hash.h:254:9`! |
| 259 | #undef BUCKET_BITScxx . . $ `c/enc/hash.h:244:9`! |
| 260 | #undef HASHERcxx . . $ `c/enc/hash.h:253:9`! |
| 261 | |
| 262 | #define HASHERcxx . . $ `c/enc/hash.h:262:9`!() H4 |
| 263 | #define BUCKET_BITScxx . . $ `c/enc/hash.h:263:9`! 17 |
| 264 | #define BUCKET_SWEEP_BITScxx . . $ `c/enc/hash.h:264:9`! 2 |
| 265 | #define USE_DICTIONARYcxx . . $ `c/enc/hash.h:265:9`! 1 |
| 266 | #include "hash_longest_match_quickly_inc.h"cxx . . $ `<file>/c/enc/hash_longest_match_quickly_inc.h`/ /* NOLINT(build/include) */ |
| 267 | #undef USE_DICTIONARYcxx . . $ `c/enc/hash.h:265:9`! |
| 268 | #undef HASH_LENcxx . . $ `c/enc/hash.h:246:9`! |
| 269 | #undef BUCKET_SWEEP_BITScxx . . $ `c/enc/hash.h:264:9`! |
| 270 | #undef BUCKET_BITScxx . . $ `c/enc/hash.h:263:9`! |
| 271 | #undef HASHERcxx . . $ `c/enc/hash.h:262:9`! |
| 272 | |
| 273 | #define HASHERcxx . . $ `c/enc/hash.h:273:9`!() H5 |
| 274 | #include "hash_longest_match_inc.h"cxx . . $ `<file>/c/enc/hash_longest_match_inc.h`/ /* NOLINT(build/include) */ |
| 275 | #undef HASHERcxx . . $ `c/enc/hash.h:273:9`! |
| 276 | |
| 277 | #define HASHERcxx . . $ `c/enc/hash.h:277:9`!() H6 |
| 278 | #include "hash_longest_match64_inc.h"cxx . . $ `<file>/c/enc/hash_longest_match64_inc.h`/ /* NOLINT(build/include) */ |
| 279 | #undef HASHERcxx . . $ `c/enc/hash.h:277:9`! |
| 280 | |
| 281 | #if defined(BROTLI_MAX_SIMD_QUALITYcxx . . $ `c/common/platform.h:655:9`!) |
| 282 | #define HASHERcxx . . $ `c/enc/hash.h:282:9`!() H58 |
| 283 | #include "hash_longest_match_simd_inc.h"cxx . . $ `<file>/c/enc/hash_longest_match_simd_inc.h`/ /* NOLINT(build/include) */ |
| 284 | #undef HASHERcxx . . $ `c/enc/hash.h:282:9`! |
| 285 | |
| 286 | #define HASHERcxx . . $ `c/enc/hash.h:286:9`!() H68 |
| 287 | #include "hash_longest_match64_simd_inc.h"cxx . . $ `<file>/c/enc/hash_longest_match64_simd_inc.h`/ /* NOLINT(build/include) */ |
| 288 | #undef HASHERcxx . . $ `c/enc/hash.h:286:9`! |
| 289 | #endif |
| 290 | |
| 291 | #define BUCKET_BITScxx . . $ `c/enc/hash.h:291:9`! 15 |
| 292 | |
| 293 | #define NUM_LAST_DISTANCES_TO_CHECKcxx . . $ `c/enc/hash.h:293:9`! 4 |
| 294 | #define NUM_BANKScxx . . $ `c/enc/hash.h:294:9`! 1 |
| 295 | #define BANK_BITScxx . . $ `c/enc/hash.h:295:9`! 16 |
| 296 | #define HASHERcxx . . $ `c/enc/hash.h:296:9`!() H40 |
| 297 | #include "hash_forgetful_chain_inc.h"cxx . . $ `<file>/c/enc/hash_forgetful_chain_inc.h`/ /* NOLINT(build/include) */ |
| 298 | #undef HASHERcxx . . $ `c/enc/hash.h:296:9`! |
| 299 | #undef NUM_LAST_DISTANCES_TO_CHECKcxx . . $ `c/enc/hash.h:293:9`! |
| 300 | |
| 301 | #define NUM_LAST_DISTANCES_TO_CHECKcxx . . $ `c/enc/hash.h:301:9`! 10 |
| 302 | #define HASHERcxx . . $ `c/enc/hash.h:302:9`!() H41 |
| 303 | #include "hash_forgetful_chain_inc.h"cxx . . $ `<file>/c/enc/hash_forgetful_chain_inc.h`/ /* NOLINT(build/include) */ |
| 304 | #undef HASHERcxx . . $ `c/enc/hash.h:302:9`! |
| 305 | #undef NUM_LAST_DISTANCES_TO_CHECKcxx . . $ `c/enc/hash.h:301:9`! |
| 306 | #undef NUM_BANKScxx . . $ `c/enc/hash.h:294:9`! |
| 307 | #undef BANK_BITScxx . . $ `c/enc/hash.h:295:9`! |
| 308 | |
| 309 | #define NUM_LAST_DISTANCES_TO_CHECKcxx . . $ `c/enc/hash.h:309:9`! 16 |
| 310 | #define NUM_BANKScxx . . $ `c/enc/hash.h:310:9`! 512 |
| 311 | #define BANK_BITScxx . . $ `c/enc/hash.h:311:9`! 9 |
| 312 | #define HASHERcxx . . $ `c/enc/hash.h:312:9`!() H42 |
| 313 | #include "hash_forgetful_chain_inc.h"cxx . . $ `<file>/c/enc/hash_forgetful_chain_inc.h`/ /* NOLINT(build/include) */ |
| 314 | #undef HASHERcxx . . $ `c/enc/hash.h:312:9`! |
| 315 | #undef NUM_LAST_DISTANCES_TO_CHECKcxx . . $ `c/enc/hash.h:309:9`! |
| 316 | #undef NUM_BANKScxx . . $ `c/enc/hash.h:310:9`! |
| 317 | #undef BANK_BITScxx . . $ `c/enc/hash.h:311:9`! |
| 318 | |
| 319 | #undef BUCKET_BITScxx . . $ `c/enc/hash.h:291:9`! |
| 320 | |
| 321 | #define HASHERcxx . . $ `c/enc/hash.h:321:9`!() H54 |
| 322 | #define BUCKET_BITScxx . . $ `c/enc/hash.h:322:9`! 20 |
| 323 | #define BUCKET_SWEEP_BITScxx . . $ `c/enc/hash.h:323:9`! 2 |
| 324 | #define HASH_LENcxx . . $ `c/enc/hash.h:324:9`! 7 |
| 325 | #define USE_DICTIONARYcxx . . $ `c/enc/hash.h:325:9`! 0 |
| 326 | #include "hash_longest_match_quickly_inc.h"cxx . . $ `<file>/c/enc/hash_longest_match_quickly_inc.h`/ /* NOLINT(build/include) */ |
| 327 | #undef USE_DICTIONARYcxx . . $ `c/enc/hash.h:325:9`! |
| 328 | #undef HASH_LENcxx . . $ `c/enc/hash.h:324:9`! |
| 329 | #undef BUCKET_SWEEP_BITScxx . . $ `c/enc/hash.h:323:9`! |
| 330 | #undef BUCKET_BITScxx . . $ `c/enc/hash.h:322:9`! |
| 331 | #undef HASHERcxx . . $ `c/enc/hash.h:321:9`! |
| 332 | |
| 333 | /* fast large window hashers */ |
| 334 | |
| 335 | #define HASHERcxx . . $ `c/enc/hash.h:335:9`!() HROLLING_FAST |
| 336 | #define CHUNKLENcxx . . $ `c/enc/hash.h:336:9`! 32 |
| 337 | #define JUMPcxx . . $ `c/enc/hash.h:337:9`! 4 |
| 338 | #define NUMBUCKETScxx . . $ `c/enc/hash.h:338:9`! 16777216 |
| 339 | #define MASKcxx . . $ `c/enc/hash.h:339:9`! ((NUMBUCKETScxx . . $ `c/enc/hash.h:338:9`! * 64) - 1) |
| 340 | #include "hash_rolling_inc.h"cxx . . $ `<file>/c/enc/hash_rolling_inc.h`/ /* NOLINT(build/include) */ |
| 341 | #undef JUMPcxx . . $ `c/enc/hash.h:337:9`! |
| 342 | #undef HASHERcxx . . $ `c/enc/hash.h:335:9`! |
| 343 | |
| 344 | |
| 345 | #define HASHERcxx . . $ `c/enc/hash.h:345:9`!() HROLLING |
| 346 | #define JUMPcxx . . $ `c/enc/hash.h:346:9`! 1 |
| 347 | #include "hash_rolling_inc.h"cxx . . $ `<file>/c/enc/hash_rolling_inc.h`/ /* NOLINT(build/include) */ |
| 348 | #undef MASKcxx . . $ `c/enc/hash.h:339:9`! |
| 349 | #undef NUMBUCKETScxx . . $ `c/enc/hash.h:338:9`! |
| 350 | #undef JUMPcxx . . $ `c/enc/hash.h:346:9`! |
| 351 | #undef CHUNKLENcxx . . $ `c/enc/hash.h:336:9`! |
| 352 | #undef HASHERcxx . . $ `c/enc/hash.h:345:9`! |
| 353 | |
| 354 | #define HASHERcxx . . $ `c/enc/hash.h:354:9`!() H35 |
| 355 | #define HASHER_Acxx . . $ `c/enc/hash.h:355:9`! H3 |
| 356 | #define HASHER_Bcxx . . $ `c/enc/hash.h:356:9`! HROLLING_FAST |
| 357 | #include "hash_composite_inc.h"cxx . . $ `<file>/c/enc/hash_composite_inc.h`/ /* NOLINT(build/include) */ |
| 358 | #undef HASHER_Acxx . . $ `c/enc/hash.h:355:9`! |
| 359 | #undef HASHER_Bcxx . . $ `c/enc/hash.h:356:9`! |
| 360 | #undef HASHERcxx . . $ `c/enc/hash.h:354:9`! |
| 361 | |
| 362 | #define HASHERcxx . . $ `c/enc/hash.h:362:9`!() H55 |
| 363 | #define HASHER_Acxx . . $ `c/enc/hash.h:363:9`! H54 |
| 364 | #define HASHER_Bcxx . . $ `c/enc/hash.h:364:9`! HROLLING_FAST |
| 365 | #include "hash_composite_inc.h"cxx . . $ `<file>/c/enc/hash_composite_inc.h`/ /* NOLINT(build/include) */ |
| 366 | #undef HASHER_Acxx . . $ `c/enc/hash.h:363:9`! |
| 367 | #undef HASHER_Bcxx . . $ `c/enc/hash.h:364:9`! |
| 368 | #undef HASHERcxx . . $ `c/enc/hash.h:362:9`! |
| 369 | |
| 370 | #define HASHERcxx . . $ `c/enc/hash.h:370:9`!() H65 |
| 371 | #define HASHER_Acxx . . $ `c/enc/hash.h:371:9`! H6 |
| 372 | #define HASHER_Bcxx . . $ `c/enc/hash.h:372:9`! HROLLING |
| 373 | #include "hash_composite_inc.h"cxx . . $ `<file>/c/enc/hash_composite_inc.h`/ /* NOLINT(build/include) */ |
| 374 | #undef HASHER_Acxx . . $ `c/enc/hash.h:371:9`! |
| 375 | #undef HASHER_Bcxx . . $ `c/enc/hash.h:372:9`! |
| 376 | #undef HASHERcxx . . $ `c/enc/hash.h:370:9`! |
| 377 | |
| 378 | #undef FNcxx . . $ `c/enc/hash.h:225:9`! |
| 379 | #undef CATcxx . . $ `c/enc/hash.h:224:9`! |
| 380 | #undef EXPAND_CATcxx . . $ `c/enc/hash.h:223:9`! |
| 381 | |
| 382 | #if defined(BROTLI_MAX_SIMD_QUALITYcxx . . $ `c/common/platform.h:655:9`!) |
| 383 | #define FOR_SIMPLE_HASHERScxx . . $ `c/enc/hash.h:383:9`!(H) \ |
| 384 | H(2) H(3) H(4) H(5) H(6) H(40) H(41) H(42) H(54) H(58) H(68) |
| 385 | #else |
| 386 | #define FOR_SIMPLE_HASHERS(H) \ |
| 387 | H(2) H(3) H(4) H(5) H(6) H(40) H(41) H(42) H(54) |
| 388 | #endif |
| 389 | #define FOR_COMPOSITE_HASHERScxx . . $ `c/enc/hash.h:389:9`!(H) H(35) H(55) H(65) |
| 390 | #define FOR_GENERIC_HASHERScxx . . $ `c/enc/hash.h:390:9`!(H) FOR_SIMPLE_HASHERScxx . . $ `c/enc/hash.h:383:9`!(H) FOR_COMPOSITE_HASHERScxx . . $ `c/enc/hash.h:389:9`!(H) |
| 391 | #define FOR_ALL_HASHERScxx . . $ `c/enc/hash.h:391:9`!(H) FOR_GENERIC_HASHERScxx . . $ `c/enc/hash.h:390:9`!(H) H(10) |
| 392 | |
| 393 | typedef structcxx . . $ $anonymous_type_5b62deaf4afff4b7_1# { |
| 394 | HasherCommoncxx . . $ HasherCommon# commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common.; |
| 395 | |
| 396 | unioncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#$anonymous_type_2# { |
| 397 | #define MEMBER_cxx . . $ `c/enc/hash.h:397:9`!(N) \ |
| 398 | H ## N _H ## N; |
| 399 | FOR_ALL_HASHERScxx . . $ H6#(MEMBER_cxx . . $ `c/enc/hash.h:397:9`!) |
| 400 | #undef MEMBER_cxx . . $ `c/enc/hash.h:397:9`! |
| 401 | } privatcxx . . $ $anonymous_type_5b62deaf4afff4b7_1#privat.; |
| 402 | } Hashercxx . . $ Hasher#; |
| 403 | |
| 404 | /* MUST be invoked before any other method. */ |
| 405 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void HasherInitcxx . . $ HasherInit(f33823e5f94626bf).(Hashercxx . . $ Hasher#* hasher) { |
| 406 | hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..is_setup_cxx . . $ $anonymous_type_5b62deaf4afff4b7_0#is_setup_. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 407 | hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..extracxx . . $ $anonymous_type_5b62deaf4afff4b7_0#extra.[0] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 408 | hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..extracxx . . $ $anonymous_type_5b62deaf4afff4b7_0#extra.[1] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 409 | hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..extracxx . . $ $anonymous_type_5b62deaf4afff4b7_0#extra.[2] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 410 | hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..extracxx . . $ $anonymous_type_5b62deaf4afff4b7_0#extra.[3] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 411 | } |
| 412 | |
| 413 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void DestroyHashercxx . . $ DestroyHasher(c6b728d602971887).(MemoryManagercxx . . $ MemoryManager#* m, Hashercxx . . $ Hasher#* hasher) { |
| 414 | if (hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..extracxx . . $ $anonymous_type_5b62deaf4afff4b7_0#extra.[0] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) BROTLI_FREEcxx . . $ $anonymous_type_5b62deaf4afff4b7_0#extra.(m, hasher->common.extra[0]); |
| 415 | if (hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..extracxx . . $ $anonymous_type_5b62deaf4afff4b7_0#extra.[1] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) BROTLI_FREEcxx . . $ `c/enc/memory.h:55:9`!(m, hasher->common.extra[1]); |
| 416 | if (hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..extracxx . . $ $anonymous_type_5b62deaf4afff4b7_0#extra.[2] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) BROTLI_FREEcxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common.(m, hasher->common.extra[2]); |
| 417 | if (hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..extracxx . . $ $anonymous_type_5b62deaf4afff4b7_0#extra.[3] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) BROTLI_FREEcxx . . $ $anonymous_type_5b62deaf4afff4b7_0#extra.(m, hasher->common.extra[3]); |
| 418 | } |
| 419 | |
| 420 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void HasherResetcxx . . $ HasherReset(f33823e5f94626bf).(Hashercxx . . $ Hasher#* hasher) { |
| 421 | hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..is_prepared_cxx . . $ $anonymous_type_5b62deaf4afff4b7_0#is_prepared_. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 422 | } |
| 423 | |
| 424 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void HasherSizecxx . . $ HasherSize(a2873f45a8b21dd9).(const BrotliEncoderParamscxx . . $ BrotliEncoderParams#* params, |
| 425 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! one_shot, const size_tcxx . . $ size_t# input_size, size_tcxx . . $ size_t#* alloc_size) { |
| 426 | switch (params->hashercxx . . $ BrotliEncoderParams#hasher..typecxx . . $ BrotliHasherParams#type.) { |
| 427 | #define SIZE_cxx . . $ `c/enc/hash.h:427:9`!(N) \ |
| 428 | case N: \ |
| 429 | HashMemAllocInBytesH ## N(params, one_shot, input_size, alloc_size); \ |
| 430 | break; |
| 431 | FOR_ALL_HASHERScxx . . $ HashMemAllocInBytesH35(a2873f45a8b21dd9).(SIZE_cxx . . $ `c/enc/hash.h:427:9`!) |
| 432 | #undef SIZE_cxx . . $ `c/enc/hash.h:427:9`! |
| 433 | default: |
| 434 | break; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void HasherSetupcxx . . $ HasherSetup(810c3a2ca5790bc3).(MemoryManagercxx . . $ MemoryManager#* m, Hashercxx . . $ Hasher#* hasher, |
| 439 | BrotliEncoderParamscxx . . $ BrotliEncoderParams#* params, const uint8_tcxx . . $ uint8_t#* data, size_tcxx . . $ size_t# position, |
| 440 | size_tcxx . . $ size_t# input_size, BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_last) { |
| 441 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! one_shot = (position == 0 && is_last); |
| 442 | if (!hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..is_setup_cxx . . $ $anonymous_type_5b62deaf4afff4b7_0#is_setup_.) { |
| 443 | size_tcxx . . $ size_t# alloc_size[4] = {0}; |
| 444 | size_tcxx . . $ size_t# i; |
| 445 | ChooseHashercxx . . $ ChooseHasher(59aa9b7ae637a74c).(params, ¶ms->hashercxx . . $ BrotliEncoderParams#hasher.); |
| 446 | hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..paramscxx . . $ $anonymous_type_5b62deaf4afff4b7_0#params. = params->hashercxx . . $ BrotliEncoderParams#hasher.; |
| 447 | hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..dict_num_lookupscxx . . $ $anonymous_type_5b62deaf4afff4b7_0#dict_num_lookups. = 0; |
| 448 | hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..dict_num_matchescxx . . $ $anonymous_type_5b62deaf4afff4b7_0#dict_num_matches. = 0; |
| 449 | HasherSizecxx . . $ HasherSize(a2873f45a8b21dd9).(params, one_shot, input_size, alloc_size); |
| 450 | for (i = 0; i < 4; ++i) { |
| 451 | if (alloc_size[i] == 0) continue; |
| 452 | hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..extracxx . . $ $anonymous_type_5b62deaf4afff4b7_0#extra.[i] = BROTLI_ALLOCcxx . . $ `c/enc/memory.h:51:9`!(m, uint8_t, alloc_size[i]); |
| 453 | if (BROTLI_IS_OOMcxx . . $ `c/enc/memory.h:61:9`!(m) || BROTLI_IS_NULLcxx . . $ `c/enc/memory.h:75:9`!(hasher->common.extra[i])) return; |
| 454 | } |
| 455 | switch (hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..paramscxx . . $ $anonymous_type_5b62deaf4afff4b7_0#params..typecxx . . $ BrotliHasherParams#type.) { |
| 456 | #define INITIALIZE_cxx . . $ `c/enc/hash.h:456:9`!(N) \ |
| 457 | case N: \ |
| 458 | InitializeH ## N(&hasher->common, \ |
| 459 | &hasher->privat._H ## N, params); \ |
| 460 | break; |
| 461 | FOR_ALL_HASHERScxx . . $ InitializeH3(895d38534d6189ae).(INITIALIZE_cxx . . $ `c/enc/hash.h:456:9`!); |
| 462 | #undef INITIALIZE_cxx . . $ `c/enc/hash.h:456:9`! |
| 463 | default: |
| 464 | break; |
| 465 | } |
| 466 | HasherResetcxx . . $ HasherReset(f33823e5f94626bf).(hasher); |
| 467 | hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..is_setup_cxx . . $ $anonymous_type_5b62deaf4afff4b7_0#is_setup_. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 468 | } |
| 469 | |
| 470 | if (!hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..is_prepared_cxx . . $ $anonymous_type_5b62deaf4afff4b7_0#is_prepared_.) { |
| 471 | switch (hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..paramscxx . . $ $anonymous_type_5b62deaf4afff4b7_0#params..typecxx . . $ BrotliHasherParams#type.) { |
| 472 | #define PREPARE_cxx . . $ `c/enc/hash.h:472:9`!(N) \ |
| 473 | case N: \ |
| 474 | PrepareH ## N( \ |
| 475 | &hasher->privat._H ## N, \ |
| 476 | one_shot, input_size, data); \ |
| 477 | break; |
| 478 | FOR_ALL_HASHERScxx . . $ $anonymous_type_5b62deaf4afff4b7_1#$anonymous_type_2#_H40.(PREPARE_cxx . . $ `c/enc/hash.h:472:9`!) |
| 479 | #undef PREPARE_cxx . . $ `c/enc/hash.h:472:9`! |
| 480 | default: break; |
| 481 | } |
| 482 | hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..is_prepared_cxx . . $ $anonymous_type_5b62deaf4afff4b7_0#is_prepared_. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void InitOrStitchToPreviousBlockcxx . . $ InitOrStitchToPreviousBlock(11f2d960faad0df8).( |
| 487 | MemoryManagercxx . . $ MemoryManager#* m, Hashercxx . . $ Hasher#* hasher, const uint8_tcxx . . $ uint8_t#* data, size_tcxx . . $ size_t# mask, |
| 488 | BrotliEncoderParamscxx . . $ BrotliEncoderParams#* params, size_tcxx . . $ size_t# position, size_tcxx . . $ size_t# input_size, |
| 489 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_last) { |
| 490 | HasherSetupcxx . . $ HasherSetup(810c3a2ca5790bc3).(m, hasher, params, data, position, input_size, is_last); |
| 491 | if (BROTLI_IS_OOMcxx . . $ `c/enc/memory.h:61:9`!(m)) return; |
| 492 | switch (hasher->commoncxx . . $ $anonymous_type_5b62deaf4afff4b7_1#common..paramscxx . . $ $anonymous_type_5b62deaf4afff4b7_0#params..typecxx . . $ BrotliHasherParams#type.) { |
| 493 | #define INIT_cxx . . $ `c/enc/hash.h:493:9`!(N) \ |
| 494 | case N: \ |
| 495 | StitchToPreviousBlockH ## N( \ |
| 496 | &hasher->privat._H ## N, \ |
| 497 | input_size, position, data, mask); \ |
| 498 | break; |
| 499 | FOR_ALL_HASHERScxx . . $ $anonymous_type_5b62deaf4afff4b7_1#$anonymous_type_2#_H40.(INIT_cxx . . $ `c/enc/hash.h:493:9`!) |
| 500 | #undef INIT_cxx . . $ `c/enc/hash.h:493:9`! |
| 501 | default: break; |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | /* NB: when seamless dictionary-ring-buffer copies are implemented, don't forget |
| 506 | to add proper guards for non-zero-BROTLI_PARAM_STREAM_OFFSET. */ |
| 507 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void FindCompoundDictionaryMatchcxx . . $ FindCompoundDictionaryMatch(a8703a6734dcb998).( |
| 508 | const PreparedDictionarycxx . . $ PreparedDictionary#* self, const uint8_tcxx . . $ uint8_t#* BROTLI_RESTRICTcxx . . $ `c/common/platform.h:82:9`! data, |
| 509 | const size_tcxx . . $ size_t# ring_buffer_mask, const int* BROTLI_RESTRICTcxx . . $ `c/common/platform.h:82:9`! distance_cache, |
| 510 | const size_tcxx . . $ size_t# cur_ix, const size_tcxx . . $ size_t# max_length, const size_tcxx . . $ size_t# distance_offset, |
| 511 | const size_tcxx . . $ size_t# max_distance, HasherSearchResultcxx . . $ HasherSearchResult#* BROTLI_RESTRICTcxx . . $ `c/common/platform.h:82:9`! out) { |
| 512 | const uint32_tcxx . . $ uint32_t# source_size = self->source_sizecxx . . $ PreparedDictionary#source_size.; |
| 513 | const size_tcxx . . $ size_t# boundary = distance_offset - source_size; |
| 514 | const uint32_tcxx . . $ uint32_t# hash_bits = self->hash_bitscxx . . $ PreparedDictionary#hash_bits.; |
| 515 | const uint32_tcxx . . $ uint32_t# bucket_bits = self->bucket_bitscxx . . $ PreparedDictionary#bucket_bits.; |
| 516 | const uint32_tcxx . . $ uint32_t# slot_bits = self->slot_bitscxx . . $ PreparedDictionary#slot_bits.; |
| 517 | |
| 518 | const uint32_tcxx . . $ uint32_t# hash_shift = 64u - bucket_bits; |
| 519 | const uint32_tcxx . . $ uint32_t# slot_mask = (~((uint32_tcxx . . $ uint32_t#)0U)) >> (32 - slot_bits); |
| 520 | const uint64_tcxx . . $ uint64_t# hash_mask = (~((uint64_tcxx . . $ uint64_t#)0U)) >> (64 - hash_bits); |
| 521 | |
| 522 | const uint32_tcxx . . $ uint32_t#* slot_offsets = (uint32_tcxx . . $ uint32_t#*)(&self[1]); |
| 523 | const uint16_tcxx . . $ uint16_t#* heads = (uint16_tcxx . . $ uint16_t#*)(&slot_offsets[(size_tcxx . . $ size_t#)1u << slot_bits]); |
| 524 | const uint32_tcxx . . $ uint32_t#* items = (uint32_tcxx . . $ uint32_t#*)(&heads[(size_tcxx . . $ size_t#)1u << bucket_bits]); |
| 525 | const uint8_tcxx . . $ uint8_t#* source = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 526 | |
| 527 | const size_tcxx . . $ size_t# cur_ix_masked = cur_ix & ring_buffer_mask; |
| 528 | score_tcxx . . $ size_t# best_score = out->scorecxx . . $ HasherSearchResult#score.; |
| 529 | size_tcxx . . $ size_t# best_len = out->lencxx . . $ HasherSearchResult#len.; |
| 530 | size_tcxx . . $ size_t# i; |
| 531 | const uint64_tcxx . . $ uint64_t# h = |
| 532 | (BROTLI_UNALIGNED_LOAD64LEcxx . . $ BrotliUnalignedRead64(2e8e543e1193434e).(&data[cur_ix_masked]) & hash_mask) * |
| 533 | kPreparedDictionaryHashMul64Longcxx . . $ kPreparedDictionaryHashMul64Long.; |
| 534 | const uint32_tcxx . . $ uint32_t# key = (uint32_tcxx . . $ uint32_t#)(h >> hash_shift); |
| 535 | const uint32_tcxx . . $ uint32_t# slot = key & slot_mask; |
| 536 | const uint32_tcxx . . $ uint32_t# head = heads[key]; |
| 537 | const uint32_tcxx . . $ uint32_t#* BROTLI_RESTRICTcxx . . $ `c/common/platform.h:82:9`! chain = &items[slot_offsets[slot] + head]; |
| 538 | uint32_tcxx . . $ uint32_t# item = (head == 0xFFFF) ? 1 : 0; |
| 539 | |
| 540 | const void* tail = (void*)&items[self->num_itemscxx . . $ PreparedDictionary#num_items.]; |
| 541 | if (self->magiccxx . . $ PreparedDictionary#magic. == kPreparedDictionaryMagiccxx . . $ kPreparedDictionaryMagic.) { |
| 542 | source = (const uint8_tcxx . . $ uint8_t#*)tail; |
| 543 | } else { |
| 544 | /* kLeanPreparedDictionaryMagic */ |
| 545 | source = (const uint8_tcxx . . $ uint8_t#*)BROTLI_UNALIGNED_LOAD_PTRcxx . . $ BROTLI_UNALIGNED_LOAD_PTR(3343d82129b43479).((const uint8_tcxx . . $ uint8_t#**)tail); |
| 546 | } |
| 547 | |
| 548 | BROTLI_DCHECKcxx . . $ `c/common/platform.h:473:9`!(cur_ix_masked + max_length <= ring_buffer_mask); |
| 549 | |
| 550 | for (i = 0; i < 4; ++i) { |
| 551 | const size_tcxx . . $ size_t# distance = (size_tcxx . . $ size_t#)distance_cache[i]; |
| 552 | size_tcxx . . $ size_t# offset; |
| 553 | size_tcxx . . $ size_t# limit; |
| 554 | size_tcxx . . $ size_t# len; |
| 555 | if (distance <= boundary || distance > distance_offset) continue; |
| 556 | offset = distance_offset - distance; |
| 557 | limit = source_size - offset; |
| 558 | limit = limit > max_length ? max_length : limit; |
| 559 | len = FindMatchLengthWithLimitcxx . . $ FindMatchLengthWithLimit(c2ccccc71581acc8).(&source[offset], &data[cur_ix_masked], |
| 560 | limit); |
| 561 | if (len >= 2) { |
| 562 | score_tcxx . . $ `c/enc/hash.h:57:9`! score = BackwardReferenceScoreUsingLastDistancecxx . . $ BackwardReferenceScoreUsingLastDistance(ecdaa1632f49f591).(len); |
| 563 | if (best_score < score) { |
| 564 | if (i != 0) score -= BackwardReferencePenaltyUsingLastDistancecxx . . $ BackwardReferencePenaltyUsingLastDistance(ecdaa1632f49f591).(i); |
| 565 | if (best_score < score) { |
| 566 | best_score = score; |
| 567 | if (len > best_len) best_len = len; |
| 568 | out->lencxx . . $ HasherSearchResult#len. = len; |
| 569 | out->len_code_deltacxx . . $ HasherSearchResult#len_code_delta. = 0; |
| 570 | out->distancecxx . . $ HasherSearchResult#distance. = distance; |
| 571 | out->scorecxx . . $ HasherSearchResult#score. = best_score; |
| 572 | } |
| 573 | } |
| 574 | } |
| 575 | } |
| 576 | /* we require matches of len >4, so increase best_len to 3, so we can compare |
| 577 | * 4 bytes all the time. */ |
| 578 | if (best_len < 3) { |
| 579 | best_len = 3; |
| 580 | } |
| 581 | while (item == 0) { |
| 582 | size_tcxx . . $ size_t# offset; |
| 583 | size_tcxx . . $ size_t# distance; |
| 584 | size_tcxx . . $ size_t# limit; |
| 585 | item = *chain; |
| 586 | chain++; |
| 587 | offset = item & 0x7FFFFFFF; |
| 588 | item &= 0x80000000; |
| 589 | distance = distance_offset - offset; |
| 590 | limit = source_size - offset; |
| 591 | limit = (limit > max_length) ? max_length : limit; |
| 592 | if (distance > max_distance) continue; |
| 593 | if (cur_ix_masked + best_len > ring_buffer_mask || best_len >= limit || |
| 594 | /* compare 4 bytes ending at best_len + 1 */ |
| 595 | BrotliUnalignedRead32cxx . . $ BrotliUnalignedRead32(b11f534102b1ad6).(&data[cur_ix_masked + best_len - 3]) != |
| 596 | BrotliUnalignedRead32cxx . . $ BrotliUnalignedRead32(b11f534102b1ad6).(&source[offset + best_len - 3])) { |
| 597 | continue; |
| 598 | } |
| 599 | { |
| 600 | const size_tcxx . . $ size_t# len = FindMatchLengthWithLimitcxx . . $ FindMatchLengthWithLimit(c2ccccc71581acc8).(&source[offset], |
| 601 | &data[cur_ix_masked], |
| 602 | limit); |
| 603 | if (len >= 4) { |
| 604 | score_tcxx . . $ `c/enc/hash.h:57:9`! score = BackwardReferenceScorecxx . . $ BackwardReferenceScore(80bad76eed2d2579).(len, distance); |
| 605 | if (best_score < score) { |
| 606 | best_score = score; |
| 607 | best_len = len; |
| 608 | out->lencxx . . $ HasherSearchResult#len. = best_len; |
| 609 | out->len_code_deltacxx . . $ HasherSearchResult#len_code_delta. = 0; |
| 610 | out->distancecxx . . $ HasherSearchResult#distance. = distance; |
| 611 | out->scorecxx . . $ HasherSearchResult#score. = best_score; |
| 612 | } |
| 613 | } |
| 614 | } |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | /* NB: when seamless dictionary-ring-buffer copies are implemented, don't forget |
| 619 | to add proper guards for non-zero-BROTLI_PARAM_STREAM_OFFSET. */ |
| 620 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! size_tcxx . . $ size_t# FindAllCompoundDictionaryMatchescxx . . $ FindAllCompoundDictionaryMatches(f4b851ef51268af).( |
| 621 | const PreparedDictionarycxx . . $ PreparedDictionary#* self, const uint8_tcxx . . $ uint8_t#* BROTLI_RESTRICTcxx . . $ `c/common/platform.h:82:9`! data, |
| 622 | const size_tcxx . . $ size_t# ring_buffer_mask, const size_tcxx . . $ size_t# cur_ix, const size_tcxx . . $ size_t# min_length, |
| 623 | const size_tcxx . . $ size_t# max_length, const size_tcxx . . $ size_t# distance_offset, |
| 624 | const size_tcxx . . $ size_t# max_distance, BackwardMatchcxx . . $ BackwardMatch#* matches, size_tcxx . . $ size_t# match_limit) { |
| 625 | const uint32_tcxx . . $ uint32_t# source_size = self->source_sizecxx . . $ PreparedDictionary#source_size.; |
| 626 | const uint32_tcxx . . $ uint32_t# hash_bits = self->hash_bitscxx . . $ PreparedDictionary#hash_bits.; |
| 627 | const uint32_tcxx . . $ uint32_t# bucket_bits = self->bucket_bitscxx . . $ PreparedDictionary#bucket_bits.; |
| 628 | const uint32_tcxx . . $ uint32_t# slot_bits = self->slot_bitscxx . . $ PreparedDictionary#slot_bits.; |
| 629 | |
| 630 | const uint32_tcxx . . $ uint32_t# hash_shift = 64u - bucket_bits; |
| 631 | const uint32_tcxx . . $ uint32_t# slot_mask = (~((uint32_tcxx . . $ uint32_t#)0U)) >> (32 - slot_bits); |
| 632 | const uint64_tcxx . . $ uint64_t# hash_mask = (~((uint64_tcxx . . $ uint64_t#)0U)) >> (64 - hash_bits); |
| 633 | |
| 634 | const uint32_tcxx . . $ uint32_t#* slot_offsets = (uint32_tcxx . . $ uint32_t#*)(&self[1]); |
| 635 | const uint16_tcxx . . $ uint16_t#* heads = (uint16_tcxx . . $ uint16_t#*)(&slot_offsets[(size_tcxx . . $ size_t#)1u << slot_bits]); |
| 636 | const uint32_tcxx . . $ uint32_t#* items = (uint32_tcxx . . $ uint32_t#*)(&heads[(size_tcxx . . $ size_t#)1u << bucket_bits]); |
| 637 | const uint8_tcxx . . $ uint8_t#* source = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 638 | |
| 639 | const size_tcxx . . $ size_t# cur_ix_masked = cur_ix & ring_buffer_mask; |
| 640 | size_tcxx . . $ size_t# best_len = min_length; |
| 641 | const uint64_tcxx . . $ uint64_t# h = |
| 642 | (BROTLI_UNALIGNED_LOAD64LEcxx . . $ `c/common/platform.h:380:9`!(&data[cur_ix_masked]) & hash_mask) * |
| 643 | kPreparedDictionaryHashMul64Longcxx . . $ kPreparedDictionaryHashMul64Long.; |
| 644 | const uint32_tcxx . . $ uint32_t# key = (uint32_tcxx . . $ uint32_t#)(h >> hash_shift); |
| 645 | const uint32_tcxx . . $ uint32_t# slot = key & slot_mask; |
| 646 | const uint32_tcxx . . $ uint32_t# head = heads[key]; |
| 647 | const uint32_tcxx . . $ uint32_t#* BROTLI_RESTRICTcxx . . $ `c/common/platform.h:82:9`! chain = &items[slot_offsets[slot] + head]; |
| 648 | uint32_tcxx . . $ uint32_t# item = (head == 0xFFFF) ? 1 : 0; |
| 649 | size_tcxx . . $ size_t# found = 0; |
| 650 | |
| 651 | const void* tail = (void*)&items[self->num_itemscxx . . $ PreparedDictionary#num_items.]; |
| 652 | if (self->magiccxx . . $ PreparedDictionary#magic. == kPreparedDictionaryMagiccxx . . $ kPreparedDictionaryMagic.) { |
| 653 | source = (const uint8_tcxx . . $ uint8_t#*)tail; |
| 654 | } else { |
| 655 | /* kLeanPreparedDictionaryMagic */ |
| 656 | source = (const uint8_tcxx . . $ uint8_t#*)BROTLI_UNALIGNED_LOAD_PTRcxx . . $ BROTLI_UNALIGNED_LOAD_PTR(3343d82129b43479).((const uint8_tcxx . . $ uint8_t#**)tail); |
| 657 | } |
| 658 | |
| 659 | BROTLI_DCHECKcxx . . $ `c/common/platform.h:473:9`!(cur_ix_masked + max_length <= ring_buffer_mask); |
| 660 | |
| 661 | while (item == 0) { |
| 662 | size_tcxx . . $ size_t# offset; |
| 663 | size_tcxx . . $ size_t# distance; |
| 664 | size_tcxx . . $ size_t# limit; |
| 665 | size_tcxx . . $ size_t# len; |
| 666 | item = *chain; |
| 667 | chain++; |
| 668 | offset = item & 0x7FFFFFFF; |
| 669 | item &= 0x80000000; |
| 670 | distance = distance_offset - offset; |
| 671 | limit = source_size - offset; |
| 672 | limit = (limit > max_length) ? max_length : limit; |
| 673 | if (distance > max_distance) continue; |
| 674 | if (cur_ix_masked + best_len > ring_buffer_mask || |
| 675 | best_len >= limit || |
| 676 | data[cur_ix_masked + best_len] != source[offset + best_len]) { |
| 677 | continue; |
| 678 | } |
| 679 | len = FindMatchLengthWithLimitcxx . . $ FindMatchLengthWithLimit(c2ccccc71581acc8).( |
| 680 | &source[offset], &data[cur_ix_masked], limit); |
| 681 | if (len > best_len) { |
| 682 | best_len = len; |
| 683 | InitBackwardMatchcxx . . $ InitBackwardMatch(1ab56fcc6d89d1f4).(matches++, distance, len); |
| 684 | found++; |
| 685 | if (found == match_limit) break; |
| 686 | } |
| 687 | } |
| 688 | return found; |
| 689 | } |
| 690 | |
| 691 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void LookupCompoundDictionaryMatchcxx . . $ LookupCompoundDictionaryMatch(25f3201799bfafec).( |
| 692 | const CompoundDictionarycxx . . $ CompoundDictionary#* addon, const uint8_tcxx . . $ uint8_t#* BROTLI_RESTRICTcxx . . $ `c/common/platform.h:82:9`! data, |
| 693 | const size_tcxx . . $ size_t# ring_buffer_mask, const int* BROTLI_RESTRICTcxx . . $ `c/common/platform.h:82:9`! distance_cache, |
| 694 | const size_tcxx . . $ size_t# cur_ix, const size_tcxx . . $ size_t# max_length, |
| 695 | const size_tcxx . . $ size_t# max_ring_buffer_distance, const size_tcxx . . $ size_t# max_distance, |
| 696 | HasherSearchResultcxx . . $ HasherSearchResult#* sr) { |
| 697 | size_tcxx . . $ size_t# base_offset = max_ring_buffer_distance + 1 + addon->total_sizecxx . . $ CompoundDictionary#total_size. - 1; |
| 698 | size_tcxx . . $ size_t# d; |
| 699 | for (d = 0; d < addon->num_chunkscxx . . $ CompoundDictionary#num_chunks.; ++d) { |
| 700 | /* Only one prepared dictionary type is currently supported. */ |
| 701 | FindCompoundDictionaryMatchcxx . . $ FindCompoundDictionaryMatch(a8703a6734dcb998).( |
| 702 | (const PreparedDictionarycxx . . $ PreparedDictionary#*)addon->chunkscxx . . $ CompoundDictionary#chunks.[d], data, ring_buffer_mask, |
| 703 | distance_cache, cur_ix, max_length, |
| 704 | base_offset - addon->chunk_offsetscxx . . $ CompoundDictionary#chunk_offsets.[d], max_distance, sr); |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! size_tcxx . . $ size_t# LookupAllCompoundDictionaryMatchescxx . . $ LookupAllCompoundDictionaryMatches(3ea4f1eecfe09d33).( |
| 709 | const CompoundDictionarycxx . . $ CompoundDictionary#* addon, const uint8_tcxx . . $ uint8_t#* BROTLI_RESTRICTcxx . . $ `c/common/platform.h:82:9`! data, |
| 710 | const size_tcxx . . $ size_t# ring_buffer_mask, const size_tcxx . . $ size_t# cur_ix, size_tcxx . . $ size_t# min_length, |
| 711 | const size_tcxx . . $ size_t# max_length, const size_tcxx . . $ size_t# max_ring_buffer_distance, |
| 712 | const size_tcxx . . $ size_t# max_distance, BackwardMatchcxx . . $ BackwardMatch#* matches, |
| 713 | size_tcxx . . $ size_t# match_limit) { |
| 714 | size_tcxx . . $ size_t# base_offset = max_ring_buffer_distance + 1 + addon->total_sizecxx . . $ CompoundDictionary#total_size. - 1; |
| 715 | size_tcxx . . $ size_t# d; |
| 716 | size_tcxx . . $ size_t# total_found = 0; |
| 717 | for (d = 0; d < addon->num_chunkscxx . . $ CompoundDictionary#num_chunks.; ++d) { |
| 718 | /* Only one prepared dictionary type is currently supported. */ |
| 719 | total_found += FindAllCompoundDictionaryMatchescxx . . $ FindAllCompoundDictionaryMatches(f4b851ef51268af).( |
| 720 | (const PreparedDictionarycxx . . $ PreparedDictionary#*)addon->chunkscxx . . $ CompoundDictionary#chunks.[d], data, ring_buffer_mask, |
| 721 | cur_ix, min_length, max_length, base_offset - addon->chunk_offsetscxx . . $ CompoundDictionary#chunk_offsets.[d], |
| 722 | max_distance, matches + total_found, match_limit - total_found); |
| 723 | if (total_found == match_limit) break; |
| 724 | if (total_found > 0) { |
| 725 | min_length = BackwardMatchLengthcxx . . $ BackwardMatchLength(a1892b62ee829aa2).(&matches[total_found - 1]); |
| 726 | } |
| 727 | } |
| 728 | return total_found; |
| 729 | } |
| 730 | |
| 731 | #if defined(__cplusplus) || defined(c_plusplus) |
| 732 | } /* extern "C" */ |
| 733 | #endif |
| 734 | |
| 735 | #endif /* BROTLI_ENC_HASH_H_ */ |