summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-08 19:31:54 +0200
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-05-09 20:18:54 +0900
commitf58646c85c481ea51d74832cb10e5e766e9b4ca9 (patch)
tree5a2183c8e8a26dae5d4d4cc8ff7b8d2fd909dd59
parentd224c8903418d173df9459a9c2b0c4e542db661d (diff)
downloadmpv-f58646c85c481ea51d74832cb10e5e766e9b4ca9.tar.bz2
mpv-f58646c85c481ea51d74832cb10e5e766e9b4ca9.tar.xz
audio: add chmap utility function
(cherry picked from commit d32b71d52e9a45c141d2bd132189db68613ab0fb)
-rw-r--r--audio/chmap.c9
-rw-r--r--audio/chmap.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/audio/chmap.c b/audio/chmap.c
index 1c40c66b0f..61ba8b0fa7 100644
--- a/audio/chmap.c
+++ b/audio/chmap.c
@@ -400,6 +400,7 @@ void mp_chmap_get_reorder(int src[MP_NUM_CHANNELS], const struct mp_chmap *from,
assert(src[n] < 0 || (to->speaker[n] == from->speaker[src[n]]));
}
+// Return channels that are only in a.
// Performs the difference between a and b, and store it in diff. If b has
// channels that do not appear in a, those will not appear in the difference.
// To get to those the argument ordering in the function call has to be
@@ -413,6 +414,14 @@ void mp_chmap_diff(const struct mp_chmap *a, const struct mp_chmap *b,
mp_chmap_from_lavc(diff, (a_mask ^ b_mask) & a_mask);
}
+// Return the number of channels only in a.
+int mp_chmap_diffn(const struct mp_chmap *a, const struct mp_chmap *b)
+{
+ struct mp_chmap diff;
+ mp_chmap_diff(a, b, &diff);
+ return diff.num;
+}
+
// Checks whether a contains all the speakers in b
bool mp_chmap_contains(const struct mp_chmap *a, const struct mp_chmap *b)
{
diff --git a/audio/chmap.h b/audio/chmap.h
index 296b2a1712..7165375e46 100644
--- a/audio/chmap.h
+++ b/audio/chmap.h
@@ -128,6 +128,7 @@ void mp_chmap_get_reorder(int src[MP_NUM_CHANNELS], const struct mp_chmap *from,
void mp_chmap_diff(const struct mp_chmap *a, const struct mp_chmap *b,
struct mp_chmap *diff);
+int mp_chmap_diffn(const struct mp_chmap *a, const struct mp_chmap *b);
bool mp_chmap_contains(const struct mp_chmap *a, const struct mp_chmap *b);