riff: refactor out the WAVEFORMATEX parsing

Make the code simpler to follow.