From d68a759fa4dea2701087039c58961757eb246b4f Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 2 Aug 2014 03:12:09 +0200 Subject: Improve setting AVOptions Use OPT_KEYVALUELIST() for all places where AVOptions are directly set from mpv command line options. This allows escaping values, better diagnostics (also no more "pal"), and somehow reduces code size. Remove the old crappy option parser (av_opts.c). --- video/filter/vf_lavfi.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'video/filter/vf_lavfi.c') diff --git a/video/filter/vf_lavfi.c b/video/filter/vf_lavfi.c index c6f0783460..8f1ee243a2 100644 --- a/video/filter/vf_lavfi.c +++ b/video/filter/vf_lavfi.c @@ -37,9 +37,9 @@ #include #include +#include "common/av_common.h" #include "common/msg.h" #include "options/m_option.h" -#include "common/av_opts.h" #include "common/tags.h" #include "video/img_format.h" @@ -78,7 +78,7 @@ struct vf_priv_s { // options char *cfg_graph; int64_t cfg_sws_flags; - char *cfg_avopts; + char **cfg_avopts; }; static const struct vf_priv_s vf_priv_dflt = { @@ -143,11 +143,8 @@ static bool recreate_graph(struct vf_instance *vf, int width, int height, if (!graph) goto error; - if (parse_avopts(graph, p->cfg_avopts) < 0) { - MP_FATAL(vf, "lavfi: could not set opts: '%s'\n", - p->cfg_avopts); + if (mp_set_avopts(vf->log, graph, p->cfg_avopts) < 0) goto error; - } AVFilterInOut *outputs = avfilter_inout_alloc(); AVFilterInOut *inputs = avfilter_inout_alloc(); @@ -426,7 +423,7 @@ static void print_help(struct mp_log *log) static const m_option_t vf_opts_fields[] = { OPT_STRING("graph", cfg_graph, M_OPT_MIN, .min = 1), OPT_INT64("sws-flags", cfg_sws_flags, 0), - OPT_STRING("o", cfg_avopts, 0), + OPT_KEYVALUELIST("o", cfg_avopts, 0), {0} }; @@ -445,7 +442,7 @@ const vf_info_t vf_info_lavfi = { struct vf_lw_opts { int enable; int64_t sws_flags; - char *avopts; + char **avopts; }; #undef OPT_BASE_STRUCT @@ -454,7 +451,7 @@ const struct m_sub_options vf_lw_conf = { .opts = (const m_option_t[]) { OPT_FLAG("lavfi", enable, 0), OPT_INT64("lavfi-sws-flags", sws_flags, 0), - OPT_STRING("lavfi-o", avopts, 0), + OPT_KEYVALUELIST("lavfi-o", avopts, 0), {0} }, .defaults = &(const struct vf_lw_opts){ -- cgit v1.2.3