Commit 2bf291526e for ffmpeg

commit 2bf291526e50480d2c355b4c6c8dd04863212aa1
Author: Niklas Haas <git@haasn.dev>
Date:   Tue Nov 3 22:31:05 2026 +0100

    swscale/aarch64/ops: store the linear coefficients in the op chain

    Avoids a separate allocation, and the dependent load of the coefficient
    pointer in the kernel.

    Signed-off-by: Niklas Haas <git@haasn.dev>

diff --git a/libswscale/aarch64/ops.c b/libswscale/aarch64/ops.c
index 8ded09ffc6..d479eaa4f8 100644
--- a/libswscale/aarch64/ops.c
+++ b/libswscale/aarch64/ops.c
@@ -75,9 +75,12 @@ static int aarch64_setup_linear(const SwsAArch64OpImplParams *p,
      */
     const int num_vregs = linear_num_vregs(p);
     av_assert0(num_vregs <= 4);
-    void *coeffs = av_refstruct_allocz(num_vregs * 16);
-    if (!coeffs)
-        return AVERROR(ENOMEM);
+    union {
+        uint8_t  u8[4 * 16];
+        uint16_t u16[4 * 8];
+        uint32_t u32[4 * 4];
+        float    f32[4 * 4];
+    } coeffs = { 0 };

     /**
      * Copy non-zero coefficients, packed in sequential order, offset first.
@@ -90,16 +93,16 @@ static int aarch64_setup_linear(const SwsAArch64OpImplParams *p,
             if (!(p->par.lin.zero & SWS_MASK(i, jj))) {
                 const SwsPixel px = uop->data.mat4x5[i][jj];
                 switch (p->type) {
-                case SWS_PIXEL_U8:  ((uint8_t  *) coeffs)[i_coeff++] = px.u8;  break;
-                case SWS_PIXEL_U16: ((uint16_t *) coeffs)[i_coeff++] = px.u16; break;
-                case SWS_PIXEL_U32: ((uint32_t *) coeffs)[i_coeff++] = px.u32; break;
-                case SWS_PIXEL_F32: ((float    *) coeffs)[i_coeff++] = px.f32; break;
+                case SWS_PIXEL_U8:  coeffs.u8[i_coeff++]  = px.u8;  break;
+                case SWS_PIXEL_U16: coeffs.u16[i_coeff++] = px.u16; break;
+                case SWS_PIXEL_U32: coeffs.u32[i_coeff++] = px.u32; break;
+                case SWS_PIXEL_F32: coeffs.f32[i_coeff++] = px.f32; break;
                 }
             }
         }
     }

-    ff_sws_op_priv_pack_refptr(res, coeffs);
+    ff_sws_op_priv_pack(res, &coeffs, num_vregs * 16);
     return 0;
 }

diff --git a/libswscale/aarch64/ops_impl.h b/libswscale/aarch64/ops_impl.h
index 7b05962a4a..10447638b3 100644
--- a/libswscale/aarch64/ops_impl.h
+++ b/libswscale/aarch64/ops_impl.h
@@ -99,6 +99,7 @@ static inline int aarch64_priv_size(const SwsAArch64OpImplParams *params)
         return ff_sws_pixel_type_size(params->type);
     case SWS_UOP_LINEAR:
     case SWS_UOP_LINEAR_FMA:
+        return 16 * linear_num_vregs(params); /* packed coefficients */
     case SWS_UOP_DITHER:
         return 8; /* pointer */
     default:
diff --git a/libswscale/aarch64/ops_static.c b/libswscale/aarch64/ops_static.c
index d3fda52c66..18d58ca0fb 100644
--- a/libswscale/aarch64/ops_static.c
+++ b/libswscale/aarch64/ops_static.c
@@ -304,7 +304,7 @@ static void asmgen_setup_linear(SwsAArch64Context *s, const SwsAArch64OpImplPara
     case 3: coeff_veclist = vv_3(vc[0], vc[1], vc[2]);        break;
     case 4: coeff_veclist = vv_4(vc[0], vc[1], vc[2], vc[3]); break;
     }
-    i_ldr(r, ptr, IMPL_PRIV(s));                            CMT("v128 *vcoeff_ptr = impl->priv.ptr;");
+    i_add(r, ptr, s->impl, IMM(offsetof_impl_priv));        CMT("v128 *vcoeff_ptr = &impl->priv;");
     asmgen_set_load_cont_node(s);
     i_ld1(r, coeff_veclist, a64op_base(ptr));               CMT("coeff_veclist = *vcoeff_ptr;");