[MPlayer-dev-eng] [RFC] multichannel ladspa plugin support

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Jan 5 14:57:03 CET 2007


Hello,
attached is a completely untested patch that might add support for that.
Maybe someone can check it or give me a tip how to best test it.
Even if for some reason it does not work like this, some of the changes
IMHO really deobfuscate the code a bit.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libaf/af_ladspa.c
===================================================================
--- libaf/af_ladspa.c	(revision 21825)
+++ libaf/af_ladspa.c	(working copy)
@@ -255,11 +255,13 @@
         af_msg(AF_MSG_VERBOSE, "%s: this is a stereo effect\n", setup->myname);
     }
 
+#if 0
     if (setup->ninputs > 2) {
         af_msg(AF_MSG_ERROR, "%s: %s\n", setup->myname,
                                             MSGTR_AF_LADSPA_ErrMultiChannel);
         return AF_ERROR;
     }
+#endif
 
     if (setup->noutputs == 0) {
         af_msg(AF_MSG_ERROR, "%s: %s\n", setup->myname,
@@ -704,11 +706,7 @@
         }
 
         if (setup->chhandles) {
-            for(i=0; i<setup->nch; i++) {
-                if ( (setup->ninputs == 2) && (i & 1) ) { /* stereo effect */
-                    i++;
-                    continue;
-                }
+            for(i=0; i<setup->nch; i+=setup->ninputs) {
                 if (pdes->deactivate) pdes->deactivate(setup->chhandles[i]);
                 if (pdes->cleanup) pdes->cleanup(setup->chhandles[i]);
             }
@@ -837,7 +835,7 @@
 
             for(i=0; i<nch; i++) {
 
-                if ( (setup->ninputs == 2) && (i & 1) ) { /* stereo effect */
+                if (i % setup->ninputs) { /* stereo effect */
                     /* copy the handle from previous channel */
                     setup->chhandles[i] = setup->chhandles[i-1];
                     continue;
@@ -854,10 +852,10 @@
 
         for(i=0; i<nch; i++) {
             pdes->connect_port(setup->chhandles[i],
-                               setup->inputs[ (setup->ninputs==2) ? i&1 : 0 ],
+                               setup->inputs[i % setup->ninputs],
                                setup->inbufs[i]);
             pdes->connect_port(setup->chhandles[i],
-                               setup->outputs[ (setup->ninputs==2) ? i&1 : 0 ],
+                               setup->outputs[i % setup->ninputs],
                                setup->outbufs[i]);
 
             /* connect (input) controls */
@@ -888,12 +886,12 @@
          * and right. connect it to the second port.
          */
 
-        if( (setup->ninputs == 2) && (i&1) && (i >= 1) ) { 
+        for (p = i; p % setup->ninputs; p++) { 
             pdes->connect_port(setup->chhandles[i-1],
-                               setup->inputs[ (setup->ninputs==2) ? i&1 : 0 ],
+                               setup->inputs[p % setup->ninputs],
                                setup->inbufs[i-1]);
             pdes->connect_port(setup->chhandles[i-1],
-                               setup->outputs[ (setup->ninputs==2) ? i&1 : 0 ],
+                               setup->outputs[p % setup->ninputs],
                                setup->outbufs[i-1]);
         } /* done! */
 
@@ -917,10 +915,8 @@
 
     /* Run filter(s) */
 
-    for (i=0; i<nch; i++) {
+    for (i=0; i<nch; i+=setup->ninputs) {
         pdes->run(setup->chhandles[i], setup->bufsize);
-        if (setup->ninputs==2) // stereo effect just ran
-            i++;
     }
 
     /* Extract outbufs */


More information about the MPlayer-dev-eng mailing list