mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
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:
parent
c41faa3d8e
commit
19073ab8c4
3 changed files with 7 additions and 2 deletions
|
@ -197,6 +197,7 @@ typedef float spx_word32_t;
|
||||||
#define VSHR32(a,shift) (a)
|
#define VSHR32(a,shift) (a)
|
||||||
#define SATURATE16(x,a) (x)
|
#define SATURATE16(x,a) (x)
|
||||||
#define SATURATE32(x,a) (x)
|
#define SATURATE32(x,a) (x)
|
||||||
|
#define SATURATE32PSHR(x,shift,a) (x)
|
||||||
|
|
||||||
#define PSHR(a,shift) (a)
|
#define PSHR(a,shift) (a)
|
||||||
#define SHR(a,shift) (a)
|
#define SHR(a,shift) (a)
|
||||||
|
|
|
@ -52,6 +52,10 @@
|
||||||
#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
|
#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
|
||||||
#define SATURATE32(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 SHR(a,shift) ((a) >> (shift))
|
||||||
#define SHL(a,shift) ((spx_word32_t)(a) << (shift))
|
#define SHL(a,shift) ((spx_word32_t)(a) << (shift))
|
||||||
#define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift))
|
#define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift))
|
||||||
|
|
|
@ -478,7 +478,7 @@ resampler_basic_direct_single (SpeexResamplerState * st,
|
||||||
sum = inner_product_single (sinc, iptr, N);
|
sum = inner_product_single (sinc, iptr, N);
|
||||||
SSE_END (INNER_PRODUCT_SINGLE)
|
SSE_END (INNER_PRODUCT_SINGLE)
|
||||||
#endif
|
#endif
|
||||||
out[out_stride * out_sample++] = SATURATE32 (PSHR32 (sum, 15), 32767);
|
out[out_stride * out_sample++] = SATURATE32PSHR(sum, 15, 32767);
|
||||||
last_sample += int_advance;
|
last_sample += int_advance;
|
||||||
samp_frac_num += frac_advance;
|
samp_frac_num += frac_advance;
|
||||||
if (samp_frac_num >= den_rate) {
|
if (samp_frac_num >= den_rate) {
|
||||||
|
@ -616,7 +616,7 @@ resampler_basic_interpolate_single (SpeexResamplerState * st,
|
||||||
interp);
|
interp);
|
||||||
SSE_END (INTERPOLATE_PRODUCT_SINGLE)
|
SSE_END (INTERPOLATE_PRODUCT_SINGLE)
|
||||||
#endif
|
#endif
|
||||||
out[out_stride * out_sample++] = SATURATE32 (PSHR32 (sum, 14), 32767);
|
out[out_stride * out_sample++] = SATURATE32PSHR(sum, 14, 32767);
|
||||||
last_sample += int_advance;
|
last_sample += int_advance;
|
||||||
samp_frac_num += frac_advance;
|
samp_frac_num += frac_advance;
|
||||||
if (samp_frac_num >= den_rate) {
|
if (samp_frac_num >= den_rate) {
|
||||||
|
|
Loading…
Reference in a new issue