[MPlayer-dev-eng] [PATCH] Automatic downmix

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Sep 25 12:54:16 CEST 2010


On Sat, Sep 25, 2010 at 11:57:21AM +0200, Clément Bœsch wrote:
> On Fri, Sep 24, 2010 at 07:20:32PM +0200, Reimar Döffinger wrote:
> > On Thu, Sep 23, 2010 at 11:57:26PM +0200, Clément Bœsch wrote:
> > > +    static char * const downmix_strs[AF_NCH + 1] = {
> > 
> > static const char * const
> > 
> > > +    char *af_pan_str = downmix_strs[s->first->data->nch];
> > 
> > const char *
> > 
> 
> That would require a modification of the prototypes of af_{ap,pre}pend
> first, should I include it in the patch?

Already applied.
Just not adding const here is very much the wrong solution,
if af_append/af_prepend actually modified it, this way would
still crash.

> > > @@ -437,7 +456,8 @@
> > >      s->cfg.force = (s->cfg.force & ~AF_INIT_TYPE_MASK) | AF_INIT_TYPE;
> > >  
> > >    // Check if this is the first call
> > > -  if(!s->first){
> > > +  first_run = !s->first;
> > > +  if(first_run){
> > >      // Add all filters in the list (if there are any)
> > >      if(!s->cfg.list){      // To make automatic format conversion work
> > >        if(!af_append(s,s->first,"dummy"))
> > > @@ -460,6 +480,13 @@
> > >      if (!af_append(s,s->first,"dummy") || AF_OK != af_reinit(s,s->first))
> > >        return -1;
> > >  
> > > +  // Append a downmix pan filter at the beginning of the chain if needed
> > > +  if (first_run && audio_output_channels == 2) {
> > > +    af_instance_t *filter = af_downmix(s);
> > > +    if (filter && AF_OK != af_reinit(s, filter))
> > > +      return -1;
> > > +  }
> > 
> > Wouldn't it make more sense to move this into the existing
> > > if(!s->first)
> > above,
> 
> I thought about that, but I'm not sure we enter in that condition
> everytime; the first "if(!s->first)" condition seems the more reliable
> "first call" condition. I don't understand what the second one is for
> (what is AF_DETACH?).

I meant the first one.
And AF_DETACH allows a filter to remove itself if it thinks it serves
no purpose (e.g. a resampling filter with the same input and output
sample rate).

> > use af_append to put it first in the chain
> 
> Append? why?

Because all of the code around there uses af_append
and builds the filter chain front to end. Adding a
single case where it does things the other way can't
do any good.


More information about the MPlayer-dev-eng mailing list