Commit c35825a5f2 for ffmpeg
commit c35825a5f2ca0f6ca93f7f8b4b9b5be174a5c184
Author: Niklas Haas <git@haasn.dev>
Date: Wed Aug 5 22:02:50 2026 +0200
swscale/format: make ff_sws_op_list_generate() internals private
I have so far not manifested a use case for these being exposed, and it
makes it more of a chore to add or remove parameters.
Signed-off-by: Niklas Haas <git@haasn.dev>
diff --git a/libswscale/format.c b/libswscale/format.c
index b722f979d4..4f75adcc0f 100644
--- a/libswscale/format.c
+++ b/libswscale/format.c
@@ -1085,7 +1085,8 @@ static inline AVRational64 intmax_q64(int bits)
return Q(UINT64_MAX >> (64 - bits));
}
-int ff_sws_decode_pixfmt(SwsOpList *ops, const SwsFormat *fmt)
+/* Decode raw pixel values (read, swap, unpack, swizzle, shift, clear) */
+static int decode_pixfmt(SwsOpList *ops, const SwsFormat *fmt)
{
const AVPixFmtDescriptor *desc = fmt_desc_decoded(fmt->format);
SwsPixelType pixel_type, raw_type;
@@ -1173,7 +1174,8 @@ int ff_sws_decode_pixfmt(SwsOpList *ops, const SwsFormat *fmt)
return 0;
}
-int ff_sws_encode_pixfmt(SwsOpList *ops, const SwsFormat *fmt)
+/* Encode raw pixel values (shift, swizzle, pack, swap, write) */
+static int encode_pixfmt(SwsOpList *ops, const SwsFormat *fmt)
{
const AVPixFmtDescriptor *desc = fmt_desc_decoded(fmt->format);
SwsPixelType pixel_type, raw_type;
@@ -1497,8 +1499,9 @@ linear_mat3(const AVRational m00, const AVRational m01, const AVRational m02,
}};
}
-int ff_sws_decode_colors(SwsContext *ctx, SwsPixelType type,
- SwsOpList *ops, const SwsFormat *fmt, bool *incomplete)
+/* Transform decoded pixel values to normalized RGB */
+static int decode_colors(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
+ const SwsFormat *fmt, bool *incomplete)
{
const AVLumaCoefficients *c = av_csp_luma_coeffs_from_avcsp(fmt->csp);
const SwsPixelType pixel_type = fmt_pixel_type(fmt->format);
@@ -1589,9 +1592,10 @@ int ff_sws_decode_colors(SwsContext *ctx, SwsPixelType type,
return AVERROR(EINVAL);
}
-int ff_sws_encode_colors(SwsContext *ctx, SwsPixelType type,
- SwsOpList *ops, const SwsFormat *src,
- const SwsFormat *dst, bool *incomplete)
+/* Transform decoded pixel values from normalized RGB */
+static int encode_colors(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
+ const SwsFormat *src, const SwsFormat *dst,
+ bool *incomplete)
{
const AVLumaCoefficients *c = av_csp_luma_coeffs_from_avcsp(dst->csp);
const SwsPixelType pixel_type = fmt_pixel_type(dst->format);
@@ -1761,7 +1765,7 @@ static int add_filter(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
});
}
-int ff_sws_add_filters(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
+static int add_filters(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
const SwsFormat *src, const SwsFormat *dst)
{
/**
@@ -1776,7 +1780,8 @@ int ff_sws_add_filters(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
return add_filter(ctx, type, ops, SWS_OP_FILTER_V, src->height, dst->height);
}
-int ff_sws_apply_lut3d(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
+/* The input and output domain are assumed to be normalized [0, 1] RGBA */
+static int apply_lut3d(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
const SwsLut3D *lut3d)
{
/* Unnormalize to LUT input domain and clamp */
@@ -1833,13 +1838,13 @@ static int fmt_convert(SwsContext *ctx, const SwsFormat *src, const SwsFormat *d
const SwsLut3D *lut3d, SwsOpList *ops, bool *incomplete)
{
const SwsPixelType type = SWS_PIXEL_F32;
- RET(ff_sws_decode_pixfmt(ops, src));
- RET(ff_sws_decode_colors(ctx, type, ops, src, incomplete));
- RET(ff_sws_add_filters(ctx, type, ops, src, dst));
+ RET(decode_pixfmt(ops, src));
+ RET(decode_colors(ctx, type, ops, src, incomplete));
+ RET(add_filters(ctx, type, ops, src, dst));
if (lut3d)
- RET(ff_sws_apply_lut3d(ctx, type, ops, lut3d));
- RET(ff_sws_encode_colors(ctx, type, ops, src, dst, incomplete));
- RET(ff_sws_encode_pixfmt(ops, dst));
+ RET(apply_lut3d(ctx, type, ops, lut3d));
+ RET(encode_colors(ctx, type, ops, src, dst, incomplete));
+ RET(encode_pixfmt(ops, dst));
return 0;
}
diff --git a/libswscale/format.h b/libswscale/format.h
index 49f4342dc3..8174cd1891 100644
--- a/libswscale/format.h
+++ b/libswscale/format.h
@@ -175,47 +175,7 @@ void ff_sws_chroma_pos(const SwsFormat *fmt, bool *incomplete,
int *out_xpos, int *out_ypos);
typedef struct SwsOpList SwsOpList;
-typedef enum SwsPixelType SwsPixelType;
-
-/**
- * Append a set of operations for decoding/encoding raw pixels. This will
- * handle input read/write, swizzling, shifting and byte swapping.
- *
- * Returns 0 on success, or a negative error code on failure.
- */
-int ff_sws_decode_pixfmt(SwsOpList *ops, const SwsFormat *fmt);
-int ff_sws_encode_pixfmt(SwsOpList *ops, const SwsFormat *fmt);
-
-/**
- * Append a set of operations for transforming decoded pixel values to/from
- * normalized RGB in the specified gamut and pixel type.
- *
- * Returns 0 on success, or a negative error code on failure.
- */
-int ff_sws_decode_colors(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
- const SwsFormat *fmt, bool *incomplete);
-int ff_sws_encode_colors(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
- const SwsFormat *src, const SwsFormat *dst,
- bool *incomplete);
-
-/**
- * Append a set of operations for scaling pixels to a different resolution.
- *
- * Returns 0 on success, or a negative error code on failure.
- */
-int ff_sws_add_filters(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
- const SwsFormat *src, const SwsFormat *dst);
-
-/**
- * Append a set of operations for applying a gamut/tone mapping 3D LUT to
- * the pixels. The input and output domain are assumed to be normalized
- * floating point RGBA in the range [0, 1].
- *
- * Returns 0 on success, or a negative error code on failure.
- */
typedef struct SwsLut3D SwsLut3D;
-int ff_sws_apply_lut3d(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
- const SwsLut3D *lut3d);
/**
* Generate an SwsOpList defining a conversion from `src` to `dst`, with an