static int is_8x8_block_skip(MB_MODE_INFO **grid, int mi_row, int mi_col,
int mi_stride) {
MB_MODE_INFO **mbmi = grid + mi_row * mi_stride + mi_col;
for (int r = 0; r < mi_size_high[BLOCK_8X8]; ++r, mbmi += mi_stride) {
for (int c = 0; c < mi_size_wide[BLOCK_8X8]; ++c) {
if (!mbmi[c]->skip_txfm) return0;
}
}
return1;
}
int av1_cdef_compute_sb_list(const CommonModeInfoParams *const mi_params,
int mi_row, int mi_col, cdef_list *dlist,
BLOCK_SIZE bs) {
MB_MODE_INFO **grid = mi_params->mi_grid_base;
int maxc = mi_params->mi_cols - mi_col;
int maxr = mi_params->mi_rows - mi_row;
const int r_step = 2; // mi_size_high[BLOCK_8X8] const int c_step = 2; // mi_size_wide[BLOCK_8X8] const int r_shift = 1; const int c_shift = 1;
int count = 0;
for (int r = 0; r < maxr; r += r_step) {
for (int c = 0; c < maxc; c += c_step) {
if (!is_8x8_block_skip(grid, mi_row + r, mi_col + c,
mi_params->mi_stride)) {
dlist[count].by = r >> r_shift;
dlist[count].bx = c >> c_shift;
count++;
}
}
} return count;
}
void cdef_copy_rect8_8bit_to_16bit_c(uint16_t *dst, int dstride, const uint8_t *src, int sstride, int width,
int height) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
dst[i * dstride + j] = src[i * sstride + j];
}
}
}
#if CONFIG_AV1_HIGHBITDEPTH void cdef_copy_rect8_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, int sstride,
int width, int height) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
dst[i * dstride + j] = src[i * sstride + j];
}
}
} #endif// CONFIG_AV1_HIGHBITDEPTH
void 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) { const uint8_t *base = &src[src_voffset * (ptrdiff_t)sstride + src_hoffset];
cdef_copy_rect8_8bit_to_16bit(dst, dstride, base, sstride, hsize, vsize);
}
#if CONFIG_AV1_HIGHBITDEPTH void 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) { const uint16_t *base =
&CONVERT_TO_SHORTPTR(src)[src_voffset * (ptrdiff_t)sstride + src_hoffset];
cdef_copy_rect8_16bit_to_16bit(dst, dstride, base, sstride, hsize, vsize);
} #endif// CONFIG_AV1_HIGHBITDEPTH
void 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) { #if CONFIG_AV1_HIGHBITDEPTH
if (cm->seq_params->use_highbitdepth) {
av1_cdef_copy_sb8_16_highbd(dst, dstride, src, src_voffset, src_hoffset,
sstride, vsize, hsize); return;
} #else
(void)cm; #endif// CONFIG_AV1_HIGHBITDEPTH
av1_cdef_copy_sb8_16_lowbd(dst, dstride, src, src_voffset, src_hoffset,
sstride, vsize, hsize);
}
static inline void copy_rect(uint16_t *dst, int dstride, const uint16_t *src,
int sstride, int v, int h) {
for (int i = 0; i < v; i++) {
for (int j = 0; j < h; j++) {
dst[i * dstride + j] = src[i * sstride + j];
}
}
}
// Prepares intermediate input buffer for CDEF. // Inputs: // cm: Pointer to common structure. // fb_info: Pointer to the CDEF block-level parameter structure. // colbuf: Left column buffer for CDEF. // cdef_left: Left block is filtered or not. // fbc, fbr: col and row index of a block. // plane: plane index Y/CB/CR. // Returns: // Nothing will be returned. staticvoid 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) { const CommonModeInfoParams *const mi_params = &cm->mi_params;
uint16_t *src = fb_info->src; const int luma_stride =
ALIGN_POWER_OF_TWO(mi_params->mi_cols << MI_SIZE_LOG2, 4); const int nvfb = (mi_params->mi_rows + MI_SIZE_64X64 - 1) / MI_SIZE_64X64; const int nhfb = (mi_params->mi_cols + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
int cstart = 0;
if (!cdef_left) cstart = -CDEF_HBORDER;
int rend, cend; const int nhb =
AOMMIN(MI_SIZE_64X64, mi_params->mi_cols - MI_SIZE_64X64 * fbc); const int nvb =
AOMMIN(MI_SIZE_64X64, mi_params->mi_rows - MI_SIZE_64X64 * fbr); const int hsize = nhb << fb_info->mi_wide_l2; const int vsize = nvb << fb_info->mi_high_l2; const uint16_t *top_linebuf = fb_info->top_linebuf[plane]; const uint16_t *bot_linebuf = fb_info->bot_linebuf[plane]; const int bot_offset = (vsize + CDEF_VBORDER) * CDEF_BSTRIDE; const int stride =
luma_stride >> (plane == AOM_PLANE_Y ? 0 : cm->seq_params->subsampling_x);
if (fbr == nvfb - 1)
rend = vsize; else
rend = vsize + CDEF_VBORDER;
/* Copy in the pixels we need from the current superblock for
deringing.*/
av1_cdef_copy_sb8_16(
cm, &src[CDEF_VBORDER * CDEF_BSTRIDE + CDEF_HBORDER + cstart],
CDEF_BSTRIDE, fb_info->dst, fb_info->roffset, fb_info->coffset + cstart,
fb_info->dst_stride, vsize, cend - cstart);
/* Copy in the pixels we need for the current superblock from bottom buffer.*/
if (fbr < nvfb - 1) {
copy_rect(&src[bot_offset + CDEF_HBORDER], CDEF_BSTRIDE,
&bot_linebuf[fb_info->coffset], stride, CDEF_VBORDER, hsize);
} else {
fill_rect(&src[bot_offset + CDEF_HBORDER], CDEF_BSTRIDE, CDEF_VBORDER,
hsize, CDEF_VERY_LARGE);
}
if (fbr < nvfb - 1 && fbc > 0) {
copy_rect(&src[bot_offset], CDEF_BSTRIDE,
&bot_linebuf[fb_info->coffset - CDEF_HBORDER], stride,
CDEF_VBORDER, CDEF_HBORDER);
} else {
fill_rect(&src[bot_offset], CDEF_BSTRIDE, CDEF_VBORDER, CDEF_HBORDER,
CDEF_VERY_LARGE);
}
if (fbr < nvfb - 1 && fbc < nhfb - 1) {
copy_rect(&src[bot_offset + hsize + CDEF_HBORDER], CDEF_BSTRIDE,
&bot_linebuf[fb_info->coffset + hsize], stride, CDEF_VBORDER,
CDEF_HBORDER);
} else {
fill_rect(&src[bot_offset + hsize + CDEF_HBORDER], CDEF_BSTRIDE,
CDEF_VBORDER, CDEF_HBORDER, CDEF_VERY_LARGE);
}
/* Copy in the pixels we need from the current superblock from top buffer.*/
if (fbr > 0) {
copy_rect(&src[CDEF_HBORDER], CDEF_BSTRIDE, &top_linebuf[fb_info->coffset],
stride, CDEF_VBORDER, hsize);
} else {
fill_rect(&src[CDEF_HBORDER], CDEF_BSTRIDE, CDEF_VBORDER, hsize,
CDEF_VERY_LARGE);
}
if (fbr > 0 && fbc > 0) {
copy_rect(src, CDEF_BSTRIDE, &top_linebuf[fb_info->coffset - CDEF_HBORDER],
stride, CDEF_VBORDER, CDEF_HBORDER);
} else {
fill_rect(src, CDEF_BSTRIDE, CDEF_VBORDER, CDEF_HBORDER, CDEF_VERY_LARGE);
}
if (fbr > 0 && fbc < nhfb - 1) {
copy_rect(&src[hsize + CDEF_HBORDER], CDEF_BSTRIDE,
&top_linebuf[fb_info->coffset + hsize], stride, CDEF_VBORDER,
CDEF_HBORDER);
} else {
fill_rect(&src[hsize + CDEF_HBORDER], CDEF_BSTRIDE, CDEF_VBORDER,
CDEF_HBORDER, CDEF_VERY_LARGE);
}
if (cdef_left) { /* If we deringed the superblock on the left then we need to copy in
saved pixels. */
copy_rect(src, CDEF_BSTRIDE, colbuf[plane], CDEF_HBORDER,
rend + CDEF_VBORDER, CDEF_HBORDER);
} /* Saving pixels in case we need to dering the superblock on the
right. */
copy_rect(colbuf[plane], CDEF_HBORDER, src + hsize, CDEF_BSTRIDE,
rend + CDEF_VBORDER, CDEF_HBORDER);
for (int plane = 0; plane < num_planes; plane++) { // Do not skip cdef filtering for luma plane as filter direction is // computed based on luma.
if (plane && is_zero_level[get_plane_type(plane)]) {
cdef_left[plane] = 0; continue;
}
cdef_init_fb_col(xd, fb_info, level, sec_strength, fbc, fbr, plane);
cdef_prepare_fb(cm, fb_info, colbuf, cdef_left[plane], fbc, fbr, plane);
cdef_filter_fb(fb_info, plane, cm->seq_params->use_highbitdepth);
cdef_left[plane] = 1;
}
}
// Initializes row-level parameters for CDEF frame. void 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) {
(void)cdef_sync; const int num_planes = av1_num_planes(cm); const int nvfb = (cm->mi_params.mi_rows + MI_SIZE_64X64 - 1) / MI_SIZE_64X64; const int luma_stride =
ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols << MI_SIZE_LOG2, 4); constbool ping_pong = fbr & 1; // for the current filter block, it's top left corner mi structure (mi_tl) // is first accessed to check whether the top and left boundaries are // frame boundaries. Then bottom-left and top-right mi structures are // accessed to check whether the bottom and right boundaries // (respectively) are frame boundaries. // // Note that we can't just check the bottom-right mi structure - eg. if // we're at the right-hand edge of the frame but not the bottom, then // the bottom-right mi is NULL but the bottom-left is not.
fb_info->frame_boundary[TOP] = (MI_SIZE_64X64 * fbr == 0) ? 1 : 0;
if (fbr != nvfb - 1)
fb_info->frame_boundary[BOTTOM] =
(MI_SIZE_64X64 * (fbr + 1) == cm->mi_params.mi_rows) ? 1 : 0; else
fb_info->frame_boundary[BOTTOM] = 1;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.