History

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.

James Almer committed 1 year ago

Commit e20ee9f1 parent abdc2072 files · +12 −6Browse files

Unified · Split

2 files
  1. libswscale/swscale.c +1 −1
  2. libswscale/utils.h +11 −5
libswscale/swscale.c+1−1
@@ -1452,7 +1452,7 @@ int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, const AVFrame *src) · 1451 unmodified lines
14521452
14531453 src_ok = ff_test_fmt(&src_fmt, 0);
14541454 dst_ok = ff_test_fmt(&dst_fmt, 1);
1455− if ((!src_ok || !dst_ok)) {
1455+ if ((!src_ok || !dst_ok) && !ff_props_equal(&src_fmt, &dst_fmt)) {
14561456 err_msg = src_ok ? "Unsupported output" : "Unsupported input";
14571457 ret = AVERROR(ENOTSUP);
14581458 goto fail;
libswscale/utils.h+11−5
@@ -98,12 +98,10 @@ static inline int ff_color_equal(const SwsColor *c1, const SwsColor *c2) · 97 unmodified lines
9898 ff_prim_equal(&c1->gamut, &c2->gamut);
9999 }
100100
101−/* Tests only the static components of a colorspace, ignoring per-frame data */
102−static inline int ff_fmt_equal(const SwsFormat *fmt1, const SwsFormat *fmt2)
101+/* Tests only the static components of a colorspace, ignoring dimensions and per-frame data */
102+static inline int ff_props_equal(const SwsFormat *fmt1, const SwsFormat *fmt2)
103103 {
104− return fmt1->width == fmt2->width &&
105− fmt1->height == fmt2->height &&
106− fmt1->interlaced == fmt2->interlaced &&
104+ return fmt1->interlaced == fmt2->interlaced &&
107105 fmt1->format == fmt2->format &&
108106 fmt1->range == fmt2->range &&
109107 fmt1->csp == fmt2->csp &&
@@ -111,6 +109,14 @@ static inline int ff_fmt_equal(const SwsFormat *fmt1, const SwsFormat *fmt2) · 1 unmodified line
111109 ff_color_equal(&fmt1->color, &fmt2->color);
112110 }
113111
112+/* Tests only the static components of a colorspace, ignoring per-frame data */
113+static inline int ff_fmt_equal(const SwsFormat *fmt1, const SwsFormat *fmt2)
114+{
115+ return fmt1->width == fmt2->width &&
116+ fmt1->height == fmt2->height &&
117+ ff_props_equal(fmt1, fmt2);
118+}
119+
114120 static inline int ff_fmt_align(enum AVPixelFormat fmt)
115121 {
116122 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t