[pulseaudio-commits] r1942 - in /branches/lennart/src/pulsecore: sample-util.c sample-util.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Mon Oct 22 14:48:17 PDT 2007


Author: lennart
Date: Mon Oct 22 23:48:16 2007
New Revision: 1942

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1942&root=pulseaudio&view=rev
Log:
add interleaving/deinterleaving APIs

Modified:
    branches/lennart/src/pulsecore/sample-util.c
    branches/lennart/src/pulsecore/sample-util.h

Modified: branches/lennart/src/pulsecore/sample-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/sample-util.c?rev=1942&root=pulseaudio&r1=1941&r2=1942&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/sample-util.c (original)
+++ branches/lennart/src/pulsecore/sample-util.c Mon Oct 22 23:48:16 2007
@@ -31,6 +31,7 @@
 #include <stdlib.h>
 
 #include <liboil/liboilfuncs.h>
+#include <liboil/liboil.h>
 
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
@@ -485,3 +486,59 @@
 
     return l % fs == 0;
 }
+
+void pa_interleave(const void *src[], unsigned channels, void *dst, size_t ss, unsigned n) {
+    unsigned c;
+    size_t fs;
+
+    pa_assert(src);
+    pa_assert(channels > 0);
+    pa_assert(dst);
+    pa_assert(ss > 0);
+    pa_assert(n > 0);
+
+    fs = ss * channels;
+
+    for (c = 0; c < channels; c++) {
+        unsigned j;
+        void *d;
+        const void *s;
+
+        s = src[c];
+        d = (uint8_t*) dst + c * ss;
+
+        for (j = 0; j < n; j ++) {
+            oil_memcpy(d, s, ss);
+            s = (uint8_t*) s + ss;
+            d = (uint8_t*) d + fs;
+        }
+    }
+}
+
+void pa_deinterleave(const void *src, void *dst[], unsigned channels, size_t ss, unsigned n) {
+    size_t fs;
+    unsigned c;
+
+    pa_assert(src);
+    pa_assert(dst);
+    pa_assert(channels > 0);
+    pa_assert(ss > 0);
+    pa_assert(n > 0);
+
+    fs = ss * channels;
+
+    for (c = 0; c < channels; c++) {
+        unsigned j;
+        const void *s;
+        void *d;
+
+        s = (uint8_t*) src + c * ss;
+        d = dst[c];
+
+        for (j = 0; j < n; j ++) {
+            oil_memcpy(d, s, ss);
+            s = (uint8_t*) s + fs;
+            d = (uint8_t*) d + ss;
+        }
+    }
+}

Modified: branches/lennart/src/pulsecore/sample-util.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/sample-util.h?rev=1942&root=pulseaudio&r1=1941&r2=1942&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/sample-util.h (original)
+++ branches/lennart/src/pulsecore/sample-util.h Mon Oct 22 23:48:16 2007
@@ -60,4 +60,7 @@
 
 int pa_frame_aligned(size_t l, const pa_sample_spec *ss) PA_GCC_PURE;
 
+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);
+
 #endif




More information about the pulseaudio-commits mailing list