audioresample: changed inner_product_single semantics

This is an adaptation of patch #3 from Jyri Sarha
( http://lists.xiph.org/pipermail/speex-dev/2011-September/008240.html ),
but without the NEON optimizations (these come in a separate commit).
The idea is to replace SATURATE32(PSHR32(x, shift), a) operations with a
combined SATURATE32PSHR(x, shift, a) macro that can be optimized for
specific platforms (and also avoids rare rounding errors).

Signed-off-by: Carlos Rafael Giani <dv@pseudoterminal.org>
This commit is contained in:
Carlos Rafael Giani 2012-10-15 22:21:14 +02:00 committed by Sebastian Dröge
parent c41faa3d8e
commit 19073ab8c4
3 changed files with 7 additions and 2 deletions

View file

@ -197,6 +197,7 @@ typedef float spx_word32_t;
#define VSHR32(a,shift) (a)
#define SATURATE16(x,a) (x)
#define SATURATE32(x,a) (x)
#define SATURATE32PSHR(x,shift,a) (x)
#define PSHR(a,shift) (a)
#define SHR(a,shift) (a)

View file

@ -51,6 +51,10 @@
#define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift)))
#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
#define SATURATE32PSHR(x,shift,a) (((x)>=(SHL32(a,shift))) ? (a) : \
(x)<=-(SHL32(a,shift)) ? -(a) : \
(PSHR32(x, shift)))
#define SHR(a,shift) ((a) >> (shift))
#define SHL(a,shift) ((spx_word32_t)(a) << (shift))

View file

@ -478,7 +478,7 @@ resampler_basic_direct_single (SpeexResamplerState * st,
sum = inner_product_single (sinc, iptr, N);
SSE_END (INNER_PRODUCT_SINGLE)
#endif
out[out_stride * out_sample++] = SATURATE32 (PSHR32 (sum, 15), 32767);
out[out_stride * out_sample++] = SATURATE32PSHR(sum, 15, 32767);
last_sample += int_advance;
samp_frac_num += frac_advance;
if (samp_frac_num >= den_rate) {
@ -616,7 +616,7 @@ resampler_basic_interpolate_single (SpeexResamplerState * st,
interp);
SSE_END (INTERPOLATE_PRODUCT_SINGLE)
#endif
out[out_stride * out_sample++] = SATURATE32 (PSHR32 (sum, 14), 32767);
out[out_stride * out_sample++] = SATURATE32PSHR(sum, 14, 32767);
last_sample += int_advance;
samp_frac_num += frac_advance;
if (samp_frac_num >= den_rate) {