diff options
author | wm4 <wm4@nowhere> | 2013-08-25 18:24:53 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-08-26 10:09:44 +0200 |
commit | ddc973344685b8fee1d7b00e23ba93692d56d7c9 (patch) | |
tree | 44bee04409f94675f2455285555ad1a848899d3c | |
parent | 53b5227270ff21c0f4c8aeb8c33a9f4dcbe20600 (diff) | |
download | mpv-ddc973344685b8fee1d7b00e23ba93692d56d7c9.tar.bz2 mpv-ddc973344685b8fee1d7b00e23ba93692d56d7c9.tar.xz |
audio: don't allow setting unknown formats from command line
af_str2fmt_short(), which is used by the command line option parser,
allowed passing a hex number. The user could set arbitrary integers as
internal audio formats, even formats which don't exist or make no sense.
This is not very useful, so get rid of it.
-rw-r--r-- | audio/format.c | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/audio/format.c b/audio/format.c index d98de9e5fd..aa6099022f 100644 --- a/audio/format.c +++ b/audio/format.c @@ -47,11 +47,7 @@ int af_fmt2bits(int format) char* af_fmt2str(int format, char* str, int size) { const char *name = af_fmt2str_short(format); - if (name) { - snprintf(str, size, "%s", name); - } else { - snprintf(str, size, "%#x", format); - } + snprintf(str, size, "%s", name); return str; } @@ -105,11 +101,6 @@ const char *af_fmt2str_short(int format) return "??"; } -static bool af_fmt_valid(int format) -{ - return (format & AF_FORMAT_MASK) == format; -} - int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate) { int bps = (af_fmt2bits(format) / 8); @@ -122,13 +113,6 @@ int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int sampler int af_str2fmt_short(bstr str) { - if (bstr_startswith0(str, "0x")) { - bstr rest; - int fmt = bstrtoll(str, &rest, 16); - if (rest.len == 0 && af_fmt_valid(fmt)) - return fmt; - } - for (int i = 0; af_fmtstr_table[i].name; i++) if (!bstrcasecmp0(str, af_fmtstr_table[i].name)) return af_fmtstr_table[i].format; |