Commit 74c7cae450 for aom

commit 74c7cae450c2a60575e005c3cdd0639e85dfadb6
Author: Lin Zheng <linzhen@google.com>
Date:   Wed Nov 4 01:17:04 2026 +0000

    Add retain_last2_in_partial_high_motion speed feature

    Move the speed 3-4 check in get_num_refs_to_disable() to a dedicated
    speed feature under cpi->sf.inter_sf. No behavior change.

    Change-Id: I7333adb5db7e6ee7afcf9467e731a8490c2bf41f

diff --git a/av1/encoder/encodeframe_utils.h b/av1/encoder/encodeframe_utils.h
index 7d879df1ce..c988e018d1 100644
--- a/av1/encoder/encodeframe_utils.h
+++ b/av1/encoder/encodeframe_utils.h
@@ -522,10 +522,10 @@ static inline unsigned int get_num_refs_to_disable(
         const FIRSTPASS_STATS *const this_frame_stats =
             read_one_frame_stats(&cpi->ppi->twopass, cur_frame_display_index);
         const double coded_error_per_mb = this_frame_stats->coded_error;
-        // Retain LAST2_FRAME on mixed static/high-motion frames at speeds 3-4
+        // Retain LAST2_FRAME on mixed static/high-motion frames
         // to avoid quality loss.
         const bool is_partial_high_motion =
-            cpi->oxcf.speed > 2 && cpi->oxcf.speed <= 4 &&
+            cpi->sf.inter_sf.retain_last2_in_partial_high_motion &&
             this_frame_stats->pcnt_motion >= 0.1 &&
             this_frame_stats->pcnt_motion < 0.5 &&
             this_frame_stats->sr_coded_error > 2.0 * coded_error_per_mb;
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 4f2752d666..658608fcc9 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -1339,6 +1339,7 @@ static void set_good_speed_features_framesize_independent(
     sf->inter_sf.prune_inter_modes_based_on_tpl = boosted ? 1 : 2;
     sf->inter_sf.prune_comp_search_by_single_result = boosted ? 4 : 2;
     sf->inter_sf.selective_ref_frame = 5;
+    sf->inter_sf.retain_last2_in_partial_high_motion = 1;
     sf->inter_sf.reuse_compound_type_decision = 1;
     set_txfm_rd_gate_level(sf->inter_sf.txfm_rd_gate_level,
                            boosted ? 0 : (is_boosted_arf2_bwd_type ? 1 : 2));
@@ -1505,6 +1506,7 @@ static void set_good_speed_features_framesize_independent(
     sf->mv_sf.warp_search_method = WARP_SEARCH_DIAMOND;

     sf->inter_sf.prune_inter_modes_if_skippable = 1;
+    sf->inter_sf.retain_last2_in_partial_high_motion = 0;
     sf->inter_sf.prune_single_ref = is_boosted_arf2_bwd_type ? 0 : 3;
     sf->inter_sf.txfm_rd_gate_level[TX_SEARCH_DEFAULT] = boosted ? 0 : 4;
     sf->inter_sf.txfm_rd_gate_level[TX_SEARCH_COMP_TYPE_MODE] = boosted ? 0 : 5;
@@ -2441,6 +2443,7 @@ static inline void init_inter_sf(INTER_MODE_SPEED_FEATURES *inter_sf) {
   inter_sf->prune_single_ref = 0;
   inter_sf->prune_comp_ref_frames = 0;
   inter_sf->selective_ref_frame = 0;
+  inter_sf->retain_last2_in_partial_high_motion = 0;
   inter_sf->prune_ref_frame_for_rect_partitions = 0;
   inter_sf->fast_wedge_sign_estimate = 0;
   inter_sf->use_dist_wtd_comp_flag = DIST_WTD_COMP_ENABLED;
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index b1b1aa4921..1fa36994d8 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -1021,6 +1021,10 @@ typedef struct INTER_MODE_SPEED_FEATURES {
   // more aggressively than lower ones. (0 means no pruning).
   int selective_ref_frame;

+  // Retain LAST2_FRAME on mixed static/high-motion frames when
+  // selective_ref_frame == 5.
+  int retain_last2_in_partial_high_motion;
+
   // Prune reference frames for rectangular partitions.
   // 0 implies no pruning
   // 1 implies prune for extended partition