From 7c45be712f93dc965fd6c8393aa476d42cbbd64d Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 29 Aug 2012 00:34:21 +0200 Subject: options, libaf: unify audio format name handling Remove the duplicated list of audio format names from m_option.c. Remove "long" audio format names, and let af_fmt2str() print the usual short format names. The long names were overly verbose, and were actually rarely user visible. The only difference between af_fmt2str() and af_fmt2str_short() is that the former prints unknown format values as hexadecimal string as fallback. --- m_option.c | 68 ++++++++------------------------------------------------------ 1 file changed, 8 insertions(+), 60 deletions(-) (limited to 'm_option.c') diff --git a/m_option.c b/m_option.c index 941ae28f89..e4c7759f50 100644 --- a/m_option.c +++ b/m_option.c @@ -953,78 +953,26 @@ const m_option_type_t m_option_type_imgfmt = { #include "libaf/af_format.h" -/* FIXME: snyc with af_format.h */ -static struct { - const char *name; - unsigned int fmt; -} mp_afmt_list[] = { - // SPECIAL - {"mulaw", AF_FORMAT_MU_LAW}, - {"alaw", AF_FORMAT_A_LAW}, - {"mpeg2", AF_FORMAT_MPEG2}, - {"ac3le", AF_FORMAT_AC3_LE}, - {"ac3be", AF_FORMAT_AC3_BE}, - {"ac3ne", AF_FORMAT_AC3_NE}, - {"imaadpcm", AF_FORMAT_IMA_ADPCM}, - // ORDINARY - {"u8", AF_FORMAT_U8}, - {"s8", AF_FORMAT_S8}, - {"u16le", AF_FORMAT_U16_LE}, - {"u16be", AF_FORMAT_U16_BE}, - {"u16ne", AF_FORMAT_U16_NE}, - {"s16le", AF_FORMAT_S16_LE}, - {"s16be", AF_FORMAT_S16_BE}, - {"s16ne", AF_FORMAT_S16_NE}, - {"u24le", AF_FORMAT_U24_LE}, - {"u24be", AF_FORMAT_U24_BE}, - {"u24ne", AF_FORMAT_U24_NE}, - {"s24le", AF_FORMAT_S24_LE}, - {"s24be", AF_FORMAT_S24_BE}, - {"s24ne", AF_FORMAT_S24_NE}, - {"u32le", AF_FORMAT_U32_LE}, - {"u32be", AF_FORMAT_U32_BE}, - {"u32ne", AF_FORMAT_U32_NE}, - {"s32le", AF_FORMAT_S32_LE}, - {"s32be", AF_FORMAT_S32_BE}, - {"s32ne", AF_FORMAT_S32_NE}, - {"floatle", AF_FORMAT_FLOAT_LE}, - {"floatbe", AF_FORMAT_FLOAT_BE}, - {"floatne", AF_FORMAT_FLOAT_NE}, - { NULL, 0 } -}; - static int parse_afmt(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_afmt_list[i].name; i++) - mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %s", mp_afmt_list[i].name); + for (int i = 0; af_fmtstr_table[i].name; i++) + mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %s", af_fmtstr_table[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_afmt_list[i].name; i++) { - if (!bstrcasecmp0(param, mp_afmt_list[i].name)) { - fmt = mp_afmt_list[i].fmt; - break; - } - } - if (!mp_afmt_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; - } + int fmt = af_str2fmt_short(param); + if (fmt == -1) { + 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