Commit ef1b13c277 for ffmpeg

commit ef1b13c27782c6f231b6e5060c80bbb2bd487069
Author: Niklas Haas <git@haasn.dev>
Date:   Fri Aug 14 10:50:49 2026 +0200

    swscale/ops: remove SwsConvertOp.expand

    This distinction no longer exists on the ops level.

    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <git@haasn.dev>
    Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>

diff --git a/libswscale/ops.c b/libswscale/ops.c
index 4d2343f9ed..0df8ec5acb 100644
--- a/libswscale/ops.c
+++ b/libswscale/ops.c
@@ -224,12 +224,8 @@ void ff_sws_apply_op_q(const SwsOp *op, AVRational64 x[4])
     }
     case SWS_OP_CONVERT:
         if (ff_sws_pixel_type_is_int(op->convert.to)) {
-            const AVRational64 scale = ff_sws_pixel_expand(op->type, op->convert.to);
-            for (int i = 0; i < 4; i++) {
+            for (int i = 0; i < 4; i++)
                 x[i] = x[i].den ? Q(x[i].num / x[i].den) : x[i];
-                if (op->convert.expand)
-                    x[i] = ff_mul_q64(x[i], scale);
-            }
         }
         return;
     case SWS_OP_DITHER:
@@ -473,7 +469,7 @@ void ff_sws_op_list_update_comps(SwsOpList *ops)
         case SWS_OP_CONVERT:
             for (int i = 0; i < 4; i++) {
                 FORWARD(i, i, flags);
-                if (!(prev.flags[i] & SWS_COMP_EXACT) || op->convert.expand)
+                if (!(prev.flags[i] & SWS_COMP_EXACT))
                     op->comps.flags[i] &= SWS_COMP_DIRTY;
                 if (ff_sws_pixel_type_is_int(op->convert.to))
                     op->comps.flags[i] |= SWS_COMP_EXACT;
@@ -917,10 +913,9 @@ void ff_sws_op_desc(AVBPrint *bp, const SwsOp *op)
                    op->swizzle.x, op->swizzle.y, op->swizzle.z, op->swizzle.w);
         break;
     case SWS_OP_CONVERT:
