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


>From 66d529ce5ff08910d30ccd90e3cc419e0ad3aa1b Mon Sep 17 00:00:00 2001
From: Niklas Haas <[email protected]>
Date: Sun, 25 Oct 2026 18:24:29 +0100
Subject: [PATCH 1/3] swscale/format: mark XYZ formats as unsupported

Regressed by the introduction of planar XYZ formats, which unintentionally
exposed XYZ formats as "supported" in libswscale, despite that never
being the intent.

This incomplete partial support was then poorly and incorrectly worked
around by 2ed5830108, a20ae16999 and 60c8273b357. The test framework still
spams errors as a result of these three incomplete work-arounds.

Rather than pile on a third work-around (e.g. skipping XYZ in the test
framework), just do the sensible thing and revert the bugged feature, that
was never supposed to be a feature in the first place.

Fixes: 2983c23762ab62160ad8b28dff6042d15efabf20
Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/format.c         | 4 ++++
 tests/ref/fate/sws-ops-list | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libswscale/format.c b/libswscale/format.c
index 4af9c91b351..0d2a07b5bce 100644
--- a/libswscale/format.c
+++ b/libswscale/format.c
@@ -980,6 +980,10 @@ static int fmt_analyze(enum AVPixelFormat fmt, 
SwsReadWriteOp *rw_op,
     if (desc->log2_chroma_w || desc->log2_chroma_h)
         return AVERROR(ENOTSUP);
 
+    /* XYZ decoding requires TRC support, which is not implemented yet */
+    if (desc->flags & AV_PIX_FMT_FLAG_XYZ)
+        return AVERROR(ENOTSUP);
+
     /* No support for semi-planar formats at the moment */
     if (desc->flags & AV_PIX_FMT_FLAG_PLANAR &&
         av_pix_fmt_count_planes(fmt) < desc->nb_components)
diff --git a/tests/ref/fate/sws-ops-list b/tests/ref/fate/sws-ops-list
index f5519b5e194..89652b8541a 100644
--- a/tests/ref/fate/sws-ops-list
+++ b/tests/ref/fate/sws-ops-list
@@ -1 +1 @@
-5e7e06cdc6f4c715b0a7ce5ed278e084
+4e6b06a456afad8365188ff8ff897b79
-- 
2.54.0


>From fca04104ad0685f43d0dbe0d03b1199c358fdd2e Mon Sep 17 00:00:00 2001
From: Niklas Haas <[email protected]>
Date: Sun, 25 Oct 2026 18:29:15 +0100
Subject: [PATCH 2/3] Revert "swscale: treat XYZ formats as colorspace-less in
 color (de|en)coding"

This reverts commit 2ed5830108f92093cffb696e88706f970ce6bc6b.
This was wrong from the beginning, leading to the mess we're in.

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

diff --git a/libswscale/format.c b/libswscale/format.c
index 0d2a07b5bce..f0a2670a96e 100644
--- a/libswscale/format.c
+++ b/libswscale/format.c
@@ -1520,9 +1520,6 @@ static int decode_colors(SwsContext *ctx, SwsPixelType 
type, SwsOpList *ops,
         .lin  = fmt_decode_range(fmt, type, incomplete),
     }));
 
-    if (fmt->desc->flags & AV_PIX_FMT_FLAG_XYZ)
-        return 0; /* XYZ formats are treated as colorspaceless */
-
     /* Final step, decode colorspace */
     switch (fmt->csp) {
     case AVCOL_SPC_RGB:
@@ -1595,8 +1592,7 @@ static int encode_colors(SwsContext *ctx, SwsPixelType 
type, SwsOpList *ops,
     if (!pixel_type)
          return AVERROR(ENOTSUP);
 
-    /* See ff_sws_decode_colors(): XYZ formats have no colorspace matrix */
-    switch (dst->desc->flags & AV_PIX_FMT_FLAG_XYZ ? AVCOL_SPC_RGB : dst->csp) 
{
+    switch (dst->csp) {
     case AVCOL_SPC_RGB:
         break;
     case AVCOL_SPC_UNSPECIFIED:
@@ -1838,11 +1834,6 @@ int ff_sws_op_list_generate(SwsContext *ctx, const 
SwsFormat *src,
         ctx->alpha_blend != SWS_ALPHA_BLEND_NONE)
         return AVERROR(ENOTSUP);
 
-    /* XYZ<->RGB conversion requires application of a gamma function which
-     * are not currently implemented */
-    if ((src->desc->flags ^ dst->desc->flags) & AV_PIX_FMT_FLAG_XYZ)
-        return AVERROR(ENOTSUP);
-
     SwsOpList *ops = ff_sws_op_list_alloc();
     if (!ops)
         return AVERROR(ENOMEM);
-- 
2.54.0


>From 2cda6803b40ca555b241d1f140c635a0d40a2421 Mon Sep 17 00:00:00 2001
From: Niklas Haas <[email protected]>
Date: Sun, 25 Oct 2026 17:59:10 +0100
Subject: [PATCH 3/3] Revert "swscale/tests/swscale: don't bail on ENOTSUP in
 auxiliary conversions"

This reverts commit 60c8273b35762d6fdd0f70c451cba5a12b2d8e72.

No longer needed work-around (see previous commit).

Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/tests/swscale.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 10533722c7e..89d3fb23ab0 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -682,8 +682,11 @@ static int run_test(struct runner *runner, const struct 
test_case *t,
     ret = (opts->api == IMPL_LEGACY) ? scale_legacy(dst, src, &t->mode, opts, 
&r.time)
         : state.hw_device_ctx        ? scale_hw(dst, src, &t->mode, opts, 
&r.time)
         :                              scale_new(runner, dst, src, &t->mode, 
opts, &r.time);
-    if (ret < 0)
+    if (ret < 0) {
+        if (ret == AVERROR(ENOTSUP))
+            ret = 0;
         goto error;
+    }
 
     ret = init_frame(&out, ref, ref->width, ref->height, ref->format);
     if (ret < 0)
@@ -731,8 +734,6 @@ bad_loss:
  error:
     av_frame_free(&dst);
     av_frame_free(&out);
-    if (ret == AVERROR(ENOTSUP))
-        ret = 0;
     return ret;
 }
 
-- 
2.54.0

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

Reply via email to