Make apply_encoding_flags work when lag_in_frames > 0
av1_apply_encoding_flags() was called in encoder_encode(). If
lag_in_frames > 0, it wouldn't be called for last several frames
while flushing the encoder, and thus cpi->ref_frame_flags can not
be set correctly. This patch fixed the issue by adding an extra
flag cpi->ext_ref_frame_flags to store the external reference
frame flag, and pass it to cpi->ref_frame_flags correctly.
Change-Id: I9c3f22f92b81c7b4b6241a3f7edcaeabd8d8bbc9
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 4926d40..037c3c5 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -3346,7 +3346,7 @@
int av1_use_as_reference(AV1_COMP *cpi, int ref_frame_flags) {
if (ref_frame_flags > ((1 << INTER_REFS_PER_FRAME) - 1)) return -1;
- cpi->ref_frame_flags = ref_frame_flags;
+ cpi->ext_ref_frame_flags = ref_frame_flags;
return 0;
}
@@ -5092,7 +5092,7 @@
// After av1_apply_encoding_flags() is called, cpi->ref_frame_flags might be
// adjusted according to external encoder flags.
- int flags = cpi->ref_frame_flags;
+ int flags = cpi->ext_ref_frame_flags;
if (cpi->rc.frames_till_gf_update_due == INT_MAX) flags &= ~AOM_GOLD_FLAG;
@@ -6722,13 +6722,13 @@
// priority rank for 7 reference frames are: LAST, ALTREF, LAST2, LAST3,
// GOLDEN, BWDREF, ALTREF2. If only one reference frame is used, it must be
// LAST.
- cpi->ref_frame_flags = AOM_REFFRAME_ALL;
+ cpi->ext_ref_frame_flags = AOM_REFFRAME_ALL;
if (flags &
(AOM_EFLAG_NO_REF_LAST | AOM_EFLAG_NO_REF_LAST2 | AOM_EFLAG_NO_REF_LAST3 |
AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_REF_ARF | AOM_EFLAG_NO_REF_BWD |
AOM_EFLAG_NO_REF_ARF2)) {
if (flags & AOM_EFLAG_NO_REF_LAST) {
- cpi->ref_frame_flags = 0;
+ cpi->ext_ref_frame_flags = 0;
} else {
int ref = AOM_REFFRAME_ALL;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index c2a4c3d..421622c 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -470,6 +470,7 @@
int mbgraph_n_frames; // number of frames filled in the above
int static_mb_pct; // % forced skip mbs by segmentation
int ref_frame_flags;
+ int ext_ref_frame_flags;
#if CONFIG_FRAME_MARKER
RATE_FACTOR_LEVEL frame_rf_level[FRAME_BUFFERS];
#endif // CONFIG_FRAME_MARKER