refactor decoding code

so it can be used by replaygain scanner.

also created replaygain scanning framework
refactor more things into DecodeContext