diff --git a/av1/common/cdef.c b/av1/common/cdef.c index 8875ca3fd..d7fcc480c 100644 --- a/av1/common/cdef.c +++ b/av1/common/cdef.c @@ -55,7 +55,7 @@ static int is_8x8_block_skip(MODE_INFO **grid, int mi_row, int mi_col, } int sb_compute_dering_list(const AV1_COMMON *const cm, int mi_row, int mi_col, - dering_list *dlist) { + dering_list *dlist, int filter_skip) { int r, c; int maxc, maxr; MODE_INFO **grid; @@ -75,22 +75,33 @@ int sb_compute_dering_list(const AV1_COMMON *const cm, int mi_row, int mi_col, const int c_step = mi_size_wide[BLOCK_8X8]; const int r_shift = (r_step == 2); const int c_shift = (c_step == 2); - int all_skip = 1; assert(r_step == 1 || r_step == 2); assert(c_step == 1 || c_step == 2); - for (r = 0; r < maxr; r += r_step) { - for (c = 0; c < maxc; c += c_step) { - dlist[count].by = r >> r_shift; - dlist[count].bx = c >> c_shift; - dlist[count].skip = - is_8x8_block_skip(grid, mi_row + r, mi_col + c, cm->mi_stride); - all_skip &= dlist[count].skip; - count++; + if (filter_skip) { + for (r = 0; r < maxr; r += r_step) { + for (c = 0; c < maxc; c += c_step) { + dlist[count].by = r >> r_shift; + dlist[count].bx = c >> c_shift; + dlist[count].skip = + is_8x8_block_skip(grid, mi_row + r, mi_col + c, cm->mi_stride); + count++; + } + } + } else { + for (r = 0; r < maxr; r += r_step) { + for (c = 0; c < maxc; c += c_step) { + if (!is_8x8_block_skip(grid, mi_row + r, mi_col + c, cm->mi_stride)) { + dlist[count].by = r >> r_shift; + dlist[count].bx = c >> c_shift; + dlist[count].skip = 0; + count++; + } + } } } - return all_skip ? 0 : count; + return count; } void copy_rect8_8bit_to_16bit_c(uint16_t *dst, int dstride, const uint8_t *src, @@ -275,7 +286,8 @@ void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm, if ((level == 0 && clpf_strength == 0 && uv_level == 0 && uv_clpf_strength == 0) || (dering_count = sb_compute_dering_list( - cm, sbr * MAX_MIB_SIZE, sbc * MAX_MIB_SIZE, dlist)) == 0) { + cm, sbr * MAX_MIB_SIZE, sbc * MAX_MIB_SIZE, dlist, + get_filter_skip(level) || get_filter_skip(uv_level))) == 0) { dering_left = 0; continue; } diff --git a/av1/common/cdef.h b/av1/common/cdef.h index ca7b89ca9..08c438de6 100644 --- a/av1/common/cdef.h +++ b/av1/common/cdef.h @@ -41,7 +41,7 @@ extern "C" { int sb_all_skip(const AV1_COMMON *const cm, int mi_row, int mi_col); int sb_compute_dering_list(const AV1_COMMON *const cm, int mi_row, int mi_col, - dering_list *dlist); + dering_list *dlist, int filter_skip); void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm, MACROBLOCKD *xd); void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref, diff --git a/av1/common/od_dering.c b/av1/common/od_dering.c index 36dfe01ab..1a55393c1 100644 --- a/av1/common/od_dering.c +++ b/av1/common/od_dering.c @@ -308,6 +308,12 @@ static void copy_dering_16bit_to_8bit(uint8_t *dst, int dstride, } } +int get_filter_skip(int level) { + int filter_skip = level & 1; + if (level == 1) filter_skip = 0; + return filter_skip; +} + void od_dering(uint8_t *dst, int dstride, uint16_t *y, uint16_t *in, int xdec, int ydec, int dir[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS], int *dirinit, int var[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS], @@ -321,11 +327,8 @@ void od_dering(uint8_t *dst, int dstride, uint16_t *y, uint16_t *in, int xdec, int threshold = (level >> 1) << coeff_shift; int dering_damping = 5 + !pli + coeff_shift; - int filter_skip = level & 1; - if (level == 1) { - filter_skip = 0; - threshold = 31 << coeff_shift; - } + int filter_skip = get_filter_skip(level); + if (level == 1) threshold = 31 << coeff_shift; od_filter_dering_direction_func filter_dering_direction[] = { od_filter_dering_direction_4x4, od_filter_dering_direction_8x8 diff --git a/av1/common/od_dering.h b/av1/common/od_dering.h index 912c40d9f..58003c96e 100644 --- a/av1/common/od_dering.h +++ b/av1/common/od_dering.h @@ -43,6 +43,8 @@ void copy_dering_16bit_to_16bit(uint16_t *dst, int dstride, uint16_t *src, dering_list *dlist, int dering_count, int bsize); +int get_filter_skip(int level); + void od_dering(uint8_t *dst, int dstride, uint16_t *y, uint16_t *in, int xdec, int ydec, int dir[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS], int *dirinit, int var[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS], diff --git a/av1/encoder/pickcdef.c b/av1/encoder/pickcdef.c index 2c1f87a1f..bca6cdfaa 100644 --- a/av1/encoder/pickcdef.c +++ b/av1/encoder/pickcdef.c @@ -376,12 +376,12 @@ void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref, int dirinit = 0; nhb = AOMMIN(MAX_MIB_SIZE, cm->mi_cols - MAX_MIB_SIZE * sbc); nvb = AOMMIN(MAX_MIB_SIZE, cm->mi_rows - MAX_MIB_SIZE * sbr); - dering_count = sb_compute_dering_list(cm, sbr * MAX_MIB_SIZE, - sbc * MAX_MIB_SIZE, dlist); cm->mi_grid_visible[MAX_MIB_SIZE * sbr * cm->mi_stride + MAX_MIB_SIZE * sbc] ->mbmi.cdef_strength = -1; - if (dering_count == 0) continue; + if (sb_all_skip(cm, sbr * MAX_MIB_SIZE, sbc * MAX_MIB_SIZE)) continue; + dering_count = sb_compute_dering_list(cm, sbr * MAX_MIB_SIZE, + sbc * MAX_MIB_SIZE, dlist, 1); for (pli = 0; pli < nplanes; pli++) { for (i = 0; i < OD_DERING_INBUF_SIZE; i++) inbuf[i] = OD_DERING_VERY_LARGE;