40 #define MAX_CHANNELS 63
61 sscanf(*arg,
" %n", &len);
68 int len, i, channel_id = 0;
73 if (sscanf(*arg,
"%7[A-Z]%n", buf, &len)) {
76 for (i = 32; i > 0; i >>= 1) {
77 if (layout >= (int64_t)1 << i) {
83 if (channel_id >=
MAX_CHANNELS || layout0 != (int64_t)1 << channel_id)
85 *rchannel = channel_id;
91 if (sscanf(*arg,
"c%d%n", &channel_id, &len) &&
93 *rchannel = channel_id;
105 int out_ch_id, in_ch_id,
len, named,
ret;
106 int nb_in_channels[2] = { 0, 0 };
111 "pan filter needs a channel layout and a set "
112 "of channels definitions as parameter\n");
124 while ((arg = arg0 =
av_strtok(NULL,
"|", &tokenizer))) {
128 "Expected out channel name, got \"%.8s\"\n", arg);
135 "Channel \"%.8s\" does not exist in the chosen layout\n", arg0);
147 "Invalid out channel name \"%.8s\"\n", arg0);
154 }
else if (*arg ==
'<') {
159 "Syntax error after channel name in \"%.8s\"\n", arg0);
166 if (sscanf(arg,
"%lf%n *%n", &gain, &len, &len))
170 "Expected in channel name, got \"%.8s\"\n", arg);
174 nb_in_channels[named]++;
175 if (nb_in_channels[!named]) {
177 "Can not mix named and numbered channels\n");
181 pan->
gain[out_ch_id][in_ch_id] = gain;
209 double gain = pan->
gain[i][j];
213 if (gain != 0. && gain != 1.)
216 if (gain && nb_gain++)
257 char buf[1024], *cur;
277 "af_pan support a maximum of %d channels. "
278 "Feel free to ask for a higher limit.\n",
MAX_CHANNELS);
304 for (j = 0; j < link->
channels; j++) {
305 if (pan->
gain[i][j]) {
322 for (j = 0; j < link->
channels; j++)
323 t += pan->
gain[i][j];
324 if (t > -1
E-5 && t < 1
E-5) {
328 "Degenerate coefficients while renormalizing\n");
331 for (j = 0; j < link->
channels; j++)
332 pan->
gain[i][j] /= t;
346 for (j = 0; j < link->
channels; j++) {
347 r =
snprintf(cur, buf +
sizeof(buf) - cur,
"%s%.3g i%d",
348 j ?
" + " :
"", pan->
gain[i][j], j);
349 cur +=
FFMIN(buf +
sizeof(buf) - cur, r);
394 #define OFFSET(x) offsetof(PanContext, x)
425 .priv_class = &pan_class,