diff options
author | James Almer <jamrial@gmail.com> | 2025-01-22 12:12:48 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2025-01-22 12:15:18 -0300 |
commit | e20ee9f9aec94f8cea1bf4fd8ed3fb096fb205e5 (patch) | |
tree | 3d6152230af2d66403adcb175d02b91347b0b81e | |
parent | abdc20727c22433e9a3368359dccc61da835c66a (diff) | |
download | ffmpeg-e20ee9f9aec94f8cea1bf4fd8ed3fb096fb205e5.tar.gz |
swscale/swscale: don't reject scaling when color parameters are not supported but conversion is not required
Values in csp, prim, trc, etc, are irrelevant if there's no conversion needed.
Reviewed-by: Niklas Haas <ffmpeg@haasn.xyz>
Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r-- | libswscale/swscale.c | 2 | ||||
-rw-r--r-- | libswscale/utils.h | 16 |
2 files changed, 12 insertions, 6 deletions
diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 84657bb17c..98f94d029f 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1452,7 +1452,7 @@ int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, const AVFrame *src) src_ok = ff_test_fmt(&src_fmt, 0); dst_ok = ff_test_fmt(&dst_fmt, 1); - if ((!src_ok || !dst_ok)) { + if ((!src_ok || !dst_ok) && !ff_props_equal(&src_fmt, &dst_fmt)) { err_msg = src_ok ? "Unsupported output" : "Unsupported input"; ret = AVERROR(ENOTSUP); goto fail; diff --git a/libswscale/utils.h b/libswscale/utils.h index d76fea1133..8e0cdf26ec 100644 --- a/libswscale/utils.h +++ b/libswscale/utils.h @@ -98,12 +98,10 @@ static inline int ff_color_equal(const SwsColor *c1, const SwsColor *c2) ff_prim_equal(&c1->gamut, &c2->gamut); } -/* Tests only the static components of a colorspace, ignoring per-frame data */ -static inline int ff_fmt_equal(const SwsFormat *fmt1, const SwsFormat *fmt2) +/* Tests only the static components of a colorspace, ignoring dimensions and per-frame data */ +static inline int ff_props_equal(const SwsFormat *fmt1, const SwsFormat *fmt2) { - return fmt1->width == fmt2->width && - fmt1->height == fmt2->height && - fmt1->interlaced == fmt2->interlaced && + return fmt1->interlaced == fmt2->interlaced && fmt1->format == fmt2->format && fmt1->range == fmt2->range && fmt1->csp == fmt2->csp && @@ -111,6 +109,14 @@ static inline int ff_fmt_equal(const SwsFormat *fmt1, const SwsFormat *fmt2) ff_color_equal(&fmt1->color, &fmt2->color); } +/* Tests only the static components of a colorspace, ignoring per-frame data */ +static inline int ff_fmt_equal(const SwsFormat *fmt1, const SwsFormat *fmt2) +{ + return fmt1->width == fmt2->width && + fmt1->height == fmt2->height && + ff_props_equal(fmt1, fmt2); +} + static inline int ff_fmt_align(enum AVPixelFormat fmt) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); |