From ea1200111d984e697b5b9d789d23db3f8f73e209 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 13 Sep 2013 19:07:30 +0200 Subject: core: restore user-set video and audio filters with resume functionality This requires adding a function that converts the filter list back to a string. --- mpvcore/m_option.c | 37 +++++++++++++++++++++++++++++++++++++ mpvcore/mplayer.c | 2 ++ 2 files changed, 39 insertions(+) diff --git a/mpvcore/m_option.c b/mpvcore/m_option.c index f538816ea7..8b33d56dc5 100644 --- a/mpvcore/m_option.c +++ b/mpvcore/m_option.c @@ -2403,11 +2403,48 @@ static int parse_obj_settings_list(const m_option_t *opt, struct bstr name, return 1; } +static void append_param(char **res, char *param) +{ + if (strspn(param, NAMECH) == strlen(param)) { + *res = talloc_strdup_append(*res, param); + } else { + // Simple escaping: %BYTECOUNT%STRING + *res = talloc_asprintf_append(*res, "%%%d%%%s", strlen(param), param); + } +} + +static char *print_obj_settings_list(const m_option_t *opt, const void *val) +{ + m_obj_settings_t *list = VAL(val); + char *res = talloc_strdup(NULL, ""); + for (int n = 0; list && list[n].name; n++) { + m_obj_settings_t *entry = &list[n]; + if (n > 0) + res = talloc_strdup_append(res, ","); + // Assume labels and names don't need escaping + if (entry->label && entry->label[0]) + res = talloc_asprintf_append(res, "@%s:", entry->label); + res = talloc_strdup_append(res, entry->name); + if (entry->attribs && entry->attribs[0]) { + res = talloc_strdup_append(res, "="); + for (int i = 0; entry->attribs[i * 2 + 0]; i++) { + if (i > 0) + res = talloc_strdup_append(res, ":"); + append_param(&res, entry->attribs[i * 2 + 0]); + res = talloc_strdup_append(res, "="); + append_param(&res, entry->attribs[i * 2 + 1]); + } + } + } + return res; +} + const m_option_type_t m_option_type_obj_settings_list = { .name = "Object settings list", .size = sizeof(m_obj_settings_t *), .flags = M_OPT_TYPE_DYNAMIC | M_OPT_TYPE_ALLOW_WILDCARD, .parse = parse_obj_settings_list, + .print = print_obj_settings_list, .copy = copy_obj_settings_list, .free = free_obj_settings_list, }; diff --git a/mpvcore/mplayer.c b/mpvcore/mplayer.c index d20f321042..542098b5e3 100644 --- a/mpvcore/mplayer.c +++ b/mpvcore/mplayer.c @@ -841,6 +841,8 @@ static const char *backup_properties[] = { "saturation", "hue", "deinterlace", + "vf", + "af", "panscan", "aid", "vid", -- cgit v1.2.3