/src/aom/av1/encoder/intra_mode_search_utils.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2020, 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 Defines utility functions used in intra mode search. |
14 | | * |
15 | | * This includes rdcost estimations, histogram based pruning, etc. |
16 | | */ |
17 | | #ifndef AOM_AV1_ENCODER_INTRA_MODE_SEARCH_UTILS_H_ |
18 | | #define AOM_AV1_ENCODER_INTRA_MODE_SEARCH_UTILS_H_ |
19 | | |
20 | | #include "av1/common/enums.h" |
21 | | #include "av1/common/pred_common.h" |
22 | | #include "av1/common/reconintra.h" |
23 | | |
24 | | #include "av1/encoder/encoder.h" |
25 | | #include "av1/encoder/encodeframe.h" |
26 | | #include "av1/encoder/model_rd.h" |
27 | | #include "av1/encoder/palette.h" |
28 | | #include "av1/encoder/hybrid_fwd_txfm.h" |
29 | | |
30 | | #ifdef __cplusplus |
31 | | extern "C" { |
32 | | #endif |
33 | | |
34 | | /*!\cond */ |
35 | 7.44M | #define BINS 32 |
36 | | static const float av1_intra_hog_model_bias[DIRECTIONAL_MODES] = { |
37 | | 0.450578f, 0.695518f, -0.717944f, -0.639894f, |
38 | | -0.602019f, -0.453454f, 0.055857f, -0.465480f, |
39 | | }; |
40 | | |
41 | | static const float av1_intra_hog_model_weights[BINS * DIRECTIONAL_MODES] = { |
42 | | -3.076402f, -3.757063f, -3.275266f, -3.180665f, -3.452105f, -3.216593f, |
43 | | -2.871212f, -3.134296f, -1.822324f, -2.401411f, -1.541016f, -1.195322f, |
44 | | -0.434156f, 0.322868f, 2.260546f, 3.368715f, 3.989290f, 3.308487f, |
45 | | 2.277893f, 0.923793f, 0.026412f, -0.385174f, -0.718622f, -1.408867f, |
46 | | -1.050558f, -2.323941f, -2.225827f, -2.585453f, -3.054283f, -2.875087f, |
47 | | -2.985709f, -3.447155f, 3.758139f, 3.204353f, 2.170998f, 0.826587f, |
48 | | -0.269665f, -0.702068f, -1.085776f, -2.175249f, -1.623180f, -2.975142f, |
49 | | -2.779629f, -3.190799f, -3.521900f, -3.375480f, -3.319355f, -3.897389f, |
50 | | -3.172334f, -3.594528f, -2.879132f, -2.547777f, -2.921023f, -2.281844f, |
51 | | -1.818988f, -2.041771f, -0.618268f, -1.396458f, -0.567153f, -0.285868f, |
52 | | -0.088058f, 0.753494f, 2.092413f, 3.215266f, -3.300277f, -2.748658f, |
53 | | -2.315784f, -2.423671f, -2.257283f, -2.269583f, -2.196660f, -2.301076f, |
54 | | -2.646516f, -2.271319f, -2.254366f, -2.300102f, -2.217960f, -2.473300f, |
55 | | -2.116866f, -2.528246f, -3.314712f, -1.701010f, -0.589040f, -0.088077f, |
56 | | 0.813112f, 1.702213f, 2.653045f, 3.351749f, 3.243554f, 3.199409f, |
57 | | 2.437856f, 1.468854f, 0.533039f, -0.099065f, -0.622643f, -2.200732f, |
58 | | -4.228861f, -2.875263f, -1.273956f, -0.433280f, 0.803771f, 1.975043f, |
59 | | 3.179528f, 3.939064f, 3.454379f, 3.689386f, 3.116411f, 1.970991f, |
60 | | 0.798406f, -0.628514f, -1.252546f, -2.825176f, -4.090178f, -3.777448f, |
61 | | -3.227314f, -3.479403f, -3.320569f, -3.159372f, -2.729202f, -2.722341f, |
62 | | -3.054913f, -2.742923f, -2.612703f, -2.662632f, -2.907314f, -3.117794f, |
63 | | -3.102660f, -3.970972f, -4.891357f, -3.935582f, -3.347758f, -2.721924f, |
64 | | -2.219011f, -1.702391f, -0.866529f, -0.153743f, 0.107733f, 1.416882f, |
65 | | 2.572884f, 3.607755f, 3.974820f, 3.997783f, 2.970459f, 0.791687f, |
66 | | -1.478921f, -1.228154f, -1.216955f, -1.765932f, -1.951003f, -1.985301f, |
67 | | -1.975881f, -1.985593f, -2.422371f, -2.419978f, -2.531288f, -2.951853f, |
68 | | -3.071380f, -3.277027f, -3.373539f, -4.462010f, -0.967888f, 0.805524f, |
69 | | 2.794130f, 3.685984f, 3.745195f, 3.252444f, 2.316108f, 1.399146f, |
70 | | -0.136519f, -0.162811f, -1.004357f, -1.667911f, -1.964662f, -2.937579f, |
71 | | -3.019533f, -3.942766f, -5.102767f, -3.882073f, -3.532027f, -3.451956f, |
72 | | -2.944015f, -2.643064f, -2.529872f, -2.077290f, -2.809965f, -1.803734f, |
73 | | -1.783593f, -1.662585f, -1.415484f, -1.392673f, -0.788794f, -1.204819f, |
74 | | -1.998864f, -1.182102f, -0.892110f, -1.317415f, -1.359112f, -1.522867f, |
75 | | -1.468552f, -1.779072f, -2.332959f, -2.160346f, -2.329387f, -2.631259f, |
76 | | -2.744936f, -3.052494f, -2.787363f, -3.442548f, -4.245075f, -3.032172f, |
77 | | -2.061609f, -1.768116f, -1.286072f, -0.706587f, -0.192413f, 0.386938f, |
78 | | 0.716997f, 1.481393f, 2.216702f, 2.737986f, 3.109809f, 3.226084f, |
79 | | 2.490098f, -0.095827f, -3.864816f, -3.507248f, -3.128925f, -2.908251f, |
80 | | -2.883836f, -2.881411f, -2.524377f, -2.624478f, -2.399573f, -2.367718f, |
81 | | -1.918255f, -1.926277f, -1.694584f, -1.723790f, -0.966491f, -1.183115f, |
82 | | -1.430687f, 0.872896f, 2.766550f, 3.610080f, 3.578041f, 3.334928f, |
83 | | 2.586680f, 1.895721f, 1.122195f, 0.488519f, -0.140689f, -0.799076f, |
84 | | -1.222860f, -1.502437f, -1.900969f, -3.206816f, |
85 | | }; |
86 | | |
87 | | static const NN_CONFIG av1_intra_hog_model_nnconfig = { |
88 | | BINS, // num_inputs |
89 | | DIRECTIONAL_MODES, // num_outputs |
90 | | 0, // num_hidden_layers |
91 | | { 0 }, |
92 | | { |
93 | | av1_intra_hog_model_weights, |
94 | | }, |
95 | | { |
96 | | av1_intra_hog_model_bias, |
97 | | }, |
98 | | }; |
99 | | |
100 | 0 | #define FIX_PREC_BITS (16) |
101 | 0 | static AOM_INLINE int get_hist_bin_idx(int dx, int dy) { |
102 | 0 | const int32_t ratio = (dy * (1 << FIX_PREC_BITS)) / dx; |
103 | | |
104 | | // Find index by bisection |
105 | 0 | static const int thresholds[BINS] = { |
106 | 0 | -1334015, -441798, -261605, -183158, -138560, -109331, -88359, -72303, |
107 | 0 | -59392, -48579, -39272, -30982, -23445, -16400, -9715, -3194, |
108 | 0 | 3227, 9748, 16433, 23478, 31015, 39305, 48611, 59425, |
109 | 0 | 72336, 88392, 109364, 138593, 183191, 261638, 441831, INT32_MAX |
110 | 0 | }; |
111 | |
|
112 | 0 | int lo_idx = 0, hi_idx = BINS - 1; |
113 | | // Divide into segments of size 8 gives better performance than binary search |
114 | | // here. |
115 | 0 | if (ratio <= thresholds[7]) { |
116 | 0 | lo_idx = 0; |
117 | 0 | hi_idx = 7; |
118 | 0 | } else if (ratio <= thresholds[15]) { |
119 | 0 | lo_idx = 8; |
120 | 0 | hi_idx = 15; |
121 | 0 | } else if (ratio <= thresholds[23]) { |
122 | 0 | lo_idx = 16; |
123 | 0 | hi_idx = 23; |
124 | 0 | } else { |
125 | 0 | lo_idx = 24; |
126 | 0 | hi_idx = 31; |
127 | 0 | } |
128 | |
|
129 | 0 | for (int idx = lo_idx; idx <= hi_idx; idx++) { |
130 | 0 | if (ratio <= thresholds[idx]) { |
131 | 0 | return idx; |
132 | 0 | } |
133 | 0 | } |
134 | 0 | assert(0 && "No valid histogram bin found!"); |
135 | 0 | return BINS - 1; |
136 | 0 | } Unexecuted instantiation: encoder.c:get_hist_bin_idx Unexecuted instantiation: encoder_utils.c:get_hist_bin_idx Unexecuted instantiation: ethread.c:get_hist_bin_idx Unexecuted instantiation: palette.c:get_hist_bin_idx Unexecuted instantiation: rdopt.c:get_hist_bin_idx Unexecuted instantiation: superres_scale.c:get_hist_bin_idx Unexecuted instantiation: svc_layercontext.c:get_hist_bin_idx Unexecuted instantiation: intra_mode_search.c:get_hist_bin_idx Unexecuted instantiation: compound_type.c:get_hist_bin_idx Unexecuted instantiation: encodeframe.c:get_hist_bin_idx Unexecuted instantiation: encode_strategy.c:get_hist_bin_idx |
137 | | #undef FIX_PREC_BITS |
138 | | |
139 | | // Normalizes the hog data. |
140 | 112k | static AOM_INLINE void normalize_hog(float total, float *hist) { |
141 | 3.72M | for (int i = 0; i < BINS; ++i) hist[i] /= total; |
142 | 112k | } Unexecuted instantiation: encoder.c:normalize_hog Unexecuted instantiation: encoder_utils.c:normalize_hog Unexecuted instantiation: ethread.c:normalize_hog Unexecuted instantiation: palette.c:normalize_hog Unexecuted instantiation: rdopt.c:normalize_hog Unexecuted instantiation: superres_scale.c:normalize_hog Unexecuted instantiation: svc_layercontext.c:normalize_hog intra_mode_search.c:normalize_hog Line | Count | Source | 140 | 112k | static AOM_INLINE void normalize_hog(float total, float *hist) { | 141 | 3.72M | for (int i = 0; i < BINS; ++i) hist[i] /= total; | 142 | 112k | } |
Unexecuted instantiation: compound_type.c:normalize_hog Unexecuted instantiation: encodeframe.c:normalize_hog Unexecuted instantiation: encode_strategy.c:normalize_hog |
143 | | |
144 | | static AOM_INLINE void lowbd_generate_hog(const uint8_t *src, int stride, |
145 | 0 | int rows, int cols, float *hist) { |
146 | 0 | float total = 0.1f; |
147 | 0 | src += stride; |
148 | 0 | for (int r = 1; r < rows - 1; ++r) { |
149 | 0 | for (int c = 1; c < cols - 1; ++c) { |
150 | 0 | const uint8_t *above = &src[c - stride]; |
151 | 0 | const uint8_t *below = &src[c + stride]; |
152 | 0 | const uint8_t *left = &src[c - 1]; |
153 | 0 | const uint8_t *right = &src[c + 1]; |
154 | | // Calculate gradient using Sobel filters. |
155 | 0 | const int dx = (right[-stride] + 2 * right[0] + right[stride]) - |
156 | 0 | (left[-stride] + 2 * left[0] + left[stride]); |
157 | 0 | const int dy = (below[-1] + 2 * below[0] + below[1]) - |
158 | 0 | (above[-1] + 2 * above[0] + above[1]); |
159 | 0 | if (dx == 0 && dy == 0) continue; |
160 | 0 | const int temp = abs(dx) + abs(dy); |
161 | 0 | if (!temp) continue; |
162 | 0 | total += temp; |
163 | 0 | if (dx == 0) { |
164 | 0 | hist[0] += temp / 2; |
165 | 0 | hist[BINS - 1] += temp / 2; |
166 | 0 | } else { |
167 | 0 | const int idx = get_hist_bin_idx(dx, dy); |
168 | 0 | assert(idx >= 0 && idx < BINS); |
169 | 0 | hist[idx] += temp; |
170 | 0 | } |
171 | 0 | } |
172 | 0 | src += stride; |
173 | 0 | } |
174 | |
|
175 | 0 | normalize_hog(total, hist); |
176 | 0 | } Unexecuted instantiation: encoder.c:lowbd_generate_hog Unexecuted instantiation: encoder_utils.c:lowbd_generate_hog Unexecuted instantiation: ethread.c:lowbd_generate_hog Unexecuted instantiation: palette.c:lowbd_generate_hog Unexecuted instantiation: rdopt.c:lowbd_generate_hog Unexecuted instantiation: superres_scale.c:lowbd_generate_hog Unexecuted instantiation: svc_layercontext.c:lowbd_generate_hog Unexecuted instantiation: intra_mode_search.c:lowbd_generate_hog Unexecuted instantiation: compound_type.c:lowbd_generate_hog Unexecuted instantiation: encodeframe.c:lowbd_generate_hog Unexecuted instantiation: encode_strategy.c:lowbd_generate_hog |
177 | | |
178 | | // Computes and stores pixel level gradient information of a given superblock |
179 | | // for LBD encode. |
180 | | static AOM_INLINE void lowbd_compute_gradient_info_sb(MACROBLOCK *const x, |
181 | | BLOCK_SIZE sb_size, |
182 | 23.5k | PLANE_TYPE plane) { |
183 | 23.5k | PixelLevelGradientInfo *const grad_info_sb = |
184 | 23.5k | x->pixel_gradient_info + plane * MAX_SB_SQUARE; |
185 | 23.5k | const uint8_t *src = x->plane[plane].src.buf; |
186 | 23.5k | const int stride = x->plane[plane].src.stride; |
187 | 23.5k | const int ss_x = x->e_mbd.plane[plane].subsampling_x; |
188 | 23.5k | const int ss_y = x->e_mbd.plane[plane].subsampling_y; |
189 | 23.5k | const int sb_height = block_size_high[sb_size] >> ss_y; |
190 | 23.5k | const int sb_width = block_size_wide[sb_size] >> ss_x; |
191 | 23.5k | src += stride; |
192 | 1.09M | for (int r = 1; r < sb_height - 1; ++r) { |
193 | 55.3M | for (int c = 1; c < sb_width - 1; ++c) { |
194 | 54.2M | const uint8_t *above = &src[c - stride]; |
195 | 54.2M | const uint8_t *below = &src[c + stride]; |
196 | 54.2M | const uint8_t *left = &src[c - 1]; |
197 | 54.2M | const uint8_t *right = &src[c + 1]; |
198 | | // Calculate gradient using Sobel filters. |
199 | 54.2M | const int dx = (right[-stride] + 2 * right[0] + right[stride]) - |
200 | 54.2M | (left[-stride] + 2 * left[0] + left[stride]); |
201 | 54.2M | const int dy = (below[-1] + 2 * below[0] + below[1]) - |
202 | 54.2M | (above[-1] + 2 * above[0] + above[1]); |
203 | 54.2M | grad_info_sb[r * sb_width + c].is_dx_zero = (dx == 0); |
204 | 54.2M | grad_info_sb[r * sb_width + c].abs_dx_abs_dy_sum = |
205 | 54.2M | (uint16_t)(abs(dx) + abs(dy)); |
206 | 54.2M | grad_info_sb[r * sb_width + c].hist_bin_idx = |
207 | 54.2M | (dx != 0) ? get_hist_bin_idx(dx, dy) : -1; |
208 | 54.2M | } |
209 | 1.07M | src += stride; |
210 | 1.07M | } |
211 | 23.5k | } Unexecuted instantiation: encoder.c:lowbd_compute_gradient_info_sb Unexecuted instantiation: encoder_utils.c:lowbd_compute_gradient_info_sb Unexecuted instantiation: ethread.c:lowbd_compute_gradient_info_sb Unexecuted instantiation: palette.c:lowbd_compute_gradient_info_sb Unexecuted instantiation: rdopt.c:lowbd_compute_gradient_info_sb Unexecuted instantiation: superres_scale.c:lowbd_compute_gradient_info_sb Unexecuted instantiation: svc_layercontext.c:lowbd_compute_gradient_info_sb Unexecuted instantiation: intra_mode_search.c:lowbd_compute_gradient_info_sb Unexecuted instantiation: compound_type.c:lowbd_compute_gradient_info_sb encodeframe.c:lowbd_compute_gradient_info_sb Line | Count | Source | 182 | 23.5k | PLANE_TYPE plane) { | 183 | 23.5k | PixelLevelGradientInfo *const grad_info_sb = | 184 | 23.5k | x->pixel_gradient_info + plane * MAX_SB_SQUARE; | 185 | 23.5k | const uint8_t *src = x->plane[plane].src.buf; | 186 | 23.5k | const int stride = x->plane[plane].src.stride; | 187 | 23.5k | const int ss_x = x->e_mbd.plane[plane].subsampling_x; | 188 | 23.5k | const int ss_y = x->e_mbd.plane[plane].subsampling_y; | 189 | 23.5k | const int sb_height = block_size_high[sb_size] >> ss_y; | 190 | 23.5k | const int sb_width = block_size_wide[sb_size] >> ss_x; | 191 | 23.5k | src += stride; | 192 | 1.09M | for (int r = 1; r < sb_height - 1; ++r) { | 193 | 55.3M | for (int c = 1; c < sb_width - 1; ++c) { | 194 | 54.2M | const uint8_t *above = &src[c - stride]; | 195 | 54.2M | const uint8_t *below = &src[c + stride]; | 196 | 54.2M | const uint8_t *left = &src[c - 1]; | 197 | 54.2M | const uint8_t *right = &src[c + 1]; | 198 | | // Calculate gradient using Sobel filters. | 199 | 54.2M | const int dx = (right[-stride] + 2 * right[0] + right[stride]) - | 200 | 54.2M | (left[-stride] + 2 * left[0] + left[stride]); | 201 | 54.2M | const int dy = (below[-1] + 2 * below[0] + below[1]) - | 202 | 54.2M | (above[-1] + 2 * above[0] + above[1]); | 203 | 54.2M | grad_info_sb[r * sb_width + c].is_dx_zero = (dx == 0); | 204 | 54.2M | grad_info_sb[r * sb_width + c].abs_dx_abs_dy_sum = | 205 | 54.2M | (uint16_t)(abs(dx) + abs(dy)); | 206 | 54.2M | grad_info_sb[r * sb_width + c].hist_bin_idx = | 207 | 54.2M | (dx != 0) ? get_hist_bin_idx(dx, dy) : -1; | 208 | 54.2M | } | 209 | 1.07M | src += stride; | 210 | 1.07M | } | 211 | 23.5k | } |
Unexecuted instantiation: encode_strategy.c:lowbd_compute_gradient_info_sb |
212 | | |
213 | | #if CONFIG_AV1_HIGHBITDEPTH |
214 | | static AOM_INLINE void highbd_generate_hog(const uint8_t *src8, int stride, |
215 | 0 | int rows, int cols, float *hist) { |
216 | 0 | float total = 0.1f; |
217 | 0 | const uint16_t *src = CONVERT_TO_SHORTPTR(src8); |
218 | 0 | src += stride; |
219 | 0 | for (int r = 1; r < rows - 1; ++r) { |
220 | 0 | for (int c = 1; c < cols - 1; ++c) { |
221 | 0 | const uint16_t *above = &src[c - stride]; |
222 | 0 | const uint16_t *below = &src[c + stride]; |
223 | 0 | const uint16_t *left = &src[c - 1]; |
224 | 0 | const uint16_t *right = &src[c + 1]; |
225 | | // Calculate gradient using Sobel filters. |
226 | 0 | const int dx = (right[-stride] + 2 * right[0] + right[stride]) - |
227 | 0 | (left[-stride] + 2 * left[0] + left[stride]); |
228 | 0 | const int dy = (below[-1] + 2 * below[0] + below[1]) - |
229 | 0 | (above[-1] + 2 * above[0] + above[1]); |
230 | 0 | if (dx == 0 && dy == 0) continue; |
231 | 0 | const int temp = abs(dx) + abs(dy); |
232 | 0 | if (!temp) continue; |
233 | 0 | total += temp; |
234 | 0 | if (dx == 0) { |
235 | 0 | hist[0] += temp / 2; |
236 | 0 | hist[BINS - 1] += temp / 2; |
237 | 0 | } else { |
238 | 0 | const int idx = get_hist_bin_idx(dx, dy); |
239 | 0 | assert(idx >= 0 && idx < BINS); |
240 | 0 | hist[idx] += temp; |
241 | 0 | } |
242 | 0 | } |
243 | 0 | src += stride; |
244 | 0 | } |
245 | |
|
246 | 0 | normalize_hog(total, hist); |
247 | 0 | } Unexecuted instantiation: encoder.c:highbd_generate_hog Unexecuted instantiation: encoder_utils.c:highbd_generate_hog Unexecuted instantiation: ethread.c:highbd_generate_hog Unexecuted instantiation: palette.c:highbd_generate_hog Unexecuted instantiation: rdopt.c:highbd_generate_hog Unexecuted instantiation: superres_scale.c:highbd_generate_hog Unexecuted instantiation: svc_layercontext.c:highbd_generate_hog Unexecuted instantiation: intra_mode_search.c:highbd_generate_hog Unexecuted instantiation: compound_type.c:highbd_generate_hog Unexecuted instantiation: encodeframe.c:highbd_generate_hog Unexecuted instantiation: encode_strategy.c:highbd_generate_hog |
248 | | |
249 | | // Computes and stores pixel level gradient information of a given superblock |
250 | | // for HBD encode. |
251 | | static AOM_INLINE void highbd_compute_gradient_info_sb(MACROBLOCK *const x, |
252 | | BLOCK_SIZE sb_size, |
253 | 0 | PLANE_TYPE plane) { |
254 | 0 | PixelLevelGradientInfo *const grad_info_sb = |
255 | 0 | x->pixel_gradient_info + plane * MAX_SB_SQUARE; |
256 | 0 | const uint16_t *src = CONVERT_TO_SHORTPTR(x->plane[plane].src.buf); |
257 | 0 | const int stride = x->plane[plane].src.stride; |
258 | 0 | const int ss_x = x->e_mbd.plane[plane].subsampling_x; |
259 | 0 | const int ss_y = x->e_mbd.plane[plane].subsampling_y; |
260 | 0 | const int sb_height = block_size_high[sb_size] >> ss_y; |
261 | 0 | const int sb_width = block_size_wide[sb_size] >> ss_x; |
262 | 0 | src += stride; |
263 | 0 | for (int r = 1; r < sb_height - 1; ++r) { |
264 | 0 | for (int c = 1; c < sb_width - 1; ++c) { |
265 | 0 | const uint16_t *above = &src[c - stride]; |
266 | 0 | const uint16_t *below = &src[c + stride]; |
267 | 0 | const uint16_t *left = &src[c - 1]; |
268 | 0 | const uint16_t *right = &src[c + 1]; |
269 | | // Calculate gradient using Sobel filters. |
270 | 0 | const int dx = (right[-stride] + 2 * right[0] + right[stride]) - |
271 | 0 | (left[-stride] + 2 * left[0] + left[stride]); |
272 | 0 | const int dy = (below[-1] + 2 * below[0] + below[1]) - |
273 | 0 | (above[-1] + 2 * above[0] + above[1]); |
274 | 0 | grad_info_sb[r * sb_width + c].is_dx_zero = (dx == 0); |
275 | 0 | grad_info_sb[r * sb_width + c].abs_dx_abs_dy_sum = |
276 | 0 | (uint16_t)(abs(dx) + abs(dy)); |
277 | 0 | grad_info_sb[r * sb_width + c].hist_bin_idx = |
278 | 0 | (dx != 0) ? get_hist_bin_idx(dx, dy) : -1; |
279 | 0 | } |
280 | 0 | src += stride; |
281 | 0 | } |
282 | 0 | } Unexecuted instantiation: encoder.c:highbd_compute_gradient_info_sb Unexecuted instantiation: encoder_utils.c:highbd_compute_gradient_info_sb Unexecuted instantiation: ethread.c:highbd_compute_gradient_info_sb Unexecuted instantiation: palette.c:highbd_compute_gradient_info_sb Unexecuted instantiation: rdopt.c:highbd_compute_gradient_info_sb Unexecuted instantiation: superres_scale.c:highbd_compute_gradient_info_sb Unexecuted instantiation: svc_layercontext.c:highbd_compute_gradient_info_sb Unexecuted instantiation: intra_mode_search.c:highbd_compute_gradient_info_sb Unexecuted instantiation: compound_type.c:highbd_compute_gradient_info_sb Unexecuted instantiation: encodeframe.c:highbd_compute_gradient_info_sb Unexecuted instantiation: encode_strategy.c:highbd_compute_gradient_info_sb |
283 | | #endif // CONFIG_AV1_HIGHBITDEPTH |
284 | | |
285 | | static AOM_INLINE void generate_hog(const uint8_t *src8, int stride, int rows, |
286 | 0 | int cols, float *hist, int highbd) { |
287 | 0 | #if CONFIG_AV1_HIGHBITDEPTH |
288 | 0 | if (highbd) { |
289 | 0 | highbd_generate_hog(src8, stride, rows, cols, hist); |
290 | 0 | return; |
291 | 0 | } |
292 | | #else |
293 | | (void)highbd; |
294 | | #endif // CONFIG_AV1_HIGHBITDEPTH |
295 | 0 | lowbd_generate_hog(src8, stride, rows, cols, hist); |
296 | 0 | } Unexecuted instantiation: encoder.c:generate_hog Unexecuted instantiation: encoder_utils.c:generate_hog Unexecuted instantiation: ethread.c:generate_hog Unexecuted instantiation: palette.c:generate_hog Unexecuted instantiation: rdopt.c:generate_hog Unexecuted instantiation: superres_scale.c:generate_hog Unexecuted instantiation: svc_layercontext.c:generate_hog Unexecuted instantiation: intra_mode_search.c:generate_hog Unexecuted instantiation: compound_type.c:generate_hog Unexecuted instantiation: encodeframe.c:generate_hog Unexecuted instantiation: encode_strategy.c:generate_hog |
297 | | |
298 | | static AOM_INLINE void compute_gradient_info_sb(MACROBLOCK *const x, |
299 | | BLOCK_SIZE sb_size, |
300 | 23.5k | PLANE_TYPE plane) { |
301 | 23.5k | #if CONFIG_AV1_HIGHBITDEPTH |
302 | 23.5k | if (is_cur_buf_hbd(&x->e_mbd)) { |
303 | 0 | highbd_compute_gradient_info_sb(x, sb_size, plane); |
304 | 0 | return; |
305 | 0 | } |
306 | 23.5k | #endif // CONFIG_AV1_HIGHBITDEPTH |
307 | 23.5k | lowbd_compute_gradient_info_sb(x, sb_size, plane); |
308 | 23.5k | } Unexecuted instantiation: encoder.c:compute_gradient_info_sb Unexecuted instantiation: encoder_utils.c:compute_gradient_info_sb Unexecuted instantiation: ethread.c:compute_gradient_info_sb Unexecuted instantiation: palette.c:compute_gradient_info_sb Unexecuted instantiation: rdopt.c:compute_gradient_info_sb Unexecuted instantiation: superres_scale.c:compute_gradient_info_sb Unexecuted instantiation: svc_layercontext.c:compute_gradient_info_sb Unexecuted instantiation: intra_mode_search.c:compute_gradient_info_sb Unexecuted instantiation: compound_type.c:compute_gradient_info_sb encodeframe.c:compute_gradient_info_sb Line | Count | Source | 300 | 23.5k | PLANE_TYPE plane) { | 301 | 23.5k | #if CONFIG_AV1_HIGHBITDEPTH | 302 | 23.5k | if (is_cur_buf_hbd(&x->e_mbd)) { | 303 | 0 | highbd_compute_gradient_info_sb(x, sb_size, plane); | 304 | 0 | return; | 305 | 0 | } | 306 | 23.5k | #endif // CONFIG_AV1_HIGHBITDEPTH | 307 | 23.5k | lowbd_compute_gradient_info_sb(x, sb_size, plane); | 308 | 23.5k | } |
Unexecuted instantiation: encode_strategy.c:compute_gradient_info_sb |
309 | | |
310 | | // Gradient caching at superblock level is allowed only if all of the following |
311 | | // conditions are satisfied: |
312 | | // (1) The current frame is an intra only frame |
313 | | // (2) Non-RD mode decisions are not enabled |
314 | | // (3) The sf partition_search_type is set to SEARCH_PARTITION |
315 | | // (4) Either intra_pruning_with_hog or chroma_intra_pruning_with_hog is enabled |
316 | | // |
317 | | // SB level caching of gradient data may not help in speedup for the following |
318 | | // cases: |
319 | | // (1) Inter frames (due to early intra gating) |
320 | | // (2) When partition_search_type is not SEARCH_PARTITION |
321 | | // Hence, gradient data is computed at block level in such cases. |
322 | | static AOM_INLINE bool is_gradient_caching_for_hog_enabled( |
323 | 13.8k | const AV1_COMP *const cpi) { |
324 | 13.8k | const SPEED_FEATURES *const sf = &cpi->sf; |
325 | 13.8k | return frame_is_intra_only(&cpi->common) && !sf->rt_sf.use_nonrd_pick_mode && |
326 | 13.8k | (sf->part_sf.partition_search_type == SEARCH_PARTITION) && |
327 | 13.8k | (sf->intra_sf.intra_pruning_with_hog || |
328 | 13.8k | sf->intra_sf.chroma_intra_pruning_with_hog); |
329 | 13.8k | } encoder.c:is_gradient_caching_for_hog_enabled Line | Count | Source | 323 | 1.26k | const AV1_COMP *const cpi) { | 324 | 1.26k | const SPEED_FEATURES *const sf = &cpi->sf; | 325 | 1.26k | return frame_is_intra_only(&cpi->common) && !sf->rt_sf.use_nonrd_pick_mode && | 326 | 1.26k | (sf->part_sf.partition_search_type == SEARCH_PARTITION) && | 327 | 1.26k | (sf->intra_sf.intra_pruning_with_hog || | 328 | 1.26k | sf->intra_sf.chroma_intra_pruning_with_hog); | 329 | 1.26k | } |
Unexecuted instantiation: encoder_utils.c:is_gradient_caching_for_hog_enabled ethread.c:is_gradient_caching_for_hog_enabled Line | Count | Source | 323 | 830 | const AV1_COMP *const cpi) { | 324 | 830 | const SPEED_FEATURES *const sf = &cpi->sf; | 325 | 830 | return frame_is_intra_only(&cpi->common) && !sf->rt_sf.use_nonrd_pick_mode && | 326 | 830 | (sf->part_sf.partition_search_type == SEARCH_PARTITION) && | 327 | 830 | (sf->intra_sf.intra_pruning_with_hog || | 328 | 830 | sf->intra_sf.chroma_intra_pruning_with_hog); | 329 | 830 | } |
Unexecuted instantiation: palette.c:is_gradient_caching_for_hog_enabled Unexecuted instantiation: rdopt.c:is_gradient_caching_for_hog_enabled Unexecuted instantiation: superres_scale.c:is_gradient_caching_for_hog_enabled Unexecuted instantiation: svc_layercontext.c:is_gradient_caching_for_hog_enabled Unexecuted instantiation: intra_mode_search.c:is_gradient_caching_for_hog_enabled Unexecuted instantiation: compound_type.c:is_gradient_caching_for_hog_enabled encodeframe.c:is_gradient_caching_for_hog_enabled Line | Count | Source | 323 | 11.7k | const AV1_COMP *const cpi) { | 324 | 11.7k | const SPEED_FEATURES *const sf = &cpi->sf; | 325 | 11.7k | return frame_is_intra_only(&cpi->common) && !sf->rt_sf.use_nonrd_pick_mode && | 326 | 11.7k | (sf->part_sf.partition_search_type == SEARCH_PARTITION) && | 327 | 11.7k | (sf->intra_sf.intra_pruning_with_hog || | 328 | 11.7k | sf->intra_sf.chroma_intra_pruning_with_hog); | 329 | 11.7k | } |
Unexecuted instantiation: encode_strategy.c:is_gradient_caching_for_hog_enabled |
330 | | |
331 | | // Function to generate pixel level gradient information for a given superblock. |
332 | | // Sets the flags 'is_sb_gradient_cached' for the specific plane-type if |
333 | | // gradient info is generated for the same. |
334 | | static AOM_INLINE void produce_gradients_for_sb(AV1_COMP *cpi, MACROBLOCK *x, |
335 | | BLOCK_SIZE sb_size, int mi_row, |
336 | 11.7k | int mi_col) { |
337 | | // Initialise flags related to hog data caching. |
338 | 11.7k | x->is_sb_gradient_cached[PLANE_TYPE_Y] = false; |
339 | 11.7k | x->is_sb_gradient_cached[PLANE_TYPE_UV] = false; |
340 | 11.7k | if (!is_gradient_caching_for_hog_enabled(cpi)) return; |
341 | | |
342 | 11.7k | const SPEED_FEATURES *sf = &cpi->sf; |
343 | 11.7k | const int num_planes = av1_num_planes(&cpi->common); |
344 | | |
345 | 11.7k | av1_setup_src_planes(x, cpi->source, mi_row, mi_col, num_planes, sb_size); |
346 | | |
347 | 11.7k | if (sf->intra_sf.intra_pruning_with_hog) { |
348 | 11.7k | compute_gradient_info_sb(x, sb_size, PLANE_TYPE_Y); |
349 | 11.7k | x->is_sb_gradient_cached[PLANE_TYPE_Y] = true; |
350 | 11.7k | } |
351 | 11.7k | if (sf->intra_sf.chroma_intra_pruning_with_hog && num_planes > 1) { |
352 | 11.7k | compute_gradient_info_sb(x, sb_size, PLANE_TYPE_UV); |
353 | 11.7k | x->is_sb_gradient_cached[PLANE_TYPE_UV] = true; |
354 | 11.7k | } |
355 | 11.7k | } Unexecuted instantiation: encoder.c:produce_gradients_for_sb Unexecuted instantiation: encoder_utils.c:produce_gradients_for_sb Unexecuted instantiation: ethread.c:produce_gradients_for_sb Unexecuted instantiation: palette.c:produce_gradients_for_sb Unexecuted instantiation: rdopt.c:produce_gradients_for_sb Unexecuted instantiation: superres_scale.c:produce_gradients_for_sb Unexecuted instantiation: svc_layercontext.c:produce_gradients_for_sb Unexecuted instantiation: intra_mode_search.c:produce_gradients_for_sb Unexecuted instantiation: compound_type.c:produce_gradients_for_sb encodeframe.c:produce_gradients_for_sb Line | Count | Source | 336 | 11.7k | int mi_col) { | 337 | | // Initialise flags related to hog data caching. | 338 | 11.7k | x->is_sb_gradient_cached[PLANE_TYPE_Y] = false; | 339 | 11.7k | x->is_sb_gradient_cached[PLANE_TYPE_UV] = false; | 340 | 11.7k | if (!is_gradient_caching_for_hog_enabled(cpi)) return; | 341 | | | 342 | 11.7k | const SPEED_FEATURES *sf = &cpi->sf; | 343 | 11.7k | const int num_planes = av1_num_planes(&cpi->common); | 344 | | | 345 | 11.7k | av1_setup_src_planes(x, cpi->source, mi_row, mi_col, num_planes, sb_size); | 346 | | | 347 | 11.7k | if (sf->intra_sf.intra_pruning_with_hog) { | 348 | 11.7k | compute_gradient_info_sb(x, sb_size, PLANE_TYPE_Y); | 349 | 11.7k | x->is_sb_gradient_cached[PLANE_TYPE_Y] = true; | 350 | 11.7k | } | 351 | 11.7k | if (sf->intra_sf.chroma_intra_pruning_with_hog && num_planes > 1) { | 352 | 11.7k | compute_gradient_info_sb(x, sb_size, PLANE_TYPE_UV); | 353 | 11.7k | x->is_sb_gradient_cached[PLANE_TYPE_UV] = true; | 354 | 11.7k | } | 355 | 11.7k | } |
Unexecuted instantiation: encode_strategy.c:produce_gradients_for_sb |
356 | | |
357 | | // Reuses the pixel level gradient data generated at superblock level for block |
358 | | // level histogram computation. |
359 | | static AOM_INLINE void generate_hog_using_gradient_cache(const MACROBLOCK *x, |
360 | | int rows, int cols, |
361 | | BLOCK_SIZE sb_size, |
362 | | PLANE_TYPE plane, |
363 | 112k | float *hist) { |
364 | 112k | float total = 0.1f; |
365 | 112k | const int ss_x = x->e_mbd.plane[plane].subsampling_x; |
366 | 112k | const int ss_y = x->e_mbd.plane[plane].subsampling_y; |
367 | 112k | const int sb_width = block_size_wide[sb_size] >> ss_x; |
368 | | |
369 | | // Derive the offset from the starting of the superblock in order to locate |
370 | | // the block level gradient data in the cache. |
371 | 112k | const int mi_row_in_sb = x->e_mbd.mi_row & (mi_size_high[sb_size] - 1); |
372 | 112k | const int mi_col_in_sb = x->e_mbd.mi_col & (mi_size_wide[sb_size] - 1); |
373 | 112k | const int block_offset_in_grad_cache = |
374 | 112k | sb_width * (mi_row_in_sb << (MI_SIZE_LOG2 - ss_y)) + |
375 | 112k | (mi_col_in_sb << (MI_SIZE_LOG2 - ss_x)); |
376 | 112k | const PixelLevelGradientInfo *grad_info_blk = x->pixel_gradient_info + |
377 | 112k | plane * MAX_SB_SQUARE + |
378 | 112k | block_offset_in_grad_cache; |
379 | | |
380 | | // Retrieve the cached gradient information and generate the histogram. |
381 | 1.70M | for (int r = 1; r < rows - 1; ++r) { |
382 | 46.4M | for (int c = 1; c < cols - 1; ++c) { |
383 | 44.8M | const uint16_t abs_dx_abs_dy_sum = |
384 | 44.8M | grad_info_blk[r * sb_width + c].abs_dx_abs_dy_sum; |
385 | 44.8M | if (!abs_dx_abs_dy_sum) continue; |
386 | 18.4E | total += abs_dx_abs_dy_sum; |
387 | 18.4E | const bool is_dx_zero = grad_info_blk[r * sb_width + c].is_dx_zero; |
388 | 18.4E | if (is_dx_zero) { |
389 | 0 | hist[0] += abs_dx_abs_dy_sum >> 1; |
390 | 0 | hist[BINS - 1] += abs_dx_abs_dy_sum >> 1; |
391 | 18.4E | } else { |
392 | 18.4E | const int8_t idx = grad_info_blk[r * sb_width + c].hist_bin_idx; |
393 | 18.4E | assert(idx >= 0 && idx < BINS); |
394 | 18.4E | hist[idx] += abs_dx_abs_dy_sum; |
395 | 18.4E | } |
396 | 18.4E | } |
397 | 1.59M | } |
398 | 112k | normalize_hog(total, hist); |
399 | 112k | } Unexecuted instantiation: encoder.c:generate_hog_using_gradient_cache Unexecuted instantiation: encoder_utils.c:generate_hog_using_gradient_cache Unexecuted instantiation: ethread.c:generate_hog_using_gradient_cache Unexecuted instantiation: palette.c:generate_hog_using_gradient_cache Unexecuted instantiation: rdopt.c:generate_hog_using_gradient_cache Unexecuted instantiation: superres_scale.c:generate_hog_using_gradient_cache Unexecuted instantiation: svc_layercontext.c:generate_hog_using_gradient_cache intra_mode_search.c:generate_hog_using_gradient_cache Line | Count | Source | 363 | 112k | float *hist) { | 364 | 112k | float total = 0.1f; | 365 | 112k | const int ss_x = x->e_mbd.plane[plane].subsampling_x; | 366 | 112k | const int ss_y = x->e_mbd.plane[plane].subsampling_y; | 367 | 112k | const int sb_width = block_size_wide[sb_size] >> ss_x; | 368 | | | 369 | | // Derive the offset from the starting of the superblock in order to locate | 370 | | // the block level gradient data in the cache. | 371 | 112k | const int mi_row_in_sb = x->e_mbd.mi_row & (mi_size_high[sb_size] - 1); | 372 | 112k | const int mi_col_in_sb = x->e_mbd.mi_col & (mi_size_wide[sb_size] - 1); | 373 | 112k | const int block_offset_in_grad_cache = | 374 | 112k | sb_width * (mi_row_in_sb << (MI_SIZE_LOG2 - ss_y)) + | 375 | 112k | (mi_col_in_sb << (MI_SIZE_LOG2 - ss_x)); | 376 | 112k | const PixelLevelGradientInfo *grad_info_blk = x->pixel_gradient_info + | 377 | 112k | plane * MAX_SB_SQUARE + | 378 | 112k | block_offset_in_grad_cache; | 379 | | | 380 | | // Retrieve the cached gradient information and generate the histogram. | 381 | 1.70M | for (int r = 1; r < rows - 1; ++r) { | 382 | 46.4M | for (int c = 1; c < cols - 1; ++c) { | 383 | 44.8M | const uint16_t abs_dx_abs_dy_sum = | 384 | 44.8M | grad_info_blk[r * sb_width + c].abs_dx_abs_dy_sum; | 385 | 44.8M | if (!abs_dx_abs_dy_sum) continue; | 386 | 18.4E | total += abs_dx_abs_dy_sum; | 387 | 18.4E | const bool is_dx_zero = grad_info_blk[r * sb_width + c].is_dx_zero; | 388 | 18.4E | if (is_dx_zero) { | 389 | 0 | hist[0] += abs_dx_abs_dy_sum >> 1; | 390 | 0 | hist[BINS - 1] += abs_dx_abs_dy_sum >> 1; | 391 | 18.4E | } else { | 392 | 18.4E | const int8_t idx = grad_info_blk[r * sb_width + c].hist_bin_idx; | 393 | 18.4E | assert(idx >= 0 && idx < BINS); | 394 | 18.4E | hist[idx] += abs_dx_abs_dy_sum; | 395 | 18.4E | } | 396 | 18.4E | } | 397 | 1.59M | } | 398 | 112k | normalize_hog(total, hist); | 399 | 112k | } |
Unexecuted instantiation: compound_type.c:generate_hog_using_gradient_cache Unexecuted instantiation: encodeframe.c:generate_hog_using_gradient_cache Unexecuted instantiation: encode_strategy.c:generate_hog_using_gradient_cache |
400 | | |
401 | | static INLINE void collect_hog_data(const MACROBLOCK *x, BLOCK_SIZE bsize, |
402 | 112k | BLOCK_SIZE sb_size, int plane, float *hog) { |
403 | 112k | const MACROBLOCKD *xd = &x->e_mbd; |
404 | 112k | const struct macroblockd_plane *const pd = &xd->plane[plane]; |
405 | 112k | const int ss_x = pd->subsampling_x; |
406 | 112k | const int ss_y = pd->subsampling_y; |
407 | 112k | const int bh = block_size_high[bsize]; |
408 | 112k | const int bw = block_size_wide[bsize]; |
409 | 112k | const int rows = |
410 | 112k | ((xd->mb_to_bottom_edge >= 0) ? bh : (xd->mb_to_bottom_edge >> 3) + bh) >> |
411 | 112k | ss_y; |
412 | 112k | const int cols = |
413 | 112k | ((xd->mb_to_right_edge >= 0) ? bw : (xd->mb_to_right_edge >> 3) + bw) >> |
414 | 112k | ss_x; |
415 | | |
416 | | // If gradient data is already generated at SB level, reuse the cached data. |
417 | | // Otherwise, compute the data. |
418 | 112k | if (x->is_sb_gradient_cached[plane]) { |
419 | 112k | generate_hog_using_gradient_cache(x, rows, cols, sb_size, plane, hog); |
420 | 18.4E | } else { |
421 | 18.4E | const uint8_t *src = x->plane[plane].src.buf; |
422 | 18.4E | const int src_stride = x->plane[plane].src.stride; |
423 | 18.4E | generate_hog(src, src_stride, rows, cols, hog, is_cur_buf_hbd(xd)); |
424 | 18.4E | } |
425 | | |
426 | | // Scale the hog so the luma and chroma are on the same scale |
427 | 3.72M | for (int b = 0; b < BINS; ++b) { |
428 | 3.61M | hog[b] *= (1 + ss_x) * (1 + ss_y); |
429 | 3.61M | } |
430 | 112k | } Unexecuted instantiation: encoder.c:collect_hog_data Unexecuted instantiation: encoder_utils.c:collect_hog_data Unexecuted instantiation: ethread.c:collect_hog_data Unexecuted instantiation: palette.c:collect_hog_data Unexecuted instantiation: rdopt.c:collect_hog_data Unexecuted instantiation: superres_scale.c:collect_hog_data Unexecuted instantiation: svc_layercontext.c:collect_hog_data intra_mode_search.c:collect_hog_data Line | Count | Source | 402 | 112k | BLOCK_SIZE sb_size, int plane, float *hog) { | 403 | 112k | const MACROBLOCKD *xd = &x->e_mbd; | 404 | 112k | const struct macroblockd_plane *const pd = &xd->plane[plane]; | 405 | 112k | const int ss_x = pd->subsampling_x; | 406 | 112k | const int ss_y = pd->subsampling_y; | 407 | 112k | const int bh = block_size_high[bsize]; | 408 | 112k | const int bw = block_size_wide[bsize]; | 409 | 112k | const int rows = | 410 | 112k | ((xd->mb_to_bottom_edge >= 0) ? bh : (xd->mb_to_bottom_edge >> 3) + bh) >> | 411 | 112k | ss_y; | 412 | 112k | const int cols = | 413 | 112k | ((xd->mb_to_right_edge >= 0) ? bw : (xd->mb_to_right_edge >> 3) + bw) >> | 414 | 112k | ss_x; | 415 | | | 416 | | // If gradient data is already generated at SB level, reuse the cached data. | 417 | | // Otherwise, compute the data. | 418 | 112k | if (x->is_sb_gradient_cached[plane]) { | 419 | 112k | generate_hog_using_gradient_cache(x, rows, cols, sb_size, plane, hog); | 420 | 18.4E | } else { | 421 | 18.4E | const uint8_t *src = x->plane[plane].src.buf; | 422 | 18.4E | const int src_stride = x->plane[plane].src.stride; | 423 | 18.4E | generate_hog(src, src_stride, rows, cols, hog, is_cur_buf_hbd(xd)); | 424 | 18.4E | } | 425 | | | 426 | | // Scale the hog so the luma and chroma are on the same scale | 427 | 3.72M | for (int b = 0; b < BINS; ++b) { | 428 | 3.61M | hog[b] *= (1 + ss_x) * (1 + ss_y); | 429 | 3.61M | } | 430 | 112k | } |
Unexecuted instantiation: compound_type.c:collect_hog_data Unexecuted instantiation: encodeframe.c:collect_hog_data Unexecuted instantiation: encode_strategy.c:collect_hog_data |
431 | | |
432 | | static AOM_INLINE void prune_intra_mode_with_hog( |
433 | | const MACROBLOCK *x, BLOCK_SIZE bsize, BLOCK_SIZE sb_size, float th, |
434 | 112k | uint8_t *directional_mode_skip_mask, int is_chroma) { |
435 | 112k | const int plane = is_chroma ? AOM_PLANE_U : AOM_PLANE_Y; |
436 | 112k | float hist[BINS] = { 0.0f }; |
437 | 112k | collect_hog_data(x, bsize, sb_size, plane, hist); |
438 | | |
439 | | // Make prediction for each of the mode |
440 | 112k | float scores[DIRECTIONAL_MODES] = { 0.0f }; |
441 | 112k | av1_nn_predict(hist, &av1_intra_hog_model_nnconfig, 1, scores); |
442 | 1.01M | for (UV_PREDICTION_MODE uv_mode = UV_V_PRED; uv_mode <= UV_D67_PRED; |
443 | 902k | uv_mode++) { |
444 | 902k | if (scores[uv_mode - UV_V_PRED] <= th) { |
445 | 225k | directional_mode_skip_mask[uv_mode] = 1; |
446 | 225k | } |
447 | 902k | } |
448 | 112k | } Unexecuted instantiation: encoder.c:prune_intra_mode_with_hog Unexecuted instantiation: encoder_utils.c:prune_intra_mode_with_hog Unexecuted instantiation: ethread.c:prune_intra_mode_with_hog Unexecuted instantiation: palette.c:prune_intra_mode_with_hog Unexecuted instantiation: rdopt.c:prune_intra_mode_with_hog Unexecuted instantiation: superres_scale.c:prune_intra_mode_with_hog Unexecuted instantiation: svc_layercontext.c:prune_intra_mode_with_hog intra_mode_search.c:prune_intra_mode_with_hog Line | Count | Source | 434 | 112k | uint8_t *directional_mode_skip_mask, int is_chroma) { | 435 | 112k | const int plane = is_chroma ? AOM_PLANE_U : AOM_PLANE_Y; | 436 | 112k | float hist[BINS] = { 0.0f }; | 437 | 112k | collect_hog_data(x, bsize, sb_size, plane, hist); | 438 | | | 439 | | // Make prediction for each of the mode | 440 | 112k | float scores[DIRECTIONAL_MODES] = { 0.0f }; | 441 | 112k | av1_nn_predict(hist, &av1_intra_hog_model_nnconfig, 1, scores); | 442 | 1.01M | for (UV_PREDICTION_MODE uv_mode = UV_V_PRED; uv_mode <= UV_D67_PRED; | 443 | 902k | uv_mode++) { | 444 | 902k | if (scores[uv_mode - UV_V_PRED] <= th) { | 445 | 225k | directional_mode_skip_mask[uv_mode] = 1; | 446 | 225k | } | 447 | 902k | } | 448 | 112k | } |
Unexecuted instantiation: compound_type.c:prune_intra_mode_with_hog Unexecuted instantiation: encodeframe.c:prune_intra_mode_with_hog Unexecuted instantiation: encode_strategy.c:prune_intra_mode_with_hog |
449 | | #undef BINS |
450 | | |
451 | | // Returns the cost needed to send a uniformly distributed r.v. |
452 | 0 | static AOM_INLINE int write_uniform_cost(int n, int v) { |
453 | 0 | const int l = get_unsigned_bits(n); |
454 | 0 | const int m = (1 << l) - n; |
455 | 0 | if (l == 0) return 0; |
456 | 0 | if (v < m) |
457 | 0 | return av1_cost_literal(l - 1); |
458 | 0 | else |
459 | 0 | return av1_cost_literal(l); |
460 | 0 | } Unexecuted instantiation: encoder.c:write_uniform_cost Unexecuted instantiation: encoder_utils.c:write_uniform_cost Unexecuted instantiation: ethread.c:write_uniform_cost Unexecuted instantiation: palette.c:write_uniform_cost Unexecuted instantiation: rdopt.c:write_uniform_cost Unexecuted instantiation: superres_scale.c:write_uniform_cost Unexecuted instantiation: svc_layercontext.c:write_uniform_cost Unexecuted instantiation: intra_mode_search.c:write_uniform_cost Unexecuted instantiation: compound_type.c:write_uniform_cost Unexecuted instantiation: encodeframe.c:write_uniform_cost Unexecuted instantiation: encode_strategy.c:write_uniform_cost |
461 | | /*!\endcond */ |
462 | | |
463 | | /*!\brief Returns the rate cost for luma prediction mode info of intra blocks. |
464 | | * |
465 | | * \callergraph |
466 | | */ |
467 | | static AOM_INLINE int intra_mode_info_cost_y(const AV1_COMP *cpi, |
468 | | const MACROBLOCK *x, |
469 | | const MB_MODE_INFO *mbmi, |
470 | 3.16M | BLOCK_SIZE bsize, int mode_cost) { |
471 | 3.16M | int total_rate = mode_cost; |
472 | 3.16M | const ModeCosts *mode_costs = &x->mode_costs; |
473 | 3.16M | const int use_palette = mbmi->palette_mode_info.palette_size[0] > 0; |
474 | 3.16M | const int use_filter_intra = mbmi->filter_intra_mode_info.use_filter_intra; |
475 | 3.16M | const int use_intrabc = mbmi->use_intrabc; |
476 | | // Can only activate one mode. |
477 | 3.16M | assert(((mbmi->mode != DC_PRED) + use_palette + use_intrabc + |
478 | 3.16M | use_filter_intra) <= 1); |
479 | 3.16M | const int try_palette = av1_allow_palette( |
480 | 3.16M | cpi->common.features.allow_screen_content_tools, mbmi->bsize); |
481 | 3.16M | if (try_palette && mbmi->mode == DC_PRED) { |
482 | 0 | const MACROBLOCKD *xd = &x->e_mbd; |
483 | 0 | const int bsize_ctx = av1_get_palette_bsize_ctx(bsize); |
484 | 0 | const int mode_ctx = av1_get_palette_mode_ctx(xd); |
485 | 0 | total_rate += |
486 | 0 | mode_costs->palette_y_mode_cost[bsize_ctx][mode_ctx][use_palette]; |
487 | 0 | if (use_palette) { |
488 | 0 | const uint8_t *const color_map = xd->plane[0].color_index_map; |
489 | 0 | int block_width, block_height, rows, cols; |
490 | 0 | av1_get_block_dimensions(bsize, 0, xd, &block_width, &block_height, &rows, |
491 | 0 | &cols); |
492 | 0 | const int plt_size = mbmi->palette_mode_info.palette_size[0]; |
493 | 0 | int palette_mode_cost = |
494 | 0 | mode_costs |
495 | 0 | ->palette_y_size_cost[bsize_ctx][plt_size - PALETTE_MIN_SIZE] + |
496 | 0 | write_uniform_cost(plt_size, color_map[0]); |
497 | 0 | uint16_t color_cache[2 * PALETTE_MAX_SIZE]; |
498 | 0 | const int n_cache = av1_get_palette_cache(xd, 0, color_cache); |
499 | 0 | palette_mode_cost += |
500 | 0 | av1_palette_color_cost_y(&mbmi->palette_mode_info, color_cache, |
501 | 0 | n_cache, cpi->common.seq_params->bit_depth); |
502 | 0 | palette_mode_cost += |
503 | 0 | av1_cost_color_map(x, 0, bsize, mbmi->tx_size, PALETTE_MAP); |
504 | 0 | total_rate += palette_mode_cost; |
505 | 0 | } |
506 | 0 | } |
507 | 3.16M | if (av1_filter_intra_allowed(&cpi->common, mbmi)) { |
508 | 205k | total_rate += mode_costs->filter_intra_cost[mbmi->bsize][use_filter_intra]; |
509 | 205k | if (use_filter_intra) { |
510 | 78.9k | total_rate += |
511 | 78.9k | mode_costs->filter_intra_mode_cost[mbmi->filter_intra_mode_info |
512 | 78.9k | .filter_intra_mode]; |
513 | 78.9k | } |
514 | 205k | } |
515 | 3.16M | if (av1_is_directional_mode(mbmi->mode)) { |
516 | 2.72M | if (av1_use_angle_delta(bsize)) { |
517 | 2.63M | total_rate += |
518 | 2.63M | mode_costs->angle_delta_cost[mbmi->mode - V_PRED] |
519 | 2.63M | [MAX_ANGLE_DELTA + |
520 | 2.63M | mbmi->angle_delta[PLANE_TYPE_Y]]; |
521 | 2.63M | } |
522 | 2.72M | } |
523 | 3.16M | if (av1_allow_intrabc(&cpi->common)) |
524 | 0 | total_rate += mode_costs->intrabc_cost[use_intrabc]; |
525 | 3.16M | return total_rate; |
526 | 3.16M | } Unexecuted instantiation: encoder.c:intra_mode_info_cost_y Unexecuted instantiation: encoder_utils.c:intra_mode_info_cost_y Unexecuted instantiation: ethread.c:intra_mode_info_cost_y Unexecuted instantiation: palette.c:intra_mode_info_cost_y Unexecuted instantiation: rdopt.c:intra_mode_info_cost_y Unexecuted instantiation: superres_scale.c:intra_mode_info_cost_y Unexecuted instantiation: svc_layercontext.c:intra_mode_info_cost_y intra_mode_search.c:intra_mode_info_cost_y Line | Count | Source | 470 | 3.16M | BLOCK_SIZE bsize, int mode_cost) { | 471 | 3.16M | int total_rate = mode_cost; | 472 | 3.16M | const ModeCosts *mode_costs = &x->mode_costs; | 473 | 3.16M | const int use_palette = mbmi->palette_mode_info.palette_size[0] > 0; | 474 | 3.16M | const int use_filter_intra = mbmi->filter_intra_mode_info.use_filter_intra; | 475 | 3.16M | const int use_intrabc = mbmi->use_intrabc; | 476 | | // Can only activate one mode. | 477 | 3.16M | assert(((mbmi->mode != DC_PRED) + use_palette + use_intrabc + | 478 | 3.16M | use_filter_intra) <= 1); | 479 | 3.16M | const int try_palette = av1_allow_palette( | 480 | 3.16M | cpi->common.features.allow_screen_content_tools, mbmi->bsize); | 481 | 3.16M | if (try_palette && mbmi->mode == DC_PRED) { | 482 | 0 | const MACROBLOCKD *xd = &x->e_mbd; | 483 | 0 | const int bsize_ctx = av1_get_palette_bsize_ctx(bsize); | 484 | 0 | const int mode_ctx = av1_get_palette_mode_ctx(xd); | 485 | 0 | total_rate += | 486 | 0 | mode_costs->palette_y_mode_cost[bsize_ctx][mode_ctx][use_palette]; | 487 | 0 | if (use_palette) { | 488 | 0 | const uint8_t *const color_map = xd->plane[0].color_index_map; | 489 | 0 | int block_width, block_height, rows, cols; | 490 | 0 | av1_get_block_dimensions(bsize, 0, xd, &block_width, &block_height, &rows, | 491 | 0 | &cols); | 492 | 0 | const int plt_size = mbmi->palette_mode_info.palette_size[0]; | 493 | 0 | int palette_mode_cost = | 494 | 0 | mode_costs | 495 | 0 | ->palette_y_size_cost[bsize_ctx][plt_size - PALETTE_MIN_SIZE] + | 496 | 0 | write_uniform_cost(plt_size, color_map[0]); | 497 | 0 | uint16_t color_cache[2 * PALETTE_MAX_SIZE]; | 498 | 0 | const int n_cache = av1_get_palette_cache(xd, 0, color_cache); | 499 | 0 | palette_mode_cost += | 500 | 0 | av1_palette_color_cost_y(&mbmi->palette_mode_info, color_cache, | 501 | 0 | n_cache, cpi->common.seq_params->bit_depth); | 502 | 0 | palette_mode_cost += | 503 | 0 | av1_cost_color_map(x, 0, bsize, mbmi->tx_size, PALETTE_MAP); | 504 | 0 | total_rate += palette_mode_cost; | 505 | 0 | } | 506 | 0 | } | 507 | 3.16M | if (av1_filter_intra_allowed(&cpi->common, mbmi)) { | 508 | 205k | total_rate += mode_costs->filter_intra_cost[mbmi->bsize][use_filter_intra]; | 509 | 205k | if (use_filter_intra) { | 510 | 78.9k | total_rate += | 511 | 78.9k | mode_costs->filter_intra_mode_cost[mbmi->filter_intra_mode_info | 512 | 78.9k | .filter_intra_mode]; | 513 | 78.9k | } | 514 | 205k | } | 515 | 3.16M | if (av1_is_directional_mode(mbmi->mode)) { | 516 | 2.72M | if (av1_use_angle_delta(bsize)) { | 517 | 2.63M | total_rate += | 518 | 2.63M | mode_costs->angle_delta_cost[mbmi->mode - V_PRED] | 519 | 2.63M | [MAX_ANGLE_DELTA + | 520 | 2.63M | mbmi->angle_delta[PLANE_TYPE_Y]]; | 521 | 2.63M | } | 522 | 2.72M | } | 523 | 3.16M | if (av1_allow_intrabc(&cpi->common)) | 524 | 0 | total_rate += mode_costs->intrabc_cost[use_intrabc]; | 525 | 3.16M | return total_rate; | 526 | 3.16M | } |
Unexecuted instantiation: compound_type.c:intra_mode_info_cost_y Unexecuted instantiation: encodeframe.c:intra_mode_info_cost_y Unexecuted instantiation: encode_strategy.c:intra_mode_info_cost_y |
527 | | |
528 | | /*!\brief Return the rate cost for chroma prediction mode info of intra blocks. |
529 | | * |
530 | | * \callergraph |
531 | | */ |
532 | | static AOM_INLINE int intra_mode_info_cost_uv(const AV1_COMP *cpi, |
533 | | const MACROBLOCK *x, |
534 | | const MB_MODE_INFO *mbmi, |
535 | 123k | BLOCK_SIZE bsize, int mode_cost) { |
536 | 123k | int total_rate = mode_cost; |
537 | 123k | const ModeCosts *mode_costs = &x->mode_costs; |
538 | 123k | const int use_palette = mbmi->palette_mode_info.palette_size[1] > 0; |
539 | 123k | const UV_PREDICTION_MODE mode = mbmi->uv_mode; |
540 | | // Can only activate one mode. |
541 | 123k | assert(((mode != UV_DC_PRED) + use_palette + mbmi->use_intrabc) <= 1); |
542 | | |
543 | 123k | const int try_palette = av1_allow_palette( |
544 | 123k | cpi->common.features.allow_screen_content_tools, mbmi->bsize); |
545 | 123k | if (try_palette && mode == UV_DC_PRED) { |
546 | 0 | const PALETTE_MODE_INFO *pmi = &mbmi->palette_mode_info; |
547 | 0 | total_rate += |
548 | 0 | mode_costs->palette_uv_mode_cost[pmi->palette_size[0] > 0][use_palette]; |
549 | 0 | if (use_palette) { |
550 | 0 | const int bsize_ctx = av1_get_palette_bsize_ctx(bsize); |
551 | 0 | const int plt_size = pmi->palette_size[1]; |
552 | 0 | const MACROBLOCKD *xd = &x->e_mbd; |
553 | 0 | const uint8_t *const color_map = xd->plane[1].color_index_map; |
554 | 0 | int palette_mode_cost = |
555 | 0 | mode_costs |
556 | 0 | ->palette_uv_size_cost[bsize_ctx][plt_size - PALETTE_MIN_SIZE] + |
557 | 0 | write_uniform_cost(plt_size, color_map[0]); |
558 | 0 | uint16_t color_cache[2 * PALETTE_MAX_SIZE]; |
559 | 0 | const int n_cache = av1_get_palette_cache(xd, 1, color_cache); |
560 | 0 | palette_mode_cost += av1_palette_color_cost_uv( |
561 | 0 | pmi, color_cache, n_cache, cpi->common.seq_params->bit_depth); |
562 | 0 | palette_mode_cost += |
563 | 0 | av1_cost_color_map(x, 1, bsize, mbmi->tx_size, PALETTE_MAP); |
564 | 0 | total_rate += palette_mode_cost; |
565 | 0 | } |
566 | 0 | } |
567 | 123k | if (av1_is_directional_mode(get_uv_mode(mode))) { |
568 | 3.62k | if (av1_use_angle_delta(bsize)) { |
569 | 3.58k | total_rate += |
570 | 3.58k | mode_costs->angle_delta_cost[mode - V_PRED] |
571 | 3.58k | [mbmi->angle_delta[PLANE_TYPE_UV] + |
572 | 3.58k | MAX_ANGLE_DELTA]; |
573 | 3.58k | } |
574 | 3.62k | } |
575 | 123k | return total_rate; |
576 | 123k | } Unexecuted instantiation: encoder.c:intra_mode_info_cost_uv Unexecuted instantiation: encoder_utils.c:intra_mode_info_cost_uv Unexecuted instantiation: ethread.c:intra_mode_info_cost_uv Unexecuted instantiation: palette.c:intra_mode_info_cost_uv Unexecuted instantiation: rdopt.c:intra_mode_info_cost_uv Unexecuted instantiation: superres_scale.c:intra_mode_info_cost_uv Unexecuted instantiation: svc_layercontext.c:intra_mode_info_cost_uv intra_mode_search.c:intra_mode_info_cost_uv Line | Count | Source | 535 | 123k | BLOCK_SIZE bsize, int mode_cost) { | 536 | 123k | int total_rate = mode_cost; | 537 | 123k | const ModeCosts *mode_costs = &x->mode_costs; | 538 | 123k | const int use_palette = mbmi->palette_mode_info.palette_size[1] > 0; | 539 | 123k | const UV_PREDICTION_MODE mode = mbmi->uv_mode; | 540 | | // Can only activate one mode. | 541 | 123k | assert(((mode != UV_DC_PRED) + use_palette + mbmi->use_intrabc) <= 1); | 542 | | | 543 | 123k | const int try_palette = av1_allow_palette( | 544 | 123k | cpi->common.features.allow_screen_content_tools, mbmi->bsize); | 545 | 123k | if (try_palette && mode == UV_DC_PRED) { | 546 | 0 | const PALETTE_MODE_INFO *pmi = &mbmi->palette_mode_info; | 547 | 0 | total_rate += | 548 | 0 | mode_costs->palette_uv_mode_cost[pmi->palette_size[0] > 0][use_palette]; | 549 | 0 | if (use_palette) { | 550 | 0 | const int bsize_ctx = av1_get_palette_bsize_ctx(bsize); | 551 | 0 | const int plt_size = pmi->palette_size[1]; | 552 | 0 | const MACROBLOCKD *xd = &x->e_mbd; | 553 | 0 | const uint8_t *const color_map = xd->plane[1].color_index_map; | 554 | 0 | int palette_mode_cost = | 555 | 0 | mode_costs | 556 | 0 | ->palette_uv_size_cost[bsize_ctx][plt_size - PALETTE_MIN_SIZE] + | 557 | 0 | write_uniform_cost(plt_size, color_map[0]); | 558 | 0 | uint16_t color_cache[2 * PALETTE_MAX_SIZE]; | 559 | 0 | const int n_cache = av1_get_palette_cache(xd, 1, color_cache); | 560 | 0 | palette_mode_cost += av1_palette_color_cost_uv( | 561 | 0 | pmi, color_cache, n_cache, cpi->common.seq_params->bit_depth); | 562 | 0 | palette_mode_cost += | 563 | 0 | av1_cost_color_map(x, 1, bsize, mbmi->tx_size, PALETTE_MAP); | 564 | 0 | total_rate += palette_mode_cost; | 565 | 0 | } | 566 | 0 | } | 567 | 123k | if (av1_is_directional_mode(get_uv_mode(mode))) { | 568 | 3.62k | if (av1_use_angle_delta(bsize)) { | 569 | 3.58k | total_rate += | 570 | 3.58k | mode_costs->angle_delta_cost[mode - V_PRED] | 571 | 3.58k | [mbmi->angle_delta[PLANE_TYPE_UV] + | 572 | 3.58k | MAX_ANGLE_DELTA]; | 573 | 3.58k | } | 574 | 3.62k | } | 575 | 123k | return total_rate; | 576 | 123k | } |
Unexecuted instantiation: compound_type.c:intra_mode_info_cost_uv Unexecuted instantiation: encodeframe.c:intra_mode_info_cost_uv Unexecuted instantiation: encode_strategy.c:intra_mode_info_cost_uv |
577 | | |
578 | | /*!\cond */ |
579 | | // Makes a quick intra prediction and estimate the rdcost with a model without |
580 | | // going through the whole txfm/quantize/itxfm process. |
581 | | static int64_t intra_model_rd(const AV1_COMMON *cm, MACROBLOCK *const x, |
582 | | int plane, BLOCK_SIZE plane_bsize, |
583 | 4.21M | TX_SIZE tx_size, int use_hadamard) { |
584 | 4.21M | MACROBLOCKD *const xd = &x->e_mbd; |
585 | 4.21M | const BitDepthInfo bd_info = get_bit_depth_info(xd); |
586 | 4.21M | int row, col; |
587 | 4.21M | assert(!is_inter_block(xd->mi[0])); |
588 | 4.21M | const int stepr = tx_size_high_unit[tx_size]; |
589 | 4.21M | const int stepc = tx_size_wide_unit[tx_size]; |
590 | 4.21M | const int txbw = tx_size_wide[tx_size]; |
591 | 4.21M | const int txbh = tx_size_high[tx_size]; |
592 | 4.21M | const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane); |
593 | 4.21M | const int max_blocks_high = max_block_high(xd, plane_bsize, plane); |
594 | 4.21M | int64_t satd_cost = 0; |
595 | 4.21M | struct macroblock_plane *p = &x->plane[plane]; |
596 | 4.21M | struct macroblockd_plane *pd = &xd->plane[plane]; |
597 | | // Prediction. |
598 | 9.55M | for (row = 0; row < max_blocks_high; row += stepr) { |
599 | 12.1M | for (col = 0; col < max_blocks_wide; col += stepc) { |
600 | 6.81M | av1_predict_intra_block_facade(cm, xd, plane, col, row, tx_size); |
601 | | // Here we use p->src_diff and p->coeff as temporary buffers for |
602 | | // prediction residue and transform coefficients. The buffers are only |
603 | | // used in this for loop, therefore we don't need to properly add offset |
604 | | // to the buffers. |
605 | 6.81M | av1_subtract_block( |
606 | 6.81M | bd_info, txbh, txbw, p->src_diff, block_size_wide[plane_bsize], |
607 | 6.81M | p->src.buf + (((row * p->src.stride) + col) << 2), p->src.stride, |
608 | 6.81M | pd->dst.buf + (((row * pd->dst.stride) + col) << 2), pd->dst.stride); |
609 | 6.81M | av1_quick_txfm(use_hadamard, tx_size, bd_info, p->src_diff, |
610 | 6.81M | block_size_wide[plane_bsize], p->coeff); |
611 | 6.81M | satd_cost += aom_satd(p->coeff, tx_size_2d[tx_size]); |
612 | 6.81M | } |
613 | 5.33M | } |
614 | 4.21M | return satd_cost; |
615 | 4.21M | } Unexecuted instantiation: encoder.c:intra_model_rd Unexecuted instantiation: encoder_utils.c:intra_model_rd Unexecuted instantiation: ethread.c:intra_model_rd Unexecuted instantiation: palette.c:intra_model_rd Unexecuted instantiation: rdopt.c:intra_model_rd Unexecuted instantiation: superres_scale.c:intra_model_rd Unexecuted instantiation: svc_layercontext.c:intra_model_rd intra_mode_search.c:intra_model_rd Line | Count | Source | 583 | 4.21M | TX_SIZE tx_size, int use_hadamard) { | 584 | 4.21M | MACROBLOCKD *const xd = &x->e_mbd; | 585 | 4.21M | const BitDepthInfo bd_info = get_bit_depth_info(xd); | 586 | 4.21M | int row, col; | 587 | 4.21M | assert(!is_inter_block(xd->mi[0])); | 588 | 4.21M | const int stepr = tx_size_high_unit[tx_size]; | 589 | 4.21M | const int stepc = tx_size_wide_unit[tx_size]; | 590 | 4.21M | const int txbw = tx_size_wide[tx_size]; | 591 | 4.21M | const int txbh = tx_size_high[tx_size]; | 592 | 4.21M | const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane); | 593 | 4.21M | const int max_blocks_high = max_block_high(xd, plane_bsize, plane); | 594 | 4.21M | int64_t satd_cost = 0; | 595 | 4.21M | struct macroblock_plane *p = &x->plane[plane]; | 596 | 4.21M | struct macroblockd_plane *pd = &xd->plane[plane]; | 597 | | // Prediction. | 598 | 9.55M | for (row = 0; row < max_blocks_high; row += stepr) { | 599 | 12.1M | for (col = 0; col < max_blocks_wide; col += stepc) { | 600 | 6.81M | av1_predict_intra_block_facade(cm, xd, plane, col, row, tx_size); | 601 | | // Here we use p->src_diff and p->coeff as temporary buffers for | 602 | | // prediction residue and transform coefficients. The buffers are only | 603 | | // used in this for loop, therefore we don't need to properly add offset | 604 | | // to the buffers. | 605 | 6.81M | av1_subtract_block( | 606 | 6.81M | bd_info, txbh, txbw, p->src_diff, block_size_wide[plane_bsize], | 607 | 6.81M | p->src.buf + (((row * p->src.stride) + col) << 2), p->src.stride, | 608 | 6.81M | pd->dst.buf + (((row * pd->dst.stride) + col) << 2), pd->dst.stride); | 609 | 6.81M | av1_quick_txfm(use_hadamard, tx_size, bd_info, p->src_diff, | 610 | 6.81M | block_size_wide[plane_bsize], p->coeff); | 611 | 6.81M | satd_cost += aom_satd(p->coeff, tx_size_2d[tx_size]); | 612 | 6.81M | } | 613 | 5.33M | } | 614 | 4.21M | return satd_cost; | 615 | 4.21M | } |
Unexecuted instantiation: compound_type.c:intra_model_rd Unexecuted instantiation: encodeframe.c:intra_model_rd Unexecuted instantiation: encode_strategy.c:intra_model_rd |
616 | | /*!\endcond */ |
617 | | |
618 | | /*!\brief Estimate the luma rdcost of a given intra mode and try to prune it. |
619 | | * |
620 | | * \ingroup intra_mode_search |
621 | | * \callergraph |
622 | | * This function first makes a quick luma prediction and estimates the rdcost |
623 | | * with a model without going through the txfm, then try to prune the current |
624 | | * mode if the new estimate y_rd > 1.25 * best_model_rd. |
625 | | * |
626 | | * \return Returns 1 if the given mode is prune; 0 otherwise. |
627 | | */ |
628 | | static AOM_INLINE int model_intra_yrd_and_prune(const AV1_COMP *const cpi, |
629 | | MACROBLOCK *x, BLOCK_SIZE bsize, |
630 | 58.9k | int64_t *best_model_rd) { |
631 | 58.9k | const TX_SIZE tx_size = AOMMIN(TX_32X32, max_txsize_lookup[bsize]); |
632 | 58.9k | const int plane = 0; |
633 | 58.9k | const AV1_COMMON *cm = &cpi->common; |
634 | 58.9k | const int64_t this_model_rd = |
635 | 58.9k | intra_model_rd(cm, x, plane, bsize, tx_size, /*use_hadamard=*/1); |
636 | 58.9k | if (*best_model_rd != INT64_MAX && |
637 | 58.9k | this_model_rd > *best_model_rd + (*best_model_rd >> 2)) { |
638 | 1.16k | return 1; |
639 | 57.7k | } else if (this_model_rd < *best_model_rd) { |
640 | 0 | *best_model_rd = this_model_rd; |
641 | 0 | } |
642 | 57.7k | return 0; |
643 | 58.9k | } Unexecuted instantiation: encoder.c:model_intra_yrd_and_prune Unexecuted instantiation: encoder_utils.c:model_intra_yrd_and_prune Unexecuted instantiation: ethread.c:model_intra_yrd_and_prune Unexecuted instantiation: palette.c:model_intra_yrd_and_prune Unexecuted instantiation: rdopt.c:model_intra_yrd_and_prune Unexecuted instantiation: superres_scale.c:model_intra_yrd_and_prune Unexecuted instantiation: svc_layercontext.c:model_intra_yrd_and_prune intra_mode_search.c:model_intra_yrd_and_prune Line | Count | Source | 630 | 58.9k | int64_t *best_model_rd) { | 631 | 58.9k | const TX_SIZE tx_size = AOMMIN(TX_32X32, max_txsize_lookup[bsize]); | 632 | 58.9k | const int plane = 0; | 633 | 58.9k | const AV1_COMMON *cm = &cpi->common; | 634 | 58.9k | const int64_t this_model_rd = | 635 | 58.9k | intra_model_rd(cm, x, plane, bsize, tx_size, /*use_hadamard=*/1); | 636 | 58.9k | if (*best_model_rd != INT64_MAX && | 637 | 58.9k | this_model_rd > *best_model_rd + (*best_model_rd >> 2)) { | 638 | 1.16k | return 1; | 639 | 57.7k | } else if (this_model_rd < *best_model_rd) { | 640 | 0 | *best_model_rd = this_model_rd; | 641 | 0 | } | 642 | 57.7k | return 0; | 643 | 58.9k | } |
Unexecuted instantiation: compound_type.c:model_intra_yrd_and_prune Unexecuted instantiation: encodeframe.c:model_intra_yrd_and_prune Unexecuted instantiation: encode_strategy.c:model_intra_yrd_and_prune |
644 | | |
645 | | #ifdef __cplusplus |
646 | | } // extern "C" |
647 | | #endif |
648 | | |
649 | | #endif // AOM_AV1_ENCODER_INTRA_MODE_SEARCH_UTILS_H_ |