Don't use libc's rand() function, because it is slow. Our own trivial linear congruential generator is good enough for dithering.
Copied and adapted code from the mp3 decoder plugin. This library now replaces the old and low-quality function pcm_convert_24_to_16().