audioconvert: optimize mask calculation
authorPetr Kulhavy <brain@jikos.cz>
Fri, 14 Oct 2016 20:31:41 +0000 (22:31 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 1 Nov 2016 18:02:14 +0000 (20:02 +0200)
commitca7e31f80d8b801e95ce019a14f773728c1acca8
tree7053e9bdbf2eb688e9bc9212136716ef9b1207bf
parent1820c18b0f0005b117282b2d16c33ef984e91a9b
audioconvert: optimize mask calculation

find_suitable_mask() had complexity O(n^2) on the number of bits.
For common case like 2-channel audio the mask was calculated in about 4k loop
cycles.

Optimize both n_bits_set() and find_suitable_mask() to O(n) where n is the
number of bits set in the mask.

https://bugzilla.gnome.org/show_bug.cgi?id=772864
gst/audioconvert/gstaudioconvert.c