Commit 974cbfb3 authored by Douglas Bagnall's avatar Douglas Bagnall Committed by Sebastian Dröge
Browse files

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
parent 20ced51d
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment