summaryrefslogtreecommitdiff
path: root/gst/audioresample
diff options
context:
space:
mode:
authorCarlos Rafael Giani <dv@pseudoterminal.org>2012-10-15 22:21:14 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2012-10-25 14:03:52 +0200
commit19073ab8c4898a7fb780e73748a5bfe20f79d477 (patch)
treeb1f586bc19c373a875debff0f084b3554b126e6c /gst/audioresample
parentc41faa3d8ea549479d61472b034a8f26fabe355c (diff)
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>
Diffstat (limited to 'gst/audioresample')
-rw-r--r--gst/audioresample/arch.h1
-rw-r--r--gst/audioresample/fixed_generic.h4
-rw-r--r--gst/audioresample/resample.c4
3 files changed, 7 insertions, 2 deletions
diff --git a/gst/audioresample/arch.h b/gst/audioresample/arch.h
index c5184582a..4e77e6e1c 100644
--- a/gst/audioresample/arch.h
+++ b/gst/audioresample/arch.h
@@ -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)
diff --git a/gst/audioresample/fixed_generic.h b/gst/audioresample/fixed_generic.h
index 3fb096ed9..699135215 100644
--- a/gst/audioresample/fixed_generic.h
+++ b/gst/audioresample/fixed_generic.h
@@ -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))
diff --git a/gst/audioresample/resample.c b/gst/audioresample/resample.c
index bd36bfa3d..b6b1de660 100644
--- a/gst/audioresample/resample.c
+++ b/gst/audioresample/resample.c
@@ -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) {