Coverage Report

Created: 2026-04-12 06:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libvpx/vp8/encoder/treewriter.h
Line
Count
Source
1
/*
2
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3
 *
4
 *  Use of this source code is governed by a BSD-style license
5
 *  that can be found in the LICENSE file in the root of the source
6
 *  tree. An additional intellectual property rights grant can be found
7
 *  in the file PATENTS.  All contributing project authors may
8
 *  be found in the AUTHORS file in the root of the source tree.
9
 */
10
11
#ifndef VPX_VP8_ENCODER_TREEWRITER_H_
12
#define VPX_VP8_ENCODER_TREEWRITER_H_
13
14
/* Trees map alphabets into huffman-like codes suitable for an arithmetic
15
   bit coder.  Timothy S Murphy  11 October 2004 */
16
17
#include <stdint.h>
18
19
#include "./vpx_config.h"
20
#include "vp8/common/treecoder.h"
21
22
#include "boolhuff.h" /* for now */
23
24
#ifdef __cplusplus
25
extern "C" {
26
#endif
27
28
typedef BOOL_CODER vp8_writer;
29
30
397M
#define vp8_write vp8_encode_bool
31
9.98M
#define vp8_write_literal vp8_encode_value
32
15.5M
#define vp8_write_bit(W, V) vp8_write(W, V, vp8_prob_half)
33
34
#define vp8bc_write vp8bc_write_bool
35
#define vp8bc_write_literal vp8bc_write_bits
36
#define vp8bc_write_bit(W, V) vp8bc_write_bits(W, V, 1)
37
38
/* Approximate length of an encoded bool in 256ths of a bit at given prob */
39
40
7.93G
#define vp8_cost_zero(x) (vp8_prob_cost[x])
41
2.59G
#define vp8_cost_one(x) vp8_cost_zero(vp8_complement(x))
42
43
2.88G
#define vp8_cost_bit(x, b) vp8_cost_zero((b) ? vp8_complement(x) : (x))
44
45
/* VP8BC version is scaled by 2^20 rather than 2^8; see bool_coder.h */
46
47
/* Both of these return bits, not scaled bits. */
48
49
static INLINE unsigned int vp8_cost_branch(const unsigned int ct[2],
50
1.55G
                                           vp8_prob p) {
51
  /* Imitate existing calculation */
52
53
1.55G
  return (unsigned int)(((((uint64_t)ct[0]) * vp8_cost_zero(p)) +
54
1.55G
                         (((uint64_t)ct[1]) * vp8_cost_one(p))) >>
55
1.55G
                        8);
56
1.55G
}
Unexecuted instantiation: vp8_cx_iface.c:vp8_cost_branch
Unexecuted instantiation: ethreading.c:vp8_cost_branch
Unexecuted instantiation: onyx_if.c:vp8_cost_branch
Unexecuted instantiation: pickinter.c:vp8_cost_branch
Unexecuted instantiation: picklpf.c:vp8_cost_branch
Unexecuted instantiation: vp8_quantize.c:vp8_cost_branch
Unexecuted instantiation: ratectrl.c:vp8_cost_branch
Unexecuted instantiation: rdopt.c:vp8_cost_branch
Unexecuted instantiation: segmentation.c:vp8_cost_branch
Unexecuted instantiation: vp8_skin_detection.c:vp8_cost_branch
Unexecuted instantiation: tokenize.c:vp8_cost_branch
Unexecuted instantiation: treewriter.c:vp8_cost_branch
Unexecuted instantiation: temporal_filter.c:vp8_cost_branch
bitstream.c:vp8_cost_branch
Line
Count
Source
50
1.53G
                                           vp8_prob p) {
51
  /* Imitate existing calculation */
52
53
1.53G
  return (unsigned int)(((((uint64_t)ct[0]) * vp8_cost_zero(p)) +
54
1.53G
                         (((uint64_t)ct[1]) * vp8_cost_one(p))) >>
55
1.53G
                        8);
56
1.53G
}
Unexecuted instantiation: encodeframe.c:vp8_cost_branch
Unexecuted instantiation: encodeintra.c:vp8_cost_branch
Unexecuted instantiation: encodemb.c:vp8_cost_branch
encodemv.c:vp8_cost_branch
Line
Count
Source
50
20.8M
                                           vp8_prob p) {
51
  /* Imitate existing calculation */
52
53
20.8M
  return (unsigned int)(((((uint64_t)ct[0]) * vp8_cost_zero(p)) +
54
20.8M
                         (((uint64_t)ct[1]) * vp8_cost_one(p))) >>
55
20.8M
                        8);
56
20.8M
}
Unexecuted instantiation: firstpass.c:vp8_cost_branch
Unexecuted instantiation: mcomp.c:vp8_cost_branch
Unexecuted instantiation: modecosts.c:vp8_cost_branch
57
58
/* Small functions to write explicit values and tokens, as well as
59
   estimate their lengths. */
