summaryrefslogtreecommitdiffstats
path: root/audio/format.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-06-16 20:57:43 +0200
committerwm4 <wm4@nowhere>2015-06-16 21:11:59 +0200
commit831d7c3c400b554484561bf912c1f9657f8192cd (patch)
tree7c3abe2dadd826f58ac316f9c35b56d9e869d760 /audio/format.c
parent488ebdb0d57b4e822e8dac4fac18dfe460b61ac6 (diff)
downloadmpv-831d7c3c400b554484561bf912c1f9657f8192cd.tar.bz2
mpv-831d7c3c400b554484561bf912c1f9657f8192cd.tar.xz
audio: remove S8, U16, U24, U32 formats
They are useless. Not only are they actually rarely in use; but libavcodec doesn't even output them, as libavcodec has no such sample formats for decoded audio. Even if it should happen that we actually still need them (e.g. if doing direct hardware output), there are better solutions. Swapping the sign is a fast and lossless operation and can be done inplace, so AO actually needing it could do this directly. If you wonder why we keep U8 instead of S8: because libavcodec does it.
Diffstat (limited to 'audio/format.c')
-rw-r--r--audio/format.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/audio/format.c b/audio/format.c
index 401214281b..98957f9bd4 100644
--- a/audio/format.c
+++ b/audio/format.c
@@ -65,6 +65,12 @@ int af_fmt_change_bits(int format, int bits)
return af_fmt_is_valid(format) ? format : 0;
}
+// All formats are considered signed, except explicitly unsigned int formats.
+bool af_fmt_unsigned(int format)
+{
+ return format == AF_FORMAT_U8 || format == AF_FORMAT_U8P;
+}
+
static const int planar_formats[][2] = {
{AF_FORMAT_U8P, AF_FORMAT_U8},
{AF_FORMAT_S16P, AF_FORMAT_S16},
@@ -101,12 +107,8 @@ int af_fmt_from_planar(int format)
const struct af_fmt_entry af_fmtstr_table[] = {
{"u8", AF_FORMAT_U8},
- {"s8", AF_FORMAT_S8},
- {"u16", AF_FORMAT_U16},
{"s16", AF_FORMAT_S16},
- {"u24", AF_FORMAT_U24},
{"s24", AF_FORMAT_S24},
- {"u32", AF_FORMAT_U32},
{"s32", AF_FORMAT_S32},
{"float", AF_FORMAT_FLOAT},
{"double", AF_FORMAT_DOUBLE},
@@ -169,8 +171,7 @@ int af_str2fmt_short(bstr str)
void af_fill_silence(void *dst, size_t bytes, int format)
{
- bool us = (format & AF_FORMAT_SIGN_MASK) == AF_FORMAT_US;
- memset(dst, us ? 0x80 : 0, bytes);
+ memset(dst, af_fmt_unsigned(format) ? 0x80 : 0, bytes);
}
#define FMT_DIFF(type, a, b) (((a) & type) - ((b) & type))
@@ -191,8 +192,6 @@ int af_format_conversion_score(int dst_format, int src_format)
int score = 1024;
if (FMT_DIFF(AF_FORMAT_INTERLEAVING_MASK, dst_format, src_format))
score -= 1; // has to (de-)planarize
- if (FMT_DIFF(AF_FORMAT_SIGN_MASK, dst_format, src_format))
- score -= 4; // has to swap sign
if (FMT_DIFF(AF_FORMAT_TYPE_MASK, dst_format, src_format)) {
int dst_bits = dst_format & AF_FORMAT_BITS_MASK;
if ((dst_format & AF_FORMAT_TYPE_MASK) == AF_FORMAT_F) {