From: Steve Underwood Date: Wed, 31 Aug 2016 15:59:32 +0000 (+0800) Subject: The band filter for G.722 could cause numerical overflow in unusual circumstances... X-Git-Tag: v1.6.11~9^2~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29f5fb6aa78fea53cbe3fb28693c93abdeae3632;p=thirdparty%2Ffreeswitch.git The band filter for G.722 could cause numerical overflow in unusual circumstances with the maximum possiblke signal level. The filter output is now saturated to 16 bits to avoid this. --- diff --git a/libs/spandsp/spandsp/fax-tests.xml b/libs/spandsp/spandsp/fax-tests.xml index 8c03d0e22f..b6ff399699 100644 --- a/libs/spandsp/spandsp/fax-tests.xml +++ b/libs/spandsp/spandsp/fax-tests.xml @@ -381,7 +381,7 @@ - + @@ -402,23 +402,11 @@ - - - - - - - - - - - - - + - + @@ -437,7 +425,7 @@ - + @@ -461,7 +449,7 @@ - + @@ -644,7 +632,7 @@ - + @@ -686,7 +674,7 @@ - + diff --git a/libs/spandsp/src/g722.c b/libs/spandsp/src/g722.c index f3126e8aa1..f9bd7f37b2 100644 --- a/libs/spandsp/src/g722.c +++ b/libs/spandsp/src/g722.c @@ -426,8 +426,8 @@ SPAN_DECLARE(int) g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8 s->ptr = 0; /* We shift by 12 to allow for the QMF filters (DC gain = 4096), less 1 to allow for the 15 bit input to the G.722 algorithm. */ - amp[outlen++] = (int16_t) (vec_circular_dot_prodi16(s->y, qmf_coeffs_rev, 12, s->ptr) >> 11); - amp[outlen++] = (int16_t) (vec_circular_dot_prodi16(s->x, qmf_coeffs_fwd, 12, s->ptr) >> 11); + amp[outlen++] = saturate16(vec_circular_dot_prodi16(s->y, qmf_coeffs_rev, 12, s->ptr) >> 11); + amp[outlen++] = saturate16(vec_circular_dot_prodi16(s->x, qmf_coeffs_fwd, 12, s->ptr) >> 11); } } }