summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/vf.rst5
-rw-r--r--video/filter/vf_dsize.c50
2 files changed, 23 insertions, 32 deletions
diff --git a/DOCS/man/en/vf.rst b/DOCS/man/en/vf.rst
index 7c5b524875..8f5ebc3885 100644
--- a/DOCS/man/en/vf.rst
+++ b/DOCS/man/en/vf.rst
@@ -156,7 +156,7 @@ Available filters are:
:0: Disable accurate rounding (default).
:1: Enable accurate rounding.
-``dsize[=aspect|w:h:aspect-method:r]``
+``dsize[=w:h:aspect-method:r:aspect]``
Changes the intended display size/aspect at an arbitrary point in the
filter chain. Aspect can be given as a fraction (4/3) or floating point
number (1.33). Alternatively, you may specify the exact display width and
@@ -205,6 +205,9 @@ Available filters are:
Rounds up to make both width and height divisible by ``<r>``
(default: 1).
+ ``<aspect>``
+ Force an aspect ratio.
+
``format[=fmt[:outfmt]]``
Restricts the color space for the next filter without doing any conversion.
Use together with the scale filter for a real conversion.
diff --git a/video/filter/vf_dsize.c b/video/filter/vf_dsize.c
index 31b1dde568..be8b73133d 100644
--- a/video/filter/vf_dsize.c
+++ b/video/filter/vf_dsize.c
@@ -20,9 +20,11 @@
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
+#include <limits.h>
#include "config.h"
#include "mpvcore/mp_msg.h"
+#include "mpvcore/m_option.h"
#include "video/img_format.h"
#include "video/mp_image.h"
@@ -76,45 +78,31 @@ static int config(struct vf_instance *vf,
return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt);
}
-static void uninit(vf_instance_t *vf) {
- free(vf->priv);
- vf->priv = NULL;
-}
-
static int vf_open(vf_instance_t *vf, char *args)
{
vf->config = config;
- vf->uninit = uninit;
- vf->priv = calloc(sizeof(struct vf_priv_s), 1);
- vf->priv->aspect = 0.;
- vf->priv->w = -1;
- vf->priv->h = -1;
- vf->priv->method = -1;
- vf->priv->round = 1;
- if (args) {
- if (strchr(args, '/')) {
- int w, h;
- sscanf(args, "%d/%d", &w, &h);
- vf->priv->aspect = (float)w/h;
- } else if (strchr(args, '.')) {
- sscanf(args, "%f", &vf->priv->aspect);
- } else {
- sscanf(args, "%d:%d:%d:%d", &vf->priv->w, &vf->priv->h, &vf->priv->method, &vf->priv->round);
- }
- }
- if ((vf->priv->aspect < 0.) || (vf->priv->w < -3) || (vf->priv->h < -3) ||
- ((vf->priv->w < -1) && (vf->priv->h < -1)) ||
- (vf->priv->method < -1) || (vf->priv->method > 3) ||
- (vf->priv->round < 0)) {
- mp_msg(MSGT_VFILTER, MSGL_ERR, "[dsize] Illegal value(s): aspect: %f w: %d h: %d aspect_method: %d round: %d\n", vf->priv->aspect, vf->priv->w, vf->priv->h, vf->priv->method, vf->priv->round);
- free(vf->priv); vf->priv = NULL;
- return -1;
- }
return 1;
}
+#define OPT_BASE_STRUCT struct vf_priv_s
const vf_info_t vf_info_dsize = {
.description = "reset displaysize/aspect",
.name = "dsize",
.open = vf_open,
+ .priv_size = sizeof(struct vf_priv_s),
+ .priv_defaults = &(const struct vf_priv_s){
+ .aspect = 0.0,
+ .w = -1,
+ .h = -1,
+ .method = -1,
+ .round = 1,
+ },
+ .options = (const struct m_option[]){
+ OPT_INTRANGE("w", w, 0, -3, INT_MAX),
+ OPT_INTRANGE("h", w, 0, -3, INT_MAX),
+ OPT_INTRANGE("method", method, 0, -1, 3),
+ OPT_INTRANGE("round", round, 0, 0, 9999),
+ OPT_FLOAT("aspect", aspect, CONF_RANGE, .min = 0, .max = 10),
+ {0}
+ },
};