Adapted by Steve Underwood <steveu@coppice.org> from the source code supplied by Polycom in ITU specification G.722.1.