Commit 5ad5b289 authored by Cheng Chen's avatar Cheng Chen

Loop filtering after each superblock

The patch is to enable loop filtering for intra block copy.

Apply loop filtering right after each superblock is encoded.
Use a constant filter level for now. In future updates, the filter
level should be optimized by LPF_SB and better guess value.

Change-Id: I0a5797b5ba5384c00044a8ec4a495dc75aa0f3fe
parent e87fb237
......@@ -104,6 +104,9 @@ extern "C" {
// Half of maximum loop filter length (15-tap)
#define FILT_BOUNDARY_OFFSET 8
#define FILT_BOUNDARY_MI_OFFSET (FILT_BOUNDARY_OFFSET >> MI_SIZE_LOG2)
#define FAKE_FILTER_LEVEL 10
#define USE_LOOP_FILTER_SUPERBLOCK 1
#endif // CONFIG_LPF_SB
// Bitstream profiles indicated by 2-3 bits in the uncompressed header.
......
......@@ -3969,6 +3969,14 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
#if CONFIG_NCOBMC_ADAPT_WEIGHT
free_ncobmc_pred_buffer(&td->xd);
#endif
#if CONFIG_LPF_SB
if (USE_LOOP_FILTER_SUPERBLOCK) {
// apply deblocking filtering right after each superblock is decoded
const int guess_filter_lvl = FAKE_FILTER_LEVEL;
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, &pbi->mb,
guess_filter_lvl, 0, 1, mi_row, mi_col);
}
#endif // CONFIG_LPF_SB
}
aom_merge_corrupted_flag(&pbi->mb.corrupted, td->xd.corrupted);
if (pbi->mb.corrupted)
......@@ -4018,6 +4026,11 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
}
#if CONFIG_VAR_TX || CONFIG_CB4X4
#if CONFIG_INTRABC
// When intraBC is on, do loop filtering per superblock,
// instead of do it after the whole frame has been encoded,
// as is in the else branch
#else
// Loopfilter the whole frame.
#if CONFIG_LPF_SB
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, &pbi->mb,
......@@ -4040,6 +4053,7 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
cm->lf.filter_level, 0, 0);
#endif // CONFIG_LOOPFILTER_LEVEL
#endif // CONFIG_LPF_SB
#endif // CONFIG_INTRABC
#else
#if CONFIG_PARALLEL_DEBLOCKING
// Loopfilter all rows in the frame in the frame.
......
......@@ -4777,6 +4777,14 @@ static void encode_rd_sb_row(AV1_COMP *cpi, ThreadData *td,
#endif // CONFIG_SUPERTX
INT64_MAX, pc_root);
}
#if CONFIG_LPF_SB
if (USE_LOOP_FILTER_SUPERBLOCK) {
// apply deblocking filtering right after each superblock is encoded.
const int guess_filter_lvl = FAKE_FILTER_LEVEL;
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, xd, guess_filter_lvl,
0, 1, mi_row, mi_col);
}
#endif // CONFIG_LPF_SB
}
}
......
......@@ -4682,6 +4682,11 @@ static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
cpi->time_pick_lpf += aom_usec_timer_elapsed(&timer);
}
#if CONFIG_INTRABC
// When intraBC is on, do loop filtering per superblock,
// instead of do it after the whole frame has been encoded,
// as is in the else branch
#else
#if !CONFIG_LPF_SB
#if CONFIG_LOOPFILTER_LEVEL
if (lf->filter_level[0] || lf->filter_level[1])
......@@ -4716,6 +4721,7 @@ static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
av1_loop_filter_frame(cm->frame_to_show, cm, xd, lf->filter_level, 0, 0);
#endif
}
#endif // CONFIG_INTRABC
#if CONFIG_STRIPED_LOOP_RESTORATION
av1_loop_restoration_save_boundary_lines(cm->frame_to_show, cm);
......
......@@ -478,6 +478,7 @@ void av1_pick_filter_level(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi,
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {
int lvl =
search_filter_level(sd, cpi, 1, NULL, mi_row, mi_col, last_lvl);
if (USE_LOOP_FILTER_SUPERBLOCK) lvl = FAKE_FILTER_LEVEL;
av1_loop_filter_sb_level_init(cm, mi_row, mi_col, lvl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment