diff options
author | Marcoen Hirschberg <m.hirschberg@activevideo.com> | 2014-05-27 08:21:18 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-05-28 21:38:00 +0200 |
commit | 31a10f7c38887294af758d21a19596b7772f328a (patch) | |
tree | 545cd862c7bd4cc6c916e91f5a4d69fa586170be /audio/format.c | |
parent | 434242adb5dc045faf16f8bb19aa740732cc3345 (diff) | |
download | mpv-31a10f7c38887294af758d21a19596b7772f328a.tar.bz2 mpv-31a10f7c38887294af758d21a19596b7772f328a.tar.xz |
af_fmt2bits: change to af_fmt2bps (bytes/sample) where appropriate
In most places where af_fmt2bits is called to get the bits/sample, the
result is immediately converted to bytes/sample. Avoid this by getting
bytes/sample directly by introducing af_fmt2bps.
Diffstat (limited to 'audio/format.c')
-rw-r--r-- | audio/format.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/audio/format.c b/audio/format.c index e343ca36db..9b14fd167b 100644 --- a/audio/format.c +++ b/audio/format.c @@ -28,21 +28,26 @@ #include "common/common.h" #include "audio/filter/af.h" -int af_fmt2bits(int format) +int af_fmt2bps(int format) { - if (AF_FORMAT_IS_AC3(format)) return 16; + if (AF_FORMAT_IS_AC3(format)) return 2; if (format == AF_FORMAT_UNKNOWN) return 0; switch (format & AF_FORMAT_BITS_MASK) { - case AF_FORMAT_8BIT: return 8; - case AF_FORMAT_16BIT: return 16; - case AF_FORMAT_24BIT: return 24; - case AF_FORMAT_32BIT: return 32; - case AF_FORMAT_64BIT: return 64; + case AF_FORMAT_8BIT: return 1; + case AF_FORMAT_16BIT: return 2; + case AF_FORMAT_24BIT: return 3; + case AF_FORMAT_32BIT: return 4; + case AF_FORMAT_64BIT: return 8; } return 0; } +int af_fmt2bits(int format) +{ + return af_fmt2bps(format) * 8; +} + static int bits_to_mask(int bits) { switch (bits) { @@ -159,7 +164,7 @@ const char *af_fmt_to_str(int format) int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate) { assert(!af_fmt_is_planar(format)); - int bps = (af_fmt2bits(format) / 8); + int bps = af_fmt2bps(format); int framelen = channels * bps; int bytes = seconds * bps * samplerate; if (bytes % framelen) |