summaryrefslogtreecommitdiffstats
path: root/libaf
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-09-02 20:13:12 +0200
committerwm4 <wm4@nowhere>2012-09-18 21:07:29 +0200
commit1ba5a8f283e3894158f12f025035903e13d0f8ae (patch)
tree7ff315850990353487a332cfc9f2917f6d43ed14 /libaf
parent1f5635d02cf1ad89025e5409fc05b718cbb04935 (diff)
downloadmpv-1ba5a8f283e3894158f12f025035903e13d0f8ae.tar.bz2
mpv-1ba5a8f283e3894158f12f025035903e13d0f8ae.tar.xz
rawaudio: use mplayer audio format for format option
The rawaudio demuxer had a rather hard to use way to set the audio format with the --rawaudio=format=value option. The user had to pass a numeric value, which then was set as wFormatTag member in the WAVEFORMATEX header. Make it use the mplayer audio format (the same as --af=format=value). Add a new internal pseudo audio codec tag, which is hopefully unused, which makes ad_pcm use the value in wFormatTag as internal mplayer audio format. Playing non-PCM formats is disabled. (At least AC3 can be played directly.)
Diffstat (limited to 'libaf')
-rw-r--r--libaf/format.c7
-rw-r--r--libaf/format.h2
2 files changed, 8 insertions, 1 deletions
diff --git a/libaf/format.c b/libaf/format.c
index ffdf435e71..88d66522a0 100644
--- a/libaf/format.c
+++ b/libaf/format.c
@@ -112,12 +112,17 @@ const char *af_fmt2str_short(int format)
return "??";
}
+static bool af_fmt_valid(int format)
+{
+ return (format & AF_FORMAT_MASK) == format;
+}
+
int af_str2fmt_short(bstr str)
{
if (bstr_startswith0(str, "0x")) {
bstr rest;
int fmt = bstrtoll(str, &rest, 16);
- if (rest.len == 0)
+ if (rest.len == 0 && af_fmt_valid(fmt))
return fmt;
}
diff --git a/libaf/format.h b/libaf/format.h
index 36f5c3fb59..e60c0789b9 100644
--- a/libaf/format.h
+++ b/libaf/format.h
@@ -66,6 +66,8 @@
#define AF_FORMAT_IEC61937 (6<<6)
#define AF_FORMAT_SPECIAL_MASK (7<<6)
+#define AF_FORMAT_MASK ((1<<9)-1)
+
// PREDEFINED formats
#define AF_FORMAT_U8 (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_8BIT|AF_FORMAT_NE)