Commit 1c03b6d9ef for aom

commit 1c03b6d9ef8f29124f5e1519a13f094c547960fa
Author: Julio Barba <juliobbv@gmail.com>
Date:   Tue Mar 17 12:32:18 2026 -0400

    Frame scaling loop restoration crash fix

    `av1_loop_restoration_[de]alloc()`, `av1_init_lr_mt_buffers()`:
    assign LR arrays from the `AV1Common` struct to the first worker,
    to avoid moving those LR arrays around workers.

    Change-Id: I18df528eb12c493888b6ca14487f13a7733f7960

diff --git a/av1/common/thread_common.c b/av1/common/thread_common.c
index 0ff6238992..858b4e309f 100644
--- a/av1/common/thread_common.c
+++ b/av1/common/thread_common.c
@@ -623,15 +623,14 @@ void av1_loop_restoration_alloc(AV1LrSync *lr_sync, AV1_COMMON *cm,
   lr_sync->num_workers = num_workers;

   for (int worker_idx = 0; worker_idx < num_workers; ++worker_idx) {
-    if (worker_idx < num_workers - 1) {
+    if (worker_idx == 0) {
+      lr_sync->lrworkerdata[worker_idx].rst_tmpbuf = cm->rst_tmpbuf;
+      lr_sync->lrworkerdata[worker_idx].rlbs = cm->rlbs;
+    } else {
       CHECK_MEM_ERROR(cm, lr_sync->lrworkerdata[worker_idx].rst_tmpbuf,
                       (int32_t *)aom_memalign(16, RESTORATION_TMPBUF_SIZE));
       CHECK_MEM_ERROR(cm, lr_sync->lrworkerdata[worker_idx].rlbs,
                       aom_malloc(sizeof(RestorationLineBuffers)));
-
-    } else {
-      lr_sync->lrworkerdata[worker_idx].rst_tmpbuf = cm->rst_tmpbuf;
-      lr_sync->lrworkerdata[worker_idx].rlbs = cm->rlbs;
     }
   }

@@ -679,7 +678,7 @@ void av1_loop_restoration_dealloc(AV1LrSync *lr_sync) {
     aom_free(lr_sync->job_queue);

     if (lr_sync->lrworkerdata) {
-      for (int worker_idx = 0; worker_idx < lr_sync->num_workers - 1;
+      for (int worker_idx = 1; worker_idx < lr_sync->num_workers;
            worker_idx++) {
         LRWorkerData *const workerdata_data =
             lr_sync->lrworkerdata + worker_idx;
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index 4f5fe5d5f9..e76912c11c 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -831,14 +831,12 @@ void av1_init_cdef_worker(AV1_COMP *cpi) {
 void av1_init_lr_mt_buffers(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
   AV1LrSync *lr_sync = &cpi->mt_info.lr_row_sync;
-  if (lr_sync->sync_range) {
-    if (cpi->ppi->gf_group.frame_parallel_level[cpi->gf_frame_index] > 0)
-      return;
-    int num_lr_workers =
-        av1_get_num_mod_workers_for_alloc(&cpi->ppi->p_mt_info, MOD_LR);
-    assert(num_lr_workers <= lr_sync->num_workers);
-    lr_sync->lrworkerdata[num_lr_workers - 1].rst_tmpbuf = cm->rst_tmpbuf;
-    lr_sync->lrworkerdata[num_lr_workers - 1].rlbs = cm->rlbs;
+
+  if (lr_sync->sync_range &&
+      cpi->ppi->gf_group.frame_parallel_level[cpi->gf_frame_index] == 0) {
+    assert(lr_sync->num_workers > 0);
+    lr_sync->lrworkerdata[0].rst_tmpbuf = cm->rst_tmpbuf;
+    lr_sync->lrworkerdata[0].rlbs = cm->rlbs;
   }
 }
 #endif