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;
228 int nb_samples, ns, i;
232 for (input_number = 0; input_number < am->
nb_inputs; input_number++)
233 if (inlink == ctx->
inputs[input_number])
252 outs = outbuf->
data[0];
255 ins[i] = inbuf[i]->
data[0] +
263 ctx->outputs[0]->time_base);
265 outbuf->nb_samples = nb_samples;
266 outbuf->channel_layout = outlink->channel_layout;
271 for (i = 0; i < am->nb_inputs; i++)
272 ns =
FFMIN(ns, inbuf[i]->nb_samples - am->in[i].pos);
277 copy_samples(am->nb_inputs, am->in, am->route, ins, &outs, ns, 1);
280 copy_samples(am->nb_inputs, am->in, am->route, ins, &outs, ns, 2);
283 copy_samples(am->nb_inputs, am->in, am->route, ins, &outs, ns, 4);
286 copy_samples(am->nb_inputs, am->in, am->route, ins, &outs, ns, am->bps);
291 for (i = 0; i < am->nb_inputs; i++) {
292 am->in[i].nb_samples -= ns;
294 if (am->in[i].pos == inbuf[i]->nb_samples) {
299 ins[i] = inbuf[i] ? inbuf[i]->data[0] : NULL;
341 "a single multi-channel stream."),
348 .priv_class = &amerge_class,