Coverage Report

Created: 2025-11-16 07:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libjxl/third_party/brotli/c/enc/cluster.c
Line
Count
Source
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 "../common/platform.h"
12
#include "bit_cost.h"  /* BrotliPopulationCost */
13
#include "fast_log.h"
14
#include "histogram.h"
15
#include "memory.h"
16
17
#if defined(__cplusplus) || defined(c_plusplus)
18
extern "C" {
19
#endif
20
21
static BROTLI_INLINE BROTLI_BOOL HistogramPairIsLess(
22
0
    const HistogramPair* p1, const HistogramPair* p2) {
23
0
  if (p1->cost_diff != p2->cost_diff) {
24
0
    return TO_BROTLI_BOOL(p1->cost_diff > p2->cost_diff);
25
0
  }
26
0
  return TO_BROTLI_BOOL((p1->idx2 - p1->idx1) > (p2->idx2 - p2->idx1));
27
0
}
28
29
/* Returns entropy reduction of the context map when we combine two clusters. */
30
0
static BROTLI_INLINE double ClusterCostDiff(size_t size_a, size_t size_b) {
31
0
  size_t size_c = size_a + size_b;
32
0
  return (double)size_a * FastLog2(size_a) +
33
0
    (double)size_b * FastLog2(size_b) -
34
0
    (double)size_c * FastLog2(size_c);
35
0
}
36
37
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
38
39
#define FN(X) X ## Literal
40
#include "cluster_inc.h"  /* NOLINT(build/include) */
41
#undef FN
42
43
#define FN(X) X ## Command
44
#include "cluster_inc.h"  /* NOLINT(build/include) */
45
#undef FN
46
47
#define FN(X) X ## Distance
48
#include "cluster_inc.h"  /* NOLINT(build/include) */
49
#undef FN
50
51
#undef CODE
52
53
#if defined(__cplusplus) || defined(c_plusplus)
54
}  /* extern "C" */
55
#endif