[pulseaudio-commits] r2318 - in /branches/glitch-free/src/pulsecore: sample-util.c sample-util.h
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Thu May 1 12:09:05 PDT 2008
Author: lennart
Date: Thu May 1 21:09:03 2008
New Revision: 2318
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2318&root=pulseaudio&view=rev
Log:
add new function pa_sample_clamp()
Modified:
branches/glitch-free/src/pulsecore/sample-util.c
branches/glitch-free/src/pulsecore/sample-util.h
Modified: branches/glitch-free/src/pulsecore/sample-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulsecore/sample-util.c?rev=2318&root=pulseaudio&r1=2317&r2=2318&view=diff
==============================================================================
--- branches/glitch-free/src/pulsecore/sample-util.c (original)
+++ branches/glitch-free/src/pulsecore/sample-util.c Thu May 1 21:09:03 2008
@@ -1000,3 +1000,34 @@
return ret;
}
+
+void pa_sample_clamp(pa_sample_format_t format, void *dst, size_t dstr, const void *src, size_t sstr, unsigned n) {
+
+ const float *s;
+ float *d;
+
+ if (format != PA_SAMPLE_FLOAT32BE && format != PA_SAMPLE_FLOAT32LE)
+ return;
+
+ s = src;
+ d = dst;
+
+ if (format == PA_SAMPLE_FLOAT32NE) {
+ for (; n > 0; n--) {
+ *d = PA_CLAMP_UNLIKELY(*s, -1.0, 1.0);
+
+ s = (const float*) ((const uint8_t*) s + sstr);
+ d = (float*) ((uint8_t*) d + dstr);
+ }
+ } else
+ for (; n > 0; n--) {
+ float f;
+
+ f = PA_FLOAT32_SWAP(*s);
+ f = PA_CLAMP_UNLIKELY(f, -1.0, 1.0);
+ *d = PA_FLOAT32_SWAP(f);
+
+ s = (const float*) ((const uint8_t*) s + sstr);
+ d = (float*) ((uint8_t*) d + dstr);
+ }
+}
Modified: branches/glitch-free/src/pulsecore/sample-util.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulsecore/sample-util.h?rev=2318&root=pulseaudio&r1=2317&r2=2318&view=diff
==============================================================================
--- branches/glitch-free/src/pulsecore/sample-util.h (original)
+++ branches/glitch-free/src/pulsecore/sample-util.h Thu May 1 21:09:03 2008
@@ -78,4 +78,6 @@
void pa_interleave(const void *src[], unsigned channels, void *dst, size_t ss, unsigned n);
void pa_deinterleave(const void *src, void *dst[], unsigned channels, size_t ss, unsigned n);
+void pa_sample_clamp(pa_sample_format_t format, void *dst, size_t dstr, const void *src, size_t sstr, unsigned n);
+
#endif
More information about the pulseaudio-commits
mailing list