Commit 22e1f16f07 for aom

commit 22e1f16f078e85807d9d1657ce25674239805b5e
Author: Yunqing Wang <yunqingwang@google.com>
Date:   Wed Mar 18 11:23:36 2026 -0700

    Always allow second ARF temporal filtering

    For hdres set, this brings coding gain:
    ssim:   psnr1411:  vmaf:  vmaf_neg:  uvq:
    -0.145   -0.145   -0.139   -0.097   -0.59
    For Shorts set, the uvq gain is -1.9%.
    No impact on encoder/decoder time.

    STATS_CHANGED

    Change-Id: I05f852c228b77981258f1ce1f1b5e21cf6273add

diff --git a/av1/encoder/encode_strategy.c b/av1/encoder/encode_strategy.c
index d8232f9f6b..816ae20995 100644
--- a/av1/encoder/encode_strategy.c
+++ b/av1/encoder/encode_strategy.c
@@ -797,7 +797,7 @@ static int denoise_and_encode(AV1_COMP *const cpi, uint8_t *const dest,
         frame_input->source = tf_buf;
         show_existing_alt_ref = av1_check_show_filtered_frame(
             tf_buf, &frame_diff, q_index, cm->seq_params->bit_depth,
-            cpi->oxcf.algo_cfg.enable_overlay);
+            cpi->oxcf.algo_cfg.enable_overlay, 0);
         if (show_existing_alt_ref) {
           cpi->common.showable_frame |= 1;
         } else {
@@ -834,7 +834,7 @@ static int denoise_and_encode(AV1_COMP *const cpi, uint8_t *const dest,
                           tf_buf_second_arf);
       show_existing_alt_ref =
           av1_check_show_filtered_frame(tf_buf_second_arf, &frame_diff, q_index,
-                                        cm->seq_params->bit_depth, 1);
+                                        cm->seq_params->bit_depth, 1, 1);
       if (show_existing_alt_ref) {
         aom_extend_frame_borders(tf_buf_second_arf, av1_num_planes(cm));
         frame_input->source = tf_buf_second_arf;
diff --git a/av1/encoder/temporal_filter.c b/av1/encoder/temporal_filter.c
index daab015fff..68c8ae6a8b 100644
--- a/av1/encoder/temporal_filter.c
+++ b/av1/encoder/temporal_filter.c
@@ -1589,9 +1589,9 @@ static void init_tf_ctx(AV1_COMP *cpi, int filter_frame_lookahead_idx,

 int av1_check_show_filtered_frame(const YV12_BUFFER_CONFIG *frame,
                                   const FRAME_DIFF *frame_diff, int q_index,
-                                  aom_bit_depth_t bit_depth,
-                                  int enable_overlay) {
-  if (!enable_overlay) return 1;
+                                  aom_bit_depth_t bit_depth, int enable_overlay,
+                                  int is_second_arf) {
+  if (!enable_overlay || is_second_arf) return 1;

   const int frame_height = frame->y_crop_height;
   const int frame_width = frame->y_crop_width;
diff --git a/av1/encoder/temporal_filter.h b/av1/encoder/temporal_filter.h
index 5d380a2009..bef61f5fd2 100644
--- a/av1/encoder/temporal_filter.h
+++ b/av1/encoder/temporal_filter.h
@@ -347,13 +347,14 @@ void av1_temporal_filter(struct AV1_COMP *cpi,
  * \param[in]  q_index        q_index used for this frame
  * \param[in]  bit_depth      bit depth
  * \param[in]  enable_overlay arf overlay is enabled or disabled
+ * \param[in]  is_second_arf  whether or not this is a second ARF frame
  * \return     return 1 if this frame can be shown directly, otherwise
  *             return 0
  */
 int av1_check_show_filtered_frame(const YV12_BUFFER_CONFIG *frame,
                                   const FRAME_DIFF *frame_diff, int q_index,
-                                  aom_bit_depth_t bit_depth,
-                                  int enable_overlay);
+                                  aom_bit_depth_t bit_depth, int enable_overlay,
+                                  int is_second_arf);

 /*!\cond */
 // Allocates memory for members of TemporalFilterData.