/src/aom/av1/common/cfl.c
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 | | #include "av1/common/av1_common_int.h" |
13 | | #include "av1/common/cfl.h" |
14 | | #include "av1/common/common_data.h" |
15 | | |
16 | | #include "config/av1_rtcd.h" |
17 | | |
18 | 10.7k | void cfl_init(CFL_CTX *cfl, const SequenceHeader *seq_params) { |
19 | 10.7k | assert(block_size_wide[CFL_MAX_BLOCK_SIZE] == CFL_BUF_LINE); |
20 | 10.7k | assert(block_size_high[CFL_MAX_BLOCK_SIZE] == CFL_BUF_LINE); |
21 | | |
22 | 10.7k | memset(&cfl->recon_buf_q3, 0, sizeof(cfl->recon_buf_q3)); |
23 | 10.7k | memset(&cfl->ac_buf_q3, 0, sizeof(cfl->ac_buf_q3)); |
24 | 10.7k | cfl->subsampling_x = seq_params->subsampling_x; |
25 | 10.7k | cfl->subsampling_y = seq_params->subsampling_y; |
26 | 10.7k | cfl->are_parameters_computed = 0; |
27 | 10.7k | cfl->store_y = 0; |
28 | | // The DC_PRED cache is disabled by default and is only enabled in |
29 | | // cfl_rd_pick_alpha |
30 | 10.7k | cfl->use_dc_pred_cache = 0; |
31 | 10.7k | cfl->dc_pred_is_cached[CFL_PRED_U] = 0; |
32 | 10.7k | cfl->dc_pred_is_cached[CFL_PRED_V] = 0; |
33 | 10.7k | } |
34 | | |
35 | | void cfl_store_dc_pred(MACROBLOCKD *const xd, const uint8_t *input, |
36 | 77.0k | CFL_PRED_TYPE pred_plane, int width) { |
37 | 77.0k | assert(pred_plane < CFL_PRED_PLANES); |
38 | 77.0k | assert(width <= CFL_BUF_LINE); |
39 | | |
40 | 77.0k | if (is_cur_buf_hbd(xd)) { |
41 | 0 | uint16_t *const input_16 = CONVERT_TO_SHORTPTR(input); |
42 | 0 | memcpy(xd->cfl.dc_pred_cache[pred_plane], input_16, width << 1); |
43 | 0 | return; |
44 | 0 | } |
45 | | |
46 | 77.0k | memcpy(xd->cfl.dc_pred_cache[pred_plane], input, width); |
47 | 77.0k | } |
48 | | |
49 | | static void cfl_load_dc_pred_lbd(const int16_t *dc_pred_cache, uint8_t *dst, |
50 | 539k | int dst_stride, int width, int height) { |
51 | 4.37M | for (int j = 0; j < height; j++) { |
52 | 3.83M | memcpy(dst, dc_pred_cache, width); |
53 | 3.83M | dst += dst_stride; |
54 | 3.83M | } |
55 | 539k | } |
56 | | |
57 | | static void cfl_load_dc_pred_hbd(const int16_t *dc_pred_cache, uint16_t *dst, |
58 | 0 | int dst_stride, int width, int height) { |
59 | 0 | const size_t num_bytes = width << 1; |
60 | 0 | for (int j = 0; j < height; j++) { |
61 | 0 | memcpy(dst, dc_pred_cache, num_bytes); |
62 | 0 | dst += dst_stride; |
63 | 0 | } |
64 | 0 | } |
65 | | void cfl_load_dc_pred(MACROBLOCKD *const xd, uint8_t *dst, int dst_stride, |
66 | 539k | TX_SIZE tx_size, CFL_PRED_TYPE pred_plane) { |
67 | 539k | const int width = tx_size_wide[tx_size]; |
68 | 539k | const int height = tx_size_high[tx_size]; |
69 | 539k | assert(pred_plane < CFL_PRED_PLANES); |
70 | 539k | assert(width <= CFL_BUF_LINE); |
71 | 539k | assert(height <= CFL_BUF_LINE); |
72 | 539k | if (is_cur_buf_hbd(xd)) { |
73 | 0 | uint16_t *dst_16 = CONVERT_TO_SHORTPTR(dst); |
74 | 0 | cfl_load_dc_pred_hbd(xd->cfl.dc_pred_cache[pred_plane], dst_16, dst_stride, |
75 | 0 | width, height); |
76 | 0 | return; |
77 | 0 | } |
78 | 539k | cfl_load_dc_pred_lbd(xd->cfl.dc_pred_cache[pred_plane], dst, dst_stride, |
79 | 539k | width, height); |
80 | 539k | } |
81 | | |
82 | | // Due to frame boundary issues, it is possible that the total area covered by |
83 | | // chroma exceeds that of luma. When this happens, we fill the missing pixels by |
84 | | // repeating the last columns and/or rows. |
85 | 38.5k | static INLINE void cfl_pad(CFL_CTX *cfl, int width, int height) { |
86 | 38.5k | const int diff_width = width - cfl->buf_width; |
87 | 38.5k | const int diff_height = height - cfl->buf_height; |
88 | | |
89 | 38.5k | if (diff_width > 0) { |
90 | 0 | const int min_height = height - diff_height; |
91 | 0 | uint16_t *recon_buf_q3 = cfl->recon_buf_q3 + (width - diff_width); |
92 | 0 | for (int j = 0; j < min_height; j++) { |
93 | 0 | const uint16_t last_pixel = recon_buf_q3[-1]; |
94 | 0 | assert(recon_buf_q3 + diff_width <= cfl->recon_buf_q3 + CFL_BUF_SQUARE); |
95 | 0 | for (int i = 0; i < diff_width; i++) { |
96 | 0 | recon_buf_q3[i] = last_pixel; |
97 | 0 | } |
98 | 0 | recon_buf_q3 += CFL_BUF_LINE; |
99 | 0 | } |
100 | 0 | cfl->buf_width = width; |
101 | 0 | } |
102 | 38.5k | if (diff_height > 0) { |
103 | 0 | uint16_t *recon_buf_q3 = |
104 | 0 | cfl->recon_buf_q3 + ((height - diff_height) * CFL_BUF_LINE); |
105 | 0 | for (int j = 0; j < diff_height; j++) { |
106 | 0 | const uint16_t *last_row_q3 = recon_buf_q3 - CFL_BUF_LINE; |
107 | 0 | assert(recon_buf_q3 + width <= cfl->recon_buf_q3 + CFL_BUF_SQUARE); |
108 | 0 | for (int i = 0; i < width; i++) { |
109 | 0 | recon_buf_q3[i] = last_row_q3[i]; |
110 | 0 | } |
111 | 0 | recon_buf_q3 += CFL_BUF_LINE; |
112 | 0 | } |
113 | 0 | cfl->buf_height = height; |
114 | 0 | } |
115 | 38.5k | } |
116 | | |
117 | | static void subtract_average_c(const uint16_t *src, int16_t *dst, int width, |
118 | 38.5k | int height, int round_offset, int num_pel_log2) { |
119 | 38.5k | int sum = round_offset; |
120 | 38.5k | const uint16_t *recon = src; |
121 | 312k | for (int j = 0; j < height; j++) { |
122 | 2.61M | for (int i = 0; i < width; i++) { |
123 | 2.33M | sum += recon[i]; |
124 | 2.33M | } |
125 | 274k | recon += CFL_BUF_LINE; |
126 | 274k | } |
127 | 38.5k | const int avg = sum >> num_pel_log2; |
128 | 312k | for (int j = 0; j < height; j++) { |
129 | 2.61M | for (int i = 0; i < width; i++) { |
130 | 2.33M | dst[i] = src[i] - avg; |
131 | 2.33M | } |
132 | 274k | src += CFL_BUF_LINE; |
133 | 274k | dst += CFL_BUF_LINE; |
134 | 274k | } |
135 | 38.5k | } |
136 | | |
137 | | CFL_SUB_AVG_FN(c) |
138 | | |
139 | | static INLINE int cfl_idx_to_alpha(uint8_t alpha_idx, int8_t joint_sign, |
140 | 616k | CFL_PRED_TYPE pred_type) { |
141 | 616k | const int alpha_sign = (pred_type == CFL_PRED_U) ? CFL_SIGN_U(joint_sign) |
142 | 616k | : CFL_SIGN_V(joint_sign); |
143 | 616k | if (alpha_sign == CFL_SIGN_ZERO) return 0; |
144 | 462k | const int abs_alpha_q3 = |
145 | 462k | (pred_type == CFL_PRED_U) ? CFL_IDX_U(alpha_idx) : CFL_IDX_V(alpha_idx); |
146 | 462k | return (alpha_sign == CFL_SIGN_POS) ? abs_alpha_q3 + 1 : -abs_alpha_q3 - 1; |
147 | 616k | } |
148 | | |
149 | | static INLINE void cfl_predict_lbd_c(const int16_t *ac_buf_q3, uint8_t *dst, |
150 | | int dst_stride, int alpha_q3, int width, |
151 | 616k | int height) { |
152 | 5.00M | for (int j = 0; j < height; j++) { |
153 | 41.7M | for (int i = 0; i < width; i++) { |
154 | 37.4M | dst[i] = clip_pixel(get_scaled_luma_q0(alpha_q3, ac_buf_q3[i]) + dst[i]); |
155 | 37.4M | } |
156 | 4.38M | dst += dst_stride; |
157 | 4.38M | ac_buf_q3 += CFL_BUF_LINE; |
158 | 4.38M | } |
159 | 616k | } |
160 | | |
161 | | CFL_PREDICT_FN(c, lbd) |
162 | | |
163 | | #if CONFIG_AV1_HIGHBITDEPTH |
164 | | void cfl_predict_hbd_c(const int16_t *ac_buf_q3, uint16_t *dst, int dst_stride, |
165 | 0 | int alpha_q3, int bit_depth, int width, int height) { |
166 | 0 | for (int j = 0; j < height; j++) { |
167 | 0 | for (int i = 0; i < width; i++) { |
168 | 0 | dst[i] = clip_pixel_highbd( |
169 | 0 | get_scaled_luma_q0(alpha_q3, ac_buf_q3[i]) + dst[i], bit_depth); |
170 | 0 | } |
171 | 0 | dst += dst_stride; |
172 | 0 | ac_buf_q3 += CFL_BUF_LINE; |
173 | 0 | } |
174 | 0 | } |
175 | | |
176 | | CFL_PREDICT_FN(c, hbd) |
177 | | #endif |
178 | | |
179 | 38.5k | static void cfl_compute_parameters(MACROBLOCKD *const xd, TX_SIZE tx_size) { |
180 | 38.5k | CFL_CTX *const cfl = &xd->cfl; |
181 | | // Do not call cfl_compute_parameters multiple time on the same values. |
182 | 38.5k | assert(cfl->are_parameters_computed == 0); |
183 | | |
184 | 38.5k | cfl_pad(cfl, tx_size_wide[tx_size], tx_size_high[tx_size]); |
185 | 38.5k | cfl_get_subtract_average_fn(tx_size)(cfl->recon_buf_q3, cfl->ac_buf_q3); |
186 | 38.5k | cfl->are_parameters_computed = 1; |
187 | 38.5k | } |
188 | | |
189 | | void cfl_predict_block(MACROBLOCKD *const xd, uint8_t *dst, int dst_stride, |
190 | 616k | TX_SIZE tx_size, int plane) { |
191 | 616k | CFL_CTX *const cfl = &xd->cfl; |
192 | 616k | MB_MODE_INFO *mbmi = xd->mi[0]; |
193 | 616k | assert(is_cfl_allowed(xd)); |
194 | | |
195 | 616k | if (!cfl->are_parameters_computed) cfl_compute_parameters(xd, tx_size); |
196 | | |
197 | 616k | const int alpha_q3 = |
198 | 616k | cfl_idx_to_alpha(mbmi->cfl_alpha_idx, mbmi->cfl_alpha_signs, plane - 1); |
199 | 616k | assert((tx_size_high[tx_size] - 1) * CFL_BUF_LINE + tx_size_wide[tx_size] <= |
200 | 616k | CFL_BUF_SQUARE); |
201 | 616k | #if CONFIG_AV1_HIGHBITDEPTH |
202 | 616k | if (is_cur_buf_hbd(xd)) { |
203 | 0 | uint16_t *dst_16 = CONVERT_TO_SHORTPTR(dst); |
204 | 0 | cfl_get_predict_hbd_fn(tx_size)(cfl->ac_buf_q3, dst_16, dst_stride, |
205 | 0 | alpha_q3, xd->bd); |
206 | 0 | return; |
207 | 0 | } |
208 | 616k | #endif |
209 | 616k | cfl_get_predict_lbd_fn(tx_size)(cfl->ac_buf_q3, dst, dst_stride, alpha_q3); |
210 | 616k | } |
211 | | |
212 | | static void cfl_luma_subsampling_420_lbd_c(const uint8_t *input, |
213 | | int input_stride, |
214 | | uint16_t *output_q3, int width, |
215 | 111k | int height) { |
216 | 509k | for (int j = 0; j < height; j += 2) { |
217 | 2.74M | for (int i = 0; i < width; i += 2) { |
218 | 2.34M | const int bot = i + input_stride; |
219 | 2.34M | output_q3[i >> 1] = |
220 | 2.34M | (input[i] + input[i + 1] + input[bot] + input[bot + 1]) << 1; |
221 | 2.34M | } |
222 | 398k | input += input_stride << 1; |
223 | 398k | output_q3 += CFL_BUF_LINE; |
224 | 398k | } |
225 | 111k | } |
226 | | |
227 | | static void cfl_luma_subsampling_422_lbd_c(const uint8_t *input, |
228 | | int input_stride, |
229 | | uint16_t *output_q3, int width, |
230 | 0 | int height) { |
231 | 0 | assert((height - 1) * CFL_BUF_LINE + width <= CFL_BUF_SQUARE); |
232 | 0 | for (int j = 0; j < height; j++) { |
233 | 0 | for (int i = 0; i < width; i += 2) { |
234 | 0 | output_q3[i >> 1] = (input[i] + input[i + 1]) << 2; |
235 | 0 | } |
236 | 0 | input += input_stride; |
237 | 0 | output_q3 += CFL_BUF_LINE; |
238 | 0 | } |
239 | 0 | } |
240 | | |
241 | | static void cfl_luma_subsampling_444_lbd_c(const uint8_t *input, |
242 | | int input_stride, |
243 | | uint16_t *output_q3, int width, |
244 | 0 | int height) { |
245 | 0 | assert((height - 1) * CFL_BUF_LINE + width <= CFL_BUF_SQUARE); |
246 | 0 | for (int j = 0; j < height; j++) { |
247 | 0 | for (int i = 0; i < width; i++) { |
248 | 0 | output_q3[i] = input[i] << 3; |
249 | 0 | } |
250 | 0 | input += input_stride; |
251 | 0 | output_q3 += CFL_BUF_LINE; |
252 | 0 | } |
253 | 0 | } |
254 | | |
255 | | #if CONFIG_AV1_HIGHBITDEPTH |
256 | | static void cfl_luma_subsampling_420_hbd_c(const uint16_t *input, |
257 | | int input_stride, |
258 | | uint16_t *output_q3, int width, |
259 | 0 | int height) { |
260 | 0 | for (int j = 0; j < height; j += 2) { |
261 | 0 | for (int i = 0; i < width; i += 2) { |
262 | 0 | const int bot = i + input_stride; |
263 | 0 | output_q3[i >> 1] = |
264 | 0 | (input[i] + input[i + 1] + input[bot] + input[bot + 1]) << 1; |
265 | 0 | } |
266 | 0 | input += input_stride << 1; |
267 | 0 | output_q3 += CFL_BUF_LINE; |
268 | 0 | } |
269 | 0 | } |
270 | | |
271 | | static void cfl_luma_subsampling_422_hbd_c(const uint16_t *input, |
272 | | int input_stride, |
273 | | uint16_t *output_q3, int width, |
274 | 0 | int height) { |
275 | 0 | assert((height - 1) * CFL_BUF_LINE + width <= CFL_BUF_SQUARE); |
276 | 0 | for (int j = 0; j < height; j++) { |
277 | 0 | for (int i = 0; i < width; i += 2) { |
278 | 0 | output_q3[i >> 1] = (input[i] + input[i + 1]) << 2; |
279 | 0 | } |
280 | 0 | input += input_stride; |
281 | 0 | output_q3 += CFL_BUF_LINE; |
282 | 0 | } |
283 | 0 | } |
284 | | |
285 | | static void cfl_luma_subsampling_444_hbd_c(const uint16_t *input, |
286 | | int input_stride, |
287 | | uint16_t *output_q3, int width, |
288 | 0 | int height) { |
289 | 0 | assert((height - 1) * CFL_BUF_LINE + width <= CFL_BUF_SQUARE); |
290 | 0 | for (int j = 0; j < height; j++) { |
291 | 0 | for (int i = 0; i < width; i++) { |
292 | 0 | output_q3[i] = input[i] << 3; |
293 | 0 | } |
294 | 0 | input += input_stride; |
295 | 0 | output_q3 += CFL_BUF_LINE; |
296 | 0 | } |
297 | 0 | } |
298 | | #endif |
299 | | |
300 | | CFL_GET_SUBSAMPLE_FUNCTION(c) |
301 | | |
302 | | #if CONFIG_AV1_HIGHBITDEPTH |
303 | | static INLINE cfl_subsample_hbd_fn cfl_subsampling_hbd(TX_SIZE tx_size, |
304 | 0 | int sub_x, int sub_y) { |
305 | 0 | if (sub_x == 1) { |
306 | 0 | if (sub_y == 1) { |
307 | 0 | return cfl_get_luma_subsampling_420_hbd(tx_size); |
308 | 0 | } |
309 | 0 | return cfl_get_luma_subsampling_422_hbd(tx_size); |
310 | 0 | } |
311 | 0 | return cfl_get_luma_subsampling_444_hbd(tx_size); |
312 | 0 | } |
313 | | #endif |
314 | | |
315 | | static INLINE cfl_subsample_lbd_fn cfl_subsampling_lbd(TX_SIZE tx_size, |
316 | 111k | int sub_x, int sub_y) { |
317 | 111k | if (sub_x == 1) { |
318 | 111k | if (sub_y == 1) { |
319 | 111k | return cfl_get_luma_subsampling_420_lbd(tx_size); |
320 | 111k | } |
321 | 0 | return cfl_get_luma_subsampling_422_lbd(tx_size); |
322 | 111k | } |
323 | 0 | return cfl_get_luma_subsampling_444_lbd(tx_size); |
324 | 111k | } |
325 | | |
326 | | static void cfl_store(CFL_CTX *cfl, const uint8_t *input, int input_stride, |
327 | 111k | int row, int col, TX_SIZE tx_size, int use_hbd) { |
328 | 111k | const int width = tx_size_wide[tx_size]; |
329 | 111k | const int height = tx_size_high[tx_size]; |
330 | 111k | const int tx_off_log2 = MI_SIZE_LOG2; |
331 | 111k | const int sub_x = cfl->subsampling_x; |
332 | 111k | const int sub_y = cfl->subsampling_y; |
333 | 111k | const int store_row = row << (tx_off_log2 - sub_y); |
334 | 111k | const int store_col = col << (tx_off_log2 - sub_x); |
335 | 111k | const int store_height = height >> sub_y; |
336 | 111k | const int store_width = width >> sub_x; |
337 | | |
338 | | // Invalidate current parameters |
339 | 111k | cfl->are_parameters_computed = 0; |
340 | | |
341 | | // Store the surface of the pixel buffer that was written to, this way we |
342 | | // can manage chroma overrun (e.g. when the chroma surfaces goes beyond the |
343 | | // frame boundary) |
344 | 111k | if (col == 0 && row == 0) { |
345 | 40.7k | cfl->buf_width = store_width; |
346 | 40.7k | cfl->buf_height = store_height; |
347 | 70.2k | } else { |
348 | 70.2k | cfl->buf_width = OD_MAXI(store_col + store_width, cfl->buf_width); |
349 | 70.2k | cfl->buf_height = OD_MAXI(store_row + store_height, cfl->buf_height); |
350 | 70.2k | } |
351 | | |
352 | | // Check that we will remain inside the pixel buffer. |
353 | 111k | assert(store_row + store_height <= CFL_BUF_LINE); |
354 | 111k | assert(store_col + store_width <= CFL_BUF_LINE); |
355 | | |
356 | | // Store the input into the CfL pixel buffer |
357 | 111k | uint16_t *recon_buf_q3 = |
358 | 111k | cfl->recon_buf_q3 + (store_row * CFL_BUF_LINE + store_col); |
359 | 111k | #if CONFIG_AV1_HIGHBITDEPTH |
360 | 111k | if (use_hbd) { |
361 | 0 | cfl_subsampling_hbd(tx_size, sub_x, sub_y)(CONVERT_TO_SHORTPTR(input), |
362 | 0 | input_stride, recon_buf_q3); |
363 | 111k | } else { |
364 | 111k | cfl_subsampling_lbd(tx_size, sub_x, sub_y)(input, input_stride, |
365 | 111k | recon_buf_q3); |
366 | 111k | } |
367 | | #else |
368 | | (void)use_hbd; |
369 | | cfl_subsampling_lbd(tx_size, sub_x, sub_y)(input, input_stride, recon_buf_q3); |
370 | | #endif |
371 | 111k | } |
372 | | |
373 | | // Adjust the row and column of blocks smaller than 8X8, as chroma-referenced |
374 | | // and non-chroma-referenced blocks are stored together in the CfL buffer. |
375 | | static INLINE void sub8x8_adjust_offset(const CFL_CTX *cfl, int mi_row, |
376 | | int mi_col, int *row_out, |
377 | 7.77k | int *col_out) { |
378 | | // Increment row index for bottom: 8x4, 16x4 or both bottom 4x4s. |
379 | 7.77k | if ((mi_row & 0x01) && cfl->subsampling_y) { |
380 | 1.91k | assert(*row_out == 0); |
381 | 1.91k | (*row_out)++; |
382 | 1.91k | } |
383 | | |
384 | | // Increment col index for right: 4x8, 4x16 or both right 4x4s. |
385 | 7.77k | if ((mi_col & 0x01) && cfl->subsampling_x) { |
386 | 2.06k | assert(*col_out == 0); |
387 | 2.06k | (*col_out)++; |
388 | 2.06k | } |
389 | 7.77k | } |
390 | | |
391 | | void cfl_store_tx(MACROBLOCKD *const xd, int row, int col, TX_SIZE tx_size, |
392 | 111k | BLOCK_SIZE bsize) { |
393 | 111k | CFL_CTX *const cfl = &xd->cfl; |
394 | 111k | struct macroblockd_plane *const pd = &xd->plane[AOM_PLANE_Y]; |
395 | 111k | uint8_t *dst = &pd->dst.buf[(row * pd->dst.stride + col) << MI_SIZE_LOG2]; |
396 | | |
397 | 111k | if (block_size_high[bsize] == 4 || block_size_wide[bsize] == 4) { |
398 | | // Only dimensions of size 4 can have an odd offset. |
399 | 7.77k | assert(!((col & 1) && tx_size_wide[tx_size] != 4)); |
400 | 7.77k | assert(!((row & 1) && tx_size_high[tx_size] != 4)); |
401 | 7.77k | sub8x8_adjust_offset(cfl, xd->mi_row, xd->mi_col, &row, &col); |
402 | 7.77k | } |
403 | 111k | cfl_store(cfl, dst, pd->dst.stride, row, col, tx_size, is_cur_buf_hbd(xd)); |
404 | 111k | } |
405 | | |
406 | | static INLINE int max_intra_block_width(const MACROBLOCKD *xd, |
407 | | BLOCK_SIZE plane_bsize, int plane, |
408 | 0 | TX_SIZE tx_size) { |
409 | 0 | const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane) |
410 | 0 | << MI_SIZE_LOG2; |
411 | 0 | return ALIGN_POWER_OF_TWO(max_blocks_wide, tx_size_wide_log2[tx_size]); |
412 | 0 | } |
413 | | |
414 | | static INLINE int max_intra_block_height(const MACROBLOCKD *xd, |
415 | | BLOCK_SIZE plane_bsize, int plane, |
416 | 0 | TX_SIZE tx_size) { |
417 | 0 | const int max_blocks_high = max_block_high(xd, plane_bsize, plane) |
418 | 0 | << MI_SIZE_LOG2; |
419 | 0 | return ALIGN_POWER_OF_TWO(max_blocks_high, tx_size_high_log2[tx_size]); |
420 | 0 | } |
421 | | |
422 | 0 | void cfl_store_block(MACROBLOCKD *const xd, BLOCK_SIZE bsize, TX_SIZE tx_size) { |
423 | 0 | CFL_CTX *const cfl = &xd->cfl; |
424 | 0 | struct macroblockd_plane *const pd = &xd->plane[AOM_PLANE_Y]; |
425 | 0 | int row = 0; |
426 | 0 | int col = 0; |
427 | |
|
428 | 0 | if (block_size_high[bsize] == 4 || block_size_wide[bsize] == 4) { |
429 | 0 | sub8x8_adjust_offset(cfl, xd->mi_row, xd->mi_col, &row, &col); |
430 | 0 | } |
431 | 0 | const int width = max_intra_block_width(xd, bsize, AOM_PLANE_Y, tx_size); |
432 | 0 | const int height = max_intra_block_height(xd, bsize, AOM_PLANE_Y, tx_size); |
433 | 0 | tx_size = get_tx_size(width, height); |
434 | 0 | cfl_store(cfl, pd->dst.buf, pd->dst.stride, row, col, tx_size, |
435 | 0 | is_cur_buf_hbd(xd)); |
436 | 0 | } |