summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-09 14:14:14 +0100
committerwm4 <wm4@nowhere>2020-02-09 18:23:22 +0100
commitee4a8f0d577974ddbf1fc2c4a0e0055fab783119 (patch)
treee3203cfc99ab20d8e74ca192465ff8db6fdced85
parenteb1d50ba201d4efc9959d81112191b68c39eb290 (diff)
downloadmpv-ee4a8f0d577974ddbf1fc2c4a0e0055fab783119.tar.bz2
mpv-ee4a8f0d577974ddbf1fc2c4a0e0055fab783119.tar.xz
vf_format: add w, h parameters
Yes, this thing became vf_scale through the back door.
-rw-r--r--DOCS/man/vf.rst4
-rw-r--r--video/filter/vf_format.c14
2 files changed, 15 insertions, 3 deletions
diff --git a/DOCS/man/vf.rst b/DOCS/man/vf.rst
index 463ce07cbc..50609f978a 100644
--- a/DOCS/man/vf.rst
+++ b/DOCS/man/vf.rst
@@ -321,6 +321,10 @@ Available mpv-only filters are:
Set the rotation the video is assumed to be encoded with in degrees.
The special value ``-1`` uses the input format.
+ ``<w>``, ``<h>``
+ If not 0, perform conversion to the given size. Ignored if
+ ``convert=yes`` is not set.
+
``<dw>``, ``<dh>``
Set the display size. Note that setting the display size such that
the video is scaled in both directions instead of just changing the
diff --git a/video/filter/vf_format.c b/video/filter/vf_format.c
index 942fa27a52..6681467fc3 100644
--- a/video/filter/vf_format.c
+++ b/video/filter/vf_format.c
@@ -50,12 +50,14 @@ struct vf_format_opts {
int chroma_location;
int stereo_in;
int rotate;
+ int w, h;
int dw, dh;
double dar;
int convert;
};
-static void set_params(struct vf_format_opts *p, struct mp_image_params *out)
+static void set_params(struct vf_format_opts *p, struct mp_image_params *out,
+ bool set_size)
{
if (p->colormatrix)
out->color.space = p->colormatrix;
@@ -85,6 +87,10 @@ static void set_params(struct vf_format_opts *p, struct mp_image_params *out)
if (p->rotate >= 0)
out->rotate = p->rotate;
+ if (p->w > 0 && set_size)
+ out->w = p->w;
+ if (p->h > 0 && set_size)
+ out->h = p->h;
AVRational dsize;
mp_image_params_get_dsize(out, &dsize.num, &dsize.den);
if (p->dw > 0)
@@ -115,7 +121,7 @@ static void vf_format_process(struct mp_filter *f)
par.color.levels = MP_CSP_LEVELS_TV;
}
- set_params(priv->opts, &par);
+ set_params(priv->opts, &par, true);
if (par.imgfmt != outfmt) {
par.imgfmt = outfmt;
@@ -135,7 +141,7 @@ static void vf_format_process(struct mp_filter *f)
if (!priv->opts->convert && frame.type == MP_FRAME_VIDEO) {
struct mp_image *img = frame.data;
- set_params(priv->opts, &img->params);
+ set_params(priv->opts, &img->params, false);
mp_image_params_guess_csp(&img->params);
}
@@ -187,6 +193,8 @@ static const m_option_t vf_opts_fields[] = {
OPT_CHOICE_C("chroma-location", chroma_location, 0, mp_chroma_names),
OPT_CHOICE_C("stereo-in", stereo_in, 0, mp_stereo3d_names),
OPT_INTRANGE("rotate", rotate, 0, -1, 359),
+ OPT_INT("w", w, 0),
+ OPT_INT("h", h, 0),
OPT_INT("dw", dw, 0),
OPT_INT("dh", dh, 0),
OPT_DOUBLE("dar", dar, 0),