Commit 4f0033fed1 for aom

commit 4f0033fed1b2f1ac590f793418011f3bbe44e5ea
Author: Marco Paniconi <marpan@google.com>
Date:   Tue May 5 15:21:22 2026 -0700

    Set the svc number of layers to 1 when invalid params

    For ctrl_set_svc_params: on exit to invalid parameters
    make sure the number of spatial/temporal layers is set
    to 1.

    Bug: 503171639
    Change-Id: I288de61cda32ca535709f18b13a0fd6fc16987ee

diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index b474517b79..99402f6b56 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -4080,6 +4080,14 @@ static aom_codec_err_t ctrl_set_layer_id(aom_codec_alg_priv_t *ctx,
   return AOM_CODEC_OK;
 }

+static void disable_svc(AV1_PRIMARY *ppi, AV1_COMP *cpi) {
+  cpi->svc.number_spatial_layers = 1;
+  cpi->svc.number_temporal_layers = 1;
+  ppi->number_spatial_layers = 1;
+  ppi->number_temporal_layers = 1;
+  ppi->use_svc = 0;
+}
+
 static aom_codec_err_t ctrl_set_svc_params(aom_codec_alg_priv_t *ctx,
                                            va_list args) {
   AV1_PRIMARY *const ppi = ctx->ppi;
@@ -4139,6 +4147,15 @@ static aom_codec_err_t ctrl_set_svc_params(aom_codec_alg_priv_t *ctx,
       if (params->max_quantizers[layer] > 63 ||
           params->min_quantizers[layer] < 0 ||
           params->min_quantizers[layer] > params->max_quantizers[layer]) {
+        disable_svc(ppi, cpi);
+        return AOM_CODEC_INVALID_PARAM;
+      }
+    }
+    for (sl = 0; sl < ppi->number_spatial_layers; ++sl) {
+      // Check scaling factors: spatial scaling (scaling_factor_num[]/den[]) is
+      // always to a lower resolution, so den must be >= num.
+      if (params->scaling_factor_den[sl] < params->scaling_factor_num[sl]) {
+        disable_svc(ppi, cpi);
         return AOM_CODEC_INVALID_PARAM;
       }
     }
@@ -4151,14 +4168,8 @@ static aom_codec_err_t ctrl_set_svc_params(aom_codec_alg_priv_t *ctx,
         LAYER_CONTEXT *lc = &cpi->svc.layer_context[layer];
         lc->max_q = params->max_quantizers[layer];
         lc->min_q = params->min_quantizers[layer];
-        // spatial scaling (scaling_factor_num[]/den[]) is always to a lower
-        // resolution, so den must be >= num.
-        if (params->scaling_factor_den[sl] < params->scaling_factor_num[sl]) {
-          return AOM_CODEC_INVALID_PARAM;
-        } else {
-          lc->scaling_factor_num = AOMMAX(1, params->scaling_factor_num[sl]);
-          lc->scaling_factor_den = AOMMAX(1, params->scaling_factor_den[sl]);
-        }
+        lc->scaling_factor_num = AOMMAX(1, params->scaling_factor_num[sl]);
+        lc->scaling_factor_den = AOMMAX(1, params->scaling_factor_den[sl]);
         const int layer_target_bitrate = params->layer_target_bitrate[layer];
         if (layer_target_bitrate > INT_MAX / 1000) {
           lc->layer_target_bitrate = INT_MAX;