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

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri Sep 24 19:20:32 CEST 2010


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 *

> @@ -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, use af_append to put it first in the chain
and of course change the condition to
> if (s->input.nch != audio_output_channels && audio_output_channels == 2)
(the == 2 part only because other downmixing is not
supported, should not be hard to also add
downmixing to 1 channel if desired).


More information about the MPlayer-dev-eng mailing list