summaryrefslogtreecommitdiffstats
path: root/m_option.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-28 23:58:48 +0200
committerwm4 <wm4@nowhere>2012-08-29 00:14:11 +0200
commit7bb95cd8a5130a971d3d07eb79ba08fc91e4b7cb (patch)
tree69f9a86fb5b4cdedc659af433564e0d120b49bac /m_option.c
parentd5aa8dc88f00ac07f2f35788a230385abd404634 (diff)
downloadmpv-7bb95cd8a5130a971d3d07eb79ba08fc91e4b7cb.tar.bz2
mpv-7bb95cd8a5130a971d3d07eb79ba08fc91e4b7cb.tar.xz
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.
Diffstat (limited to 'm_option.c')
-rw-r--r--m_option.c26
1 files changed, 7 insertions, 19 deletions
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)