Coverage Report

Created: 2025-11-24 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libavif/ext/aom/aom_dsp/recenter.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2018, Alliance for Open Media. All rights reserved.
3
 *
4
 * This source code is subject to the terms of the BSD 2 Clause License and
5
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6
 * was not distributed with this source code in the LICENSE file, you can
7
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8
 * Media Patent License 1.0 was not distributed with this source code in the
9
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10
 */
11
12
#ifndef AOM_AOM_DSP_RECENTER_H_
13
#define AOM_AOM_DSP_RECENTER_H_
14
15
#include "config/aom_config.h"
16
17
#include "aom/aom_integer.h"
18
19
// Inverse recenters a non-negative literal v around a reference r
20
87.3k
static inline uint16_t inv_recenter_nonneg(uint16_t r, uint16_t v) {
21
87.3k
  if (v > (r << 1))
22
4.82k
    return v;
23
82.5k
  else if ((v & 1) == 0)
24
42.4k
    return (v >> 1) + r;
25
40.0k
  else
26
40.0k
    return r - ((v + 1) >> 1);
27
87.3k
}
bitreader_buffer.c:inv_recenter_nonneg
Line
Count
Source
20
32.5k
static inline uint16_t inv_recenter_nonneg(uint16_t r, uint16_t v) {
21
32.5k
  if (v > (r << 1))
22
0
    return v;
23
32.5k
  else if ((v & 1) == 0)
24
18.5k
    return (v >> 1) + r;
25
13.9k
  else
26
13.9k
    return r - ((v + 1) >> 1);
27
32.5k
}
Unexecuted instantiation: bitwriter_buffer.c:inv_recenter_nonneg
binary_codes_reader.c:inv_recenter_nonneg
Line
Count
Source
20
54.7k
static inline uint16_t inv_recenter_nonneg(uint16_t r, uint16_t v) {
21
54.7k
  if (v > (r << 1))
22
4.82k
    return v;
23
49.9k
  else if ((v & 1) == 0)
24
23.8k
    return (v >> 1) + r;
25
26.0k
  else
26
26.0k
    return r - ((v + 1) >> 1);
27
54.7k
}
Unexecuted instantiation: binary_codes_writer.c:inv_recenter_nonneg
28
29
// Inverse recenters a non-negative literal v in [0, n-1] around a
30
// reference r also in [0, n-1]
31
static inline uint16_t inv_recenter_finite_nonneg(uint16_t n, uint16_t r,
32
87.3k
                                                  uint16_t v) {
33
87.3k
  if ((r << 1) <= n) {
34
72.3k
    return inv_recenter_nonneg(r, v);
35
72.3k
  } else {
36
15.0k
    return n - 1 - inv_recenter_nonneg(n - 1 - r, v);
37
15.0k
  }
38
87.3k
}
bitreader_buffer.c:inv_recenter_finite_nonneg
Line
Count
Source
32
32.5k
                                                  uint16_t v) {
33
32.5k
  if ((r << 1) <= n) {
34
32.5k
    return inv_recenter_nonneg(r, v);
35
32.5k
  } else {
36
0
    return n - 1 - inv_recenter_nonneg(n - 1 - r, v);
37
0
  }
38
32.5k
}
Unexecuted instantiation: bitwriter_buffer.c:inv_recenter_finite_nonneg
binary_codes_reader.c:inv_recenter_finite_nonneg
Line
Count
Source
32
54.7k
                                                  uint16_t v) {
33
54.7k
  if ((r << 1) <= n) {
34
39.7k
    return inv_recenter_nonneg(r, v);
35
39.7k
  } else {
36
15.0k
    return n - 1 - inv_recenter_nonneg(n - 1 - r, v);
37
15.0k
  }
38
54.7k
}
Unexecuted instantiation: binary_codes_writer.c:inv_recenter_finite_nonneg
39
40
// Recenters a non-negative literal v around a reference r
41
54.0k
static inline uint16_t recenter_nonneg(uint16_t r, uint16_t v) {
42
54.0k
  if (v > (r << 1))
43
0
    return v;
44
54.0k
  else if (v >= r)
45
29.5k
    return ((v - r) << 1);
46
24.4k
  else
47
24.4k
    return ((r - v) << 1) - 1;
48
54.0k
}
Unexecuted instantiation: bitreader_buffer.c:recenter_nonneg
Unexecuted instantiation: bitwriter_buffer.c:recenter_nonneg
Unexecuted instantiation: binary_codes_reader.c:recenter_nonneg
binary_codes_writer.c:recenter_nonneg
Line
Count
Source
41
54.0k
static inline uint16_t recenter_nonneg(uint16_t r, uint16_t v) {
42
54.0k
  if (v > (r << 1))
43
0
    return v;
44
54.0k
  else if (v >= r)
45
29.5k
    return ((v - r) << 1);
46
24.4k
  else
47
24.4k
    return ((r - v) << 1) - 1;
48
54.0k
}
49
50
// Recenters a non-negative literal v in [0, n-1] around a
51
// reference r also in [0, n-1]
52
static inline uint16_t recenter_finite_nonneg(uint16_t n, uint16_t r,
53
54.0k
                                              uint16_t v) {
54
54.0k
  if ((r << 1) <= n) {
55
54.0k
    return recenter_nonneg(r, v);
56
18.4E
  } else {
57
18.4E
    return recenter_nonneg(n - 1 - r, n - 1 - v);
58
18.4E
  }
59
54.0k
}
Unexecuted instantiation: bitreader_buffer.c:recenter_finite_nonneg
Unexecuted instantiation: bitwriter_buffer.c:recenter_finite_nonneg
Unexecuted instantiation: binary_codes_reader.c:recenter_finite_nonneg
binary_codes_writer.c:recenter_finite_nonneg
Line
Count
Source
53
54.0k
                                              uint16_t v) {
54
54.0k
  if ((r << 1) <= n) {
55
54.0k
    return recenter_nonneg(r, v);
56
18.4E
  } else {
57
18.4E
    return recenter_nonneg(n - 1 - r, n - 1 - v);
58
18.4E
  }
59
54.0k
}
60
61
#endif  // AOM_AOM_DSP_RECENTER_H_