Commit 2ed5830108 for ffmpeg
commit 2ed5830108f92093cffb696e88706f970ce6bc6b
Author: Lynne <dev@lynne.ee>
Date: Sun Jul 26 13:53:52 2026 +0800
swscale: treat XYZ formats as colorspace-less in color (de|en)coding
XYZ formats carry no YCbCr matrix, so decode and encode them like RGB
instead of falling into the unspecified colorspace path, which applied
a BT.470BG matrix and marked the graph as incomplete.
Note that the new code does not yet convert between XYZ and RGB.
diff --git a/libswscale/format.c b/libswscale/format.c
index 631719fa8e..5484e8180c 100644
--- a/libswscale/format.c
+++ b/libswscale/format.c
@@ -1522,8 +1522,10 @@ int ff_sws_decode_colors(SwsContext *ctx, SwsPixelType type,
.lin = fmt_decode_range(fmt, incomplete),
}));
- /* Final step, decode colorspace */
- switch (fmt->csp) {
+ /* Final step, decode colorspace. XYZ formats carry no colorspace
+ * matrix; their transfer/primaries are handled by the color mapping
+ * layer, so treat them like RGB here. */
+ switch (fmt->desc->flags & AV_PIX_FMT_FLAG_XYZ ? AVCOL_SPC_RGB : fmt->csp) {
case AVCOL_SPC_RGB:
return 0;
case AVCOL_SPC_UNSPECIFIED:
@@ -1595,7 +1597,8 @@ int ff_sws_encode_colors(SwsContext *ctx, SwsPixelType type,
if (!pixel_type)
return AVERROR(ENOTSUP);
- switch (dst->csp) {
+ /* 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) {
case AVCOL_SPC_RGB:
break;
case AVCOL_SPC_UNSPECIFIED:
diff --git a/tests/ref/fate/sws-ops-list b/tests/ref/fate/sws-ops-list
index f3a5b44b56..59913a43f1 100644
--- a/tests/ref/fate/sws-ops-list
+++ b/tests/ref/fate/sws-ops-list
@@ -1 +1 @@
-b4ea23c724f642b3e43d329ed4981d38
+1f03295f230be02367e812f3670230cc