Add encoder support to fwd-kf
Encoder now writes the binary symbol for show_existing_frame to
indicate the value of reset_decoder_state. The default value now
is set as zero regardless. This enables the bitstream match with
the decoder.
With this patch when fwd-kf is enabled, one additional bit is
signaled at the frame header for show_existing_frame, but without
any coding performance impact.
Change-Id: Ib0137e6a513011c0ac9506837d32e9ad405508af
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index ede1c9c..95aaf00 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -3579,6 +3579,15 @@
}
#endif // CONFIG_REFERENCE_BUFFER
+#if CONFIG_FWD_KF
+ if (cm->reset_decoder_state && !frame_bufs[frame_to_show].intra_only) {
+ aom_internal_error(
+ &cm->error, AOM_CODEC_UNSUP_BITSTREAM,
+ "show_existing_frame to reset state on non-intra_only");
+ }
+ aom_wb_write_bit(wb, cm->reset_decoder_state);
+#endif // CONFIG_FWD_KF
+
return;
} else {
aom_wb_write_bit(wb, 0); // show_existing_frame
@@ -3902,6 +3911,15 @@
}
#endif // CONFIG_REFERENCE_BUFFER
+#if CONFIG_FWD_KF
+ if (cm->reset_decoder_state && !frame_bufs[frame_to_show].intra_only) {
+ aom_internal_error(
+ &cm->error, AOM_CODEC_UNSUP_BITSTREAM,
+ "show_existing_frame to reset state on non-intra_only");
+ }
+ aom_wb_write_bit(wb, cm->reset_decoder_state);
+#endif // CONFIG_FWD_KF
+
return;
} else {
aom_wb_write_bit(wb, 0); // show_existing_frame
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index e4bf069..03d3701 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -6024,13 +6024,15 @@
set_arf_sign_bias(cpi);
#endif // !CONFIG_FRAME_SIGN_BIAS
-#if CONFIG_TEMPMV_SIGNALING
+#if CONFIG_TEMPMV_SIGNALING || CONFIG_FWD_KF
// frame type has been decided outside of this function call
cm->cur_frame->intra_only = cm->frame_type == KEY_FRAME || cm->intra_only;
+#endif // CONFIG_TEMPMV_SIGNALING || CONFIG_FWD_KF
+#if CONFIG_TEMPMV_SIGNALING
cm->use_ref_frame_mvs =
!cpi->oxcf.disable_tempmv && !cm->cur_frame->intra_only;
cm->use_prev_frame_mvs = cm->use_ref_frame_mvs;
-#endif
+#endif // CONFIG_TEMPMV_SIGNALING
// Reset the frame packet stamp index.
if (cm->frame_type == KEY_FRAME) cm->current_video_frame = 0;
@@ -7011,6 +7013,12 @@
cpi->refresh_alt2_ref_frame = 0;
cpi->refresh_alt_ref_frame = 0;
+#if CONFIG_FWD_KF
+ // TODO(zoeliu@gmail.com): To support forward-KEY_FRAME and set up the
+ // following flag accordingly.
+ cm->reset_decoder_state = 0;
+#endif // CONFIG_FWD_KF
+
#if !CONFIG_XIPHRC
if (oxcf->pass == 2 && cm->show_existing_frame) {
// Manage the source buffer and flush out the source frame that has been