LPF_SB: set row delay to work with intrabc Intrabc search area can't use pixels of the last 8 rows in the current superblock row. Add a delay so that lpf_sb can work with intrabc. Let lpf_sb on with intrabc while other loop filtering off (cdef, loop restoration). Change-Id: I98ab093a17096387b6233182da2656f90dfa09eb
diff --git a/av1/common/enums.h b/av1/common/enums.h index ee48306..3425c97 100644 --- a/av1/common/enums.h +++ b/av1/common/enums.h
@@ -103,10 +103,10 @@ #define LPF_SIGN_CONTEXT 2 // Half of maximum loop filter length (15-tap) -#define FILT_BOUNDARY_OFFSET 8 +#define FILT_BOUNDARY_OFFSET 0 #define FILT_BOUNDARY_MI_OFFSET (FILT_BOUNDARY_OFFSET >> MI_SIZE_LOG2) -#define USE_GUESS_LEVEL 1 +#define USE_GUESS_LEVEL 0 #define USE_LOOP_FILTER_SUPERBLOCK 1 #endif // CONFIG_LPF_SB
diff --git a/av1/common/mvref_common.h b/av1/common/mvref_common.h index eace078..4b0f884 100644 --- a/av1/common/mvref_common.h +++ b/av1/common/mvref_common.h
@@ -476,6 +476,7 @@ #define INTRABC_DELAY_PIXELS 256 // Delay of 256 pixels #define INTRABC_DELAY_SB64 (INTRABC_DELAY_PIXELS / 64) #define USE_WAVE_FRONT 1 // Use only top left area of frame for reference. +#define INTRABC_ROW_DELAY 8 static INLINE int av1_is_dv_valid(const MV dv, const TileInfo *const tile, int mi_row, int mi_col, BLOCK_SIZE bsize, int mib_size_log2) { @@ -514,6 +515,20 @@ const int active_sb64 = active_sb_row * total_sb64_per_row + active_sb64_col; const int src_sb64 = src_sb_row * total_sb64_per_row + src_sb64_col; if (src_sb64 >= active_sb64 - INTRABC_DELAY_SB64) return 0; + +#if CONFIG_LPF_SB + // Because of loop filter, the last 8 rows of current superblock row can't be + // used as intrabc search area. + if ((src_bottom_edge >> 3) >= + (active_sb_row + 1) * sb_size - INTRABC_ROW_DELAY) + return 0; + + // The last 8 rows of the above superblock is invalid + if ((src_bottom_edge >> 3) >= active_sb_row * sb_size - INTRABC_ROW_DELAY && + (src_right_edge >> 3) >= (mi_col >> mib_size_log2) * sb_size) + return 0; +#endif // CONFIG_LPF_SB + #if USE_WAVE_FRONT const int gradient = 1 + INTRABC_DELAY_SB64 + (sb_size > 64); const int wf_offset = gradient * (active_sb_row - src_sb_row);
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index 7200a91..ef5f370 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c
@@ -1109,9 +1109,9 @@ #endif // CONFIG_LOOP_RESTORATION static void setup_loopfilter(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) { -#if CONFIG_INTRABC +#if CONFIG_INTRABC && !CONFIG_LPF_SB if (cm->allow_intrabc && NO_FILTER_FOR_IBC) return; -#endif // CONFIG_INTRABC +#endif // CONFIG_INTRABC && !CONFIG_LPF_SB struct loopfilter *lf = &cm->lf; #if CONFIG_LOOPFILTER_LEVEL lf->filter_level[0] = aom_rb_read_literal(rb, 6); @@ -2241,9 +2241,9 @@ av1_frameworker_broadcast(pbi->cur_buf, mi_row << cm->mib_size_log2); } -#if CONFIG_INTRABC +#if CONFIG_INTRABC && !CONFIG_LPF_SB if (!(cm->allow_intrabc && NO_FILTER_FOR_IBC)) -#endif // CONFIG_INTRABC +#endif // CONFIG_INTRABC && !CONFIG_LPF_SB { // Loopfilter the whole frame. #if CONFIG_LPF_SB
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index 73db844..ba271c7 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c
@@ -2578,9 +2578,9 @@ #endif // CONFIG_LOOP_RESTORATION static void encode_loopfilter(AV1_COMMON *cm, struct aom_write_bit_buffer *wb) { -#if CONFIG_INTRABC +#if CONFIG_INTRABC && !CONFIG_LPF_SB if (cm->allow_intrabc && NO_FILTER_FOR_IBC) return; -#endif // CONFIG_INTRABC +#endif // CONFIG_INTRABC && !CONFIG_LPF_SB int i; struct loopfilter *lf = &cm->lf;