60
61
static void vp8_treed_write(vp8_writer *const w, vp8_tree t,
62
                            const vp8_prob *const p, int v,
63
7.35M
                            int n) { /* number of bits in v, assumed nonzero */
64
7.35M
  vp8_tree_index i = 0;
65
66
17.5M
  do {
67
17.5M
    const int b = (v >> --n) & 1;
68
17.5M
    vp8_write(w, b, p[i >> 1]);
69
17.5M
    i = t[i + b];
70
17.5M
  } while (n);
71
7.35M
}
Unexecuted instantiation: vp8_cx_iface.c:vp8_treed_write
Unexecuted instantiation: ethreading.c:vp8_treed_write
Unexecuted instantiation: onyx_if.c:vp8_treed_write
Unexecuted instantiation: pickinter.c:vp8_treed_write
Unexecuted instantiation: picklpf.c:vp8_treed_write
Unexecuted instantiation: vp8_quantize.c:vp8_treed_write
Unexecuted instantiation: ratectrl.c:vp8_treed_write
Unexecuted instantiation: rdopt.c:vp8_treed_write
Unexecuted instantiation: segmentation.c:vp8_treed_write
Unexecuted instantiation: vp8_skin_detection.c:vp8_treed_write
Unexecuted instantiation: tokenize.c:vp8_treed_write
Unexecuted instantiation: treewriter.c:vp8_treed_write
Unexecuted instantiation: temporal_filter.c:vp8_treed_write
bitstream.c:vp8_treed_write
Line
Count
Source
63
6.80M
                            int n) { /* number of bits in v, assumed nonzero */
64
6.80M
  vp8_tree_index i = 0;
65
66
15.8M
  do {
67
15.8M
    const int b = (v >> --n) & 1;
68
15.8M
    vp8_write(w, b, p[i >> 1]);
69
15.8M
    i = t[i + b];
70
15.8M
  } while (n);
71
6.80M
}
Unexecuted instantiation: encodeframe.c:vp8_treed_write
Unexecuted instantiation: encodeintra.c:vp8_treed_write
Unexecuted instantiation: encodemb.c:vp8_treed_write
encodemv.c:vp8_treed_write
Line
Count
Source
63
545k
                            int n) { /* number of bits in v, assumed nonzero */
64
545k
  vp8_tree_index i = 0;
65
66
1.63M
  do {
67
1.63M
    const int b = (v >> --n) & 1;
68
1.63M
    vp8_write(w, b, p[i >> 1]);
69
1.63M
    i = t[i + b];
70
1.63M
  } while (n);
71
545k
}
Unexecuted instantiation: firstpass.c:vp8_treed_write
Unexecuted instantiation: mcomp.c:vp8_treed_write
Unexecuted instantiation: modecosts.c:vp8_treed_write
72
static INLINE void vp8_write_token(vp8_writer *const w, vp8_tree t,
73
                                   const vp8_prob *const p,
74
6.80M
                                   vp8_token *const x) {
75
6.80M
  vp8_treed_write(w, t, p, x->value, x->Len);
76
6.80M
}
Unexecuted instantiation: vp8_cx_iface.c:vp8_write_token
Unexecuted instantiation: ethreading.c:vp8_write_token
Unexecuted instantiation: onyx_if.c:vp8_write_token
Unexecuted instantiation: pickinter.c:vp8_write_token
Unexecuted instantiation: picklpf.c:vp8_write_token
Unexecuted instantiation: vp8_quantize.c:vp8_write_token
Unexecuted instantiation: ratectrl.c:vp8_write_token
Unexecuted instantiation: rdopt.c:vp8_write_token
Unexecuted instantiation: segmentation.c:vp8_write_token
Unexecuted instantiation: vp8_skin_detection.c:vp8_write_token
Unexecuted instantiation: tokenize.c:vp8_write_token
Unexecuted instantiation: treewriter.c:vp8_write_token
Unexecuted instantiation: temporal_filter.c:vp8_write_token
bitstream.c:vp8_write_token
Line
Count
Source
74
6.80M
                                   vp8_token *const x) {
75
6.80M
  vp8_treed_write(w, t, p, x->value, x->Len);
76
6.80M
}
Unexecuted instantiation: encodeframe.c:vp8_write_token
Unexecuted instantiation: encodeintra.c:vp8_write_token
Unexecuted instantiation: encodemb.c:vp8_write_token
Unexecuted instantiation: encodemv.c:vp8_write_token
Unexecuted instantiation: firstpass.c:vp8_write_token
Unexecuted instantiation: mcomp.c:vp8_write_token
Unexecuted instantiation: modecosts.c:vp8_write_token
77
78
static int vp8_treed_cost(vp8_tree t, const vp8_prob *const p, int v,
79
10.9M
                          int n) { /* number of bits in v, assumed nonzero */
80
10.9M
  int c = 0;
81
10.9M
  vp8_tree_index i = 0;
82
83
29.8M
  do {
84
29.8M
    const int b = (v >> --n) & 1;
85
29.8M
    c += vp8_cost_bit(p[i >> 1], b);
86
29.8M
    i = t[i + b];
87
29.8M
  } while (n);
88
89
10.9M
  return c;
90
10.9M
}
Unexecuted instantiation: vp8_cx_iface.c:vp8_treed_cost
Unexecuted instantiation: ethreading.c:vp8_treed_cost
Unexecuted instantiation: onyx_if.c:vp8_treed_cost
Unexecuted instantiation: pickinter.c:vp8_treed_cost
Unexecuted instantiation: picklpf.c:vp8_treed_cost
Unexecuted instantiation: vp8_quantize.c:vp8_treed_cost
Unexecuted instantiation: ratectrl.c:vp8_treed_cost
rdopt.c:vp8_treed_cost
Line
Count
Source
79
9.91M
                          int n) { /* number of bits in v, assumed nonzero */
80
9.91M
  int c = 0;
81
9.91M
  vp8_tree_index i = 0;
82
83
26.8M
  do {
84
26.8M
    const int b = (v >> --n) & 1;
85
26.8M
    c += vp8_cost_bit(p[i >> 1], b);
86
26.8M
    i = t[i + b];
87
26.8M
  } while (n);
88
89
9.91M
  return c;
90
9.91M
}
Unexecuted instantiation: segmentation.c:vp8_treed_cost
Unexecuted instantiation: vp8_skin_detection.c:vp8_treed_cost
Unexecuted instantiation: tokenize.c:vp8_treed_cost
Unexecuted instantiation: treewriter.c:vp8_treed_cost
Unexecuted instantiation: temporal_filter.c:vp8_treed_cost
Unexecuted instantiation: bitstream.c:vp8_treed_cost
Unexecuted instantiation: encodeframe.c:vp8_treed_cost
Unexecuted instantiation: encodeintra.c:vp8_treed_cost
Unexecuted instantiation: encodemb.c:vp8_treed_cost
encodemv.c:vp8_treed_cost
Line
Count
Source
79
996k
                          int n) { /* number of bits in v, assumed nonzero */
80
996k
  int c = 0;
81
996k
  vp8_tree_index i = 0;
82
83
2.98M
  do {
84
2.98M
    const int b = (v >> --n) & 1;
85
2.98M
    c += vp8_cost_bit(p[i >> 1], b);
86
2.98M
    i = t[i + b];
87
2.98M
  } while (n);
88
89
996k
  return c;
90
996k
}
Unexecuted instantiation: firstpass.c:vp8_treed_cost
Unexecuted instantiation: mcomp.c:vp8_treed_cost
Unexecuted instantiation: modecosts.c:vp8_treed_cost
91
static INLINE int vp8_cost_token(vp8_tree t, const vp8_prob *const p,
92
9.91M
                                 vp8_token *const x) {
93
9.91M
  return vp8_treed_cost(t, p, x->value, x->Len);
94
9.91M
}
Unexecuted instantiation: vp8_cx_iface.c:vp8_cost_token
Unexecuted instantiation: ethreading.c:vp8_cost_token
Unexecuted instantiation: onyx_if.c:vp8_cost_token
Unexecuted instantiation: pickinter.c:vp8_cost_token
Unexecuted instantiation: picklpf.c:vp8_cost_token
Unexecuted instantiation: vp8_quantize.c:vp8_cost_token
Unexecuted instantiation: ratectrl.c:vp8_cost_token
rdopt.c:vp8_cost_token
Line
Count
Source
92
9.91M
                                 vp8_token *const x) {
93
9.91M
  return vp8_treed_cost(t, p, x->value, x->Len);
94
9.91M
}
Unexecuted instantiation: segmentation.c:vp8_cost_token
Unexecuted instantiation: vp8_skin_detection.c:vp8_cost_token
Unexecuted instantiation: tokenize.c:vp8_cost_token
Unexecuted instantiation: treewriter.c:vp8_cost_token
Unexecuted instantiation: temporal_filter.c:vp8_cost_token
Unexecuted instantiation: bitstream.c:vp8_cost_token
Unexecuted instantiation: encodeframe.c:vp8_cost_token
Unexecuted instantiation: encodeintra.c:vp8_cost_token
Unexecuted instantiation: encodemb.c:vp8_cost_token
Unexecuted instantiation: encodemv.c:vp8_cost_token
Unexecuted instantiation: firstpass.c:vp8_cost_token
Unexecuted instantiation: mcomp.c:vp8_cost_token
Unexecuted instantiation: modecosts.c:vp8_cost_token
95
96
/* Fill array of costs for all possible token values. */
97
98
void vp8_cost_tokens(int *c, const vp8_prob *, vp8_tree);
99
100
void vp8_cost_tokens2(int *c, const vp8_prob *, vp8_tree, int);
101
102
#ifdef __cplusplus
103
}  // extern "C"
104
#endif
105
106
#endif  // VPX_VP8_ENCODER_TREEWRITER_H_