[MPlayer-dev-eng] [PATCH] af_pan.c: Avoid zero output channels when reinit af pan

Zuxy Meng zuxy.meng at gmail.com
Mon Jun 11 02:32:22 CEST 2007


Hi,

2007/6/11, Zuxy Meng <zuxy.meng at gmail.com>:
> Hi,
>
> 2007/6/11, Reimar Doeffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> > Hello,
> > On Sun, Jun 10, 2007 at 07:16:23PM +0200, Reimar Doeffinger wrote:
> > > On Sun, Jun 10, 2007 at 07:04:57PM +0800, Zuxy Meng wrote:
> > > [...]
> > > > I got tired about this issue.  All I want is an audio filter used for
> > > > balancing that can be 'af_add()'ed at runtime and doesn't alter the #
> > > > of channels before and after it. If one day you come up with an ideal
> > > > solution, pls kindly ping me.
> > >
> > > You'd only have to add nch to af_pan_t, set that in the comamndline
> > > control and on reinit read it end set af->data->nch to it if it's
> > > non-zero or to the current number of channels otherwise.
> >
> > As in attached patch. As my development machines are all dead currently
> > I can't test beyond compilation.
> > If it is somehow possible to use this feature from the command line it
> > should be documented, too.
>
> Looks pretty good. But if s->nch, maybe we shouldn't call
> control(af,AF_CONTROL_PAN_NOUT | AF_CONTROL_SET...) in REINIT any
> more.

What I mean is in the patch: once the user has requested the # of
output explicitly, either thru command line or AF_CONTROL_PAN_NOUT,
that number is remembered across reinit (stored in s->nch); otherwise
pan won't alter the # of channels.

Just one tiny question: should AF_CONTROL_NOUT|AF_CONTROL_GET return
af->data->nch or s->nch?
-- 
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6
-------------- next part --------------
Index: libaf/af_pan.c
===================================================================
--- libaf/af_pan.c	?????? 23533??
+++ libaf/af_pan.c	????????????
@@ -22,6 +22,7 @@
 // Data for specific instances of this filter
 typedef struct af_pan_s
 {
+  int nch; // Number of output channels; zero means same as input
   float level[AF_NCH][AF_NCH];	// Gain level for each channel
 }af_pan_t;
 
@@ -38,6 +39,7 @@
     af->data->rate   = ((af_data_t*)arg)->rate;
     af->data->format = AF_FORMAT_FLOAT_NE;
     af->data->bps    = 4;
+    af->data->nch    = s->nch ? s->nch: ((af_data_t*)arg)->nch;
     af->mul.n        = af->data->nch;
     af->mul.d	     = ((af_data_t*)arg)->nch;
     af_frac_cancel(&af->mul);
@@ -48,7 +50,11 @@
       ((af_data_t*)arg)->bps = af->data->bps;
       return AF_FALSE;
     }
-    return control(af,AF_CONTROL_PAN_NOUT | AF_CONTROL_SET, &af->data->nch);
+
+    if (s->nch)
+      return control(af,AF_CONTROL_PAN_NOUT | AF_CONTROL_SET, &af->data->nch);
+    else
+      return AF_OK;
   case AF_CONTROL_COMMAND_LINE:{
     int   nch = 0;
     int   n = 0;
@@ -104,7 +110,7 @@
 	     " between 1 and %i. Current value is %i\n",AF_NCH,((int*)arg)[0]);
       return AF_ERROR;
     }
-    af->data->nch=((int*)arg)[0];
+    s->nch=af->data->nch=((int*)arg)[0];
     return AF_OK;
   case AF_CONTROL_PAN_NOUT | AF_CONTROL_GET:
     *(int*)arg = af->data->nch;


More information about the MPlayer-dev-eng mailing list