summaryrefslogtreecommitdiffstats
path: root/m_option.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-29 00:34:21 +0200
committerwm4 <wm4@nowhere>2012-08-29 00:36:44 +0200
commit7c45be712f93dc965fd6c8393aa476d42cbbd64d (patch)
tree22815d9db15b2bdeae78607fbeeaff90eff97424 /m_option.c
parent7bb95cd8a5130a971d3d07eb79ba08fc91e4b7cb (diff)
downloadmpv-7c45be712f93dc965fd6c8393aa476d42cbbd64d.tar.bz2
mpv-7c45be712f93dc965fd6c8393aa476d42cbbd64d.tar.xz
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.
Diffstat (limited to 'm_option.c')
-rw-r--r--m_option.c68
1 files changed, 8 insertions, 60 deletions
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)