This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit cc7784205c5b2877c693fafcfe859d6f3caada9d
Author:     Ramiro Polla <[email protected]>
AuthorDate: Fri Jun 12 22:07:48 2026 +0200
Commit:     Ramiro Polla <[email protected]>
CommitDate: Sun Jul 19 15:07:02 2026 +0200

    swscale/aarch64/ops: specialize clear operation
    
    There are now more specialized functions for components that clear to
    zero and one (using `movi` instead of `dup`).
    
    This is similar to the way SWS_UOP_CLEAR works and will simplify the
    move to uops.
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Ramiro Polla <[email protected]>
---
 libswscale/aarch64/ops_asmgen.c    | 40 +++++++++++++++++----
 libswscale/aarch64/ops_entries.c   | 74 ++++++++++++++++++++++----------------
 libswscale/aarch64/ops_impl.c      |  3 +-
 libswscale/aarch64/ops_impl.h      |  7 ++++
 libswscale/aarch64/ops_impl_conv.c | 15 +++++++-
 5 files changed, 100 insertions(+), 39 deletions(-)

diff --git a/libswscale/aarch64/ops_asmgen.c b/libswscale/aarch64/ops_asmgen.c
index 260279117c..1dfc0060e5 100644
--- a/libswscale/aarch64/ops_asmgen.c
+++ b/libswscale/aarch64/ops_asmgen.c
@@ -823,11 +823,32 @@ static void asmgen_op_rshift(SwsAArch64Context *s, const 
SwsAArch64OpImplParams
 /* clear pixel values */
 /* AARCH64_SWS_OP_CLEAR */
 
+static void emit_clear(SwsAArch64Context *s, const SwsAArch64OpImplParams *p,
+                       RasmOp *vx, int i, const char *vx_str)
+{
+    RasmContext *r = s->rctx;
+    RasmOp clear_vec = s->vt[0];
+    switch (MASK_GET(p->clear, i)) {
+    case 0:
+        i_movi(r, vx[i], IMM(0));                   CMTF("%s[%u] = 0;", 
vx_str, i);
+        break;
+    case 1:
+        if (p->block_size * aarch64_pixel_size(p->type) == 8) {
+            i_movi(r, v_8b (vx[i]), IMM(0xff));
+        } else {
+            i_movi(r, v_16b(vx[i]), IMM(0xff));
+        }
+        CMTF("%s[%u] = UINT_MAX;", vx_str, i);
+        break;
+    default:
+        i_dup (r, vx[i], a64op_elem(clear_vec, i)); CMTF("%s[%u] = 
broadcast(clear_vec[%u]);", vx_str, i, i);
+        break;
+    }
+}
+
 static void asmgen_op_clear(SwsAArch64Context *s, const SwsAArch64OpImplParams 
*p)
 {
     RasmContext *r = s->rctx;
-    RasmOp *vl = s->vl;
-    RasmOp *vh = s->vh;
     RasmOp clear_vec = s->vt[0];
 
     /**
@@ -836,11 +857,18 @@ static void asmgen_op_clear(SwsAArch64Context *s, const 
SwsAArch64OpImplParams *
      * - if only 1 element and not vh, load directly with ld1r
      */
 
-    i_ldr(r, v_q(clear_vec), a64op_off(s->impl, offsetof_impl_priv));   
CMT("v128 clear_vec = impl->priv.v128;");
-    asmgen_set_load_cont_node(s);
+    bool load_priv = false;
+    LOOP_MASK(p, i) {
+        if (MASK_GET(p->clear, i) == 0xf)
+            load_priv = true;
+    }
+    if (load_priv) {
+        i_ldr(r, v_q(clear_vec), a64op_off(s->impl, offsetof_impl_priv));   
CMT("v128 clear_vec = impl->priv.v128;");
+        asmgen_set_load_cont_node(s);
+    }
 
-    LOOP_MASK      (p, i) { i_dup(r, vl[i], a64op_elem(clear_vec, i));  
CMTF("vl[%u] = broadcast(clear_vec[%u])", i, i); }
-    LOOP_MASK_VH(s, p, i) { i_dup(r, vh[i], a64op_elem(clear_vec, i));  
CMTF("vh[%u] = broadcast(clear_vec[%u])", i, i); }
+    LOOP_MASK      (p, i) { emit_clear(s, p, s->vl, i, "vl"); }
+    LOOP_MASK_VH(s, p, i) { emit_clear(s, p, s->vh, i, "vh"); }
 }
 
 /*********************************************************************/
diff --git a/libswscale/aarch64/ops_entries.c b/libswscale/aarch64/ops_entries.c
index 3f0fc83e26..9c4e103007 100644
--- a/libswscale/aarch64/ops_entries.c
+++ b/libswscale/aarch64/ops_entries.c
@@ -241,37 +241,49 @@
 { .op = AARCH64_SWS_OP_RSHIFT, .shift = 6, .block_size = 8, .type = 
AARCH64_PIXEL_U16, .mask = 0x0001 },
 { .op = AARCH64_SWS_OP_RSHIFT, .shift = 6, .block_size = 8, .type = 
AARCH64_PIXEL_U16, .mask = 0x0111 },
 { .op = AARCH64_SWS_OP_RSHIFT, .shift = 6, .block_size = 16, .type = 
AARCH64_PIXEL_U16, .mask = 0x0111 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U8, .mask 
= 0x0001 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U8, .mask 
= 0x0010 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U8, .mask 
= 0x0011 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U8, .mask 
= 0x0101 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U8, .mask 
= 0x1000 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U8, .mask 
= 0x1011 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U8, .mask 
= 0x1100 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U8, .mask 
= 0x1101 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U16, 
.mask = 0x0001 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U16, 
.mask = 0x0010 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U16, 
.mask = 0x1000 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U16, 
.mask = 0x1100 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U16, 
.mask = 0x1101 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U32, 
.mask = 0x0001 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U32, 
.mask = 0x0010 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U32, 
.mask = 0x0101 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U32, 
.mask = 0x1000 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U32, 
.mask = 0x1010 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U32, 
.mask = 0x1011 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 8, .type = AARCH64_PIXEL_U32, 
.mask = 0x1101 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 16, .type = AARCH64_PIXEL_U8, 
.mask = 0x0001 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 16, .type = AARCH64_PIXEL_U8, 
.mask = 0x0010 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 16, .type = AARCH64_PIXEL_U8, 
.mask = 0x0011 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 16, .type = AARCH64_PIXEL_U8, 
.mask = 0x0110 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 16, .type = AARCH64_PIXEL_U8, 
.mask = 0x0111 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 16, .type = AARCH64_PIXEL_U8, 
.mask = 0x1000 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 16, .type = AARCH64_PIXEL_U16, 
.mask = 0x0001 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 16, .type = AARCH64_PIXEL_U16, 
.mask = 0x0010 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 16, .type = AARCH64_PIXEL_U16, 
.mask = 0x0011 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 16, .type = AARCH64_PIXEL_U16, 
.mask = 0x0111 },
-{ .op = AARCH64_SWS_OP_CLEAR, .block_size = 16, .type = AARCH64_PIXEL_U16, 
.mask = 0x1000 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0x0fff, .block_size = 8, .type = 
AARCH64_PIXEL_U8, .mask = 0x1000 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0x0fff, .block_size = 8, .type = 
AARCH64_PIXEL_U8, .mask = 0x1011 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0x0fff, .block_size = 8, .type = 
AARCH64_PIXEL_U16, .mask = 0x1000 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0x0fff, .block_size = 8, .type = 
AARCH64_PIXEL_U16, .mask = 0x1101 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0x0fff, .block_size = 16, .type = 
AARCH64_PIXEL_U8, .mask = 0x1000 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0x0fff, .block_size = 16, .type = 
AARCH64_PIXEL_U16, .mask = 0x1000 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0x1fff, .block_size = 8, .type = 
AARCH64_PIXEL_U8, .mask = 0x1000 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0x1fff, .block_size = 8, .type = 
AARCH64_PIXEL_U8, .mask = 0x1011 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0x1fff, .block_size = 8, .type = 
AARCH64_PIXEL_U8, .mask = 0x1101 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0x1fff, .block_size = 8, .type = 
AARCH64_PIXEL_U16, .mask = 0x1000 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0x1fff, .block_size = 16, .type = 
AARCH64_PIXEL_U8, .mask = 0x1000 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0x1fff, .block_size = 16, .type = 
AARCH64_PIXEL_U16, .mask = 0x1000 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xff1f, .block_size = 8, .type = 
AARCH64_PIXEL_U8, .mask = 0x0010 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xff1f, .block_size = 8, .type = 
AARCH64_PIXEL_U16, .mask = 0x0010 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xff1f, .block_size = 16, .type = 
AARCH64_PIXEL_U8, .mask = 0x0010 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xff1f, .block_size = 16, .type = 
AARCH64_PIXEL_U16, .mask = 0x0010 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xfff0, .block_size = 8, .type = 
AARCH64_PIXEL_U8, .mask = 0x0001 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xfff0, .block_size = 16, .type = 
AARCH64_PIXEL_U8, .mask = 0x0001 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xfff1, .block_size = 8, .type = 
AARCH64_PIXEL_U8, .mask = 0x0001 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xfff1, .block_size = 8, .type = 
AARCH64_PIXEL_U8, .mask = 0x1101 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xfff1, .block_size = 8, .type = 
AARCH64_PIXEL_U16, .mask = 0x0001 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xfff1, .block_size = 8, .type = 
AARCH64_PIXEL_U16, .mask = 0x1101 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xfff1, .block_size = 16, .type = 
AARCH64_PIXEL_U8, .mask = 0x0001 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xfff1, .block_size = 16, .type = 
AARCH64_PIXEL_U8, .mask = 0x0111 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xfff1, .block_size = 16, .type = 
AARCH64_PIXEL_U16, .mask = 0x0001 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xfff1, .block_size = 16, .type = 
AARCH64_PIXEL_U16, .mask = 0x0111 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 8, .type = 
AARCH64_PIXEL_U8, .mask = 0x0011 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 8, .type = 
AARCH64_PIXEL_U8, .mask = 0x0101 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 8, .type = 
AARCH64_PIXEL_U8, .mask = 0x1100 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 8, .type = 
AARCH64_PIXEL_U16, .mask = 0x1100 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 8, .type = 
AARCH64_PIXEL_U32, .mask = 0x0001 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 8, .type = 
AARCH64_PIXEL_U32, .mask = 0x0010 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 8, .type = 
AARCH64_PIXEL_U32, .mask = 0x0101 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 8, .type = 
AARCH64_PIXEL_U32, .mask = 0x1000 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 8, .type = 
AARCH64_PIXEL_U32, .mask = 0x1010 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 8, .type = 
AARCH64_PIXEL_U32, .mask = 0x1011 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 8, .type = 
AARCH64_PIXEL_U32, .mask = 0x1101 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 16, .type = 
AARCH64_PIXEL_U8, .mask = 0x0011 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 16, .type = 
AARCH64_PIXEL_U8, .mask = 0x0110 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 16, .type = 
AARCH64_PIXEL_U16, .mask = 0x0001 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 16, .type = 
AARCH64_PIXEL_U16, .mask = 0x0011 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 16, .type = 
AARCH64_PIXEL_U16, .mask = 0x0111 },
+{ .op = AARCH64_SWS_OP_CLEAR, .clear = 0xffff, .block_size = 16, .type = 
AARCH64_PIXEL_U16, .mask = 0x1000 },
 { .op = AARCH64_SWS_OP_TO_U8, .block_size = 8, .type = AARCH64_PIXEL_F32, 
.mask = 0x0001 },
 { .op = AARCH64_SWS_OP_TO_U8, .block_size = 8, .type = AARCH64_PIXEL_F32, 
.mask = 0x0011 },
 { .op = AARCH64_SWS_OP_TO_U8, .block_size = 8, .type = AARCH64_PIXEL_F32, 
.mask = 0x0111 },
diff --git a/libswscale/aarch64/ops_impl.c b/libswscale/aarch64/ops_impl.c
index e0dbcd5d80..799558613f 100644
--- a/libswscale/aarch64/ops_impl.c
+++ b/libswscale/aarch64/ops_impl.c
@@ -344,6 +344,7 @@ static const ParamField field_mask             = { 
PARAM_FIELD(mask),
 static const ParamField field_type             = { PARAM_FIELD(type),          
   print_pixel_name, print_pixel_val, cmp_pixel };
 static const ParamField field_block_size       = { PARAM_FIELD(block_size),    
   print_u8_name,    print_u8_val,    cmp_u8 };
 static const ParamField field_shift            = { PARAM_FIELD(shift),         
   print_u8_name,    print_u8_val,    cmp_u8 };
+static const ParamField field_clear            = { PARAM_FIELD(clear),         
   print_u16_name,   print_u16_val,   cmp_u16 };
 static const ParamField field_move             = { PARAM_FIELD(move),          
   print_u48_name,   print_u48_val,   cmp_u48 };
 static const ParamField field_pack             = { PARAM_FIELD(pack),          
   print_u16_name,   print_u16_val,   cmp_u16 };
 static const ParamField field_linear_mask      = { PARAM_FIELD(linear.mask),   
   print_u40_name,   print_u40_val,   cmp_u40 };
@@ -368,7 +369,7 @@ static const ParamField 
*op_fields[AARCH64_SWS_OP_TYPE_NB][MAX_LEVELS] = {
     [AARCH64_SWS_OP_PACK          ] = { &field_op, &field_pack,                
                     &field_block_size, &field_type, &field_mask },
     [AARCH64_SWS_OP_LSHIFT        ] = { &field_op, &field_shift,               
                     &field_block_size, &field_type, &field_mask },
     [AARCH64_SWS_OP_RSHIFT        ] = { &field_op, &field_shift,               
                     &field_block_size, &field_type, &field_mask },
-    [AARCH64_SWS_OP_CLEAR         ] = { &field_op,                             
                     &field_block_size, &field_type, &field_mask },
+    [AARCH64_SWS_OP_CLEAR         ] = { &field_op, &field_clear,               
                     &field_block_size, &field_type, &field_mask },
     [AARCH64_SWS_OP_TO_U8         ] = { &field_op,                             
                     &field_block_size, &field_type, &field_mask },
     [AARCH64_SWS_OP_TO_U16        ] = { &field_op,                             
                     &field_block_size, &field_type, &field_mask },
     [AARCH64_SWS_OP_TO_U32        ] = { &field_op,                             
                     &field_block_size, &field_type, &field_mask },
diff --git a/libswscale/aarch64/ops_impl.h b/libswscale/aarch64/ops_impl.h
index 60fc14ee89..7461612ebd 100644
--- a/libswscale/aarch64/ops_impl.h
+++ b/libswscale/aarch64/ops_impl.h
@@ -71,6 +71,12 @@ typedef enum SwsAArch64OpType {
 /* Each nibble in the mask corresponds to one component. */
 typedef uint16_t SwsAArch64OpMask;
 
+/**
+ * Each nibble in the mask specifies whether to clear by all 0s (0),
+ * all 1s (1), or another value (f).
+ */
+typedef uint16_t SwsAArch64ClearMask;
+
 /* Each byte is an LSB src|dst pair until 00 is reached. */
 typedef uint64_t SwsAArch64MoveOp;
 #define AARCH64_MOVE_TMP 0xf
@@ -105,6 +111,7 @@ typedef struct SwsAArch64OpImplParams {
     uint8_t block_size;
     union {
         uint8_t             shift;
+        SwsAArch64ClearMask clear;
         SwsAArch64MoveOp    move;
         SwsAArch64OpMask    pack;
         SwsAArch64LinearOp  linear;
diff --git a/libswscale/aarch64/ops_impl_conv.c 
b/libswscale/aarch64/ops_impl_conv.c
index 1279108e98..0c472ae84f 100644
--- a/libswscale/aarch64/ops_impl_conv.c
+++ b/libswscale/aarch64/ops_impl_conv.c
@@ -275,9 +275,22 @@ static int convert_to_aarch64_impl(SwsContext *ctx, const 
SwsOpList *ops, int n,
         break;
     case AARCH64_SWS_OP_CLEAR:
         out->mask = 0;
+        out->clear = 0;
         for (int i = 0; i < 4; i++) {
-            if (op->clear.mask & SWS_COMP(i))
+            int mask_val = 0xf;
+            if (op->clear.mask & SWS_COMP(i)) {
                 MASK_SET(out->mask, i, 1);
+                if (op->clear.value[i].num == 0) {
+                    mask_val = 0;
+                } else {
+                    uint32_t val = op->clear.value[i].num / 
op->clear.value[i].den;
+                    if ((op->type == SWS_PIXEL_U8  && val == UINT8_MAX)  ||
+                        (op->type == SWS_PIXEL_U16 && val == UINT16_MAX) ||
+                        (op->type == SWS_PIXEL_U32 && val == UINT32_MAX))
+                        mask_val = 1;
+                }
+            }
+            MASK_SET(out->clear, i, mask_val);
         }
         break;
     case AARCH64_SWS_OP_LINEAR:

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to