summaryrefslogtreecommitdiffstats
path: root/audio/chmap.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-04 23:59:20 +0200
committerwm4 <wm4@nowhere>2015-05-05 01:11:16 +0200
commit06050aed9906b784159ad03e86e13348c4d9fa47 (patch)
treec9cd6861e1c1cc41066cc0663a8e29e28bed4502 /audio/chmap.h
parent1b0b094ca2c25ad162f8f8c84ebebef9a963552e (diff)
downloadmpv-06050aed9906b784159ad03e86e13348c4d9fa47.tar.bz2
mpv-06050aed9906b784159ad03e86e13348c4d9fa47.tar.xz
audio: introduce support for padding channels
Some audio APIs explicitly require you to add dummy channels. These are not rendered, and only exist for the sake of the audio API or hardware strangeness. At least ALSA, Sndio, and CoreAudio seem to have them. This commit is preparation for using them with ao_coreaudio. The result is a bit messy. libavresample/libswresample don't have good API for this; avresample_set_channel_mapping() is pretty useless. Although in theory you can use it to add and remove channels, you can't set the channel counts. So we do the ordering ourselves by making sure the audio data is planar, and by swapping the plane pointers. This requires lots of messiness to get the conversions in place. Also, the input reordering is still done with the "old" method, and doesn't support padded channels - hopefully this will never be needed. (I tried to come up with cleaner solutions, but compared to my other attempts, the final commit is not that bad.)
Diffstat (limited to 'audio/chmap.h')
-rw-r--r--audio/chmap.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/audio/chmap.h b/audio/chmap.h
index 1ae4fb0697..296b2a1712 100644
--- a/audio/chmap.h
+++ b/audio/chmap.h
@@ -61,6 +61,11 @@ enum mp_speaker_id {
MP_SPEAKER_ID_UNKNOWN0 = 64,
MP_SPEAKER_ID_UNKNOWN_LAST = MP_SPEAKER_ID_UNKNOWN0 + MP_NUM_CHANNELS - 1,
+ // "Silent" channels. These are sometimes used to insert padding for
+ // unused channels.
+ MP_SPEAKER_ID_NA0,
+ MP_SPEAKER_ID_NA_LAST = MP_SPEAKER_ID_NA0 + MP_NUM_CHANNELS - 1,
+
// Including the unassigned IDs in between. This is not a valid ID anymore,
// but is still within uint8_t.
MP_SPEAKER_ID_COUNT,
@@ -101,6 +106,8 @@ bool mp_chmap_equals_reordered(const struct mp_chmap *a, const struct mp_chmap *
bool mp_chmap_is_stereo(const struct mp_chmap *src);
void mp_chmap_reorder_norm(struct mp_chmap *map);
+void mp_chmap_remove_na(struct mp_chmap *map);
+void mp_chmap_fill_na(struct mp_chmap *map, int num);
void mp_chmap_from_channels(struct mp_chmap *dst, int num_channels);
void mp_chmap_set_unknown(struct mp_chmap *dst, int num_channels);
@@ -116,7 +123,7 @@ void mp_chmap_from_lavc(struct mp_chmap *dst, uint64_t src);
bool mp_chmap_is_lavc(const struct mp_chmap *src);
void mp_chmap_reorder_to_lavc(struct mp_chmap *map);
-void mp_chmap_get_reorder(int dst[MP_NUM_CHANNELS], const struct mp_chmap *from,
+void mp_chmap_get_reorder(int src[MP_NUM_CHANNELS], const struct mp_chmap *from,
const struct mp_chmap *to);
void mp_chmap_diff(const struct mp_chmap *a, const struct mp_chmap *b,