summaryrefslogtreecommitdiff
path: root/audio/format.c
diff options
context:
space:
mode:
authorJames Cowgill <jcowgill@debian.org>2018-10-03 09:34:10 +0100
committerJames Cowgill <jcowgill@debian.org>2018-10-03 09:34:10 +0100
commita6680ec06c4f17bb7b60c18ebd611ef40c5c6d68 (patch)
tree00780369c30413610781ace95a12b87fe7d79fe8 /audio/format.c
parentf4faf74f8747c113bd8c1f99e6b6fb1983f11e0d (diff)
New upstream version 0.29.1
Diffstat (limited to 'audio/format.c')
-rw-r--r--audio/format.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/audio/format.c b/audio/format.c
index 8a13698..f56546a 100644
--- a/audio/format.c
+++ b/audio/format.c
@@ -55,12 +55,6 @@ bool af_fmt_is_int(int format)
return format && !af_fmt_is_spdif(format) && !af_fmt_is_float(format);
}
-// false for interleaved and AF_FORMAT_UNKNOWN
-bool af_fmt_is_planar(int format)
-{
- return format && af_fmt_to_planar(format) == format;
-}
-
bool af_fmt_is_spdif(int format)
{
return af_format_sample_alignment(format) > 1;
@@ -79,23 +73,30 @@ static const int planar_formats[][2] = {
{AF_FORMAT_DOUBLEP, AF_FORMAT_DOUBLE},
};
+bool af_fmt_is_planar(int format)
+{
+ for (int n = 0; n < MP_ARRAY_SIZE(planar_formats); n++) {
+ if (planar_formats[n][0] == format)
+ return true;
+ }
+ return false;
+}
+
// Return the planar format corresponding to the given format.
-// If the format is already planar, return it.
-// Return 0 if there's no equivalent.
+// If the format is already planar or if there's no equivalent,
+// return it.
int af_fmt_to_planar(int format)
{
for (int n = 0; n < MP_ARRAY_SIZE(planar_formats); n++) {
if (planar_formats[n][1] == format)
return planar_formats[n][0];
- if (planar_formats[n][0] == format)
- return format;
}
- return 0;
+ return format;
}
// Return the interleaved format corresponding to the given format.
-// If the format is already interleaved, return it.
-// Always succeeds if format is actually planar; otherwise return 0.
+// If the format is already interleaved or if there's no equivalent,
+// return it.
int af_fmt_from_planar(int format)
{
for (int n = 0; n < MP_ARRAY_SIZE(planar_formats); n++) {
@@ -134,17 +135,6 @@ const char *af_fmt_to_str(int format)
return "??";
}
-int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate)
-{
- assert(!af_fmt_is_planar(format));
- int bps = af_fmt_to_bytes(format);
- int framelen = channels * bps;
- int bytes = seconds * bps * samplerate;
- if (bytes % framelen)
- bytes += framelen - (bytes % framelen);
- return bytes;
-}
-
void af_fill_silence(void *dst, size_t bytes, int format)
{
memset(dst, af_fmt_is_unsigned(format) ? 0x80 : 0, bytes);