]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/remap.c
remap: Add helper function to setup channel arrangement information
[pulseaudio] / src / pulsecore / remap.c
index 4108fdd6c003e3379e203ecbe4689bc0608fc58d..a550b569bf74bb844901e859ce10a9f6c19acc1a 100644 (file)
@@ -120,13 +120,13 @@ static void remap_channels_matrix_float32ne_c(pa_remap_t *m, void *dst, const vo
 
             vol = m->map_table_f[oc][ic];
 
-            if (vol <= 0.0)
+            if (vol <= 0.0f)
                 continue;
 
             d = (float *)dst + oc;
             s = (float *)src + ic;
 
-            if (vol >= 1.0) {
+            if (vol >= 1.0f) {
                 for (i = n; i > 0; i--, s += n_ic, d += n_oc)
                     *d += *s;
             } else {
@@ -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;