Coverage Report

Created: 2025-06-16 07:00

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