Unify is_frame_tpl_eligible() checking condition

BUG=aomedia:2730

Change-Id: Ia0ca5a47f358afa14351f596d67c2b42e7225455
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 06e017c..d64b07a 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -287,13 +287,14 @@
                                const BLOCK_SIZE bsize, const int mi_row,
                                const int mi_col, int orig_rdmult) {
   const AV1_COMMON *const cm = &cpi->common;
+  const GF_GROUP *const gf_group = &cpi->gf_group;
   assert(IMPLIES(cpi->gf_group.size > 0,
                  cpi->gf_group.index < cpi->gf_group.size));
   const int tpl_idx = cpi->gf_group.index;
   const TplDepFrame *tpl_frame = &cpi->tpl_data.tpl_frame[tpl_idx];
   const int deltaq_rdmult = set_deltaq_rdmult(cpi, x);
   if (tpl_frame->is_valid == 0) return deltaq_rdmult;
-  if (!is_frame_tpl_eligible((AV1_COMP *)cpi)) return deltaq_rdmult;
+  if (!is_frame_tpl_eligible(gf_group)) return deltaq_rdmult;
   if (tpl_idx >= MAX_TPL_FRAME_IDX) return deltaq_rdmult;
   if (cpi->superres_mode != AOM_SUPERRES_NONE) return deltaq_rdmult;
   if (cpi->oxcf.q_cfg.aq_mode != NO_AQ) return deltaq_rdmult;
@@ -4268,6 +4269,7 @@
 static int get_rdmult_delta(AV1_COMP *cpi, BLOCK_SIZE bsize, int analysis_type,
                             int mi_row, int mi_col, int orig_rdmult) {
   AV1_COMMON *const cm = &cpi->common;
+  const GF_GROUP *const gf_group = &cpi->gf_group;
   assert(IMPLIES(cpi->gf_group.size > 0,
                  cpi->gf_group.index < cpi->gf_group.size));
   const int tpl_idx = cpi->gf_group.index;
@@ -4283,7 +4285,7 @@
 
   if (tpl_frame->is_valid == 0) return orig_rdmult;
 
-  if (!is_frame_tpl_eligible(cpi)) return orig_rdmult;
+  if (!is_frame_tpl_eligible(gf_group)) return orig_rdmult;
 
   if (cpi->gf_group.index >= MAX_TPL_FRAME_IDX) return orig_rdmult;
 
@@ -4420,6 +4422,7 @@
 static int get_q_for_deltaq_objective(AV1_COMP *const cpi, BLOCK_SIZE bsize,
                                       int mi_row, int mi_col) {
   AV1_COMMON *const cm = &cpi->common;
+  const GF_GROUP *const gf_group = &cpi->gf_group;
   assert(IMPLIES(cpi->gf_group.size > 0,
                  cpi->gf_group.index < cpi->gf_group.size));
   const int tpl_idx = cpi->gf_group.index;
@@ -4436,7 +4439,7 @@
 
   if (tpl_frame->is_valid == 0) return base_qindex;
 
-  if (!is_frame_tpl_eligible(cpi)) return base_qindex;
+  if (!is_frame_tpl_eligible(gf_group)) return base_qindex;
 
   if (cpi->gf_group.index >= MAX_TPL_FRAME_IDX) return base_qindex;
 
@@ -4970,6 +4973,7 @@
 static void init_ref_frame_space(AV1_COMP *cpi, ThreadData *td, int mi_row,
                                  int mi_col) {
   const AV1_COMMON *cm = &cpi->common;
+  const GF_GROUP *const gf_group = &cpi->gf_group;
   const CommonModeInfoParams *const mi_params = &cm->mi_params;
   MACROBLOCK *x = &td->mb;
   const int frame_idx = cpi->gf_group.index;
@@ -4980,7 +4984,7 @@
   av1_zero(x->tpl_keep_ref_frame);
 
   if (tpl_frame->is_valid == 0) return;
-  if (!is_frame_tpl_eligible(cpi)) return;
+  if (!is_frame_tpl_eligible(gf_group)) return;
   if (frame_idx >= MAX_TPL_FRAME_IDX) return;
   if (cpi->superres_mode != AOM_SUPERRES_NONE) return;
   if (cpi->oxcf.q_cfg.aq_mode != NO_AQ) return;
@@ -5937,8 +5941,9 @@
     // is used for ineligible frames. That effectively will turn off row_mt
     // usage. Note objective delta_q and tpl eligible frames are only altref
     // frames currently.
+    const GF_GROUP *gf_group = &cpi->gf_group;
     if (cm->delta_q_info.delta_q_present_flag) {
-      if (deltaq_mode == DELTA_Q_OBJECTIVE && !is_frame_tpl_eligible(cpi))
+      if (deltaq_mode == DELTA_Q_OBJECTIVE && !is_frame_tpl_eligible(gf_group))
         cm->delta_q_info.delta_q_present_flag = 0;
     }
 
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index f1d5e5c..9c8fa1d 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -2157,7 +2157,7 @@
     } else {
       aom_clear_system_state();
       cpi->rd.r0 = (double)intra_cost_base / mc_dep_cost_base;
-      if (is_frame_arf_and_tpl_eligible(gf_group)) {
+      if (is_frame_tpl_eligible(gf_group)) {
         cpi->rd.arf_r0 = cpi->rd.r0;
         if (cpi->lap_enabled) {
           double min_boost_factor = sqrt(cpi->rc.baseline_gf_interval);
@@ -2212,7 +2212,8 @@
   av1_set_speed_features_framesize_dependent(cpi, cpi->speed);
 
 #if !CONFIG_REALTIME_ONLY
-  if (cpi->oxcf.enable_tpl_model && is_frame_tpl_eligible(cpi)) {
+  GF_GROUP *gf_group = &cpi->gf_group;
+  if (cpi->oxcf.enable_tpl_model && is_frame_tpl_eligible(gf_group)) {
     process_tpl_stats_frame(cpi);
     av1_tpl_rdmult_setup(cpi);
   }
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 04f4e2d..6b7fc2a 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -2819,16 +2819,12 @@
 #define MAX_GFUBOOST_FACTOR 10.0
 #define MIN_GFUBOOST_FACTOR 4.0
 
-static INLINE int is_frame_arf_and_tpl_eligible(const GF_GROUP *gf_group) {
+static INLINE int is_frame_tpl_eligible(const GF_GROUP *const gf_group) {
   const FRAME_UPDATE_TYPE update_type = gf_group->update_type[gf_group->index];
   return update_type == ARF_UPDATE || update_type == GF_UPDATE ||
          update_type == KF_UPDATE;
 }
 
-static INLINE int is_frame_tpl_eligible(AV1_COMP *const cpi) {
-  return is_frame_arf_and_tpl_eligible(&cpi->gf_group);
-}
-
 // Get update type of the current frame.
 static INLINE FRAME_UPDATE_TYPE
 get_frame_update_type(const GF_GROUP *gf_group) {
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index 4d4df7d..72c6bec 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -1201,13 +1201,14 @@
 void av1_tpl_rdmult_setup_sb(AV1_COMP *cpi, MACROBLOCK *const x,
                              BLOCK_SIZE sb_size, int mi_row, int mi_col) {
   AV1_COMMON *const cm = &cpi->common;
+  GF_GROUP *gf_group = &cpi->gf_group;
   assert(IMPLIES(cpi->gf_group.size > 0,
                  cpi->gf_group.index < cpi->gf_group.size));
   const int tpl_idx = cpi->gf_group.index;
   TplDepFrame *tpl_frame = &cpi->tpl_data.tpl_frame[tpl_idx];
 
   if (tpl_frame->is_valid == 0) return;
-  if (!is_frame_tpl_eligible(cpi)) return;
+  if (!is_frame_tpl_eligible(gf_group)) return;
   if (tpl_idx >= MAX_TPL_FRAME_IDX) return;
   if (cpi->superres_mode != AOM_SUPERRES_NONE) return;
   if (cpi->oxcf.q_cfg.aq_mode != NO_AQ) return;