Code refactoring
Fix phase shift in format conversion
Fix pre-processing of pcm24 samples

And optimize the whole thing a bit.