From e83573fd8d232a0b6defe99ca4ee28c4cbef0ff8 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Fri, 31 Mar 2017 23:40:05 +1300 Subject: [PATCH] audiointerleave: don't overflow channel map with >64 channels When there are more than 64 channels, we don't want to exceed the bounds of the ordering_map buffer, and in these cases we don't want to remap at all. Here we avoid doing that. Based on a patch originally for plugins-good/interleave in https://bugzilla.gnome.org/show_bug.cgi?id=780331 --- gst/audiomixer/gstaudiointerleave.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gst/audiomixer/gstaudiointerleave.c b/gst/audiomixer/gstaudiointerleave.c index e91b645..f4e9fa1 100644 --- a/gst/audiomixer/gstaudiointerleave.c +++ b/gst/audiomixer/gstaudiointerleave.c @@ -330,7 +330,8 @@ gst_audio_interleave_get_channel_mask (GstAudioInterleave * self) { guint64 channel_mask = 0; - if (self->channel_positions != NULL && + if (self->channels <= 64 && + self->channel_positions != NULL && self->channels == self->channel_positions->n_values) { if (!gst_audio_interleave_channel_positions_to_mask (self->channel_positions, self->default_channels_ordering_map, @@ -338,7 +339,7 @@ gst_audio_interleave_get_channel_mask (GstAudioInterleave * self) GST_WARNING_OBJECT (self, "Invalid channel positions, using NONE"); channel_mask = 0; } - } else { + } else if (self->channels <= 64) { GST_WARNING_OBJECT (self, "Using NONE channel positions"); } @@ -826,7 +827,7 @@ gst_audio_interleave_aggregate_one_buffer (GstAudioAggregator * aagg, GstAudioInterleavePad *pad = GST_AUDIO_INTERLEAVE_PAD (aaggpad); GstMapInfo inmap; GstMapInfo outmap; - gint out_width, in_bpf, out_bpf, out_channels; + gint out_width, in_bpf, out_bpf, out_channels, channel; guint8 *outdata; out_width = GST_AUDIO_INFO_WIDTH (&aagg->info) / 8; @@ -840,8 +841,13 @@ gst_audio_interleave_aggregate_one_buffer (GstAudioAggregator * aagg, " from offset %u", num_frames, pad->channel, out_channels, out_offset * out_bpf, in_offset * in_bpf); - outdata = outmap.data + (out_offset * out_bpf) + - (out_width * self->default_channels_ordering_map[pad->channel]); + if (self->channels > 64) { + channel = pad->channel; + } else { + channel = self->default_channels_ordering_map[pad->channel]; + } + + outdata = outmap.data + (out_offset * out_bpf) + (out_width * channel); self->func (outdata, inmap.data + (in_offset * in_bpf), out_channels, -- 2.7.4