diff options
author | wm4 <wm4@nowhere> | 2019-10-21 01:29:48 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-10-21 01:38:25 +0200 |
commit | 5dba244c226383f9f3b15b07dfa5133ad08b6497 (patch) | |
tree | 3b6e46e9ef3350670f32a56140322980e3b37954 /filters/f_swscale.c | |
parent | 8a4e9d5c180157684546db4c1235d8c958172ca9 (diff) | |
download | mpv-5dba244c226383f9f3b15b07dfa5133ad08b6497.tar.bz2 mpv-5dba244c226383f9f3b15b07dfa5133ad08b6497.tar.xz |
filters: extend vf_format so that it can convert color parameters
Form some reason (and because of my fault), vf_format converts image
formats, but nothing else. For example, setting the "colormatrix"
sub-parameter would not convert it to the new value, but instead
overwrite the metadata (basically "reinterpreting" the image data
without changing it).
Make the historical mistake worse, and go all the way and extend it such
that it can perform a conversion. For compatibility reasons, this needs
to be requested explicitly. (Maybe this would deserve a separate filter
to begin with, but things are messed up anyway. Feel free to suggest an
elegant and simple solution.)
This demonstrates how zimg can properly perform some conversions which
swscale cannot (see examples added to vf.rst).
Stupidly this requires 2 code paths, one for conversion, and one for
overriding the parameters.
Due to the filter bullshit (what was I thinking), this requires quite
some acrobatics that would not be necessary without these abstractions.
On the other hand, it'd definitely be more of a mess without it. Oh
whatever.
Diffstat (limited to 'filters/f_swscale.c')
-rw-r--r-- | filters/f_swscale.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/filters/f_swscale.c b/filters/f_swscale.c index 07198b1377..1ff25ab909 100644 --- a/filters/f_swscale.c +++ b/filters/f_swscale.c @@ -88,9 +88,18 @@ static void process(struct mp_filter *f) } struct mp_image *src = frame.data; + int dstfmt = s->out_format ? s->out_format : src->imgfmt; + int w = src->w; + int h = src->h; + + if (s->use_out_params) { + w = s->out_params.w; + h = s->out_params.h; + dstfmt = s->out_params.imgfmt; + } - struct mp_image *dst = mp_image_pool_get(s->pool, dstfmt, src->w, src->h); + struct mp_image *dst = mp_image_pool_get(s->pool, dstfmt, w, h); if (!dst) goto error; @@ -102,6 +111,8 @@ static void process(struct mp_filter *f) { dst->params.color.levels = MP_CSP_LEVELS_TV; } + if (s->use_out_params) + dst->params = s->out_params; mp_image_params_guess_csp(&dst->params); bool ok = mp_sws_scale(s->sws, dst, src) >= 0; |