[MPlayer-dev-eng] [BUG] in pan filter
Artem Astafyev
ace at insurer.com.ua
Thu Jul 15 11:28:18 CEST 2004
I'm trying to make 6 channel audio from ordinary stereo track with pan
filter. According to documentation I do such thing:
mplayer -ao alsa9:surround51 -af pan=6:1:0:0:1:1:0:0:1:0.5:0.5,sub -v
-channels 6 movie.avi
Checking audio filter chain for 48000Hz/2ch/16bit -> 48000Hz/6ch/16bit...
[libaf] Adding filter pan
[pan] Pan level from channel 0 to channel 0 = 1.000000
[pan] Pan level from channel 1 to channel 0 = 0.000000
[pan] Pan level from channel 2 to channel 0 = 0.000000
[pan] Pan level from channel 3 to channel 0 = 1.000000
[pan] Pan level from channel 4 to channel 0 = 1.000000
[pan] Pan level from channel 5 to channel 0 = 0.000000
[pan] Pan level from channel 0 to channel 1 = 0.000000
[pan] Pan level from channel 1 to channel 1 = 1.000000
[pan] Pan level from channel 2 to channel 1 = 0.500000
[pan] Pan level from channel 3 to channel 1 = 0.500000
[libaf] Adding filter sub
[libaf] Adding filter format
But as we see signal routing is strange, not as I'm expecting. Then I try:
mplayer -ao alsa9:surround51 -af pan=2:1:0:0:1:1:0:0:1:0.5:0.5,sub -v
-channels 6
Checking audio filter chain for 48000Hz/2ch/16bit -> 48000Hz/6ch/16bit...
[libaf] Adding filter pan
[pan] Pan level from channel 0 to channel 0 = 1.000000
[pan] Pan level from channel 1 to channel 0 = 0.000000
[pan] Pan level from channel 0 to channel 1 = 0.000000
[pan] Pan level from channel 1 to channel 1 = 1.000000
[pan] Pan level from channel 0 to channel 2 = 1.000000
[pan] Pan level from channel 1 to channel 2 = 0.000000
[pan] Pan level from channel 0 to channel 3 = 0.000000
[pan] Pan level from channel 1 to channel 3 = 1.000000
[pan] Pan level from channel 0 to channel 4 = 0.500000
[pan] Pan level from channel 1 to channel 4 = 0.500000
[libaf] Adding filter sub
[libaf] Adding filter format
[format] Changing sample format from 16bit little endian signed int to
32bit little endian float
[libaf] Adding filter channels
[channels] Changing number of channels to 6
Exactly what I need. So, first number after pan filter is not a number
of output channels as stated in docs, but number of input channels.
So, I looked up in code (af_pan.c):
static int control(struct af_instance_s* af, int cmd, void* arg)
.....
while((*cp == ':') && (k < AF_NCH)){
sscanf(cp, ":%f%n" , &s->level[k][j], &n);
s->level[k][j] = clamp(s->level[k][j],0.0,1.0);
af_msg(AF_MSG_VERBOSE,"[pan] Pan level from channel %i to"
" channel %i = %f\n",j,k,s->level[k][j]);
cp =&cp[n];
j++;
if(j>=nch){
j = 0;
k++;
}
}
...
As we see j is used as second array index and increments up to nch which
is number of OUTPUT channels. Let's see play function:
.....
int nchi = c->nch; // Number of input channels
.....
while(in < end){
for(j=0;j<ncho;j++){
register float x = 0.0;
register float* tin = in;
for(k=0;k<nchi;k++)
x += tin[k] * s->level[j][k];
out[j] = x;
}
out+= ncho;
in+= nchi;
}
Here k is used as second array index and increments up to nchi, which is
number od INPUT channels.
So, "nature" test with mplayer given above shows the same.
Maybe I'm missing something?
--
Best regards,
Artem Astafyev
More information about the MPlayer-dev-eng
mailing list