Commit aac27b8f29 for aom

commit aac27b8f291ed449fac576bcce0ad0ca189be851
Author: Frank Galligan <fgalligan@google.com>
Date:   Sat Nov 14 11:59:32 2026 -0800

    av1: Opt allintra_vis boost & q_to_qindex lookup

    Early-exit av1_get_sbq_variance_boost when deltaq_strength <= 0 or
    variance >= 1024, and replace the linear scan in
    av1_convert_q_to_qindex with a binary search.

    Speedup: -0.94% (4T Neoverse N3) and -1.99% (1T Cortex-A720) / -7.25%
    (4T) on Pixel 9 avifenc (bit-exact).

    TAG=agy
    CONV=490488d4-7005-402a-8cc4-c245227f80fe

    Change-Id: Iaded1227d1058c3ec875ff5d3c4bcd092912b360

diff --git a/av1/encoder/allintra_vis.c b/av1/encoder/allintra_vis.c
index 91b51471e1..2d93c6294f 100644
--- a/av1/encoder/allintra_vis.c
+++ b/av1/encoder/allintra_vis.c
@@ -1106,7 +1106,15 @@ int av1_get_sbq_variance_boost(const AV1_COMP *cpi, const MACROBLOCK *x) {
   // Variance Boost only supports 64x64 SBs.
   assert(cm->seq_params->sb_size == BLOCK_64X64);

+  if (cpi->oxcf.q_cfg.deltaq_strength == 0) {
+    return AOMMAX(base_qindex, MINQ + 1);
+  }
+
   unsigned int variance = av1_get_variance_boost_block_variance(cpi, x);
+  if (variance >= 1024) {
+    return AOMMAX(base_qindex, MINQ + 1);
+  }
+
   // Compute Variance Boost strength from the deltaq_strength value.
   double strength = (cpi->oxcf.q_cfg.deltaq_strength / 100.0) * 3.0;

diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index 03cb5c945d..117322eb25 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -209,17 +209,22 @@ double av1_convert_qindex_to_q(int qindex, aom_bit_depth_t bit_depth) {
 }

 int av1_convert_q_to_qindex(double q, aom_bit_depth_t bit_depth) {
-  int qindex = MINQ;
+  int low = MINQ;
+  int high = MAXQ;

-  // Find the first qindex that matches or exceeds q.
-  // Note: this operation can also be done with a binary search, as
+  // Find the first qindex that matches or exceeds q via binary search, as
   // av1_convert_qindex_to_q() is monotonically increasing with respect to
   // increasing qindex.
-  while (qindex < MAXQ && av1_convert_qindex_to_q(qindex, bit_depth) < q) {
-    qindex++;
+  while (low < high) {
+    const int mid = (low + high) >> 1;
+    if (av1_convert_qindex_to_q(mid, bit_depth) < q) {
+      low = mid + 1;
+    } else {
+      high = mid;
+    }
   }

-  return qindex;
+  return low;
 }

 // Gets the appropriate bpmb enumerator based on the frame and content type