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 <assert.h>
13 #include <math.h>
14 #include <string.h>
15
16 #include "config/aom_scale_rtcd.h"
17
18 #include "aom/aom_integer.h"
19 #include "av1/common/av1_common_int.h"
20 #include "av1/common/cdef.h"
21 #include "av1/common/cdef_block.h"
22 #include "av1/common/reconinter.h"
23
is_8x8_block_skip(MB_MODE_INFO ** grid,int mi_row,int mi_col,int mi_stride)24 static int is_8x8_block_skip(MB_MODE_INFO **grid, int mi_row, int mi_col,
25 int mi_stride) {
26 MB_MODE_INFO **mbmi = grid + mi_row * mi_stride + mi_col;
27 for (int r = 0; r < mi_size_high[BLOCK_8X8]; ++r, mbmi += mi_stride) {
28 for (int c = 0; c < mi_size_wide[BLOCK_8X8]; ++c) {
29 if (!mbmi[c]->skip_txfm) return 0;
30 }
31 }
32
33 return 1;
34 }
35
av1_cdef_compute_sb_list(const CommonModeInfoParams * const mi_params,int mi_row,int mi_col,cdef_list * dlist,BLOCK_SIZE bs)36 int av1_cdef_compute_sb_list(const CommonModeInfoParams *const mi_params,
37 int mi_row, int mi_col, cdef_list *dlist,
38 BLOCK_SIZE bs) {
39 MB_MODE_INFO **grid = mi_params->mi_grid_base;
40 int maxc = mi_params->mi_cols - mi_col;
41 int maxr = mi_params->mi_rows - mi_row;
42
43 if (bs == BLOCK_128X128 || bs == BLOCK_128X64)
44 maxc = AOMMIN(maxc, MI_SIZE_128X128);
45 else
46 maxc = AOMMIN(maxc, MI_SIZE_64X64);
47 if (bs == BLOCK_128X128 || bs == BLOCK_64X128)
48 maxr = AOMMIN(maxr, MI_SIZE_128X128);
49 else
50 maxr = AOMMIN(maxr, MI_SIZE_64X64);
51
52 const int r_step = 2; // mi_size_high[BLOCK_8X8]
53 const int c_step = 2; // mi_size_wide[BLOCK_8X8]
54 const int r_shift = 1;
55 const int c_shift = 1;
56 int count = 0;
57 for (int r = 0; r < maxr; r += r_step) {
58 for (int c = 0; c < maxc; c += c_step) {
59 if (!is_8x8_block_skip(grid, mi_row + r, mi_col + c,
60 mi_params->mi_stride)) {
61 dlist[count].by = r >> r_shift;
62 dlist[count].bx = c >> c_shift;
63 count++;
64 }
65 }
66 }
67 return count;
68 }
69
cdef_copy_rect8_8bit_to_16bit_c(uint16_t * dst,int dstride,const uint8_t * src,int sstride,int width,int height)70 void cdef_copy_rect8_8bit_to_16bit_c(uint16_t *dst, int dstride,
71 const uint8_t *src, int sstride, int width,
72 int height) {
73 for (int i = 0; i < height; i++) {
74 for (int j = 0; j < width; j++) {
75 dst[i * dstride + j] = src[i * sstride + j];
76 }
77 }
78 }
79
cdef_copy_rect8_16bit_to_16bit_c(uint16_t * dst,int dstride,const uint16_t * src,int sstride,int width,int height)80 void cdef_copy_rect8_16bit_to_16bit_c(uint16_t *dst, int dstride,
81 const uint16_t *src, int sstride,
82 int width, int height) {
83 for (int i = 0; i < height; i++) {
84 for (int j = 0; j < width; j++) {
85 dst[i * dstride + j] = src[i * sstride + j];
86 }
87 }
88 }
89
av1_cdef_copy_sb8_16_lowbd(uint16_t * const dst,int dstride,const uint8_t * src,int src_voffset,int src_hoffset,int sstride,int vsize,int hsize)90 void av1_cdef_copy_sb8_16_lowbd(uint16_t *const dst, int dstride,
91 const uint8_t *src, int src_voffset,
92 int src_hoffset, int sstride, int vsize,
93 int hsize) {
94 const uint8_t *base = &src[src_voffset * sstride + src_hoffset];
95 cdef_copy_rect8_8bit_to_16bit(dst, dstride, base, sstride, hsize, vsize);
96 }
97
av1_cdef_copy_sb8_16_highbd(uint16_t * const dst,int dstride,const uint8_t * src,int src_voffset,int src_hoffset,int sstride,int vsize,int hsize)98 void av1_cdef_copy_sb8_16_highbd(uint16_t *const dst, int dstride,
99 const uint8_t *src, int src_voffset,
100 int src_hoffset, int sstride, int vsize,
101 int hsize) {
102 const uint16_t *base =
103 &CONVERT_TO_SHORTPTR(src)[src_voffset * sstride + src_hoffset];
104 cdef_copy_rect8_16bit_to_16bit(dst, dstride, base, sstride, hsize, vsize);
105 }
106
av1_cdef_copy_sb8_16(const AV1_COMMON * const cm,uint16_t * const dst,int dstride,const uint8_t * src,int src_voffset,int src_hoffset,int sstride,int vsize,int hsize)107 void av1_cdef_copy_sb8_16(const AV1_COMMON *const cm, uint16_t *const dst,
108 int dstride, const uint8_t *src, int src_voffset,
109 int src_hoffset, int sstride, int vsize, int hsize) {
110 if (cm->seq_params->use_highbitdepth) {
111 av1_cdef_copy_sb8_16_highbd(dst, dstride, src, src_voffset, src_hoffset,
112 sstride, vsize, hsize);
113 } else {
114 av1_cdef_copy_sb8_16_lowbd(dst, dstride, src, src_voffset, src_hoffset,
115 sstride, vsize, hsize);
116 }
117 }
118
copy_rect(uint16_t * dst,int dstride,const uint16_t * src,int sstride,int v,int h)119 static INLINE void copy_rect(uint16_t *dst, int dstride, const uint16_t *src,
120 int sstride, int v, int h) {
121 for (int i = 0; i < v; i++) {
122 for (int j = 0; j < h; j++) {
123 dst[i * dstride + j] = src[i * sstride + j];
124 }
125 }
126 }
127
128 // Prepares intermediate input buffer for CDEF.
129 // Inputs:
130 // cm: Pointer to common structure.
131 // fb_info: Pointer to the CDEF block-level parameter structure.
132 // colbuf: Left column buffer for CDEF.
133 // cdef_left: Left block is filtered or not.
134 // fbc, fbr: col and row index of a block.
135 // plane: plane index Y/CB/CR.
136 // Returns:
137 // Nothing will be returned.
cdef_prepare_fb(const AV1_COMMON * const cm,CdefBlockInfo * fb_info,uint16_t ** const colbuf,const int cdef_left,int fbc,int fbr,int plane)138 static void cdef_prepare_fb(const AV1_COMMON *const cm, CdefBlockInfo *fb_info,
139 uint16_t **const colbuf, const int cdef_left,
140 int fbc, int fbr, int plane) {
141 const CommonModeInfoParams *const mi_params = &cm->mi_params;
142 uint16_t *src = fb_info->src;
143 const int luma_stride =
144 ALIGN_POWER_OF_TWO(mi_params->mi_cols << MI_SIZE_LOG2, 4);
145 const int nvfb = (mi_params->mi_rows + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
146 const int nhfb = (mi_params->mi_cols + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
147 int cstart = 0;
148 if (!cdef_left) cstart = -CDEF_HBORDER;
149 int rend, cend;
150 const int nhb =
151 AOMMIN(MI_SIZE_64X64, mi_params->mi_cols - MI_SIZE_64X64 * fbc);
152 const int nvb =
153 AOMMIN(MI_SIZE_64X64, mi_params->mi_rows - MI_SIZE_64X64 * fbr);
154 const int hsize = nhb << fb_info->mi_wide_l2;
155 const int vsize = nvb << fb_info->mi_high_l2;
156 const uint16_t *top_linebuf = fb_info->top_linebuf[plane];
157 const uint16_t *bot_linebuf = fb_info->bot_linebuf[plane];
158 const int bot_offset = (vsize + CDEF_VBORDER) * CDEF_BSTRIDE;
159 const int stride =
160 luma_stride >> (plane == AOM_PLANE_Y ? 0 : cm->seq_params->subsampling_x);
161
162 if (fbc == nhfb - 1)
163 cend = hsize;
164 else
165 cend = hsize + CDEF_HBORDER;
166
167 if (fbr == nvfb - 1)
168 rend = vsize;
169 else
170 rend = vsize + CDEF_VBORDER;
171
172 /* Copy in the pixels we need from the current superblock for
173 deringing.*/
174 av1_cdef_copy_sb8_16(
175 cm, &src[CDEF_VBORDER * CDEF_BSTRIDE + CDEF_HBORDER + cstart],
176 CDEF_BSTRIDE, fb_info->dst, fb_info->roffset, fb_info->coffset + cstart,
177 fb_info->dst_stride, vsize, cend - cstart);
178
179 /* Copy in the pixels we need for the current superblock from bottom buffer.*/
180 if (fbr < nvfb - 1) {
181 copy_rect(&src[bot_offset + CDEF_HBORDER], CDEF_BSTRIDE,
182 &bot_linebuf[fb_info->coffset], stride, CDEF_VBORDER, hsize);
183 } else {
184 fill_rect(&src[bot_offset + CDEF_HBORDER], CDEF_BSTRIDE, CDEF_VBORDER,
185 hsize, CDEF_VERY_LARGE);
186 }
187 if (fbr < nvfb - 1 && fbc > 0) {
188 copy_rect(&src[bot_offset], CDEF_BSTRIDE,
189 &bot_linebuf[fb_info->coffset - CDEF_HBORDER], stride,
190 CDEF_VBORDER, CDEF_HBORDER);
191 } else {
192 fill_rect(&src[bot_offset], CDEF_BSTRIDE, CDEF_VBORDER, CDEF_HBORDER,
193 CDEF_VERY_LARGE);
194 }
195 if (fbr < nvfb - 1 && fbc < nhfb - 1) {
196 copy_rect(&src[bot_offset + hsize + CDEF_HBORDER], CDEF_BSTRIDE,
197 &bot_linebuf[fb_info->coffset + hsize], stride, CDEF_VBORDER,
198 CDEF_HBORDER);
199 } else {
200 fill_rect(&src[bot_offset + hsize + CDEF_HBORDER], CDEF_BSTRIDE,
201 CDEF_VBORDER, CDEF_HBORDER, CDEF_VERY_LARGE);
202 }
203
204 /* Copy in the pixels we need from the current superblock from top buffer.*/
205 if (fbr > 0) {
206 copy_rect(&src[CDEF_HBORDER], CDEF_BSTRIDE, &top_linebuf[fb_info->coffset],
207 stride, CDEF_VBORDER, hsize);
208 } else {
209 fill_rect(&src[CDEF_HBORDER], CDEF_BSTRIDE, CDEF_VBORDER, hsize,
210 CDEF_VERY_LARGE);
211 }
212 if (fbr > 0 && fbc > 0) {
213 copy_rect(src, CDEF_BSTRIDE, &top_linebuf[fb_info->coffset - CDEF_HBORDER],
214 stride, CDEF_VBORDER, CDEF_HBORDER);
215 } else {
216 fill_rect(src, CDEF_BSTRIDE, CDEF_VBORDER, CDEF_HBORDER, CDEF_VERY_LARGE);
217 }
218 if (fbr > 0 && fbc < nhfb - 1) {
219 copy_rect(&src[hsize + CDEF_HBORDER], CDEF_BSTRIDE,
220 &top_linebuf[fb_info->coffset + hsize], stride, CDEF_VBORDER,
221 CDEF_HBORDER);
222 } else {
223 fill_rect(&src[hsize + CDEF_HBORDER], CDEF_BSTRIDE, CDEF_VBORDER,
224 CDEF_HBORDER, CDEF_VERY_LARGE);
225 }
226 if (cdef_left) {
227 /* If we deringed the superblock on the left then we need to copy in
228 saved pixels. */
229 copy_rect(src, CDEF_BSTRIDE, colbuf[plane], CDEF_HBORDER,
230 rend + CDEF_VBORDER, CDEF_HBORDER);
231 }
232 /* Saving pixels in case we need to dering the superblock on the
233 right. */
234 copy_rect(colbuf[plane], CDEF_HBORDER, src + hsize, CDEF_BSTRIDE,
235 rend + CDEF_VBORDER, CDEF_HBORDER);
236
237 if (fb_info->frame_boundary[LEFT]) {
238 fill_rect(src, CDEF_BSTRIDE, vsize + 2 * CDEF_VBORDER, CDEF_HBORDER,
239 CDEF_VERY_LARGE);
240 }
241 if (fb_info->frame_boundary[RIGHT]) {
242 fill_rect(&src[hsize + CDEF_HBORDER], CDEF_BSTRIDE,
243 vsize + 2 * CDEF_VBORDER, CDEF_HBORDER, CDEF_VERY_LARGE);
244 }
245 }
246
cdef_filter_fb(CdefBlockInfo * const fb_info,int plane,uint8_t use_highbitdepth)247 static INLINE void cdef_filter_fb(CdefBlockInfo *const fb_info, int plane,
248 uint8_t use_highbitdepth) {
249 int offset = fb_info->dst_stride * fb_info->roffset + fb_info->coffset;
250 if (use_highbitdepth) {
251 av1_cdef_filter_fb(
252 NULL, CONVERT_TO_SHORTPTR(fb_info->dst + offset), fb_info->dst_stride,
253 &fb_info->src[CDEF_VBORDER * CDEF_BSTRIDE + CDEF_HBORDER],
254 fb_info->xdec, fb_info->ydec, fb_info->dir, NULL, fb_info->var, plane,
255 fb_info->dlist, fb_info->cdef_count, fb_info->level,
256 fb_info->sec_strength, fb_info->damping, fb_info->coeff_shift);
257 } else {
258 av1_cdef_filter_fb(
259 fb_info->dst + offset, NULL, fb_info->dst_stride,
260 &fb_info->src[CDEF_VBORDER * CDEF_BSTRIDE + CDEF_HBORDER],
261 fb_info->xdec, fb_info->ydec, fb_info->dir, NULL, fb_info->var, plane,
262 fb_info->dlist, fb_info->cdef_count, fb_info->level,
263 fb_info->sec_strength, fb_info->damping, fb_info->coeff_shift);
264 }
265 }
266
267 // Initializes block-level parameters for CDEF.
cdef_init_fb_col(const MACROBLOCKD * const xd,CdefBlockInfo * const fb_info,int * level,int * sec_strength,int fbc,int fbr,int plane)268 static INLINE void cdef_init_fb_col(const MACROBLOCKD *const xd,
269 CdefBlockInfo *const fb_info, int *level,
270 int *sec_strength, int fbc, int fbr,
271 int plane) {
272 const PLANE_TYPE plane_type = get_plane_type(plane);
273 fb_info->level = level[plane_type];
274 fb_info->sec_strength = sec_strength[plane_type];
275 fb_info->dst = xd->plane[plane].dst.buf;
276 fb_info->dst_stride = xd->plane[plane].dst.stride;
277
278 fb_info->xdec = xd->plane[plane].subsampling_x;
279 fb_info->ydec = xd->plane[plane].subsampling_y;
280 fb_info->mi_wide_l2 = MI_SIZE_LOG2 - xd->plane[plane].subsampling_x;
281 fb_info->mi_high_l2 = MI_SIZE_LOG2 - xd->plane[plane].subsampling_y;
282 fb_info->roffset = MI_SIZE_64X64 * fbr << fb_info->mi_high_l2;
283 fb_info->coffset = MI_SIZE_64X64 * fbc << fb_info->mi_wide_l2;
284 }
285
cdef_fb_col(const AV1_COMMON * const cm,const MACROBLOCKD * const xd,CdefBlockInfo * const fb_info,uint16_t ** const colbuf,int * cdef_left,int fbc,int fbr)286 static void cdef_fb_col(const AV1_COMMON *const cm, const MACROBLOCKD *const xd,
287 CdefBlockInfo *const fb_info, uint16_t **const colbuf,
288 int *cdef_left, int fbc, int fbr) {
289 const CommonModeInfoParams *const mi_params = &cm->mi_params;
290 const int mbmi_cdef_strength =
291 mi_params
292 ->mi_grid_base[MI_SIZE_64X64 * fbr * mi_params->mi_stride +
293 MI_SIZE_64X64 * fbc]
294 ->cdef_strength;
295 const int num_planes = av1_num_planes(cm);
296 int is_zero_level[PLANE_TYPES] = { 1, 1 };
297 int level[PLANE_TYPES] = { 0 };
298 int sec_strength[PLANE_TYPES] = { 0 };
299 const CdefInfo *const cdef_info = &cm->cdef_info;
300
301 if (mi_params->mi_grid_base[MI_SIZE_64X64 * fbr * mi_params->mi_stride +
302 MI_SIZE_64X64 * fbc] == NULL ||
303 mbmi_cdef_strength == -1) {
304 av1_zero_array(cdef_left, num_planes);
305 return;
306 }
307
308 // Compute level and secondary strength for planes
309 level[PLANE_TYPE_Y] =
310 cdef_info->cdef_strengths[mbmi_cdef_strength] / CDEF_SEC_STRENGTHS;
311 sec_strength[PLANE_TYPE_Y] =
312 cdef_info->cdef_strengths[mbmi_cdef_strength] % CDEF_SEC_STRENGTHS;
313 sec_strength[PLANE_TYPE_Y] += sec_strength[PLANE_TYPE_Y] == 3;
314 is_zero_level[PLANE_TYPE_Y] =
315 (level[PLANE_TYPE_Y] == 0) && (sec_strength[PLANE_TYPE_Y] == 0);
316
317 if (num_planes > 1) {
318 level[PLANE_TYPE_UV] =
319 cdef_info->cdef_uv_strengths[mbmi_cdef_strength] / CDEF_SEC_STRENGTHS;
320 sec_strength[PLANE_TYPE_UV] =
321 cdef_info->cdef_uv_strengths[mbmi_cdef_strength] % CDEF_SEC_STRENGTHS;
322 sec_strength[PLANE_TYPE_UV] += sec_strength[PLANE_TYPE_UV] == 3;
323 is_zero_level[PLANE_TYPE_UV] =
324 (level[PLANE_TYPE_UV] == 0) && (sec_strength[PLANE_TYPE_UV] == 0);
325 }
326
327 if (is_zero_level[PLANE_TYPE_Y] && is_zero_level[PLANE_TYPE_UV]) {
328 av1_zero_array(cdef_left, num_planes);
329 return;
330 }
331
332 fb_info->cdef_count = av1_cdef_compute_sb_list(mi_params, fbr * MI_SIZE_64X64,
333 fbc * MI_SIZE_64X64,
334 fb_info->dlist, BLOCK_64X64);
335 if (!fb_info->cdef_count) {
336 av1_zero_array(cdef_left, num_planes);
337 return;
338 }
339
340 for (int plane = 0; plane < num_planes; plane++) {
341 // Do not skip cdef filtering for luma plane as filter direction is
342 // computed based on luma.
343 if (plane && is_zero_level[get_plane_type(plane)]) {
344 cdef_left[plane] = 0;
345 continue;
346 }
347 cdef_init_fb_col(xd, fb_info, level, sec_strength, fbc, fbr, plane);
348 cdef_prepare_fb(cm, fb_info, colbuf, cdef_left[plane], fbc, fbr, plane);
349 cdef_filter_fb(fb_info, plane, cm->seq_params->use_highbitdepth);
350 cdef_left[plane] = 1;
351 }
352 }
353
354 // Initializes row-level parameters for CDEF frame.
av1_cdef_init_fb_row(const AV1_COMMON * const cm,const MACROBLOCKD * const xd,CdefBlockInfo * const fb_info,uint16_t ** const linebuf,uint16_t * const src,struct AV1CdefSyncData * const cdef_sync,int fbr)355 void av1_cdef_init_fb_row(const AV1_COMMON *const cm,
356 const MACROBLOCKD *const xd,
357 CdefBlockInfo *const fb_info,
358 uint16_t **const linebuf, uint16_t *const src,
359 struct AV1CdefSyncData *const cdef_sync, int fbr) {
360 (void)cdef_sync;
361 const int num_planes = av1_num_planes(cm);
362 const int nvfb = (cm->mi_params.mi_rows + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
363 const int luma_stride =
364 ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols << MI_SIZE_LOG2, 4);
365 const bool ping_pong = fbr & 1;
366 // for the current filter block, it's top left corner mi structure (mi_tl)
367 // is first accessed to check whether the top and left boundaries are
368 // frame boundaries. Then bottom-left and top-right mi structures are
369 // accessed to check whether the bottom and right boundaries
370 // (respectively) are frame boundaries.
371 //
372 // Note that we can't just check the bottom-right mi structure - eg. if
373 // we're at the right-hand edge of the frame but not the bottom, then
374 // the bottom-right mi is NULL but the bottom-left is not.
375 fb_info->frame_boundary[TOP] = (MI_SIZE_64X64 * fbr == 0) ? 1 : 0;
376 if (fbr != nvfb - 1)
377 fb_info->frame_boundary[BOTTOM] =
378 (MI_SIZE_64X64 * (fbr + 1) == cm->mi_params.mi_rows) ? 1 : 0;
379 else
380 fb_info->frame_boundary[BOTTOM] = 1;
381
382 fb_info->src = src;
383 fb_info->damping = cm->cdef_info.cdef_damping;
384 fb_info->coeff_shift = AOMMAX(cm->seq_params->bit_depth - 8, 0);
385 av1_zero(fb_info->dir);
386 av1_zero(fb_info->var);
387
388 for (int plane = 0; plane < num_planes; plane++) {
389 const int mi_high_l2 = MI_SIZE_LOG2 - xd->plane[plane].subsampling_y;
390 const int offset = MI_SIZE_64X64 * (fbr + 1) << mi_high_l2;
391 const int stride = luma_stride >> xd->plane[plane].subsampling_x;
392 // here ping-pong buffers are maintained for top linebuf
393 // to avoid linebuf over-write by consecutive row.
394 uint16_t *const top_linebuf =
395 &linebuf[plane][ping_pong * CDEF_VBORDER * stride];
396 fb_info->bot_linebuf[plane] = &linebuf[plane][(CDEF_VBORDER << 1) * stride];
397
398 if (fbr != nvfb - 1) // top line buffer copy
399 av1_cdef_copy_sb8_16(cm, top_linebuf, stride, xd->plane[plane].dst.buf,
400 offset - CDEF_VBORDER, 0,
401 xd->plane[plane].dst.stride, CDEF_VBORDER, stride);
402 fb_info->top_linebuf[plane] =
403 &linebuf[plane][(!ping_pong) * CDEF_VBORDER * stride];
404
405 if (fbr != nvfb - 1) // bottom line buffer copy
406 av1_cdef_copy_sb8_16(cm, fb_info->bot_linebuf[plane], stride,
407 xd->plane[plane].dst.buf, offset, 0,
408 xd->plane[plane].dst.stride, CDEF_VBORDER, stride);
409 }
410 }
411
av1_cdef_fb_row(const AV1_COMMON * const cm,MACROBLOCKD * xd,uint16_t ** const linebuf,uint16_t ** const colbuf,uint16_t * const src,int fbr,cdef_init_fb_row_t cdef_init_fb_row_fn,struct AV1CdefSyncData * const cdef_sync)412 void av1_cdef_fb_row(const AV1_COMMON *const cm, MACROBLOCKD *xd,
413 uint16_t **const linebuf, uint16_t **const colbuf,
414 uint16_t *const src, int fbr,
415 cdef_init_fb_row_t cdef_init_fb_row_fn,
416 struct AV1CdefSyncData *const cdef_sync) {
417 CdefBlockInfo fb_info;
418 int cdef_left[MAX_MB_PLANE] = { 1, 1, 1 };
419 const int nhfb = (cm->mi_params.mi_cols + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
420
421 cdef_init_fb_row_fn(cm, xd, &fb_info, linebuf, src, cdef_sync, fbr);
422 for (int fbc = 0; fbc < nhfb; fbc++) {
423 fb_info.frame_boundary[LEFT] = (MI_SIZE_64X64 * fbc == 0) ? 1 : 0;
424 if (fbc != nhfb - 1)
425 fb_info.frame_boundary[RIGHT] =
426 (MI_SIZE_64X64 * (fbc + 1) == cm->mi_params.mi_cols) ? 1 : 0;
427 else
428 fb_info.frame_boundary[RIGHT] = 1;
429 cdef_fb_col(cm, xd, &fb_info, colbuf, &cdef_left[0], fbc, fbr);
430 }
431 }
432
433 // Perform CDEF on input frame.
434 // Inputs:
435 // frame: Pointer to input frame buffer.
436 // cm: Pointer to common structure.
437 // xd: Pointer to common current coding block structure.
438 // Returns:
439 // Nothing will be returned.
av1_cdef_frame(YV12_BUFFER_CONFIG * frame,AV1_COMMON * const cm,MACROBLOCKD * xd,cdef_init_fb_row_t cdef_init_fb_row_fn)440 void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *const cm,
441 MACROBLOCKD *xd, cdef_init_fb_row_t cdef_init_fb_row_fn) {
442 const int num_planes = av1_num_planes(cm);
443 const int nvfb = (cm->mi_params.mi_rows + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
444
445 av1_setup_dst_planes(xd->plane, cm->seq_params->sb_size, frame, 0, 0, 0,
446 num_planes);
447
448 for (int fbr = 0; fbr < nvfb; fbr++)
449 av1_cdef_fb_row(cm, xd, cm->cdef_info.linebuf, cm->cdef_info.colbuf,
450 cm->cdef_info.srcbuf, fbr, cdef_init_fb_row_fn, NULL);
451 }
452