summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/vf.rst2
-rw-r--r--video/filter/vf_phase.c83
2 files changed, 49 insertions, 36 deletions
diff --git a/DOCS/man/en/vf.rst b/DOCS/man/en/vf.rst
index 9ad8dfa07f..82d4b7500b 100644
--- a/DOCS/man/en/vf.rst
+++ b/DOCS/man/en/vf.rst
@@ -680,7 +680,7 @@ Available filters are:
``v``
Verbose operation. Prints the selected mode for each frame and the
average squared difference between fields for ``t``, ``b``, and ``p``
- alternatives.
+ alternatives. (Ignored when libavfilter is used.)
``yadif=[mode[:enabled=yes|no]]``
Yet another deinterlacing filter
diff --git a/video/filter/vf_phase.c b/video/filter/vf_phase.c
index f2a4a3f4be..46b75b28c4 100644
--- a/video/filter/vf_phase.c
+++ b/video/filter/vf_phase.c
@@ -23,6 +23,7 @@
#include "config.h"
#include "mpvcore/mp_msg.h"
+#include "mpvcore/m_option.h"
#include "video/img_format.h"
#include "video/mp_image.h"
@@ -30,6 +31,8 @@
#include "video/memcpy_pic.h"
+#include "vf_lavfi.h"
+
enum mode { PROGRESSIVE, TOP_FIRST, BOTTOM_FIRST,
TOP_FIRST_ANALYZE, BOTTOM_FIRST_ANALYZE,
ANALYZE, FULL_ANALYZE, AUTO, AUTO_ANALYZE };
@@ -38,9 +41,10 @@ enum mode { PROGRESSIVE, TOP_FIRST, BOTTOM_FIRST,
struct vf_priv_s
{
- enum mode mode;
+ int mode;
int verbose;
unsigned char *buf[3];
+ struct vf_lw_opts *lw_opts;
};
/*
@@ -246,51 +250,60 @@ static int query_format(struct vf_instance *vf, unsigned int fmt)
return vf_next_query_format(vf, fmt);
}
+static const char *get_lavfi_mode(int mode)
+{
+ switch (mode) {
+ case PROGRESSIVE: return "p";
+ case TOP_FIRST: return "t";
+ case BOTTOM_FIRST: return "b";
+ case TOP_FIRST_ANALYZE: return "T";
+ case BOTTOM_FIRST_ANALYZE: return "B";
+ case ANALYZE: return "u";
+ case FULL_ANALYZE: return "U";
+ case AUTO: return "a";
+ case AUTO_ANALYZE: return "A";
+ default: return "?";
+ }
+}
+
static int vf_open(vf_instance_t *vf, char *args)
{
vf->filter = filter;
vf->uninit = uninit;
vf->query_format = query_format;
- if(!(vf->priv = calloc(1, sizeof(struct vf_priv_s))))
- {
- uninit(vf);
- return 0;
- }
-
- vf->priv->mode=AUTO_ANALYZE;
- vf->priv->verbose=0;
-
- while(args && *args)
- {
- switch(*args)
- {
- case 't': vf->priv->mode=TOP_FIRST; break;
- case 'a': vf->priv->mode=AUTO; break;
- case 'b': vf->priv->mode=BOTTOM_FIRST; break;
- case 'u': vf->priv->mode=ANALYZE; break;
- case 'T': vf->priv->mode=TOP_FIRST_ANALYZE; break;
- case 'A': vf->priv->mode=AUTO_ANALYZE; break;
- case 'B': vf->priv->mode=BOTTOM_FIRST_ANALYZE; break;
- case 'U': vf->priv->mode=FULL_ANALYZE; break;
- case 'p': vf->priv->mode=PROGRESSIVE; break;
- case 'v': vf->priv->verbose=1; break;
- case ':': break;
-
- default:
- uninit(vf);
- return 0; /* bad args */
- }
-
- if( (args=strchr(args, ':')) ) args++;
- }
+ if (vf_lw_set_graph(vf, vf->priv->lw_opts, "phase", "%s",
+ get_lavfi_mode(vf->priv->mode)) >= 0)
+ {
+ return 1;
+ }
return 1;
}
+#define OPT_BASE_STRUCT struct vf_priv_s
const vf_info_t vf_info_phase =
- {
+{
.description = "phase shift fields",
.name = "phase",
.open = vf_open,
- };
+ .priv_size = sizeof(struct vf_priv_s),
+ .priv_defaults = &(const struct vf_priv_s){
+ .mode = AUTO_ANALYZE,
+ },
+ .options = (const struct m_option[]){
+ OPT_CHOICE("mode", mode, 0,
+ ({"t", TOP_FIRST},
+ {"a", AUTO},
+ {"b", BOTTOM_FIRST},
+ {"u", ANALYZE},
+ {"T", TOP_FIRST_ANALYZE},
+ {"A", AUTO_ANALYZE},
+ {"B", BOTTOM_FIRST_ANALYZE},
+ {"U", FULL_ANALYZE},
+ {"p", PROGRESSIVE})),
+ OPT_FLAG("v", verbose, 0),
+ OPT_SUBSTRUCT("", lw_opts, vf_lw_conf, 0),
+ {0}
+ },
+};