-        av_bprintf(bp, "%-20s: %s -> %s%s", name,
+        av_bprintf(bp, "%-20s: %s -> %s", name,
                    ff_sws_pixel_type_name(op->type),
-                   ff_sws_pixel_type_name(op->convert.to),
-                   op->convert.expand ? " (expand)" : "");
+                   ff_sws_pixel_type_name(op->convert.to));
         break;
     case SWS_OP_DITHER:
         av_bprintf(bp, "%-20s: %dx%d matrix + {%d %d %d %d}", name,
diff --git a/libswscale/ops.h b/libswscale/ops.h
index 008e8c5b31..465f5d4d49 100644
--- a/libswscale/ops.h
+++ b/libswscale/ops.h
@@ -171,7 +171,6 @@ typedef struct SwsClearOp {

 typedef struct SwsConvertOp {
     SwsPixelType to; /* type of pixel to convert to */
-    bool expand; /* if true, integers are expanded to the full range */
 } SwsConvertOp;

 typedef struct SwsClampOp {
diff --git a/libswscale/ops_internal.h b/libswscale/ops_internal.h
index 7d3e499047..b9e070e81b 100644
--- a/libswscale/ops_internal.h
+++ b/libswscale/ops_internal.h
@@ -28,18 +28,6 @@

 #define Q(N) ((AVRational64) { N, 1 })

-static inline AVRational64 ff_sws_pixel_expand(SwsPixelType from, SwsPixelType to)
-{
-    const int src = ff_sws_pixel_type_size(from);
-    const int dst = ff_sws_pixel_type_size(to);
-    if (src > dst)
-        return Q(0);
-    int scale = 1;
-    for (int i = 1; i < dst / src; i++)
-        scale = (scale << (src * 8)) | 1;
-    return Q(scale);
-}
-
 static inline void ff_sws_pack_op_decode(const SwsOp *op, uint64_t mask[4], int shift[4])
 {
     int size = 0;
diff --git a/libswscale/ops_optimizer.c b/libswscale/ops_optimizer.c
index ad2c151024..a11fee293a 100644
--- a/libswscale/ops_optimizer.c
+++ b/libswscale/ops_optimizer.c
@@ -361,7 +361,7 @@ retry:
             }

             /* Merge filter with prior conversion */
-            if (prev->op == SWS_OP_CONVERT && !prev->convert.expand) {
+            if (prev->op == SWS_OP_CONVERT) {
                 int size_from = ff_sws_pixel_type_size(prev->type);
                 int size_to   = ff_sws_pixel_type_size(op->type);
                 av_assert1(prev->convert.to == op->type);
@@ -555,9 +555,7 @@ retry:
             }

             /* Transitive conversion */
-            if (next->op == SWS_OP_CONVERT &&
-                op->convert.expand == next->convert.expand)
-            {
+            if (next->op == SWS_OP_CONVERT) {
                 av_assert1(op->convert.to == next->type);
                 op->convert.to = next->convert.to;
                 ff_sws_op_list_remove_at(ops, n + 1, 1);
diff --git a/libswscale/uops.c b/libswscale/uops.c
index 127a19fab0..dbcdc07d89 100644
--- a/libswscale/uops.c
+++ b/libswscale/uops.c
@@ -594,19 +594,11 @@ static int translate_op(SwsContext *ctx, SwsUOpList *uops, SwsUOpFlags flags,

     switch (op->op) {
     case SWS_OP_CONVERT:
-        if (op->convert.expand) {
-            av_assert0(op->type == SWS_PIXEL_U8);
-            switch (op->convert.to) {
-            case SWS_PIXEL_U16: uop.uop = SWS_UOP_EXPAND_PAIR; break;
-            case SWS_PIXEL_U32: uop.uop = SWS_UOP_EXPAND_QUAD; break;
-            }
-        } else {
-            switch (op->convert.to) {
-            case SWS_PIXEL_U8:  uop.uop = SWS_UOP_TO_U8;  break;
-            case SWS_PIXEL_U16: uop.uop = SWS_UOP_TO_U16; break;
-            case SWS_PIXEL_U32: uop.uop = SWS_UOP_TO_U32; break;
-            case SWS_PIXEL_F32: uop.uop = SWS_UOP_TO_F32; break;
-            }
+        switch (op->convert.to) {
+        case SWS_PIXEL_U8:  uop.uop = SWS_UOP_TO_U8;  break;
+        case SWS_PIXEL_U16: uop.uop = SWS_UOP_TO_U16; break;
+        case SWS_PIXEL_U32: uop.uop = SWS_UOP_TO_U32; break;
+        case SWS_PIXEL_F32: uop.uop = SWS_UOP_TO_F32; break;
         }
         break;
     case SWS_OP_UNPACK:
diff --git a/libswscale/vulkan/ops.c b/libswscale/vulkan/ops.c
index 8fc16274a3..eeb86eec35 100644
--- a/libswscale/vulkan/ops.c
+++ b/libswscale/vulkan/ops.c
@@ -519,15 +519,6 @@ static void define_shader_consts(SwsContext *sws, const SwsOpList *ops,
         av_assert0((id->nb_const_ids + 31) <= FF_ARRAY_ELEMS(id->const_ids));
         const SwsOp *op = &ops->ops[n];
         switch (op->op) {
-        case SWS_OP_CONVERT:
-            if (ff_sws_pixel_type_is_int(op->convert.to) && op->convert.expand) {
-                AVRational64 m = ff_sws_pixel_expand(op->type, op->convert.to);
-                int tmp = spi_OpConstantUInt(spi, id->u32_type, m.num);
-                tmp = spi_OpConstantComposite(spi, id->u32vec4_type,
-                                              tmp, tmp, tmp, tmp);
-                id->const_ids[id->nb_const_ids++] = tmp;
-            }
-            break;
         case SWS_OP_CLEAR:
             for (int i = 0; i < 4; i++) {
                 if (!SWS_COMP_TEST(op->clear.mask, i))
@@ -1184,9 +1175,7 @@ static int add_ops_spirv(SwsContext *sws, VulkanPriv *p, FFVulkanOpsCtx *s,
                                        op->swizzle.in[3]);
             break;
         case SWS_OP_CONVERT:
-            if (ff_sws_pixel_type_is_int(cur_type) && op->convert.expand)
-                data = spi_OpIMul(spi, type_v, data, id->const_ids[nb_const_ids++]);
-            else if (op->type == SWS_PIXEL_F32 && type_s == id->u32_type)
+            if (op->type == SWS_PIXEL_F32 && type_s == id->u32_type)
                 data = spi_OpConvertFToU(spi, type_v, data);
             else if (op->type != SWS_PIXEL_F32 && type_s == id->f32_type)
                 data = spi_OpConvertUToF(spi, type_v, data);