Adapted by Steve Underwood from the source code supplied by Polycom in ITU specification G.722.1.