summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-25 18:23:40 +0200
committerwm4 <wm4@nowhere>2013-08-26 10:09:41 +0200
commit53b5227270ff21c0f4c8aeb8c33a9f4dcbe20600 (patch)
tree6a34e81c038c740e7dfcf11aadcc49b87d125ca5
parent58e826e6f27a17ca1a2325e9987d234cf7408fdd (diff)
downloadmpv-53b5227270ff21c0f4c8aeb8c33a9f4dcbe20600.tar.bz2
mpv-53b5227270ff21c0f4c8aeb8c33a9f4dcbe20600.tar.xz
audio: make internal audio format 0 an invalid format
Having to use -1 for that is generally quite annoying. Audio formats are created from bitmasks, and it can't be excluded that 0 is not a valid format. Fix this by adjusting AF_FORMAT_I so that it is never 0. Along with AF_FORMAT_F and the special formats, all valid formats are covered and guaranteed to be non-0. It's possible that this commit will cause some regressions, as the check for invalid audio formats changes a bit.
-rw-r--r--audio/filter/af_format.c2
-rw-r--r--audio/format.c2
-rw-r--r--audio/format.h14
-rw-r--r--mpvcore/m_option.c2
-rw-r--r--mpvcore/options.c2
5 files changed, 11 insertions, 11 deletions
diff --git a/audio/filter/af_format.c b/audio/filter/af_format.c
index 616bc9e494..6166ee3ff0 100644
--- a/audio/filter/af_format.c
+++ b/audio/filter/af_format.c
@@ -150,7 +150,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
}
case AF_CONTROL_COMMAND_LINE:{
int format = af_str2fmt_short(bstr0(arg));
- if (format == -1) {
+ if (!format) {
mp_msg(MSGT_AFILTER, MSGL_ERR, "[format] %s is not a valid format\n", (char *)arg);
return AF_ERROR;
}
diff --git a/audio/format.c b/audio/format.c
index a65c10472d..d98de9e5fd 100644
--- a/audio/format.c
+++ b/audio/format.c
@@ -133,5 +133,5 @@ int af_str2fmt_short(bstr str)
if (!bstrcasecmp0(str, af_fmtstr_table[i].name))
return af_fmtstr_table[i].format;
- return -1;
+ return 0;
}
diff --git a/audio/format.h b/audio/format.h
index 01478afc52..e4173550c6 100644
--- a/audio/format.h
+++ b/audio/format.h
@@ -43,11 +43,6 @@
#define AF_FORMAT_US (1<<1) // Unsigned
#define AF_FORMAT_SIGN_MASK (1<<1)
-// Fixed or floating point
-#define AF_FORMAT_I (0<<2) // Int
-#define AF_FORMAT_F (1<<2) // Foating point
-#define AF_FORMAT_POINT_MASK (1<<2)
-
// Bits used
#define AF_FORMAT_8BIT (0<<3)
#define AF_FORMAT_16BIT (1<<3)
@@ -62,7 +57,12 @@
#define AF_FORMAT_IEC61937 (6<<6)
#define AF_FORMAT_SPECIAL_MASK (7<<6)
-#define AF_FORMAT_MASK ((1<<9)-1)
+// Fixed or floating point
+#define AF_FORMAT_I (1<<9) // Int
+#define AF_FORMAT_F (2<<9) // Foating point
+#define AF_FORMAT_POINT_MASK (3<<9)
+
+#define AF_FORMAT_MASK ((1<<11)-1)
// PREDEFINED formats
@@ -117,7 +117,7 @@
#define AF_FORMAT_IEC61937_NE AF_FORMAT_IEC61937_LE
#endif
-#define AF_FORMAT_UNKNOWN (-1)
+#define AF_FORMAT_UNKNOWN 0
#define AF_FORMAT_IS_AC3(fmt) (((fmt) & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_AC3)
#define AF_FORMAT_IS_IEC61937(fmt) (AF_FORMAT_IS_AC3(fmt) || ((fmt) & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_IEC61937)
diff --git a/mpvcore/m_option.c b/mpvcore/m_option.c
index b51aa64bd5..f538816ea7 100644
--- a/mpvcore/m_option.c
+++ b/mpvcore/m_option.c
@@ -1601,7 +1601,7 @@ static int parse_afmt(const m_option_t *opt, struct bstr name,
}
int fmt = af_str2fmt_short(param);
- if (fmt == -1) {
+ if (!fmt) {
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
"Option %.*s: unknown format name: '%.*s'\n",
BSTR_P(name), BSTR_P(param));
diff --git a/mpvcore/options.c b/mpvcore/options.c
index eeda836914..733b104a46 100644
--- a/mpvcore/options.c
+++ b/mpvcore/options.c
@@ -802,7 +802,7 @@ const struct MPOpts mp_default_opts = {
.sub_pos = 100,
.sub_speed = 1.0,
.audio_output_channels = MP_CHMAP_INIT_STEREO,
- .audio_output_format = -1, // AF_FORMAT_UNKNOWN
+ .audio_output_format = 0, // AF_FORMAT_UNKNOWN
.playback_speed = 1.,
.movie_aspect = -1.,
.field_dominance = -1,