summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-03 23:25:49 +0100
committerwm4 <wm4@nowhere>2013-12-04 00:07:39 +0100
commit3201a40234e89590d1b8a7f65dcd08a71691e644 (patch)
tree9a9c71a1606e7207070fc412e8a7a4aada4e7be5 /video
parent43a6dd1ed5b35e3464adb994ab4cb900563d3da3 (diff)
downloadmpv-3201a40234e89590d1b8a7f65dcd08a71691e644.tar.bz2
mpv-3201a40234e89590d1b8a7f65dcd08a71691e644.tar.xz
vf_dsize: use option parser
Mostly backwards compatible, we don't change much because we just want to get rid of the legacy option string handling. You can't pass an aspect as first argument anymore.
Diffstat (limited to 'video')
-rw-r--r--video/filter/vf_dsize.c50
1 files changed, 19 insertions, 31 deletions
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}
+ },
};