• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 v,int h)70 void cdef_copy_rect8_8bit_to_16bit_c(uint16_t *dst, int dstride,
71                                      const uint8_t *src, int sstride, int v,
72                                      int h) {
73   for (int i = 0; i < v; i++) {
74     for (int j = 0; j < h; 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 v,int h)80 void cdef_copy_rect8_16bit_to_16bit_c(uint16_t *dst, int dstride,
81                                       const uint16_t *src, int sstride, int v,
82                                       int h) {
83   for (int i = 0; i < v; i++) {
84     for (int j = 0; j < h; j++) {
85       dst[i * dstride + j] = src[i * sstride + j];
86     }
87   }
88 }
89 
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)90 void av1_cdef_copy_sb8_16(const AV1_COMMON *const cm, uint16_t *const dst,
91                           int dstride, const uint8_t *src, int src_voffset,
92                           int src_hoffset, int sstride, int vsize, int hsize) {
93   if (cm->seq_params->use_highbitdepth) {
94     const uint16_t *base =
95         &CONVERT_TO_SHORTPTR(src)[src_voffset * sstride + src_hoffset];
96     cdef_copy_rect8_16bit_to_16bit(dst, dstride, base, sstride, vsize, hsize);
97   } else {
98     const uint8_t *base = &src[src_voffset * sstride + src_hoffset];
99     cdef_copy_rect8_8bit_to_16bit(dst, dstride, base, sstride, vsize, hsize);
100   }
101 }
102 
fill_rect(uint16_t * dst,int dstride,int v,int h,uint16_t x)103 static INLINE void fill_rect(uint16_t *dst, int dstride, int v, int h,
104                              uint16_t x) {
105   for (int i = 0; i < v; i++) {
106     for (int j = 0; j < h; j++) {
107       dst[i * dstride + j] = x;
108     }
109   }
110 }
111 
copy_rect(uint16_t * dst,int dstride,const uint16_t * src,int sstride,int v,int h)112 static INLINE void copy_rect(uint16_t *dst, int dstride, const uint16_t *src,
113                              int sstride, int v, int h) {
114   for (int i = 0; i < v; i++) {
115     for (int j = 0; j < h; j++) {
116       dst[i * dstride + j] = src[i * sstride + j];
117     }
118   }
119 }
120 
121 // Prepares intermediate input buffer for CDEF.
122 // Inputs:
123 //   cm: Pointer to common structure.
124 //   fb_info: Pointer to the CDEF block-level parameter structure.
125 //   colbuf: Left column buffer for CDEF.
126 //   cdef_left: Left block is filtered or not.
127 //   fbc, fbr: col and row index of a block.
128 //   plane: plane index Y/CB/CR.
129 // Returns:
130 //   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)131 static void cdef_prepare_fb(const AV1_COMMON *const cm, CdefBlockInfo *fb_info,
132                             uint16_t **const colbuf, const int *cdef_left,
133                             int fbc, int fbr, int plane) {
134   const CommonModeInfoParams *const mi_params = &cm->mi_params;
135   uint16_t *src = fb_info->src;
136   const int luma_stride =
137       ALIGN_POWER_OF_TWO(mi_params->mi_cols << MI_SIZE_LOG2, 4);
138   const int nvfb = (mi_params->mi_rows + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
139   const int nhfb = (mi_params->mi_cols + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
140   int cstart = 0;
141   if (!*cdef_left) cstart = -CDEF_HBORDER;
142   int rend, cend;
143   const int nhb =
144       AOMMIN(MI_SIZE_64X64, mi_params->mi_cols - MI_SIZE_64X64 * fbc);
145   const int nvb =
146       AOMMIN(MI_SIZE_64X64, mi_params->mi_rows - MI_SIZE_64X64 * fbr);
147   const int hsize = nhb << fb_info->mi_wide_l2;
148   const int vsize = nvb << fb_info->mi_high_l2;
149   const uint16_t *top_linebuf = fb_info->top_linebuf[plane];
150   const uint16_t *bot_linebuf = fb_info->bot_linebuf[plane];
151   const int bot_offset = (vsize + CDEF_VBORDER) * CDEF_BSTRIDE;
152   const int stride =
153       luma_stride >> (plane == AOM_PLANE_Y ? 0 : cm->seq_params->subsampling_x);
154 
155   if (fbc == nhfb - 1)
156     cend = hsize;
157   else
158     cend = hsize + CDEF_HBORDER;
159 
160   if (fbr == nvfb - 1)
161     rend = vsize;
162   else
163     rend = vsize + CDEF_VBORDER;
164 
165   /* Copy in the pixels we need from the current superblock for
166   deringing.*/
167   av1_cdef_copy_sb8_16(
168       cm, &src[CDEF_VBORDER * CDEF_BSTRIDE + CDEF_HBORDER + cstart],
169       CDEF_BSTRIDE, fb_info->dst, fb_info->roffset, fb_info->coffset + cstart,
170       fb_info->dst_stride, vsize, cend - cstart);
171 
172   /* Copy in the pixels we need for the current superblock from bottom buffer.*/
173   if (fbr < nvfb - 1) {
174     copy_rect(&src[bot_offset + CDEF_HBORDER], CDEF_BSTRIDE,
175               &bot_linebuf[fb_info->coffset], stride, CDEF_VBORDER, hsize);
176   } else {
177     fill_rect(&src[bot_offset + CDEF_HBORDER], CDEF_BSTRIDE, CDEF_VBORDER,
178               hsize, CDEF_VERY_LARGE);
179   }
180   if (fbr < nvfb - 1 && fbc > 0) {
181     copy_rect(&src[bot_offset], CDEF_BSTRIDE,
182               &bot_linebuf[fb_info->coffset - CDEF_HBORDER], stride,
183               CDEF_VBORDER, CDEF_HBORDER);
184   } else {
185     fill_rect(&src[bot_offset], CDEF_BSTRIDE, CDEF_VBORDER, CDEF_HBORDER,
186               CDEF_VERY_LARGE);
187   }
188   if (fbr < nvfb - 1 && fbc < nhfb - 1) {
189     copy_rect(&src[bot_offset + hsize + CDEF_HBORDER], CDEF_BSTRIDE,
190               &bot_linebuf[fb_info->coffset + hsize], stride, CDEF_VBORDER,
191               CDEF_HBORDER);
192   } else {
193     fill_rect(&src[bot_offset + hsize + CDEF_HBORDER], CDEF_BSTRIDE,
194               CDEF_VBORDER, CDEF_HBORDER, CDEF_VERY_LARGE);
195   }
196 
197   /* Copy in the pixels we need from the current superblock from top buffer.*/
198   if (fbr > 0) {
199     copy_rect(&src[CDEF_HBORDER], CDEF_BSTRIDE, &top_linebuf[fb_info->coffset],
200               stride, CDEF_VBORDER, hsize);
201   } else {
202     fill_rect(&src[CDEF_HBORDER], CDEF_BSTRIDE, CDEF_VBORDER, hsize,
203               CDEF_VERY_LARGE);
204   }
205   if (fbr > 0 && fbc > 0) {
206     copy_rect(src, CDEF_BSTRIDE, &top_linebuf[fb_info->coffset - CDEF_HBORDER],
207               stride, CDEF_VBORDER, CDEF_HBORDER);
208   } else {
209     fill_rect(src, CDEF_BSTRIDE, CDEF_VBORDER, CDEF_HBORDER, CDEF_VERY_LARGE);
210   }
211   if (fbr > 0 && fbc < nhfb - 1) {
212     copy_rect(&src[hsize + CDEF_HBORDER], CDEF_BSTRIDE,
213               &top_linebuf[fb_info->coffset + hsize], stride, CDEF_VBORDER,
214               CDEF_HBORDER);
215   } else {
216     fill_rect(&src[hsize + CDEF_HBORDER], CDEF_BSTRIDE, CDEF_VBORDER,
217               CDEF_HBORDER, CDEF_VERY_LARGE);
218   }
219   if (*cdef_left) {
220     /* If we deringed the superblock on the left then we need to copy in
221     saved pixels. */
222     copy_rect(src, CDEF_BSTRIDE, colbuf[plane], CDEF_HBORDER,
223               rend + CDEF_VBORDER, CDEF_HBORDER);
224   }
225   /* Saving pixels in case we need to dering the superblock on the
226   right. */
227   copy_rect(colbuf[plane], CDEF_HBORDER, src + hsize, CDEF_BSTRIDE,
228             rend + CDEF_VBORDER, CDEF_HBORDER);
229 
230   if (fb_info->frame_boundary[LEFT]) {
231     fill_rect(src, CDEF_BSTRIDE, vsize + 2 * CDEF_VBORDER, CDEF_HBORDER,
232               CDEF_VERY_LARGE);
233   }
234   if (fb_info->frame_boundary[RIGHT]) {
235     fill_rect(&src[hsize + CDEF_HBORDER], CDEF_BSTRIDE,
236               vsize + 2 * CDEF_VBORDER, CDEF_HBORDER, CDEF_VERY_LARGE);
237   }
238 }
239 
cdef_filter_fb(CdefBlockInfo * const fb_info,int plane,uint8_t use_highbitdepth)240 static INLINE void cdef_filter_fb(CdefBlockInfo *const fb_info, int plane,
241                                   uint8_t use_highbitdepth) {
242   int offset = fb_info->dst_stride * fb_info->roffset + fb_info->coffset;
243   if (use_highbitdepth) {
244     av1_cdef_filter_fb(
245         NULL, CONVERT_TO_SHORTPTR(fb_info->dst + offset), fb_info->dst_stride,
246         &fb_info->src[CDEF_VBORDER * CDEF_BSTRIDE + CDEF_HBORDER],
247         fb_info->xdec, fb_info->ydec, fb_info->dir, NULL, fb_info->var, plane,
248         fb_info->dlist, fb_info->cdef_count, fb_info->level,
249         fb_info->sec_strength, fb_info->damping, fb_info->coeff_shift);
250   } else {
251     av1_cdef_filter_fb(
252         fb_info->dst + offset, NULL, 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   }
258 }
259 
260 // Initializes block-level parameters for CDEF.
cdef_init_fb_col(const MACROBLOCKD * const xd,const CdefInfo * const cdef_info,CdefBlockInfo * const fb_info,int mbmi_cdef_strength,int fbc,int fbr,int plane)261 static INLINE void cdef_init_fb_col(const MACROBLOCKD *const xd,
262                                     const CdefInfo *const cdef_info,
263                                     CdefBlockInfo *const fb_info,
264                                     int mbmi_cdef_strength, int fbc, int fbr,
265                                     int plane) {
266   if (plane == AOM_PLANE_Y) {
267     fb_info->level =
268         cdef_info->cdef_strengths[mbmi_cdef_strength] / CDEF_SEC_STRENGTHS;
269     fb_info->sec_strength =
270         cdef_info->cdef_strengths[mbmi_cdef_strength] % CDEF_SEC_STRENGTHS;
271     fb_info->sec_strength += fb_info->sec_strength == 3;
272     int uv_level =
273         cdef_info->cdef_uv_strengths[mbmi_cdef_strength] / CDEF_SEC_STRENGTHS;
274     int uv_sec_strength =
275         cdef_info->cdef_uv_strengths[mbmi_cdef_strength] % CDEF_SEC_STRENGTHS;
276     uv_sec_strength += uv_sec_strength == 3;
277     fb_info->is_zero_level = (fb_info->level == 0) &&
278                              (fb_info->sec_strength == 0) && (uv_level == 0) &&
279                              (uv_sec_strength == 0);
280   } else {
281     fb_info->level =
282         cdef_info->cdef_uv_strengths[mbmi_cdef_strength] / CDEF_SEC_STRENGTHS;
283     fb_info->sec_strength =
284         cdef_info->cdef_uv_strengths[mbmi_cdef_strength] % CDEF_SEC_STRENGTHS;
285     fb_info->sec_strength += fb_info->sec_strength == 3;
286   }
287   fb_info->dst = xd->plane[plane].dst.buf;
288   fb_info->dst_stride = xd->plane[plane].dst.stride;
289 
290   fb_info->xdec = xd->plane[plane].subsampling_x;
291   fb_info->ydec = xd->plane[plane].subsampling_y;
292   fb_info->mi_wide_l2 = MI_SIZE_LOG2 - xd->plane[plane].subsampling_x;
293   fb_info->mi_high_l2 = MI_SIZE_LOG2 - xd->plane[plane].subsampling_y;
294   fb_info->roffset = MI_SIZE_64X64 * fbr << fb_info->mi_high_l2;
295   fb_info->coffset = MI_SIZE_64X64 * fbc << fb_info->mi_wide_l2;
296 }
297 
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)298 static void cdef_fb_col(const AV1_COMMON *const cm, const MACROBLOCKD *const xd,
299                         CdefBlockInfo *const fb_info, uint16_t **const colbuf,
300                         int *cdef_left, int fbc, int fbr) {
301   const CommonModeInfoParams *const mi_params = &cm->mi_params;
302   const int mbmi_cdef_strength =
303       mi_params
304           ->mi_grid_base[MI_SIZE_64X64 * fbr * mi_params->mi_stride +
305                          MI_SIZE_64X64 * fbc]
306           ->cdef_strength;
307   const int num_planes = av1_num_planes(cm);
308 
309   if (mi_params->mi_grid_base[MI_SIZE_64X64 * fbr * mi_params->mi_stride +
310                               MI_SIZE_64X64 * fbc] == NULL ||
311       mbmi_cdef_strength == -1) {
312     *cdef_left = 0;
313     return;
314   }
315   for (int plane = 0; plane < num_planes; plane++) {
316     cdef_init_fb_col(xd, &cm->cdef_info, fb_info, mbmi_cdef_strength, fbc, fbr,
317                      plane);
318     if (fb_info->is_zero_level ||
319         (fb_info->cdef_count = av1_cdef_compute_sb_list(
320              mi_params, fbr * MI_SIZE_64X64, fbc * MI_SIZE_64X64,
321              fb_info->dlist, BLOCK_64X64)) == 0) {
322       *cdef_left = 0;
323       return;
324     }
325     cdef_prepare_fb(cm, fb_info, colbuf, cdef_left, fbc, fbr, plane);
326     cdef_filter_fb(fb_info, plane, cm->seq_params->use_highbitdepth);
327   }
328   *cdef_left = 1;
329 }
330 
331 // 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)332 void av1_cdef_init_fb_row(const AV1_COMMON *const cm,
333                           const MACROBLOCKD *const xd,
334                           CdefBlockInfo *const fb_info,
335                           uint16_t **const linebuf, uint16_t *const src,
336                           struct AV1CdefSyncData *const cdef_sync, int fbr) {
337   (void)cdef_sync;
338   const int num_planes = av1_num_planes(cm);
339   const int nvfb = (cm->mi_params.mi_rows + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
340   const int luma_stride =
341       ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols << MI_SIZE_LOG2, 4);
342   const bool ping_pong = fbr & 1;
343   // for the current filter block, it's top left corner mi structure (mi_tl)
344   // is first accessed to check whether the top and left boundaries are
345   // frame boundaries. Then bottom-left and top-right mi structures are
346   // accessed to check whether the bottom and right boundaries
347   // (respectively) are frame boundaries.
348   //
349   // Note that we can't just check the bottom-right mi structure - eg. if
350   // we're at the right-hand edge of the frame but not the bottom, then
351   // the bottom-right mi is NULL but the bottom-left is not.
352   fb_info->frame_boundary[TOP] = (MI_SIZE_64X64 * fbr == 0) ? 1 : 0;
353   if (fbr != nvfb - 1)
354     fb_info->frame_boundary[BOTTOM] =
355         (MI_SIZE_64X64 * (fbr + 1) == cm->mi_params.mi_rows) ? 1 : 0;
356   else
357     fb_info->frame_boundary[BOTTOM] = 1;
358 
359   fb_info->src = src;
360   fb_info->damping = cm->cdef_info.cdef_damping;
361   fb_info->coeff_shift = AOMMAX(cm->seq_params->bit_depth - 8, 0);
362   av1_zero(fb_info->dir);
363   av1_zero(fb_info->var);
364 
365   for (int plane = 0; plane < num_planes; plane++) {
366     const int mi_high_l2 = MI_SIZE_LOG2 - xd->plane[plane].subsampling_y;
367     const int offset = MI_SIZE_64X64 * (fbr + 1) << mi_high_l2;
368     const int stride = luma_stride >> xd->plane[plane].subsampling_x;
369     // here ping-pong buffers are maintained for top linebuf
370     // to avoid linebuf over-write by consecutive row.
371     uint16_t *const top_linebuf =
372         &linebuf[plane][ping_pong * CDEF_VBORDER * stride];
373     fb_info->bot_linebuf[plane] = &linebuf[plane][(CDEF_VBORDER << 1) * stride];
374 
375     if (fbr != nvfb - 1)  // top line buffer copy
376       av1_cdef_copy_sb8_16(cm, top_linebuf, stride, xd->plane[plane].dst.buf,
377                            offset - CDEF_VBORDER, 0,
378                            xd->plane[plane].dst.stride, CDEF_VBORDER, stride);
379     fb_info->top_linebuf[plane] =
380         &linebuf[plane][(!ping_pong) * CDEF_VBORDER * stride];
381 
382     if (fbr != nvfb - 1)  // bottom line buffer copy
383       av1_cdef_copy_sb8_16(cm, fb_info->bot_linebuf[plane], stride,
384                            xd->plane[plane].dst.buf, offset, 0,
385                            xd->plane[plane].dst.stride, CDEF_VBORDER, stride);
386   }
387 }
388 
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)389 void av1_cdef_fb_row(const AV1_COMMON *const cm, MACROBLOCKD *xd,
390                      uint16_t **const linebuf, uint16_t **const colbuf,
391                      uint16_t *const src, int fbr,
392                      cdef_init_fb_row_t cdef_init_fb_row_fn,
393                      struct AV1CdefSyncData *const cdef_sync) {
394   CdefBlockInfo fb_info;
395   int cdef_left = 1;
396   const int nhfb = (cm->mi_params.mi_cols + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
397 
398   cdef_init_fb_row_fn(cm, xd, &fb_info, linebuf, src, cdef_sync, fbr);
399   for (int fbc = 0; fbc < nhfb; fbc++) {
400     fb_info.frame_boundary[LEFT] = (MI_SIZE_64X64 * fbc == 0) ? 1 : 0;
401     if (fbc != nhfb - 1)
402       fb_info.frame_boundary[RIGHT] =
403           (MI_SIZE_64X64 * (fbc + 1) == cm->mi_params.mi_cols) ? 1 : 0;
404     else
405       fb_info.frame_boundary[RIGHT] = 1;
406     cdef_fb_col(cm, xd, &fb_info, colbuf, &cdef_left, fbc, fbr);
407   }
408 }
409 
410 // Perform CDEF on input frame.
411 // Inputs:
412 //   frame: Pointer to input frame buffer.
413 //   cm: Pointer to common structure.
414 //   xd: Pointer to common current coding block structure.
415 // Returns:
416 //   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)417 void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *const cm,
418                     MACROBLOCKD *xd, cdef_init_fb_row_t cdef_init_fb_row_fn) {
419   const int num_planes = av1_num_planes(cm);
420   const int nvfb = (cm->mi_params.mi_rows + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
421 
422   av1_setup_dst_planes(xd->plane, cm->seq_params->sb_size, frame, 0, 0, 0,
423                        num_planes);
424 
425   for (int fbr = 0; fbr < nvfb; fbr++)
426     av1_cdef_fb_row(cm, xd, cm->cdef_info.linebuf, cm->cdef_info.colbuf,
427                     cm->cdef_info.srcbuf, fbr, cdef_init_fb_row_fn, NULL);
428 }
429