Commit 0bfd0b97dc for aom

commit 0bfd0b97dc864882284da1c9f98a82c06cbfc58e
Author: Lin Zheng <linzhen@google.com>
Date:   Mon Mar 9 16:26:16 2026 +0000

    Fix a bug when CONFIG_REALTIME_ONLY=1

    When CONFIG_REALTIMIE_ONLY=1 and mode=REALTIME, then force lag_in_frames
    to be 0 when we set up num_lap_buffers. After this bug fix, we can make
    the threshold in the unit test BasicRateTargetingVBRLagRealtime to be
    more strict.

    Change-Id: I5e08d8214ffb758379c73328d26694206d6e02b6

diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 36df9636ca..e4e77c9d83 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -1388,6 +1388,8 @@ static void set_encoder_config(AV1EncoderConfig *oxcf,

   // Set Group of frames configuration.
 #if CONFIG_REALTIME_ONLY
+  // When CONFIG_REALTIMIE_ONLY=1 and mode=REALTIME, then force lag_in_frames
+  // = 0.
   gf_cfg->lag_in_frames = (oxcf->mode == REALTIME)
                               ? 0
                               : clamp(cfg->g_lag_in_frames, 0, MAX_LAG_BUFFERS);
@@ -3055,10 +3057,16 @@ static aom_codec_err_t encoder_init(aom_codec_ctx_t *ctx) {
       set_encoder_config(&priv->oxcf, &priv->cfg, &priv->extra_cfg);
       if (priv->oxcf.pass == AOM_RC_ONE_PASS) {
         // Enable look ahead.
-        *num_lap_buffers =
-            AOMMIN((int)priv->cfg.g_lag_in_frames,
-                   AOMMIN(MAX_LAP_BUFFERS, priv->oxcf.kf_cfg.key_freq_max +
-                                               SCENE_CUT_KEY_TEST_INTERVAL));
+        *num_lap_buffers = AOMMIN(
+#if CONFIG_REALTIME_ONLY
+            // When CONFIG_REALTIMIE_ONLY=1 and mode=REALTIME, then force
+            // lag_in_frames = 0.
+            (priv->oxcf.mode == REALTIME) ? 0 : (int)priv->cfg.g_lag_in_frames,
+#else
+            (int)priv->cfg.g_lag_in_frames,
+#endif
+            AOMMIN(MAX_LAP_BUFFERS, priv->oxcf.kf_cfg.key_freq_max +
+                                        SCENE_CUT_KEY_TEST_INTERVAL));
         if ((int)priv->cfg.g_lag_in_frames - (*num_lap_buffers) >=
             LAP_LAG_IN_FRAMES) {
           lap_lag_in_frames = LAP_LAG_IN_FRAMES;
diff --git a/test/datarate_test.cc b/test/datarate_test.cc
index d886c2a942..0969e9fd4f 100644
--- a/test/datarate_test.cc
+++ b/test/datarate_test.cc
@@ -377,7 +377,7 @@ class DatarateTestLarge
     // With CONFIG_REALTIME_ONLY=1, lag_in_frames is set to 0, and along with
     // other factors in that configuration the threshold needs to be lowered
     // after commit 2fed9c389d.
-    ASSERT_GE(effective_datarate_, cfg_.rc_target_bitrate * 0.65)
+    ASSERT_GE(effective_datarate_, cfg_.rc_target_bitrate * 0.8)
         << " The datarate for the file is lower than target by too much!";
 #else
     ASSERT_GE(effective_datarate_, cfg_.rc_target_bitrate * 0.85)