Expand skip mode support for all comp frames
All compound predicted frames now have the choice to either turn on
or off the use of the skip mode. The current encoder design only
turns on the use of skip mode when the temporal distances of the two
reference frames to the current frame are only different by 1.
This patch also includes a fix on the calculating of the temporal
distance between the two reference frames to the current frame for
skip mode.
Performance wise, this patch does not have noticeable impact as the
encoder stays with the same choice with the frame-level skip mode
flag.
Change-Id: I34f370940b3b25d2ab429b8721344133ae6288ad
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index f98ce30..7386ff3 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -1389,9 +1389,11 @@
if (mbmi->skip_mode) {
#if CONFIG_JNT_COMP && SKIP_MODE_WITH_JNT_COMP
const int cur_offset = (int)cm->frame_offset;
- const int cur_to_fwd = cur_offset - cm->ref_frame_idx_0;
- const int cur_to_bwd = abs(cm->ref_frame_idx_1 - cur_offset);
- if (cur_to_fwd != cur_to_bwd && xd->all_one_sided_refs) {
+ int ref_offset[2];
+ get_skip_mode_ref_offsets(cm, ref_offset);
+ const int cur_to_ref0 = cur_offset - ref_offset[0];
+ const int cur_to_ref1 = abs(cur_offset - ref_offset[1]);
+ if (cur_to_ref0 != cur_to_ref1 && xd->all_one_sided_refs) {
const int comp_index_ctx = get_comp_index_context(cm, xd);
aom_write_symbol(w, mbmi->compound_idx,
ec_ctx->compound_index_cdf[comp_index_ctx], 2);
@@ -3805,10 +3807,6 @@
arf_offset = AOMMIN((MAX_GF_INTERVAL - 1), arf_offset + brf_offset);
aom_wb_write_literal(wb, arf_offset, FRAME_OFFSET_BITS);
}
-
-#if CONFIG_EXT_SKIP
- if (cm->is_skip_mode_allowed) aom_wb_write_bit(wb, cm->skip_mode_flag);
-#endif // CONFIG_EXT_SKIP
#endif // CONFIG_FRAME_MARKER
#if CONFIG_REFERENCE_BUFFER
@@ -3889,6 +3887,11 @@
if (!use_hybrid_pred) aom_wb_write_bit(wb, use_compound_pred);
#endif // !CONFIG_REF_ADAPT
}
+
+#if CONFIG_EXT_SKIP
+ if (cm->is_skip_mode_allowed) aom_wb_write_bit(wb, cm->skip_mode_flag);
+#endif // CONFIG_EXT_SKIP
+
write_compound_tools(cm, wb);
aom_wb_write_bit(wb, cm->reduced_tx_set_used);
@@ -4167,10 +4170,6 @@
arf_offset = AOMMIN((MAX_GF_INTERVAL - 1), arf_offset + brf_offset);
aom_wb_write_literal(wb, arf_offset, FRAME_OFFSET_BITS);
}
-
-#if CONFIG_EXT_SKIP
- if (cm->is_skip_mode_allowed) aom_wb_write_bit(wb, cm->skip_mode_flag);
-#endif // CONFIG_EXT_SKIP
#endif // CONFIG_FRAME_MARKER
#if CONFIG_REFERENCE_BUFFER
@@ -4245,6 +4244,15 @@
if (!use_hybrid_pred) aom_wb_write_bit(wb, use_compound_pred);
#endif // !CONFIG_REF_ADAPT
}
+
+#if CONFIG_EXT_SKIP
+#if 0
+ printf("\n[ENCODER] Frame=%d, is_skip_mode_allowed=%d, skip_mode_flag=%d\n\n",
+ (int)cm->frame_offset, cm->is_skip_mode_allowed, cm->skip_mode_flag);
+#endif // 0
+ if (cm->is_skip_mode_allowed) aom_wb_write_bit(wb, cm->skip_mode_flag);
+#endif // CONFIG_EXT_SKIP
+
write_compound_tools(cm, wb);
aom_wb_write_bit(wb, cm->reduced_tx_set_used);