/src/h2o/deps/brotli/c/enc/cluster.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright 2013 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 | | /* Functions for clustering similar histograms together. */ |
8 | | |
9 | | #include "./cluster.h" |
10 | | |
11 | | #include <brotli/types.h> |
12 | | #include "./bit_cost.h" /* BrotliPopulationCost */ |
13 | | #include "./fast_log.h" |
14 | | #include "./histogram.h" |
15 | | #include "./memory.h" |
16 | | #include "./port.h" |
17 | | |
18 | | #if defined(__cplusplus) || defined(c_plusplus) |
19 | | extern "C" { |
20 | | #endif |
21 | | |
22 | | static BROTLI_INLINE BROTLI_BOOL HistogramPairIsLess( |
23 | 0 | const HistogramPair* p1, const HistogramPair* p2) { |
24 | 0 | if (p1->cost_diff != p2->cost_diff) { |
25 | 0 | return TO_BROTLI_BOOL(p1->cost_diff > p2->cost_diff); |
26 | 0 | } |
27 | 0 | return TO_BROTLI_BOOL((p1->idx2 - p1->idx1) > (p2->idx2 - p2->idx1)); |
28 | 0 | } |
29 | | |
30 | | /* Returns entropy reduction of the context map when we combine two clusters. */ |
31 | 0 | static BROTLI_INLINE double ClusterCostDiff(size_t size_a, size_t size_b) { |
32 | 0 | size_t size_c = size_a + size_b; |
33 | 0 | return (double)size_a * FastLog2(size_a) + |
34 | 0 | (double)size_b * FastLog2(size_b) - |
35 | 0 | (double)size_c * FastLog2(size_c); |
36 | 0 | } |
37 | | |
38 | 0 | #define CODE(X) X Unexecuted instantiation: BrotliCompareAndPushToQueueLiteral Unexecuted instantiation: BrotliHistogramCombineLiteral Unexecuted instantiation: BrotliHistogramBitCostDistanceLiteral Unexecuted instantiation: BrotliHistogramRemapLiteral Unexecuted instantiation: BrotliHistogramReindexLiteral Unexecuted instantiation: BrotliClusterHistogramsLiteral Unexecuted instantiation: BrotliCompareAndPushToQueueCommand Unexecuted instantiation: BrotliHistogramCombineCommand Unexecuted instantiation: BrotliHistogramBitCostDistanceCommand Unexecuted instantiation: BrotliHistogramRemapCommand Unexecuted instantiation: BrotliHistogramReindexCommand Unexecuted instantiation: BrotliClusterHistogramsCommand Unexecuted instantiation: BrotliCompareAndPushToQueueDistance Unexecuted instantiation: BrotliHistogramCombineDistance Unexecuted instantiation: BrotliHistogramBitCostDistanceDistance Unexecuted instantiation: BrotliHistogramRemapDistance Unexecuted instantiation: BrotliHistogramReindexDistance Unexecuted instantiation: BrotliClusterHistogramsDistance |
39 | | |
40 | | #define FN(X) X ## Literal |
41 | | #include "./cluster_inc.h" /* NOLINT(build/include) */ |
42 | | #undef FN |
43 | | |
44 | | #define FN(X) X ## Command |
45 | | #include "./cluster_inc.h" /* NOLINT(build/include) */ |
46 | | #undef FN |
47 | | |
48 | | #define FN(X) X ## Distance |
49 | | #include "./cluster_inc.h" /* NOLINT(build/include) */ |
50 | | #undef FN |
51 | | |
52 | | #undef CODE |
53 | | |
54 | | #if defined(__cplusplus) || defined(c_plusplus) |
55 | | } /* extern "C" */ |
56 | | #endif |