/src/aom/aom_dsp/grain_params.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 | | /*!\file |
13 | | * \brief Describes film grain parameters |
14 | | * |
15 | | */ |
16 | | #ifndef AOM_AOM_DSP_GRAIN_PARAMS_H_ |
17 | | #define AOM_AOM_DSP_GRAIN_PARAMS_H_ |
18 | | |
19 | | #ifdef __cplusplus |
20 | | extern "C" { |
21 | | #endif |
22 | | |
23 | | #include <stdint.h> |
24 | | #include <string.h> |
25 | | |
26 | | #include "config/aom_config.h" |
27 | | |
28 | | /*!\brief Structure containing film grain synthesis parameters for a frame |
29 | | * |
30 | | * This structure contains input parameters for film grain synthesis |
31 | | */ |
32 | | typedef struct { |
33 | | // This structure is compared element-by-element in the function |
34 | | // aom_check_grain_params_equiv: this function must be updated if any changes |
35 | | // are made to this structure. |
36 | | int apply_grain; |
37 | | |
38 | | int update_parameters; |
39 | | |
40 | | // 8 bit values |
41 | | int scaling_points_y[14][2]; |
42 | | int num_y_points; // value: 0..14 |
43 | | |
44 | | // 8 bit values |
45 | | int scaling_points_cb[10][2]; |
46 | | int num_cb_points; // value: 0..10 |
47 | | |
48 | | // 8 bit values |
49 | | int scaling_points_cr[10][2]; |
50 | | int num_cr_points; // value: 0..10 |
51 | | |
52 | | int scaling_shift; // values : 8..11 |
53 | | |
54 | | int ar_coeff_lag; // values: 0..3 |
55 | | |
56 | | // 8 bit values |
57 | | int ar_coeffs_y[24]; |
58 | | int ar_coeffs_cb[25]; |
59 | | int ar_coeffs_cr[25]; |
60 | | |
61 | | // Shift value: AR coeffs range |
62 | | // 6: [-2, 2) |
63 | | // 7: [-1, 1) |
64 | | // 8: [-0.5, 0.5) |
65 | | // 9: [-0.25, 0.25) |
66 | | int ar_coeff_shift; // values : 6..9 |
67 | | |
68 | | int cb_mult; // 8 bits |
69 | | int cb_luma_mult; // 8 bits |
70 | | int cb_offset; // 9 bits |
71 | | |
72 | | int cr_mult; // 8 bits |
73 | | int cr_luma_mult; // 8 bits |
74 | | int cr_offset; // 9 bits |
75 | | |
76 | | int overlap_flag; |
77 | | |
78 | | int clip_to_restricted_range; |
79 | | |
80 | | unsigned int bit_depth; // video bit depth |
81 | | |
82 | | int chroma_scaling_from_luma; |
83 | | |
84 | | int grain_scale_shift; |
85 | | |
86 | | uint16_t random_seed; |
87 | | // This structure is compared element-by-element in the function |
88 | | // aom_check_grain_params_equiv: this function must be updated if any changes |
89 | | // are made to this structure. |
90 | | } aom_film_grain_t; |
91 | | |
92 | | /*!\brief Check if two film grain parameters structs are equivalent |
93 | | * |
94 | | * Check if two film grain parameters are equal, except for the |
95 | | * update_parameters and random_seed elements which are ignored. |
96 | | * |
97 | | * \param[in] pa The first set of parameters to compare |
98 | | * \param[in] pb The second set of parameters to compare |
99 | | * \return Returns 1 if the params are equivalent, 0 otherwise |
100 | | */ |
101 | | static inline int aom_check_grain_params_equiv( |
102 | 0 | const aom_film_grain_t *const pa, const aom_film_grain_t *const pb) { |
103 | 0 | if (pa->apply_grain != pb->apply_grain) return 0; |
104 | | // Don't compare update_parameters |
105 | | |
106 | 0 | if (pa->num_y_points != pb->num_y_points) return 0; |
107 | 0 | if (memcmp(pa->scaling_points_y, pb->scaling_points_y, |
108 | 0 | pa->num_y_points * 2 * sizeof(*pa->scaling_points_y)) != 0) |
109 | 0 | return 0; |
110 | | |
111 | 0 | if (pa->num_cb_points != pb->num_cb_points) return 0; |
112 | 0 | if (memcmp(pa->scaling_points_cb, pb->scaling_points_cb, |
113 | 0 | pa->num_cb_points * 2 * sizeof(*pa->scaling_points_cb)) != 0) |
114 | 0 | return 0; |
115 | | |
116 | 0 | if (pa->num_cr_points != pb->num_cr_points) return 0; |
117 | 0 | if (memcmp(pa->scaling_points_cr, pb->scaling_points_cr, |
118 | 0 | pa->num_cr_points * 2 * sizeof(*pa->scaling_points_cr)) != 0) |
119 | 0 | return 0; |
120 | | |
121 | 0 | if (pa->scaling_shift != pb->scaling_shift) return 0; |
122 | 0 | if (pa->ar_coeff_lag != pb->ar_coeff_lag) return 0; |
123 | | |
124 | 0 | const int num_pos = 2 * pa->ar_coeff_lag * (pa->ar_coeff_lag + 1); |
125 | 0 | if (memcmp(pa->ar_coeffs_y, pb->ar_coeffs_y, |
126 | 0 | num_pos * sizeof(*pa->ar_coeffs_y)) != 0) |
127 | 0 | return 0; |
128 | 0 | if (memcmp(pa->ar_coeffs_cb, pb->ar_coeffs_cb, |
129 | 0 | num_pos * sizeof(*pa->ar_coeffs_cb)) != 0) |
130 | 0 | return 0; |
131 | 0 | if (memcmp(pa->ar_coeffs_cr, pb->ar_coeffs_cr, |
132 | 0 | num_pos * sizeof(*pa->ar_coeffs_cr)) != 0) |
133 | 0 | return 0; |
134 | | |
135 | 0 | if (pa->ar_coeff_shift != pb->ar_coeff_shift) return 0; |
136 | | |
137 | 0 | if (pa->cb_mult != pb->cb_mult) return 0; |
138 | 0 | if (pa->cb_luma_mult != pb->cb_luma_mult) return 0; |
139 | 0 | if (pa->cb_offset != pb->cb_offset) return 0; |
140 | | |
141 | 0 | if (pa->cr_mult != pb->cr_mult) return 0; |
142 | 0 | if (pa->cr_luma_mult != pb->cr_luma_mult) return 0; |
143 | 0 | if (pa->cr_offset != pb->cr_offset) return 0; |
144 | | |
145 | 0 | if (pa->overlap_flag != pb->overlap_flag) return 0; |
146 | 0 | if (pa->clip_to_restricted_range != pb->clip_to_restricted_range) return 0; |
147 | 0 | if (pa->bit_depth != pb->bit_depth) return 0; |
148 | 0 | if (pa->chroma_scaling_from_luma != pb->chroma_scaling_from_luma) return 0; |
149 | 0 | if (pa->grain_scale_shift != pb->grain_scale_shift) return 0; |
150 | | |
151 | 0 | return 1; |
152 | 0 | } Unexecuted instantiation: av1_dx_iface.c:aom_check_grain_params_equiv Unexecuted instantiation: decodeframe.c:aom_check_grain_params_equiv Unexecuted instantiation: decodemv.c:aom_check_grain_params_equiv Unexecuted instantiation: decoder.c:aom_check_grain_params_equiv Unexecuted instantiation: decodetxb.c:aom_check_grain_params_equiv Unexecuted instantiation: detokenize.c:aom_check_grain_params_equiv Unexecuted instantiation: grain_synthesis.c:aom_check_grain_params_equiv Unexecuted instantiation: obu.c:aom_check_grain_params_equiv Unexecuted instantiation: av1_cx_iface.c:aom_check_grain_params_equiv Unexecuted instantiation: allintra_vis.c:aom_check_grain_params_equiv Unexecuted instantiation: av1_quantize.c:aom_check_grain_params_equiv Unexecuted instantiation: bitstream.c:aom_check_grain_params_equiv Unexecuted instantiation: context_tree.c:aom_check_grain_params_equiv Unexecuted instantiation: encodeframe.c:aom_check_grain_params_equiv Unexecuted instantiation: encodeframe_utils.c:aom_check_grain_params_equiv Unexecuted instantiation: encodemb.c:aom_check_grain_params_equiv Unexecuted instantiation: encodemv.c:aom_check_grain_params_equiv Unexecuted instantiation: encoder.c:aom_check_grain_params_equiv Unexecuted instantiation: encoder_utils.c:aom_check_grain_params_equiv Unexecuted instantiation: encodetxb.c:aom_check_grain_params_equiv Unexecuted instantiation: ethread.c:aom_check_grain_params_equiv Unexecuted instantiation: firstpass.c:aom_check_grain_params_equiv Unexecuted instantiation: global_motion_facade.c:aom_check_grain_params_equiv Unexecuted instantiation: hash_motion.c:aom_check_grain_params_equiv Unexecuted instantiation: level.c:aom_check_grain_params_equiv Unexecuted instantiation: lookahead.c:aom_check_grain_params_equiv Unexecuted instantiation: mcomp.c:aom_check_grain_params_equiv Unexecuted instantiation: mv_prec.c:aom_check_grain_params_equiv Unexecuted instantiation: palette.c:aom_check_grain_params_equiv Unexecuted instantiation: partition_search.c:aom_check_grain_params_equiv Unexecuted instantiation: partition_strategy.c:aom_check_grain_params_equiv Unexecuted instantiation: pass2_strategy.c:aom_check_grain_params_equiv Unexecuted instantiation: pickcdef.c:aom_check_grain_params_equiv Unexecuted instantiation: picklpf.c:aom_check_grain_params_equiv Unexecuted instantiation: pickrst.c:aom_check_grain_params_equiv Unexecuted instantiation: ratectrl.c:aom_check_grain_params_equiv Unexecuted instantiation: rd.c:aom_check_grain_params_equiv Unexecuted instantiation: rdopt.c:aom_check_grain_params_equiv Unexecuted instantiation: nonrd_pickmode.c:aom_check_grain_params_equiv Unexecuted instantiation: nonrd_opt.c:aom_check_grain_params_equiv Unexecuted instantiation: reconinter_enc.c:aom_check_grain_params_equiv Unexecuted instantiation: segmentation.c:aom_check_grain_params_equiv Unexecuted instantiation: speed_features.c:aom_check_grain_params_equiv Unexecuted instantiation: superres_scale.c:aom_check_grain_params_equiv Unexecuted instantiation: svc_layercontext.c:aom_check_grain_params_equiv Unexecuted instantiation: temporal_filter.c:aom_check_grain_params_equiv Unexecuted instantiation: tokenize.c:aom_check_grain_params_equiv Unexecuted instantiation: tpl_model.c:aom_check_grain_params_equiv Unexecuted instantiation: tx_search.c:aom_check_grain_params_equiv Unexecuted instantiation: txb_rdopt.c:aom_check_grain_params_equiv Unexecuted instantiation: intra_mode_search.c:aom_check_grain_params_equiv Unexecuted instantiation: var_based_part.c:aom_check_grain_params_equiv Unexecuted instantiation: av1_noise_estimate.c:aom_check_grain_params_equiv Unexecuted instantiation: variance.c:aom_check_grain_params_equiv Unexecuted instantiation: pyramid.c:aom_check_grain_params_equiv Unexecuted instantiation: grain_table.c:aom_check_grain_params_equiv Unexecuted instantiation: noise_model.c:aom_check_grain_params_equiv Unexecuted instantiation: alloccommon.c:aom_check_grain_params_equiv Unexecuted instantiation: av1_loopfilter.c:aom_check_grain_params_equiv Unexecuted instantiation: blockd.c:aom_check_grain_params_equiv Unexecuted instantiation: cdef.c:aom_check_grain_params_equiv Unexecuted instantiation: cdef_block.c:aom_check_grain_params_equiv Unexecuted instantiation: cfl.c:aom_check_grain_params_equiv Unexecuted instantiation: debugmodes.c:aom_check_grain_params_equiv Unexecuted instantiation: entropy.c:aom_check_grain_params_equiv Unexecuted instantiation: entropymode.c:aom_check_grain_params_equiv Unexecuted instantiation: entropymv.c:aom_check_grain_params_equiv Unexecuted instantiation: mvref_common.c:aom_check_grain_params_equiv Unexecuted instantiation: pred_common.c:aom_check_grain_params_equiv Unexecuted instantiation: quant_common.c:aom_check_grain_params_equiv Unexecuted instantiation: reconinter.c:aom_check_grain_params_equiv Unexecuted instantiation: reconintra.c:aom_check_grain_params_equiv Unexecuted instantiation: resize.c:aom_check_grain_params_equiv Unexecuted instantiation: restoration.c:aom_check_grain_params_equiv Unexecuted instantiation: scan.c:aom_check_grain_params_equiv Unexecuted instantiation: thread_common.c:aom_check_grain_params_equiv Unexecuted instantiation: tile_common.c:aom_check_grain_params_equiv Unexecuted instantiation: txb_common.c:aom_check_grain_params_equiv Unexecuted instantiation: warped_motion.c:aom_check_grain_params_equiv Unexecuted instantiation: aq_complexity.c:aom_check_grain_params_equiv Unexecuted instantiation: aq_cyclicrefresh.c:aom_check_grain_params_equiv Unexecuted instantiation: aq_variance.c:aom_check_grain_params_equiv Unexecuted instantiation: cnn.c:aom_check_grain_params_equiv Unexecuted instantiation: compound_type.c:aom_check_grain_params_equiv Unexecuted instantiation: encode_strategy.c:aom_check_grain_params_equiv Unexecuted instantiation: global_motion.c:aom_check_grain_params_equiv Unexecuted instantiation: gop_structure.c:aom_check_grain_params_equiv Unexecuted instantiation: interp_search.c:aom_check_grain_params_equiv Unexecuted instantiation: motion_search_facade.c:aom_check_grain_params_equiv Unexecuted instantiation: wedge_utils.c:aom_check_grain_params_equiv Unexecuted instantiation: convolve.c:aom_check_grain_params_equiv |
153 | | |
154 | | #ifdef __cplusplus |
155 | | } // extern "C" |
156 | | #endif |
157 | | |
158 | | #endif // AOM_AOM_DSP_GRAIN_PARAMS_H_ |