FFmpeg
Loading...
Searching...
No Matches
af_join.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19/**
20 * @file
21 * Audio join filter
22 *
23 * Join multiple audio inputs as different channels in
24 * a single output
25 */
26
27#include "libavutil/avassert.h"
28#include "libavutil/avstring.h"
30#include "libavutil/common.h"
31#include "libavutil/mem.h"
32#include "libavutil/opt.h"
33
34#include "audio.h"
35#include "avfilter.h"
36#include "formats.h"
37#include "filters.h"
38
39typedef struct ChannelMap {
40 int input; ///< input stream index
41 int in_channel_idx; ///< index of in_channel in the input stream data
45
46typedef struct JoinContext {
47 const AVClass *class;
48
49 int inputs;
50 char *map;
52
54 int eof;
55
57
58 /**
59 * Temporary storage for input frames, until we get one on each input.
60 */
62
63 /**
64 * Temporary storage for buffer references, for assembling the output frame.
65 */
68
69#define OFFSET(x) offsetof(JoinContext, x)
70#define A AV_OPT_FLAG_AUDIO_PARAM
71#define F AV_OPT_FLAG_FILTERING_PARAM
72static const AVOption join_options[] = {
73 { "inputs", "Number of input streams.", OFFSET(inputs), AV_OPT_TYPE_INT, { .i64 = 2 }, 1, INT_MAX, A|F },
74 { "channel_layout", "Channel layout of the "
75 "output stream.", OFFSET(ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str = "stereo"}, 0, 0, A|F },
76 { "map", "A comma-separated list of channels maps in the format "
77 "'input_stream.input_channel-output_channel.",
78 OFFSET(map), AV_OPT_TYPE_STRING, .flags = A|F },
79 { NULL }
80};
81
82#define MAP_SEPARATOR '|'
83
85
87{
88 JoinContext *s = ctx->priv;
89 char *cur = s->map;
90
91 while (cur && *cur) {
93 char *sep, *next, *p;
94 int input_idx, out_ch_idx;
95
96 next = strchr(cur, MAP_SEPARATOR);
97 if (next)
98 *next++ = 0;
99
100 /* split the map into input and output parts */
101 if (!(sep = strchr(cur, '-'))) {
102 av_log(ctx, AV_LOG_ERROR, "Missing separator '-' in channel "
103 "map '%s'\n", cur);
104 return AVERROR(EINVAL);
105 }
106 *sep++ = 0;
107
108 /* parse output channel */
109 out_ch_idx = av_channel_layout_index_from_string(&s->ch_layout, sep);
110 if (out_ch_idx < 0) {
111 av_log(ctx, AV_LOG_ERROR, "Invalid output channel: %s.\n", sep);
112 return AVERROR(EINVAL);
113 }
114
115 map = &s->channels[out_ch_idx];
116
117 if (map->input >= 0) {
118 av_log(ctx, AV_LOG_ERROR, "Multiple maps for output channel "
119 "'%s'.\n", sep);
120 return AVERROR(EINVAL);
121 }
122
123 /* parse input channel */
124 input_idx = strtol(cur, &cur, 0);
125 if (input_idx < 0 || input_idx >= s->inputs) {
126 av_log(ctx, AV_LOG_ERROR, "Invalid input stream index: %d.\n",
127 input_idx);
128 return AVERROR(EINVAL);
129 }
130
131 if (*cur)
132 cur++;
133
134 map->input = input_idx;
135 map->in_channel = AV_CHAN_NONE;
136 map->in_channel_idx = strtol(cur, &p, 0);
137 if (p == cur) {
138 /* channel specifier is not a number, handle as channel name */
139 map->in_channel = av_channel_from_string(cur);
140 if (map->in_channel < 0) {
141 av_log(ctx, AV_LOG_ERROR, "Invalid input channel: %s.\n", cur);
142 return AVERROR(EINVAL);
143 }
144 } else if (map->in_channel_idx < 0) {
145 av_log(ctx, AV_LOG_ERROR, "Invalid input channel index: %d\n", map->in_channel_idx);
146 return AVERROR(EINVAL);
147 }
148
149 cur = next;
150 }
151 return 0;
152}
153
155{
156 JoinContext *s = ctx->priv;
157 int ret, i;
158
159 s->channels = av_calloc(s->ch_layout.nb_channels, sizeof(*s->channels));
160 s->buffers = av_calloc(s->ch_layout.nb_channels, sizeof(*s->buffers));
161 s->input_frames = av_calloc(s->inputs, sizeof(*s->input_frames));
162 if (!s->channels || !s->buffers|| !s->input_frames)
163 return AVERROR(ENOMEM);
164
165 for (i = 0; i < s->ch_layout.nb_channels; i++) {
166 s->channels[i].out_channel = av_channel_layout_channel_from_index(&s->ch_layout, i);
167 s->channels[i].input = -1;
168 s->channels[i].in_channel_idx = -1;
169 s->channels[i].in_channel = AV_CHAN_NONE;
170 }
171
172 if ((ret = parse_maps(ctx)) < 0)
173 return ret;
174
175 for (i = 0; i < s->inputs; i++) {
176 AVFilterPad pad = { 0 };
177
179 pad.name = av_asprintf("input%d", i);
180 if (!pad.name)
181 return AVERROR(ENOMEM);
182
183 if ((ret = ff_append_inpad_free_name(ctx, &pad)) < 0)
184 return ret;
185 }
186
187 return 0;
188}
189
191{
192 JoinContext *s = ctx->priv;
193 int i;
194
195 for (i = 0; i < s->inputs && s->input_frames; i++) {
196 av_frame_free(&s->input_frames[i]);
197 }
198
199 av_freep(&s->channels);
200 av_freep(&s->buffers);
201 av_freep(&s->input_frames);
202}
203
205 AVFilterFormatsConfig **cfg_in,
206 AVFilterFormatsConfig **cfg_out)
207{
208 const JoinContext *s = ctx->priv;
210 int i, ret;
211
212 if ((ret = ff_add_channel_layout(&layouts, &s->ch_layout)) < 0 ||
213 (ret = ff_channel_layouts_ref(layouts, &cfg_out[0]->channel_layouts)) < 0)
214 return ret;
215
216 for (i = 0; i < ctx->nb_inputs; i++) {
218 if ((ret = ff_channel_layouts_ref(layouts, &cfg_in[i]->channel_layouts)) < 0)
219 return ret;
220 }
221
222 if ((ret = ff_set_common_formats2(ctx, cfg_in, cfg_out, ff_planar_sample_fmts())) < 0)
223 return ret;
224
225 return 0;
226}
227
228typedef struct ChannelList {
230 int nb_ch;
232
233static enum AVChannel channel_list_pop(ChannelList *chl, int idx)
234{
235 enum AVChannel ret = chl->ch[idx];
236 memmove(chl->ch + idx, chl->ch + idx + 1,
237 (chl->nb_ch - idx - 1) * sizeof(*chl->ch));
238 chl->nb_ch--;
239 return ret;
240}
241
242/*
243 * If ch is present in chl, remove it from the list and return it.
244 * Otherwise return AV_CHAN_NONE.
245 */
247{
248 for (int i = 0; i < chl->nb_ch; i++)
249 if (chl->ch[i] == ch)
250 return channel_list_pop(chl, i);
251 return AV_CHAN_NONE;
252}
253
256{
257 int i;
258
259 for (i = 0; i < ctx->nb_inputs; i++) {
261 ch->input = i;
262 ch->in_channel = ch->out_channel;
263 return;
264 }
265 }
266}
267
270{
271 int i;
272
273 for (i = 0; i < ctx->nb_inputs; i++) {
274 if (inputs[i].nb_ch) {
275 ch->input = i;
277 return;
278 }
279 }
280}
281
283{
284 AVFilterContext *ctx = outlink->src;
285 JoinContext *s = ctx->priv;
286 // unused channels from each input
287 ChannelList *inputs_unused;
288 char inbuf[64], outbuf[64];
289 int i, ret = 0;
290
291 /* initialize unused channel list for each input */
292 inputs_unused = av_calloc(ctx->nb_inputs, sizeof(*inputs_unused));
293 if (!inputs_unused)
294 return AVERROR(ENOMEM);
295 for (i = 0; i < ctx->nb_inputs; i++) {
296 AVFilterLink *inlink = ctx->inputs[i];
297 AVChannelLayout *chl = &inlink->ch_layout;
298 ChannelList *iu = &inputs_unused[i];
299
300 iu->nb_ch = chl->nb_channels;
301 iu->ch = av_malloc_array(iu->nb_ch, sizeof(*iu->ch));
302 if (!iu->ch) {
303 ret = AVERROR(ENOMEM);
304 goto fail;
305 }
306
307 for (int ch_idx = 0; ch_idx < iu->nb_ch; ch_idx++) {
308 iu->ch[ch_idx] = av_channel_layout_channel_from_index(chl, ch_idx);
309 if (iu->ch[ch_idx] < 0) {
310 /* no channel ordering information in this input,
311 * so don't auto-map from it */
312 iu->nb_ch = 0;
313 break;
314 }
315 }
316 }
317
318 /* process user-specified maps */
319 for (i = 0; i < s->ch_layout.nb_channels; i++) {
320 ChannelMap *ch = &s->channels[i];
321 AVFilterLink *inlink;
322 AVChannelLayout *ichl;
323 ChannelList *iu;
324
325 if (ch->input < 0)
326 continue;
327
328 inlink = ctx->inputs[ch->input];
329 ichl = &inlink->ch_layout;
330 iu = &inputs_unused[ch->input];
331
332 /* get the index for the channels defined by name */
333 if (ch->in_channel != AV_CHAN_NONE) {
335 if (ch->in_channel_idx < 0) {
336 av_channel_name(inbuf, sizeof(inbuf), ch->in_channel);
337 av_log(ctx, AV_LOG_ERROR, "Requested channel %s is not present in "
338 "input stream #%d.\n", inbuf,
339 ch->input);
340 ret = AVERROR(EINVAL);
341 goto fail;
342 }
343 }
344
345 /* make sure channels specified by index actually exist */
346 if (ch->in_channel_idx >= ichl->nb_channels) {
347 av_log(ctx, AV_LOG_ERROR, "Requested channel with index %d is not "
348 "present in input stream #%d.\n", ch->in_channel_idx, ch->input);
349 ret = AVERROR(EINVAL);
350 goto fail;
351 }
352
354 }
355
356 /* guess channel maps when not explicitly defined */
357 /* first try unused matching channels */
358 for (i = 0; i < s->ch_layout.nb_channels; i++) {
359 ChannelMap *ch = &s->channels[i];
360
361 if (ch->input < 0)
362 guess_map_matching(ctx, ch, inputs_unused);
363 }
364
365 /* if the above failed, try to find _any_ unused input channel */
366 for (i = 0; i < s->ch_layout.nb_channels; i++) {
367 ChannelMap *ch = &s->channels[i];
368
369 if (ch->input < 0)
370 guess_map_any(ctx, ch, inputs_unused);
371
372 if (ch->input < 0) {
373 av_channel_name(outbuf, sizeof(outbuf), ch->out_channel);
374 av_log(ctx, AV_LOG_ERROR, "Could not find input channel for "
375 "output channel '%s'.\n",
376 outbuf);
377 ret = AVERROR(EINVAL);
378 goto fail;
379 }
380
381 if (ch->in_channel != AV_CHAN_NONE) {
383 &ctx->inputs[ch->input]->ch_layout, ch->in_channel);
384 }
385
386 av_assert0(ch->in_channel_idx >= 0);
387 }
388
389 /* print mappings */
390 av_log(ctx, AV_LOG_VERBOSE, "mappings: ");
391 for (i = 0; i < s->ch_layout.nb_channels; i++) {
392 ChannelMap *ch = &s->channels[i];
393 AVFilterLink *inlink = ctx->inputs[ch->input];
394 AVChannelLayout *ichl = &inlink->ch_layout;
396 ichl, ch->in_channel_idx);
397
398 av_channel_name(inbuf, sizeof(inbuf), in_ch);
399 av_channel_name(outbuf, sizeof(outbuf), ch->out_channel);
400 av_log(ctx, AV_LOG_VERBOSE, "%d.%s(%d) => %s(%d) ", ch->input,
401 inbuf, ch->in_channel_idx,
402 outbuf, i);
403 }
404 av_log(ctx, AV_LOG_VERBOSE, "\n");
405
406 for (i = 0; i < ctx->nb_inputs; i++) {
407 if (inputs_unused[i].nb_ch == ctx->inputs[i]->ch_layout.nb_channels)
408 av_log(ctx, AV_LOG_WARNING, "No channels are used from input "
409 "stream %d.\n", i);
410 }
411
412fail:
413 for (i = 0; i < ctx->nb_inputs; i++)
414 av_freep(&inputs_unused[i].ch);
415 av_freep(&inputs_unused);
416 return ret;
417}
418
420{
421 AVFilterLink *outlink = ctx->outputs[0];
422 JoinContext *s = ctx->priv;
423 AVFrame *frame;
424 int linesize = INT_MAX;
425 int nb_samples = INT_MAX;
426 int nb_buffers = 0;
427 int i, j, ret;
428
429 for (i = 0; i < ctx->nb_inputs; i++) {
430 if (!s->input_frames[i]) {
431 nb_samples = 0;
432 break;
433 } else {
434 nb_samples = FFMIN(nb_samples, s->input_frames[i]->nb_samples);
435 }
436 }
437 if (!nb_samples)
438 goto eof;
439
440 /* setup the output frame */
442 if (!frame)
443 return AVERROR(ENOMEM);
444 if (s->ch_layout.nb_channels > FF_ARRAY_ELEMS(frame->data)) {
445 frame->extended_data = av_calloc(s->ch_layout.nb_channels,
446 sizeof(*frame->extended_data));
447 if (!frame->extended_data) {
448 ret = AVERROR(ENOMEM);
449 goto fail;
450 }
451 }
452
453 /* copy the data pointers */
454 for (i = 0; i < s->ch_layout.nb_channels; i++) {
455 ChannelMap *ch = &s->channels[i];
456 AVFrame *cur = s->input_frames[ch->input];
457 AVBufferRef *buf;
458
459 frame->extended_data[i] = cur->extended_data[ch->in_channel_idx];
460 linesize = FFMIN(linesize, cur->linesize[0]);
461
462 /* add the buffer where this plan is stored to the list if it's
463 * not already there */
465 if (!buf) {
466 ret = AVERROR(EINVAL);
467 goto fail;
468 }
469 for (j = 0; j < nb_buffers; j++)
470 if (s->buffers[j]->buffer == buf->buffer)
471 break;
472 if (j == nb_buffers)
473 s->buffers[nb_buffers++] = buf;
474 }
475
476 /* create references to the buffers we copied to output */
477 if (nb_buffers > FF_ARRAY_ELEMS(frame->buf)) {
478 frame->nb_extended_buf = nb_buffers - FF_ARRAY_ELEMS(frame->buf);
479 frame->extended_buf = av_calloc(frame->nb_extended_buf,
480 sizeof(*frame->extended_buf));
481 if (!frame->extended_buf) {
482 frame->nb_extended_buf = 0;
483 ret = AVERROR(ENOMEM);
484 goto fail;
485 }
486 }
487 for (i = 0; i < FFMIN(FF_ARRAY_ELEMS(frame->buf), nb_buffers); i++) {
488 frame->buf[i] = av_buffer_ref(s->buffers[i]);
489 if (!frame->buf[i]) {
490 ret = AVERROR(ENOMEM);
491 goto fail;
492 }
493 }
494 for (i = 0; i < frame->nb_extended_buf; i++) {
495 frame->extended_buf[i] = av_buffer_ref(s->buffers[i +
496 FF_ARRAY_ELEMS(frame->buf)]);
497 if (!frame->extended_buf[i]) {
498 ret = AVERROR(ENOMEM);
499 goto fail;
500 }
501 }
502
503 frame->nb_samples = nb_samples;
504 frame->duration = av_rescale_q(frame->nb_samples,
505 av_make_q(1, outlink->sample_rate),
506 outlink->time_base);
507
508 if ((ret = av_channel_layout_copy(&frame->ch_layout, &outlink->ch_layout)) < 0)
509 goto fail;
510 frame->sample_rate = outlink->sample_rate;
511 frame->format = outlink->format;
512 frame->pts = s->input_frames[0]->pts;
513 frame->linesize[0] = linesize;
514 if (frame->data != frame->extended_data) {
515 memcpy(frame->data, frame->extended_data, sizeof(*frame->data) *
516 FFMIN(FF_ARRAY_ELEMS(frame->data), s->ch_layout.nb_channels));
517 }
518
519 s->eof_pts = frame->pts + av_rescale_q(frame->nb_samples,
520 av_make_q(1, outlink->sample_rate),
521 outlink->time_base);
522 ret = ff_filter_frame(outlink, frame);
523
524 for (i = 0; i < ctx->nb_inputs; i++)
525 av_frame_free(&s->input_frames[i]);
526
527 return ret;
528
529fail:
531 return ret;
532eof:
533 for (i = 0; i < ctx->nb_inputs; i++) {
534 if (s->eof &&
535 ff_inlink_queued_samples(ctx->inputs[i]) <= 0 &&
536 !s->input_frames[i]) {
537 ff_outlink_set_status(outlink, AVERROR_EOF, s->eof_pts);
538 break;
539 }
540 }
541
542 return 0;
543}
544
546{
547 JoinContext *s = ctx->priv;
548 int i, ret, status;
549 int nb_samples = 0;
550 int64_t pts;
551
553
554 if (!s->input_frames[0]) {
555 ret = ff_inlink_consume_frame(ctx->inputs[0], &s->input_frames[0]);
556 if (ret < 0) {
557 return ret;
558 } else if (ret == 0 && ff_inlink_acknowledge_status(ctx->inputs[0], &status, &pts)) {
559 s->eof |= status == AVERROR_EOF;
560 }
561
562 if (!s->eof && !s->input_frames[0] && ff_outlink_frame_wanted(ctx->outputs[0])) {
563 ff_inlink_request_frame(ctx->inputs[0]);
564 return 0;
565 }
566 }
567
568 if (s->input_frames[0])
569 nb_samples = s->input_frames[0]->nb_samples;
570
571 for (i = 1; i < ctx->nb_inputs && nb_samples > 0; i++) {
572 if (s->input_frames[i])
573 continue;
574 ret = ff_inlink_consume_samples(ctx->inputs[i], nb_samples, nb_samples, &s->input_frames[i]);
575 if (ret < 0) {
576 return ret;
577 } else if (ff_inlink_acknowledge_status(ctx->inputs[i], &status, &pts)) {
578 s->eof |= status == AVERROR_EOF;
579 }
580
581 if (!s->eof && !s->input_frames[i]) {
582 ff_inlink_request_frame(ctx->inputs[i]);
583 return 0;
584 }
585 }
586
587 return try_push_frame(ctx);
588}
589
591 {
592 .name = "default",
593 .type = AVMEDIA_TYPE_AUDIO,
594 .config_props = join_config_output,
595 },
596};
597
599 .p.name = "join",
600 .p.description = NULL_IF_CONFIG_SMALL("Join multiple audio streams into "
601 "multi-channel output."),
602 .p.priv_class = &join_class,
604 .priv_size = sizeof(JoinContext),
605 .init = join_init,
610};
static const AVFilterPad inputs[]
Definition af_aap.c:299
static int join_query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition af_join.c:204
static enum AVChannel channel_list_pop_ch(ChannelList *chl, enum AVChannel ch)
Definition af_join.c:246
static void guess_map_matching(AVFilterContext *ctx, ChannelMap *ch, ChannelList *inputs)
Definition af_join.c:254
static int parse_maps(AVFilterContext *ctx)
Definition af_join.c:86
static enum AVChannel channel_list_pop(ChannelList *chl, int idx)
Definition af_join.c:233
static int join_config_output(AVFilterLink *outlink)
Definition af_join.c:282
static void guess_map_any(AVFilterContext *ctx, ChannelMap *ch, ChannelList *inputs)
Definition af_join.c:268
static const AVOption join_options[]
Definition af_join.c:72
static av_cold void join_uninit(AVFilterContext *ctx)
Definition af_join.c:190
const FFFilter ff_af_join
Definition af_join.c:598
static const AVFilterPad avfilter_af_join_outputs[]
Definition af_join.c:590
static int activate(AVFilterContext *ctx)
Definition af_join.c:545
#define MAP_SEPARATOR
Definition af_join.c:82
#define OFFSET(x)
Definition af_join.c:69
static int try_push_frame(AVFilterContext *ctx)
Definition af_join.c:419
static av_cold int join_init(AVFilterContext *ctx)
Definition af_join.c:154
#define A(x)
Definition vpx_arith.h:28
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
Definition avfilter.c:132
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition avfilter.c:1467
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
Definition avfilter.c:1690
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
Definition avfilter.c:1540
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition avfilter.c:1520
int ff_inlink_queued_samples(AVFilterLink *link)
Definition avfilter.c:1495
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition avfilter.c:1623
Main libavfilter public API header.
char * av_asprintf(const char *fmt,...)
Definition avstring.c:115
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
Public libavutil channel layout APIs header.
common internal and external API header
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
static const uint16_t channel_layouts[7]
Definition dca_lbr.c:112
static AVFrame * frame
#define F(x)
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
AVFilterChannelLayouts * ff_all_channel_layouts(void)
Construct an empty AVFilterChannelLayouts/AVFilterFormats struct – representing any channel layout (w...
Definition formats.c:679
int ff_set_common_formats2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, AVFilterFormats *formats)
Definition formats.c:1137
AVFilterFormats * ff_planar_sample_fmts(void)
Construct a formats list containing all planar sample formats.
Definition formats.c:660
int ff_add_channel_layout(AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout)
Definition formats.c:588
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition formats.c:751
#define fail
Definition test.h:479
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
Definition opt.h:330
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition avfilter.h:155
int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout, enum AVChannel channel)
Get the index of a given channel in a channel layout.
int av_channel_layout_index_from_string(const AVChannelLayout *channel_layout, const char *str)
Get the index in a channel layout of a channel described by the given string.
int av_channel_name(char *buf, size_t buf_size, enum AVChannel channel_id)
Get a human readable string in an abbreviated form describing a given channel.
enum AVChannel av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx)
Get the channel with the given index in a channel layout.
AVChannel
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
enum AVChannel av_channel_from_string(const char *str)
This is the inverse function of av_channel_name().
@ AV_CHAN_NONE
Invalid channel index.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition buffer.c:103
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition frame.c:52
AVBufferRef * av_frame_get_plane_buffer(const AVFrame *frame, int plane)
Get the buffer reference a given data plane is stored in.
Definition frame.c:604
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition rational.h:71
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
const VDPAUPixFmtMap * map
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_OUTPUTS(array)
Definition filters.h:265
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition filters.h:629
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
Definition filters.h:652
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:478
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define av_cold
Definition attributes.h:117
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
#define FFMIN(a, b)
Definition macros.h:49
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:264
Memory handling functions.
enum MovChannelLayoutTag * layouts
Definition mov_chan.c:335
AVOptions.
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
Definition buffer.h:82
AVBuffer * buffer
Definition buffer.h:83
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
Definition log.h:76
A list of supported channel layouts.
Definition formats.h:85
An instance of a filter.
Definition avfilter.h:273
Lists of formats / etc.
Definition avfilter.h:120
A filter pad used for either input or output.
Definition filters.h:40
enum AVMediaType type
AVFilterPad type.
Definition filters.h:51
const char * name
Pad name.
Definition filters.h:46
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition frame.h:517
uint8_t ** extended_data
pointers to the data planes/channels.
Definition frame.h:533
AVOption.
Definition opt.h:428
enum AVChannel * ch
Definition af_join.c:229
int in_channel_idx
index of in_channel in the input stream data
int input
input stream index
Definition af_join.c:40
AVBufferRef ** buffers
Temporary storage for buffer references, for assembling the output frame.
Definition af_join.c:66
int64_t eof_pts
Definition af_join.c:53
AVFrame ** input_frames
Temporary storage for input frames, until we get one on each input.
Definition af_join.c:61
ChannelMap * channels
Definition af_join.c:56
char * map
Definition af_join.c:50
AVChannelLayout ch_layout
Definition af_join.c:51
int inputs
Definition af_join.c:49
#define av_malloc_array(a, b)
#define av_freep(p)
#define av_log(a,...)
static AVFormatContext * ctx
Definition movenc.c:49
static int64_t pts