Coverage Report

Created: 2025-06-22 08:04

/src/aom/av1/encoder/cost.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2016, 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_AV1_ENCODER_COST_H_
13
#define AOM_AV1_ENCODER_COST_H_
14
15
#include "aom_dsp/prob.h"
16
#include "aom/aom_integer.h"
17
18
#ifdef __cplusplus
19
extern "C" {
20
#endif
21
22
extern const uint16_t av1_prob_cost[128];
23
24
// The factor to scale from cost in bits to cost in av1_prob_cost units.
25
0
#define AV1_PROB_COST_SHIFT 9
26
27
// Cost of coding an n bit literal, using 128 (i.e. 50%) probability
28
// for each bit.
29
0
#define av1_cost_literal(n) ((n) * (1 << AV1_PROB_COST_SHIFT))
30
31
// Calculate the cost of a symbol with probability p15 / 2^15
32
0
static inline int av1_cost_symbol(aom_cdf_prob p15) {
33
  // p15 can be out of range [1, CDF_PROB_TOP - 1]. Clamping it, so that the
34
  // following cost calculation works correctly. Otherwise, if p15 =
35
  // CDF_PROB_TOP, shift would be -1, and "p15 << shift" would be wrong.
36
0
  p15 = (aom_cdf_prob)clamp(p15, 1, CDF_PROB_TOP - 1);
37
0
  assert(0 < p15 && p15 < CDF_PROB_TOP);
38
0
  const int shift = CDF_PROB_BITS - 1 - get_msb(p15);
39
0
  const int prob = get_prob(p15 << shift, CDF_PROB_TOP);
40
0
  assert(prob >= 128);
41
0
  return av1_prob_cost[prob - 128] + av1_cost_literal(shift);
42
0
}
Unexecuted instantiation: av1_cx_iface.c:av1_cost_symbol
Unexecuted instantiation: allintra_vis.c:av1_cost_symbol
Unexecuted instantiation: av1_quantize.c:av1_cost_symbol
Unexecuted instantiation: bitstream.c:av1_cost_symbol
Unexecuted instantiation: context_tree.c:av1_cost_symbol
Unexecuted instantiation: encodeframe.c:av1_cost_symbol
Unexecuted instantiation: encodeframe_utils.c:av1_cost_symbol
Unexecuted instantiation: encodemb.c:av1_cost_symbol
Unexecuted instantiation: encodemv.c:av1_cost_symbol
Unexecuted instantiation: encoder.c:av1_cost_symbol
Unexecuted instantiation: encoder_utils.c:av1_cost_symbol
Unexecuted instantiation: encodetxb.c:av1_cost_symbol
Unexecuted instantiation: ethread.c:av1_cost_symbol
Unexecuted instantiation: firstpass.c:av1_cost_symbol
Unexecuted instantiation: global_motion_facade.c:av1_cost_symbol
Unexecuted instantiation: level.c:av1_cost_symbol
Unexecuted instantiation: lookahead.c:av1_cost_symbol
Unexecuted instantiation: mcomp.c:av1_cost_symbol
Unexecuted instantiation: mv_prec.c:av1_cost_symbol
Unexecuted instantiation: palette.c:av1_cost_symbol
Unexecuted instantiation: partition_search.c:av1_cost_symbol
Unexecuted instantiation: partition_strategy.c:av1_cost_symbol
Unexecuted instantiation: pass2_strategy.c:av1_cost_symbol
Unexecuted instantiation: pickcdef.c:av1_cost_symbol
Unexecuted instantiation: picklpf.c:av1_cost_symbol
Unexecuted instantiation: pickrst.c:av1_cost_symbol
Unexecuted instantiation: ratectrl.c:av1_cost_symbol
Unexecuted instantiation: rd.c:av1_cost_symbol
Unexecuted instantiation: rdopt.c:av1_cost_symbol
Unexecuted instantiation: nonrd_pickmode.c:av1_cost_symbol
Unexecuted instantiation: nonrd_opt.c:av1_cost_symbol
Unexecuted instantiation: segmentation.c:av1_cost_symbol
Unexecuted instantiation: speed_features.c:av1_cost_symbol
Unexecuted instantiation: superres_scale.c:av1_cost_symbol
Unexecuted instantiation: svc_layercontext.c:av1_cost_symbol
Unexecuted instantiation: temporal_filter.c:av1_cost_symbol
Unexecuted instantiation: tokenize.c:av1_cost_symbol
Unexecuted instantiation: tpl_model.c:av1_cost_symbol
Unexecuted instantiation: tx_search.c:av1_cost_symbol
Unexecuted instantiation: txb_rdopt.c:av1_cost_symbol
Unexecuted instantiation: intra_mode_search.c:av1_cost_symbol
Unexecuted instantiation: var_based_part.c:av1_cost_symbol
Unexecuted instantiation: av1_noise_estimate.c:av1_cost_symbol
Unexecuted instantiation: aq_complexity.c:av1_cost_symbol
Unexecuted instantiation: aq_cyclicrefresh.c:av1_cost_symbol
Unexecuted instantiation: aq_variance.c:av1_cost_symbol
Unexecuted instantiation: compound_type.c:av1_cost_symbol
Unexecuted instantiation: cost.c:av1_cost_symbol
Unexecuted instantiation: encode_strategy.c:av1_cost_symbol
Unexecuted instantiation: global_motion.c:av1_cost_symbol
Unexecuted instantiation: gop_structure.c:av1_cost_symbol
Unexecuted instantiation: interp_search.c:av1_cost_symbol
Unexecuted instantiation: motion_search_facade.c:av1_cost_symbol
43
44
void av1_cost_tokens_from_cdf(int *costs, const aom_cdf_prob *cdf,
45
                              const int *inv_map);
46
47
#ifdef __cplusplus
48
}  // extern "C"
49
#endif
50
51
#endif  // AOM_AV1_ENCODER_COST_H_