/src/ghostpdl/brotli/c/enc/hash_composite_inc.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* NOLINT(build/header_guard) */ |
2 | | /* Copyright 2018 Google Inc. All Rights Reserved. |
3 | | |
4 | | Distributed under MIT license. |
5 | | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
6 | | */ |
7 | | |
8 | | /* template parameters: FN, HASHER_A, HASHER_B */ |
9 | | |
10 | | /* Composite hasher: This hasher allows to combine two other hashers, HASHER_A |
11 | | and HASHER_B. */ |
12 | | |
13 | | #define HashComposite HASHER() |
14 | | |
15 | 0 | #define FN_A(X) EXPAND_CAT(X, HASHER_A) |
16 | 0 | #define FN_B(X) EXPAND_CAT(X, HASHER_B) |
17 | | |
18 | 0 | static BROTLI_INLINE size_t FN(HashTypeLength)(void) { |
19 | 0 | size_t a = FN_A(HashTypeLength)(); |
20 | 0 | size_t b = FN_B(HashTypeLength)(); |
21 | 0 | return a > b ? a : b; |
22 | 0 | } Unexecuted instantiation: encode.c:HashTypeLengthH35 Unexecuted instantiation: encode.c:HashTypeLengthH55 Unexecuted instantiation: encode.c:HashTypeLengthH65 Unexecuted instantiation: encoder_dict.c:HashTypeLengthH35 Unexecuted instantiation: encoder_dict.c:HashTypeLengthH55 Unexecuted instantiation: encoder_dict.c:HashTypeLengthH65 Unexecuted instantiation: backward_references.c:HashTypeLengthH55 Unexecuted instantiation: backward_references.c:HashTypeLengthH65 Unexecuted instantiation: backward_references.c:HashTypeLengthH35 Unexecuted instantiation: backward_references_hq.c:HashTypeLengthH35 Unexecuted instantiation: backward_references_hq.c:HashTypeLengthH55 Unexecuted instantiation: backward_references_hq.c:HashTypeLengthH65 |
23 | | |
24 | 0 | static BROTLI_INLINE size_t FN(StoreLookahead)(void) { |
25 | 0 | size_t a = FN_A(StoreLookahead)(); |
26 | 0 | size_t b = FN_B(StoreLookahead)(); |
27 | 0 | return a > b ? a : b; |
28 | 0 | } Unexecuted instantiation: encode.c:StoreLookaheadH35 Unexecuted instantiation: encode.c:StoreLookaheadH55 Unexecuted instantiation: encode.c:StoreLookaheadH65 Unexecuted instantiation: encoder_dict.c:StoreLookaheadH35 Unexecuted instantiation: encoder_dict.c:StoreLookaheadH55 Unexecuted instantiation: encoder_dict.c:StoreLookaheadH65 Unexecuted instantiation: backward_references.c:StoreLookaheadH55 Unexecuted instantiation: backward_references.c:StoreLookaheadH65 Unexecuted instantiation: backward_references.c:StoreLookaheadH35 Unexecuted instantiation: backward_references_hq.c:StoreLookaheadH35 Unexecuted instantiation: backward_references_hq.c:StoreLookaheadH55 Unexecuted instantiation: backward_references_hq.c:StoreLookaheadH65 |
29 | | |
30 | | typedef struct HashComposite { |
31 | | HASHER_A ha; |
32 | | HASHER_B hb; |
33 | | HasherCommon ha_common; |
34 | | HasherCommon hb_common; |
35 | | |
36 | | /* Shortcuts. */ |
37 | | HasherCommon* common; |
38 | | |
39 | | BROTLI_BOOL fresh; |
40 | | const BrotliEncoderParams* params; |
41 | | } HashComposite; |
42 | | |
43 | | static void FN(Initialize)(HasherCommon* common, |
44 | 0 | HashComposite* BROTLI_RESTRICT self, const BrotliEncoderParams* params) { |
45 | 0 | self->common = common; |
46 | |
|
47 | 0 | self->ha_common = *self->common; |
48 | 0 | self->hb_common = *self->common; |
49 | 0 | self->fresh = BROTLI_TRUE; |
50 | 0 | self->params = params; |
51 | | /* TODO(lode): Initialize of the hashers is deferred to Prepare (and params |
52 | | remembered here) because we don't get the one_shot and input_size params |
53 | | here that are needed to know the memory size of them. Instead provide |
54 | | those params to all hashers FN(Initialize) */ |
55 | 0 | } Unexecuted instantiation: encode.c:InitializeH35 Unexecuted instantiation: encode.c:InitializeH55 Unexecuted instantiation: encode.c:InitializeH65 Unexecuted instantiation: encoder_dict.c:InitializeH35 Unexecuted instantiation: encoder_dict.c:InitializeH55 Unexecuted instantiation: encoder_dict.c:InitializeH65 Unexecuted instantiation: backward_references.c:InitializeH35 Unexecuted instantiation: backward_references.c:InitializeH55 Unexecuted instantiation: backward_references.c:InitializeH65 Unexecuted instantiation: backward_references_hq.c:InitializeH35 Unexecuted instantiation: backward_references_hq.c:InitializeH55 Unexecuted instantiation: backward_references_hq.c:InitializeH65 |
56 | | |
57 | | static void FN(Prepare)( |
58 | | HashComposite* BROTLI_RESTRICT self, BROTLI_BOOL one_shot, |
59 | 0 | size_t input_size, const uint8_t* BROTLI_RESTRICT data) { |
60 | 0 | if (self->fresh) { |
61 | 0 | self->fresh = BROTLI_FALSE; |
62 | 0 | self->ha_common.extra[0] = self->common->extra[0]; |
63 | 0 | self->ha_common.extra[1] = self->common->extra[1]; |
64 | 0 | self->ha_common.extra[2] = NULL; |
65 | 0 | self->ha_common.extra[3] = NULL; |
66 | 0 | self->hb_common.extra[0] = self->common->extra[2]; |
67 | 0 | self->hb_common.extra[1] = self->common->extra[3]; |
68 | 0 | self->hb_common.extra[2] = NULL; |
69 | 0 | self->hb_common.extra[3] = NULL; |
70 | |
|
71 | 0 | FN_A(Initialize)(&self->ha_common, &self->ha, self->params); |
72 | 0 | FN_B(Initialize)(&self->hb_common, &self->hb, self->params); |
73 | 0 | } |
74 | 0 | FN_A(Prepare)(&self->ha, one_shot, input_size, data); |
75 | 0 | FN_B(Prepare)(&self->hb, one_shot, input_size, data); |
76 | 0 | } Unexecuted instantiation: encode.c:PrepareH35 Unexecuted instantiation: encode.c:PrepareH55 Unexecuted instantiation: encode.c:PrepareH65 Unexecuted instantiation: encoder_dict.c:PrepareH35 Unexecuted instantiation: encoder_dict.c:PrepareH55 Unexecuted instantiation: encoder_dict.c:PrepareH65 Unexecuted instantiation: backward_references.c:PrepareH35 Unexecuted instantiation: backward_references.c:PrepareH55 Unexecuted instantiation: backward_references.c:PrepareH65 Unexecuted instantiation: backward_references_hq.c:PrepareH35 Unexecuted instantiation: backward_references_hq.c:PrepareH55 Unexecuted instantiation: backward_references_hq.c:PrepareH65 |
77 | | |
78 | | static BROTLI_INLINE void FN(HashMemAllocInBytes)( |
79 | | const BrotliEncoderParams* params, BROTLI_BOOL one_shot, |
80 | 0 | size_t input_size, size_t* alloc_size) { |
81 | 0 | size_t alloc_size_a[4] = {0}; |
82 | 0 | size_t alloc_size_b[4] = {0}; |
83 | 0 | FN_A(HashMemAllocInBytes)(params, one_shot, input_size, alloc_size_a); |
84 | 0 | FN_B(HashMemAllocInBytes)(params, one_shot, input_size, alloc_size_b); |
85 | | /* Should never happen. */ |
86 | 0 | if (alloc_size_a[2] != 0 || alloc_size_a[3] != 0) exit(EXIT_FAILURE); |
87 | 0 | if (alloc_size_b[2] != 0 || alloc_size_b[3] != 0) exit(EXIT_FAILURE); |
88 | 0 | alloc_size[0] = alloc_size_a[0]; |
89 | 0 | alloc_size[1] = alloc_size_a[1]; |
90 | 0 | alloc_size[2] = alloc_size_b[0]; |
91 | 0 | alloc_size[3] = alloc_size_b[1]; |
92 | 0 | } Unexecuted instantiation: encode.c:HashMemAllocInBytesH35 Unexecuted instantiation: encode.c:HashMemAllocInBytesH55 Unexecuted instantiation: encode.c:HashMemAllocInBytesH65 Unexecuted instantiation: encoder_dict.c:HashMemAllocInBytesH35 Unexecuted instantiation: encoder_dict.c:HashMemAllocInBytesH55 Unexecuted instantiation: encoder_dict.c:HashMemAllocInBytesH65 Unexecuted instantiation: backward_references.c:HashMemAllocInBytesH35 Unexecuted instantiation: backward_references.c:HashMemAllocInBytesH55 Unexecuted instantiation: backward_references.c:HashMemAllocInBytesH65 Unexecuted instantiation: backward_references_hq.c:HashMemAllocInBytesH35 Unexecuted instantiation: backward_references_hq.c:HashMemAllocInBytesH55 Unexecuted instantiation: backward_references_hq.c:HashMemAllocInBytesH65 |
93 | | |
94 | | static BROTLI_INLINE void FN(Store)(HashComposite* BROTLI_RESTRICT self, |
95 | 0 | const uint8_t* BROTLI_RESTRICT data, const size_t mask, const size_t ix) { |
96 | 0 | FN_A(Store)(&self->ha, data, mask, ix); |
97 | 0 | FN_B(Store)(&self->hb, data, mask, ix); |
98 | 0 | } Unexecuted instantiation: encode.c:StoreH35 Unexecuted instantiation: encode.c:StoreH55 Unexecuted instantiation: encode.c:StoreH65 Unexecuted instantiation: encoder_dict.c:StoreH35 Unexecuted instantiation: encoder_dict.c:StoreH55 Unexecuted instantiation: encoder_dict.c:StoreH65 Unexecuted instantiation: backward_references.c:StoreH55 Unexecuted instantiation: backward_references.c:StoreH65 Unexecuted instantiation: backward_references.c:StoreH35 Unexecuted instantiation: backward_references_hq.c:StoreH35 Unexecuted instantiation: backward_references_hq.c:StoreH55 Unexecuted instantiation: backward_references_hq.c:StoreH65 |
99 | | |
100 | | static BROTLI_INLINE void FN(StoreRange)( |
101 | | HashComposite* BROTLI_RESTRICT self, const uint8_t* BROTLI_RESTRICT data, |
102 | | const size_t mask, const size_t ix_start, |
103 | 0 | const size_t ix_end) { |
104 | 0 | FN_A(StoreRange)(&self->ha, data, mask, ix_start, ix_end); |
105 | 0 | FN_B(StoreRange)(&self->hb, data, mask, ix_start, ix_end); |
106 | 0 | } Unexecuted instantiation: encode.c:StoreRangeH35 Unexecuted instantiation: encode.c:StoreRangeH55 Unexecuted instantiation: encode.c:StoreRangeH65 Unexecuted instantiation: encoder_dict.c:StoreRangeH35 Unexecuted instantiation: encoder_dict.c:StoreRangeH55 Unexecuted instantiation: encoder_dict.c:StoreRangeH65 Unexecuted instantiation: backward_references.c:StoreRangeH55 Unexecuted instantiation: backward_references.c:StoreRangeH65 Unexecuted instantiation: backward_references.c:StoreRangeH35 Unexecuted instantiation: backward_references_hq.c:StoreRangeH35 Unexecuted instantiation: backward_references_hq.c:StoreRangeH55 Unexecuted instantiation: backward_references_hq.c:StoreRangeH65 |
107 | | |
108 | | static BROTLI_INLINE void FN(StitchToPreviousBlock)( |
109 | | HashComposite* BROTLI_RESTRICT self, |
110 | | size_t num_bytes, size_t position, const uint8_t* ringbuffer, |
111 | 0 | size_t ring_buffer_mask) { |
112 | 0 | FN_A(StitchToPreviousBlock)(&self->ha, num_bytes, position, |
113 | 0 | ringbuffer, ring_buffer_mask); |
114 | 0 | FN_B(StitchToPreviousBlock)(&self->hb, num_bytes, position, |
115 | 0 | ringbuffer, ring_buffer_mask); |
116 | 0 | } Unexecuted instantiation: encode.c:StitchToPreviousBlockH35 Unexecuted instantiation: encode.c:StitchToPreviousBlockH55 Unexecuted instantiation: encode.c:StitchToPreviousBlockH65 Unexecuted instantiation: encoder_dict.c:StitchToPreviousBlockH35 Unexecuted instantiation: encoder_dict.c:StitchToPreviousBlockH55 Unexecuted instantiation: encoder_dict.c:StitchToPreviousBlockH65 Unexecuted instantiation: backward_references.c:StitchToPreviousBlockH35 Unexecuted instantiation: backward_references.c:StitchToPreviousBlockH55 Unexecuted instantiation: backward_references.c:StitchToPreviousBlockH65 Unexecuted instantiation: backward_references_hq.c:StitchToPreviousBlockH35 Unexecuted instantiation: backward_references_hq.c:StitchToPreviousBlockH55 Unexecuted instantiation: backward_references_hq.c:StitchToPreviousBlockH65 |
117 | | |
118 | | static BROTLI_INLINE void FN(PrepareDistanceCache)( |
119 | 0 | HashComposite* BROTLI_RESTRICT self, int* BROTLI_RESTRICT distance_cache) { |
120 | 0 | FN_A(PrepareDistanceCache)(&self->ha, distance_cache); |
121 | 0 | FN_B(PrepareDistanceCache)(&self->hb, distance_cache); |
122 | 0 | } Unexecuted instantiation: encode.c:PrepareDistanceCacheH35 Unexecuted instantiation: encode.c:PrepareDistanceCacheH55 Unexecuted instantiation: encode.c:PrepareDistanceCacheH65 Unexecuted instantiation: encoder_dict.c:PrepareDistanceCacheH35 Unexecuted instantiation: encoder_dict.c:PrepareDistanceCacheH55 Unexecuted instantiation: encoder_dict.c:PrepareDistanceCacheH65 Unexecuted instantiation: backward_references.c:PrepareDistanceCacheH55 Unexecuted instantiation: backward_references.c:PrepareDistanceCacheH65 Unexecuted instantiation: backward_references.c:PrepareDistanceCacheH35 Unexecuted instantiation: backward_references_hq.c:PrepareDistanceCacheH35 Unexecuted instantiation: backward_references_hq.c:PrepareDistanceCacheH55 Unexecuted instantiation: backward_references_hq.c:PrepareDistanceCacheH65 |
123 | | |
124 | | static BROTLI_INLINE void FN(FindLongestMatch)( |
125 | | HashComposite* BROTLI_RESTRICT self, |
126 | | const BrotliEncoderDictionary* dictionary, |
127 | | const uint8_t* BROTLI_RESTRICT data, const size_t ring_buffer_mask, |
128 | | const int* BROTLI_RESTRICT distance_cache, const size_t cur_ix, |
129 | | const size_t max_length, const size_t max_backward, |
130 | | const size_t dictionary_distance, const size_t max_distance, |
131 | 0 | HasherSearchResult* BROTLI_RESTRICT out) { |
132 | 0 | FN_A(FindLongestMatch)(&self->ha, dictionary, data, ring_buffer_mask, |
133 | 0 | distance_cache, cur_ix, max_length, max_backward, dictionary_distance, |
134 | 0 | max_distance, out); |
135 | 0 | FN_B(FindLongestMatch)(&self->hb, dictionary, data, ring_buffer_mask, |
136 | 0 | distance_cache, cur_ix, max_length, max_backward, dictionary_distance, |
137 | 0 | max_distance, out); |
138 | 0 | } Unexecuted instantiation: encode.c:FindLongestMatchH35 Unexecuted instantiation: encode.c:FindLongestMatchH55 Unexecuted instantiation: encode.c:FindLongestMatchH65 Unexecuted instantiation: encoder_dict.c:FindLongestMatchH35 Unexecuted instantiation: encoder_dict.c:FindLongestMatchH55 Unexecuted instantiation: encoder_dict.c:FindLongestMatchH65 Unexecuted instantiation: backward_references.c:FindLongestMatchH55 Unexecuted instantiation: backward_references.c:FindLongestMatchH65 Unexecuted instantiation: backward_references.c:FindLongestMatchH35 Unexecuted instantiation: backward_references_hq.c:FindLongestMatchH35 Unexecuted instantiation: backward_references_hq.c:FindLongestMatchH55 Unexecuted instantiation: backward_references_hq.c:FindLongestMatchH65 |
139 | | |
140 | | #undef HashComposite |