From f2e7a397229c9a776279e3df3b4e54cb4d36eb44 Mon Sep 17 00:00:00 2001 From: Yunqing Wang Date: Wed, 8 Nov 2017 00:27:21 -0800 Subject: [PATCH] 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 --- av1/encoder/encoder.c | 8 ++++---- av1/encoder/encoder.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c index 4926d4038..037c3c50c 100644 --- a/av1/encoder/encoder.c +++ b/av1/encoder/encoder.c @@ -3346,7 +3346,7 @@ static void generate_psnr_packet(AV1_COMP *cpi) { 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 @@ static int get_ref_frame_flags(const AV1_COMP *cpi) { // 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 @@ void av1_apply_encoding_flags(AV1_COMP *cpi, aom_enc_frame_flags_t flags) { // 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 c2a4c3d50..421622c62 100644 --- a/av1/encoder/encoder.h +++ b/av1/encoder/encoder.h @@ -470,6 +470,7 @@ typedef struct AV1_COMP { 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 -- GitLab