49 #define OFFSET(x) offsetof(AMergeContext, x)
50 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
53 {
"inputs",
"specify the number of inputs",
OFFSET(nb_inputs),
80 int i, overlap = 0, nb_ch = 0;
86 "No channel layout for input %d\n", i + 1);
96 if (outlayout & inlayout[i])
98 outlayout |= inlayout[i];
107 "Input channel layouts overlap: "
108 "output layout will be determined by the number of distinct input channels\n");
109 for (i = 0; i < nb_ch; i++)
113 outlayout = ((int64_t)1 << nb_ch) - 1;
116 int c, out_ch_number = 0;
118 route[0] = am->
route;
120 route[i] = route[i - 1] + am->
in[i - 1].
nb_ch;
121 for (c = 0; c < 64; c++)
123 if ((inlayout[i] >> c) & 1)
124 *(route[i]++) = out_ch_number++;
150 "Inputs must have the same sample rate "
151 "%d for in%d vs %d\n",
162 av_bprintf(&bp,
"%sin%d:", i ?
" + " :
"", i);
208 for (i = 0; i < nb_inputs; i++)
209 nb_ch += in[i].nb_ch;
212 for (i = 0; i < nb_inputs; i++) {
213 for (c = 0; c < in[i].nb_ch; c++) {
214 memcpy((*outs) + bps * *(route_cur++), ins[i], bps);
218 *outs += nb_ch *
bps;
232 for (input_number = 0; input_number < am->
nb_inputs; input_number++)
233 if (inlink == ctx->
inputs[input_number])
250 outs = outbuf->
data[0];
253 ins[i] = inbuf[i]->
data[0] +
261 ctx->outputs[0]->time_base);
264 outbuf->audio->channel_layout = outlink->channel_layout;
265 outbuf->audio->channels = outlink->channels;
269 for (i = 0; i < am->nb_inputs; i++)
270 ns =
FFMIN(ns, inbuf[i]->audio->nb_samples - am->in[i].pos);
275 copy_samples(am->nb_inputs, am->in, am->route, ins, &outs, ns, 1);
278 copy_samples(am->nb_inputs, am->in, am->route, ins, &outs, ns, 2);
281 copy_samples(am->nb_inputs, am->in, am->route, ins, &outs, ns, 4);
284 copy_samples(am->nb_inputs, am->in, am->route, ins, &outs, ns, am->bps);
289 for (i = 0; i < am->nb_inputs; i++) {
290 am->in[i].nb_samples -= ns;
292 if (am->in[i].pos == inbuf[i]->audio->nb_samples) {
297 ins[i] = inbuf[i] ? inbuf[i]->data[0] :
NULL;
309 am->
class = &amerge_class;
347 "a single multi-channel stream."),
354 .priv_class = &amerge_class,