Commit 27df834d authored by Hui Su's avatar Hui Su

Disable in-loop filters for frames with intrabc enabled

Change-Id: Ia47101de22091a60d7931890f00a4a3a527f5bd4
parent 03c7549e
......@@ -405,6 +405,8 @@ typedef struct MODE_INFO {
} MODE_INFO;
#if CONFIG_INTRABC
#define NO_FILTER_FOR_IBC 1 // Disable in-loop filters for frame with intrabc
static INLINE int is_intrabc_block(const MB_MODE_INFO *mbmi) {
return mbmi->use_intrabc;
}
......
......@@ -1683,6 +1683,7 @@ int av1_loop_restoration_corners_in_sb(const struct AV1Common *cm, int plane,
assert(rcol0 && rcol1 && rrow0 && rrow1);
if (bsize != cm->sb_size) return 0;
if (cm->rst_info[plane].frame_restoration_type == RESTORE_NONE) return 0;
const int is_uv = plane > 0;
......
......@@ -1142,6 +1142,9 @@ static void setup_q_segmentation(AV1_COMMON *const cm,
#if CONFIG_LOOP_RESTORATION
static void decode_restoration_mode(AV1_COMMON *cm,
struct aom_read_bit_buffer *rb) {
#if CONFIG_INTRABC
if (cm->allow_intrabc && NO_FILTER_FOR_IBC) return;
#endif // CONFIG_INTRABC
for (int p = 0; p < MAX_MB_PLANE; ++p) {
RestorationInfo *rsi = &cm->rst_info[p];
if (aom_rb_read_bit(rb)) {
......@@ -1309,6 +1312,9 @@ static void loop_restoration_read_sb_coeffs(const AV1_COMMON *const cm,
#endif // CONFIG_LOOP_RESTORATION
static void setup_loopfilter(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
#if CONFIG_INTRABC
if (cm->allow_intrabc && NO_FILTER_FOR_IBC) return;
#endif // CONFIG_INTRABC
struct loopfilter *lf = &cm->lf;
#if !CONFIG_LPF_SB
#if CONFIG_LOOPFILTER_LEVEL
......@@ -1347,6 +1353,9 @@ static void setup_loopfilter(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
#if CONFIG_CDEF
static void setup_cdef(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
#if CONFIG_INTRABC
if (cm->allow_intrabc && NO_FILTER_FOR_IBC) return;
#endif // CONFIG_INTRABC
int i;
#if CONFIG_CDEF_SINGLEPASS
cm->cdef_pri_damping = cm->cdef_sec_damping = aom_rb_read_literal(rb, 2) + 3;
......@@ -2423,34 +2432,35 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
}
#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 (!(cm->allow_intrabc && NO_FILTER_FOR_IBC))
#endif // CONFIG_INTRABC
{
// Loopfilter the whole frame.
#if CONFIG_LPF_SB
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, &pbi->mb,
cm->lf.filter_level, 0, 0, 0, 0);
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, &pbi->mb,
cm->lf.filter_level, 0, 0, 0, 0);
#else
#if CONFIG_OBU
if (endTile == cm->tile_rows * cm->tile_cols - 1)
if (endTile == cm->tile_rows * cm->tile_cols - 1)
#endif
#if CONFIG_LOOPFILTER_LEVEL
if (cm->lf.filter_level[0] || cm->lf.filter_level[1]) {
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, &pbi->mb,
cm->lf.filter_level[0], cm->lf.filter_level[1], 0,
0);
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, &pbi->mb,
cm->lf.filter_level_u, cm->lf.filter_level_u, 1, 0);
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, &pbi->mb,
cm->lf.filter_level_v, cm->lf.filter_level_v, 2, 0);
}
if (cm->lf.filter_level[0] || cm->lf.filter_level[1]) {
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, &pbi->mb,
cm->lf.filter_level[0], cm->lf.filter_level[1], 0,
0);
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, &pbi->mb,
cm->lf.filter_level_u, cm->lf.filter_level_u, 1,
0);
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, &pbi->mb,
cm->lf.filter_level_v, cm->lf.filter_level_v, 2,
0);
}
#else
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, &pbi->mb,
cm->lf.filter_level, 0, 0);
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, &pbi->mb,
cm->lf.filter_level, 0, 0);
#endif // CONFIG_LOOPFILTER_LEVEL
#endif // CONFIG_LPF_SB
#endif // CONFIG_INTRABC
}
if (cm->frame_parallel_decode)
av1_frameworker_broadcast(pbi->cur_buf, INT_MAX);
......@@ -3182,6 +3192,29 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
if (frame_is_intra_only(cm) || cm->error_resilient_mode)
av1_setup_past_independence(cm);
#if CONFIG_INTRABC
if (cm->allow_intrabc && NO_FILTER_FOR_IBC) {
// Set parameters corresponding to no filtering.
struct loopfilter *lf = &cm->lf;
#if CONFIG_LOOPFILTER_LEVEL
lf->filter_level[0] = 0;
lf->filter_level[1] = 0;
#else
lf->filter_level = 0;
#endif
#if CONFIG_CDEF
cm->cdef_bits = 0;
cm->cdef_strengths[0] = 0;
cm->nb_cdef_strengths = 1;
#endif // CONFIG_CDEF
#if CONFIG_LOOP_RESTORATION
cm->rst_info[0].frame_restoration_type = RESTORE_NONE;
cm->rst_info[1].frame_restoration_type = RESTORE_NONE;
cm->rst_info[2].frame_restoration_type = RESTORE_NONE;
#endif // CONFIG_LOOP_RESTORATION
}
#endif // CONFIG_INTRABC
setup_loopfilter(cm, rb);
setup_quantization(cm, rb);
xd->bd = (int)cm->bit_depth;
......@@ -3810,7 +3843,11 @@ void av1_decode_tg_tiles_and_wrapup(AV1Decoder *pbi, const uint8_t *data,
#endif
#if CONFIG_CDEF
if (!cm->skip_loop_filter && !cm->all_lossless) {
if (!cm->skip_loop_filter &&
#if CONFIG_INTRABC
!(cm->allow_intrabc && NO_FILTER_FOR_IBC) &&
#endif // CONFIG_INTRABC
!cm->all_lossless) {
av1_cdef_frame(&pbi->cur_buf->buf, cm, &pbi->mb);
}
#endif // CONFIG_CDEF
......
......@@ -2532,6 +2532,9 @@ static void write_modes(AV1_COMP *const cpi, const TileInfo *const tile,
#if CONFIG_LOOP_RESTORATION
static void encode_restoration_mode(AV1_COMMON *cm,
struct aom_write_bit_buffer *wb) {
#if CONFIG_INTRABC
if (cm->allow_intrabc && NO_FILTER_FOR_IBC) return;
#endif // CONFIG_INTRABC
for (int p = 0; p < MAX_MB_PLANE; ++p) {
RestorationInfo *rsi = &cm->rst_info[p];
switch (rsi->frame_restoration_type) {
......@@ -2693,6 +2696,9 @@ static void loop_restoration_write_sb_coeffs(const AV1_COMMON *const cm,
#endif // CONFIG_LOOP_RESTORATION
static void encode_loopfilter(AV1_COMMON *cm, struct aom_write_bit_buffer *wb) {
#if CONFIG_INTRABC
if (cm->allow_intrabc && NO_FILTER_FOR_IBC) return;
#endif // CONFIG_INTRABC
int i;
struct loopfilter *lf = &cm->lf;
......@@ -2743,6 +2749,9 @@ static void encode_loopfilter(AV1_COMMON *cm, struct aom_write_bit_buffer *wb) {
#if CONFIG_CDEF
static void encode_cdef(const AV1_COMMON *cm, struct aom_write_bit_buffer *wb) {
#if CONFIG_INTRABC
if (cm->allow_intrabc && NO_FILTER_FOR_IBC) return;
#endif // CONFIG_INTRABC
int i;
#if CONFIG_CDEF_SINGLEPASS
aom_wb_write_literal(wb, cm->cdef_pri_damping - 3, 2);
......
......@@ -4616,9 +4616,12 @@ static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
#if CONFIG_LOOP_RESTORATION
int no_restoration = 0;
if (is_lossless_requested(&cpi->oxcf)
#if CONFIG_INTRABC
|| (cm->allow_intrabc && NO_FILTER_FOR_IBC)
#endif // CONFIG_INTRABC
#if CONFIG_EXT_TILE
|| cm->single_tile_decoding
#endif
#endif // CONFIG_EXT_TILE
) {
no_loopfilter = 1;
no_restoration = 1;
......@@ -4655,11 +4658,6 @@ 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])
......@@ -4685,7 +4683,6 @@ static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
#endif // CONFIG_LOOPFILTER_LEVEL
#endif // CONFIG_LPF_SB
}
#endif // CONFIG_INTRABC
#if CONFIG_STRIPED_LOOP_RESTORATION
#if CONFIG_FRAME_SUPERRES && CONFIG_HORZONLY_FRAME_SUPERRES
......
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