rtc: Avoid reset of segment for inactive blocks
For active_map in rtc mode.
For skipped blocks that are labeled as inactive:
remove the reset to 0 for the segment_id. This allows
them to be skippped in loopfilter at the block level
(since SEG_LVL_ALT_LF_Y_H/V is set in av1_apply_active_map).
The fix needed to support this is to make sure the
segment_skip block uses GLOBALMV and LAST_FRAME,
as required by the bitstream. In the current code we
were allowing for NEAREST if motion vector is (0, 0)),
which is incorrect. The current patch explicitly puts
this constraint (globalmv-last) early in nonrd_pickmode.
This fix has small speedup, ~1%, with negligible quality
change.
Change-Id: Ic5e9dbd7b9bec4d57edf90cf73f44719689e1dab
diff --git a/av1/encoder/aq_cyclicrefresh.c b/av1/encoder/aq_cyclicrefresh.c
index 73357eb..1aa8dde 100644
--- a/av1/encoder/aq_cyclicrefresh.c
+++ b/av1/encoder/aq_cyclicrefresh.c
@@ -179,10 +179,6 @@
memset(&cm->cur_frame->seg_map[map_offset], segment_id, xmis);
}
}
- } else if (prev_segment_id == AM_SEGMENT_ID_INACTIVE) {
- // TODO(marpan): Look into why this condition is needed
- // (when skip_over4x4 = 1) to prevent decoder failure.
- mbmi->segment_id = 0;
}
if (!dry_run) {
if (cyclic_refresh_segment_id(prev_segment_id) == CR_SEGMENT_ID_BOOST1)
diff --git a/av1/encoder/nonrd_pickmode.c b/av1/encoder/nonrd_pickmode.c
index 41e2e21..57c74f6 100644
--- a/av1/encoder/nonrd_pickmode.c
+++ b/av1/encoder/nonrd_pickmode.c
@@ -2357,6 +2357,10 @@
*ref_frame2 = NONE_FRAME;
}
+ if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP) &&
+ (*this_mode != GLOBALMV || *ref_frame != LAST_FRAME))
+ return true;
+
if (x->sb_me_block && *ref_frame == LAST_FRAME) {
// We want to make sure to test the superblock MV:
// so don't skip (return false) for NEAREST_LAST or NEAR_LAST if they