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

Clément Bœsch ubitux at gmail.com
Sat Sep 25 11:57:21 CEST 2010


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?

> > @@ -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?).

> use af_append to put it first in the chain

Append? why?

> and of course change the condition to
> > if (s->input.nch != audio_output_channels && audio_output_channels == 2)

Ok, I'll do that

> (the == 2 part only because other downmixing is not
> supported, should not be hard to also add
> downmixing to 1 channel if desired).

Yeah I wasn't going to drop the audio_output_channels == 2 already
present.

-- 
Clément B.


More information about the MPlayer-dev-eng mailing list