erikd/libsndfile — pull request #40 by crienzo (2013-04-25 18:17:55+00:00)
Title: src/ima_oki_adpcm: fix decoding of dialogic-encoded .vox file

This is a fix for the issue I documented on the libsndfile-devel list:

I recently added .vox (Dialogic ADPCM raw file format) support to FreeSWITCH using libsndfile and noticed the library is not decoding files encoded by a Dialogic encoder properly. I verified using spandsp’s ADPCM decoder which does not have this issue. See http://git.freeswitch.org/git/freeswitch/tree/libs/spandsp/src/oki_adpcm.c#n152 for spandsp (LGPL) implementation.

Comparing the two decoders, I noticed spandsp exactly follows the algorithm as described by Dialogic while libsndfile improves on the implementation but does not reproduce the truncation errors. For example:

Spandsp:
ss(n) = 55
L(n) = 7
d(n) = 55 + 55/2 + 55/4 + 55/8 = 101
d(n) << 4 = 1616

libsndfile:
ss(n) << 4 = 880
L(n) = 7
s = 7 << 1 | 1 = 15
d(n) << 4 = ((880 * 15) / 8) & 65520 = 1648