summaryrefslogtreecommitdiffstats
path: root/audio/format.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-07 22:12:44 +0100
committerwm4 <wm4@nowhere>2013-11-07 22:13:20 +0100
commitd74bac22b94196b99dd9c3b8df63af4fd2755b7d (patch)
tree2a538a28ed66ecd1fa6e06771b8d641e83fdd39b /audio/format.c
parent91626b1c0606afb9bb582070e8a444a3ba8395ab (diff)
downloadmpv-d74bac22b94196b99dd9c3b8df63af4fd2755b7d.tar.bz2
mpv-d74bac22b94196b99dd9c3b8df63af4fd2755b7d.tar.xz
audio/format: convert format macros to enum, drop NE suffix
Turn the sample format definitions into an enum. (The format bits are still macros.) The native endian versions of the new definitions don't have a NE suffix anymore, although there are still compatibility defines since too much code uses the NE variants. Rename the format bits for special formats to help to distinguish them from the actual definitions, e.g. AF_FORMAT_AC3 to AF_FORMAT_S_AC3.
Diffstat (limited to 'audio/format.c')
-rw-r--r--audio/format.c55
1 files changed, 22 insertions, 33 deletions
diff --git a/audio/format.c b/audio/format.c
index 01c9a431a1..b933d07e16 100644
--- a/audio/format.c
+++ b/audio/format.c
@@ -62,41 +62,30 @@ int af_fmt_change_bits(int format, int bits)
return af_fmt_is_valid(format) ? format : 0;
}
+#define FMT(string, id) \
+ {string, id},
+
+#define FMT_ENDIAN(string, id) \
+ {string, id}, \
+ {string "ne", id}, \
+ {string "le", MP_CONCAT(id, _LE)}, \
+ {string "be", MP_CONCAT(id, _BE)}, \
+
const struct af_fmt_entry af_fmtstr_table[] = {
- { "mpeg2", AF_FORMAT_MPEG2 },
- { "ac3le", AF_FORMAT_AC3_LE },
- { "ac3be", AF_FORMAT_AC3_BE },
- { "ac3ne", AF_FORMAT_AC3_NE },
- { "iec61937le", AF_FORMAT_IEC61937_LE },
- { "iec61937be", AF_FORMAT_IEC61937_BE },
- { "iec61937ne", AF_FORMAT_IEC61937_NE },
+ FMT("mpeg2", AF_FORMAT_MPEG2)
+ FMT_ENDIAN("ac3", AF_FORMAT_AC3)
+ FMT_ENDIAN("iec61937", AF_FORMAT_IEC61937)
- { "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 },
- { "doublele", AF_FORMAT_DOUBLE_LE },
- { "doublebe", AF_FORMAT_DOUBLE_BE },
- { "doublene", AF_FORMAT_DOUBLE_NE },
+ FMT("u8", AF_FORMAT_U8)
+ FMT("s8", AF_FORMAT_S8)
+ FMT_ENDIAN("u16", AF_FORMAT_U16)
+ FMT_ENDIAN("s16", AF_FORMAT_S16)
+ FMT_ENDIAN("u24", AF_FORMAT_U24)
+ FMT_ENDIAN("s24", AF_FORMAT_S24)
+ FMT_ENDIAN("u32", AF_FORMAT_U32)
+ FMT_ENDIAN("s32", AF_FORMAT_S32)
+ FMT_ENDIAN("float", AF_FORMAT_FLOAT)
+ FMT_ENDIAN("double", AF_FORMAT_DOUBLE)
{0}
};