[pulseaudio-discuss] [PATCH 08/11] remap: Add helper function to setup channel arrangement information

Peter Meerwald pmeerw at pmeerw.net
Thu Apr 24 09:09:16 PDT 2014


From: Peter Meerwald <p.meerwald at bct-electronic.com>

Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
 src/pulsecore/remap.c |   29 +++++++++++++++++++++++++++++
 src/pulsecore/remap.h |   10 ++++++++++
 2 files changed, 39 insertions(+)

diff --git a/src/pulsecore/remap.c b/src/pulsecore/remap.c
index a08f5a6..a550b56 100644
--- a/src/pulsecore/remap.c
+++ b/src/pulsecore/remap.c
@@ -137,6 +137,35 @@ static void remap_channels_matrix_float32ne_c(pa_remap_t *m, void *dst, const vo
     }
 }
 
+bool pa_setup_remap_arrange(const pa_remap_t *m, int8_t arrange[PA_CHANNELS_MAX]) {
+    unsigned ic, oc;
+    unsigned n_ic, n_oc;
+
+    pa_assert(m);
+
+    n_ic = m->i_ss.channels;
+    n_oc = m->o_ss.channels;
+
+    for (oc = 0; oc < n_oc; oc++) {
+        arrange[oc] = -1;
+        for (ic = 0; ic < n_ic; ic++) {
+            int32_t vol = m->map_table_i[oc][ic];
+
+            /* input channel is not used */
+            if (vol == 0)
+                continue;
+
+            /* if mixing this channel, we cannot just rearrange */
+            if (vol != 0x10000 || arrange[oc] >= 0)
+                return false;
+
+            arrange[oc] = ic;
+        }
+    }
+
+    return true;
+}
+
 /* set the function that will execute the remapping based on the matrices */
 static void init_remap_c(pa_remap_t *m) {
     unsigned n_oc, n_ic;
diff --git a/src/pulsecore/remap.h b/src/pulsecore/remap.h
index 3d1eec1..adf3526 100644
--- a/src/pulsecore/remap.h
+++ b/src/pulsecore/remap.h
@@ -46,4 +46,14 @@ typedef void (*pa_init_remap_func_t) (pa_remap_t *m);
 pa_init_remap_func_t pa_get_init_remap_func(void);
 void pa_set_init_remap_func(pa_init_remap_func_t func);
 
+/* Check if remapping can be performed by just copying some or all input
+ * channels' data to output channels. Returns true and a table of input
+ * channel indices, or false otherwise.
+ *
+ * The table contains an entry for each output channels. Each table entry given
+ * either the input channel index to be copied, or -1 indicating that the
+ * output channel is not used and hence zero.
+ */
+bool pa_setup_remap_arrange(const pa_remap_t *m, int8_t arrange[PA_CHANNELS_MAX]);
+
 #endif /* fooremapfoo */
-- 
1.7.9.5



More information about the pulseaudio-discuss mailing list