From 7bb95cd8a5130a971d3d07eb79ba08fc91e4b7cb Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 28 Aug 2012 23:58:48 +0200 Subject: options, codecs.conf, img_format: unify imgfmt name handling Remove the duplication of image format name lists from codec-cfg.c and img_format.c. Remove the list of "long" image format names from img_format.c. One user visible change is that now mplayer won't print "long" format names anymore: e.g. instead of "Planar 420P 10-bit little-endian", the name "420p10le" is used. This is consistent with the names used by the option parser, and also less noisy. Partially based on mplayer2 commit f98e47574de15, with some differences. --- m_option.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'm_option.c') diff --git a/m_option.c b/m_option.c index a0a96a198c..941ae28f89 100644 --- a/m_option.c +++ b/m_option.c @@ -918,35 +918,23 @@ const m_option_type_t m_option_type_subconfig_struct = { static int parse_imgfmt(const m_option_t *opt, struct bstr name, struct bstr param, void *dst) { - uint32_t fmt = 0; - int i; - if (param.len == 0) return M_OPT_MISSING_PARAM; if (!bstrcmp0(param, "help")) { mp_msg(MSGT_CFGPARSER, MSGL_INFO, "Available formats:"); - for (i = 0; mp_imgfmt_list[i].name; i++) + for (int i = 0; mp_imgfmt_list[i].name; i++) mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %s", mp_imgfmt_list[i].name); mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n"); return M_OPT_EXIT - 1; } - if (bstr_startswith0(param, "0x")) - fmt = bstrtoll(param, NULL, 16); - else { - for (i = 0; mp_imgfmt_list[i].name; i++) { - if (!bstrcasecmp0(param, mp_imgfmt_list[i].name)) { - fmt = mp_imgfmt_list[i].fmt; - break; - } - } - if (!mp_imgfmt_list[i].name) { - mp_msg(MSGT_CFGPARSER, MSGL_ERR, - "Option %.*s: unknown format name: '%.*s'\n", - BSTR_P(name), BSTR_P(param)); - return M_OPT_INVALID; - } + unsigned int fmt = mp_imgfmt_from_name(param, false); + if (!fmt) { + mp_msg(MSGT_CFGPARSER, MSGL_ERR, + "Option %.*s: unknown format name: '%.*s'\n", + BSTR_P(name), BSTR_P(param)); + return M_OPT_INVALID; } if (dst) -- cgit v1.2.3