Coverage Report

Created: 2026-04-09 07:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ghostpdl/brotli/c/enc/fast_log.h
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
/* Utilities for fast computation of logarithms. */
8
9
#ifndef BROTLI_ENC_FAST_LOG_H_
10
#define BROTLI_ENC_FAST_LOG_H_
11
12
#include <math.h>
13
14
#include "../common/platform.h"
15
16
#if defined(__cplusplus) || defined(c_plusplus)
17
extern "C" {
18
#endif
19
20
0
static BROTLI_INLINE uint32_t Log2FloorNonZero(size_t n) {
21
0
#if defined(BROTLI_BSR32)
22
0
  return BROTLI_BSR32((uint32_t)n);
23
#else
24
  uint32_t result = 0;
25
  while (n >>= 1) result++;
26
  return result;
27
#endif
28
0
}
Unexecuted instantiation: encode.c:Log2FloorNonZero
Unexecuted instantiation: encoder_dict.c:Log2FloorNonZero
Unexecuted instantiation: fast_log.c:Log2FloorNonZero
Unexecuted instantiation: metablock.c:Log2FloorNonZero
Unexecuted instantiation: backward_references.c:Log2FloorNonZero
Unexecuted instantiation: backward_references_hq.c:Log2FloorNonZero
Unexecuted instantiation: bit_cost.c:Log2FloorNonZero
Unexecuted instantiation: block_splitter.c:Log2FloorNonZero
Unexecuted instantiation: brotli_bit_stream.c:Log2FloorNonZero
Unexecuted instantiation: cluster.c:Log2FloorNonZero
Unexecuted instantiation: command.c:Log2FloorNonZero
Unexecuted instantiation: compress_fragment.c:Log2FloorNonZero
Unexecuted instantiation: compress_fragment_two_pass.c:Log2FloorNonZero
Unexecuted instantiation: histogram.c:Log2FloorNonZero
Unexecuted instantiation: literal_cost.c:Log2FloorNonZero
29
30
0
#define BROTLI_LOG2_TABLE_SIZE 256
31
32
/* A lookup table for small values of log2(int) to be used in entropy
33
   computation. */
34
BROTLI_INTERNAL extern const BROTLI_MODEL("small")
35
double kBrotliLog2Table[BROTLI_LOG2_TABLE_SIZE];
36
37
/* Visual Studio 2012 and Android API levels < 18 do not have the log2()
38
 * function defined, so we use log() and a multiplication instead. */
39
#if !defined(BROTLI_HAVE_LOG2)
40
#if ((defined(_MSC_VER) && _MSC_VER <= 1700) || \
41
     (defined(__ANDROID_API__) && __ANDROID_API__ < 18))
42
#define BROTLI_HAVE_LOG2 0
43
#else
44
#define BROTLI_HAVE_LOG2 1
45
#endif
46
#endif
47
48
#define LOG_2_INV 1.4426950408889634
49
50
/* Faster logarithm for small integers, with the property of log2(0) == 0. */
51
0
static BROTLI_INLINE double FastLog2(size_t v) {
52
0
  if (v < BROTLI_LOG2_TABLE_SIZE) {
53
0
    return kBrotliLog2Table[v];
54
0
  }
55
#if !(BROTLI_HAVE_LOG2)
56
  return log((double)v) * LOG_2_INV;
57
#else
58
0
  return log2((double)v);
59
0
#endif
60
0
}
Unexecuted instantiation: encode.c:FastLog2
Unexecuted instantiation: encoder_dict.c:FastLog2
Unexecuted instantiation: fast_log.c:FastLog2
Unexecuted instantiation: metablock.c:FastLog2
Unexecuted instantiation: backward_references.c:FastLog2
Unexecuted instantiation: backward_references_hq.c:FastLog2
Unexecuted instantiation: bit_cost.c:FastLog2
Unexecuted instantiation: block_splitter.c:FastLog2
Unexecuted instantiation: brotli_bit_stream.c:FastLog2
Unexecuted instantiation: cluster.c:FastLog2
Unexecuted instantiation: command.c:FastLog2
Unexecuted instantiation: compress_fragment.c:FastLog2
Unexecuted instantiation: compress_fragment_two_pass.c:FastLog2
Unexecuted instantiation: histogram.c:FastLog2
Unexecuted instantiation: literal_cost.c:FastLog2
61
62
#if defined(__cplusplus) || defined(c_plusplus)
63
}  /* extern "C" */
64
#endif
65
66
#endif  /* BROTLI_ENC_FAST_LOG_H_ */