PR #22749 opened by Niklas Haas (haasn)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22749
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22749.patch


>From 2b9d6f43aa53679c0675cef0db419eda4107f6c3 Mon Sep 17 00:00:00 2001
From: Niklas Haas <[email protected]>
Date: Wed, 8 Apr 2026 13:02:52 +0200
Subject: [PATCH 1/2] swscale/options: add missing option value for SWS_STRICT

Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/options.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libswscale/options.c b/libswscale/options.c
index 004988488c..8109f1d23a 100644
--- a/libswscale/options.c
+++ b/libswscale/options.c
@@ -51,6 +51,7 @@ static const AVOption swscale_options[] = {
         { "bitexact",        "bit-exact mode",                0,  
AV_OPT_TYPE_CONST, { .i64 = SWS_BITEXACT       }, .flags = VE, .unit = 
"sws_flags" },
         { "error_diffusion", "error diffusion dither",        0,  
AV_OPT_TYPE_CONST, { .i64 = SWS_ERROR_DIFFUSION}, .flags = VE, .unit = 
"sws_flags" },
         { "unstable",        "allow experimental new code",   0,  
AV_OPT_TYPE_CONST, { .i64 = SWS_UNSTABLE       }, .flags = VE, .unit = 
"sws_flags" },
+        { "strict",          "require all metadata to be set",0,  
AV_OPT_TYPE_CONST, { .i64 = SWS_STRICT         }, .flags = VE, .unit = 
"sws_flags" },
 
     { "scaler",          "set scaling algorithm",         OFFSET(scaler),      
 AV_OPT_TYPE_INT,    { .i64 = SWS_SCALE_AUTO     }, .flags = VE, .unit = 
"sws_scaler", .max = SWS_SCALE_NB - 1 },
     { "scaler_sub",      "set subsampling algorithm",     OFFSET(scaler_sub),  
 AV_OPT_TYPE_INT,    { .i64 = SWS_SCALE_AUTO     }, .flags = VE, .unit = 
"sws_scaler", .max = SWS_SCALE_NB - 1 },
-- 
2.52.0


>From ddb9c396dccd939d6721e661692ec98a558d679b Mon Sep 17 00:00:00 2001
From: Niklas Haas <[email protected]>
Date: Wed, 8 Apr 2026 13:06:06 +0200
Subject: [PATCH 2/2] swscale/graph: don't trigger SWS_STRICT for missing prim
 when not converting

If both src and dst prim are unspecified, no conversion happens, so we don't
actually infer any relevant values. In this case, it makes sense to allow
the conversion even under SWS_STRICT. This also matches the behavior of the
legacy code, which e.g. also doesn't consider missing `csp` an error when not
performing colorspace conversion.

Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/graph.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libswscale/graph.c b/libswscale/graph.c
index 1c36ea3957..ab9661a1fc 100644
--- a/libswscale/graph.c
+++ b/libswscale/graph.c
@@ -749,7 +749,8 @@ static int adapt_colors(SwsGraph *graph, SwsFormat src, 
SwsFormat dst,
     }
 
     /* Fully infer color spaces before color mapping logic */
-    graph->incomplete |= ff_infer_colors(&src.color, &dst.color);
+    bool incomplete = false;
+    ff_infer_colors(&src.color, &dst.color, &incomplete);
 
     map.intent = graph->ctx->intent;
     map.src    = src.color;
@@ -758,6 +759,9 @@ static int adapt_colors(SwsGraph *graph, SwsFormat src, 
SwsFormat dst,
     if (ff_sws_color_map_noop(&map))
         return 0;
 
+    /* Don't update `incomplete` if not actually doing anything */
+    graph->incomplete |= incomplete;
+
     if (src.hw_format != AV_PIX_FMT_NONE || dst.hw_format != AV_PIX_FMT_NONE)
         return AVERROR(ENOTSUP);
 
-- 
2.52.0

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

Reply via email to