af_join.c
Go to the documentation of this file.
1 /*
2  *
3  * This file is part of Libav.
4  *
5  * Libav is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * Libav is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with Libav; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 /**
21  * @file
22  * Audio join filter
23  *
24  * Join multiple audio inputs as different channels in
25  * a single output
26  */
27 
28 #include "libavutil/avassert.h"
30 #include "libavutil/common.h"
31 #include "libavutil/opt.h"
32 
33 #include "audio.h"
34 #include "avfilter.h"
35 #include "formats.h"
36 #include "internal.h"
37 
38 typedef struct ChannelMap {
39  int input; ///< input stream index
40  int in_channel_idx; ///< index of in_channel in the input stream data
41  uint64_t in_channel; ///< layout describing the input channel
42  uint64_t out_channel; ///< layout describing the output channel
43 } ChannelMap;
44 
45 typedef struct JoinContext {
46  const AVClass *class;
47 
48  int inputs;
49  char *map;
51  uint64_t channel_layout;
52 
55 
56  /**
57  * Temporary storage for input frames, until we get one on each input.
58  */
60 
61  /**
62  * Temporary storage for buffer references, for assembling the output frame.
63  */
65 } JoinContext;
66 
67 #define OFFSET(x) offsetof(JoinContext, x)
68 #define A AV_OPT_FLAG_AUDIO_PARAM
69 #define F AV_OPT_FLAG_FILTERING_PARAM
70 static const AVOption join_options[] = {
71  { "inputs", "Number of input streams.", OFFSET(inputs), AV_OPT_TYPE_INT, { .i64 = 2 }, 1, INT_MAX, A|F },
72  { "channel_layout", "Channel layout of the "
73  "output stream.", OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, {.str = "stereo"}, 0, 0, A|F },
74  { "map", "A comma-separated list of channels maps in the format "
75  "'input_stream.input_channel-output_channel.",
76  OFFSET(map), AV_OPT_TYPE_STRING, .flags = A|F },
77  { NULL },
78 };
79 
80 static const AVClass join_class = {
81  .class_name = "join filter",
82  .item_name = av_default_item_name,
83  .option = join_options,
84  .version = LIBAVUTIL_VERSION_INT,
85 };
86 
88 {
89  AVFilterContext *ctx = link->dst;
90  JoinContext *s = ctx->priv;
91  int i;
92 
93  for (i = 0; i < ctx->nb_inputs; i++)
94  if (link == ctx->inputs[i])
95  break;
96  av_assert0(i < ctx->nb_inputs);
97  av_assert0(!s->input_frames[i]);
98  s->input_frames[i] = frame;
99 
100  return 0;
101 }
102 
103 static int parse_maps(AVFilterContext *ctx)
104 {
105  JoinContext *s = ctx->priv;
106  char separator = '|';
107  char *cur = s->map;
108 
109 #if FF_API_OLD_FILTER_OPTS
110  if (cur && strchr(cur, ',')) {
111  av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use '|' to "
112  "separate the mappings.\n");
113  separator = ',';
114  }
115 #endif
116 
117  while (cur && *cur) {
118  char *sep, *next, *p;
119  uint64_t in_channel = 0, out_channel = 0;
120  int input_idx, out_ch_idx, in_ch_idx;
121 
122  next = strchr(cur, separator);
123  if (next)
124  *next++ = 0;
125 
126  /* split the map into input and output parts */
127  if (!(sep = strchr(cur, '-'))) {
128  av_log(ctx, AV_LOG_ERROR, "Missing separator '-' in channel "
129  "map '%s'\n", cur);
130  return AVERROR(EINVAL);
131  }
132  *sep++ = 0;
133 
134 #define PARSE_CHANNEL(str, var, inout) \
135  if (!(var = av_get_channel_layout(str))) { \
136  av_log(ctx, AV_LOG_ERROR, "Invalid " inout " channel: %s.\n", str);\
137  return AVERROR(EINVAL); \
138  } \
139  if (av_get_channel_layout_nb_channels(var) != 1) { \
140  av_log(ctx, AV_LOG_ERROR, "Channel map describes more than one " \
141  inout " channel.\n"); \
142  return AVERROR(EINVAL); \
143  }
144 
145  /* parse output channel */
146  PARSE_CHANNEL(sep, out_channel, "output");
147  if (!(out_channel & s->channel_layout)) {
148  av_log(ctx, AV_LOG_ERROR, "Output channel '%s' is not present in "
149  "requested channel layout.\n", sep);
150  return AVERROR(EINVAL);
151  }
152 
154  out_channel);
155  if (s->channels[out_ch_idx].input >= 0) {
156  av_log(ctx, AV_LOG_ERROR, "Multiple maps for output channel "
157  "'%s'.\n", sep);
158  return AVERROR(EINVAL);
159  }
160 
161  /* parse input channel */
162  input_idx = strtol(cur, &cur, 0);
163  if (input_idx < 0 || input_idx >= s->inputs) {
164  av_log(ctx, AV_LOG_ERROR, "Invalid input stream index: %d.\n",
165  input_idx);
166  return AVERROR(EINVAL);
167  }
168 
169  if (*cur)
170  cur++;
171 
172  in_ch_idx = strtol(cur, &p, 0);
173  if (p == cur) {
174  /* channel specifier is not a number,
175  * try to parse as channel name */
176  PARSE_CHANNEL(cur, in_channel, "input");
177  }
178 
179  s->channels[out_ch_idx].input = input_idx;
180  if (in_channel)
181  s->channels[out_ch_idx].in_channel = in_channel;
182  else
183  s->channels[out_ch_idx].in_channel_idx = in_ch_idx;
184 
185  cur = next;
186  }
187  return 0;
188 }
189 
190 static int join_init(AVFilterContext *ctx)
191 {
192  JoinContext *s = ctx->priv;
193  int ret, i;
194 
196  av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout '%s'.\n",
197  s->channel_layout_str);
198  ret = AVERROR(EINVAL);
199  goto fail;
200  }
201 
203  s->channels = av_mallocz(sizeof(*s->channels) * s->nb_channels);
204  s->buffers = av_mallocz(sizeof(*s->buffers) * s->nb_channels);
205  s->input_frames = av_mallocz(sizeof(*s->input_frames) * s->inputs);
206  if (!s->channels || !s->buffers|| !s->input_frames) {
207  ret = AVERROR(ENOMEM);
208  goto fail;
209  }
210 
211  for (i = 0; i < s->nb_channels; i++) {
213  s->channels[i].input = -1;
214  }
215 
216  if ((ret = parse_maps(ctx)) < 0)
217  goto fail;
218 
219  for (i = 0; i < s->inputs; i++) {
220  char name[32];
221  AVFilterPad pad = { 0 };
222 
223  snprintf(name, sizeof(name), "input%d", i);
224  pad.type = AVMEDIA_TYPE_AUDIO;
225  pad.name = av_strdup(name);
227 
228  pad.needs_fifo = 1;
229 
230  ff_insert_inpad(ctx, i, &pad);
231  }
232 
233 fail:
234  av_opt_free(s);
235  return ret;
236 }
237 
238 static void join_uninit(AVFilterContext *ctx)
239 {
240  JoinContext *s = ctx->priv;
241  int i;
242 
243  for (i = 0; i < ctx->nb_inputs; i++) {
244  av_freep(&ctx->input_pads[i].name);
245  av_frame_free(&s->input_frames[i]);
246  }
247 
248  av_freep(&s->channels);
249  av_freep(&s->buffers);
250  av_freep(&s->input_frames);
251 }
252 
254 {
255  JoinContext *s = ctx->priv;
257  int i;
258 
261 
262  for (i = 0; i < ctx->nb_inputs; i++)
264  &ctx->inputs[i]->out_channel_layouts);
265 
268 
269  return 0;
270 }
271 
273  uint64_t *inputs)
274 {
275  int i;
276 
277  for (i = 0; i < ctx->nb_inputs; i++) {
278  AVFilterLink *link = ctx->inputs[i];
279 
280  if (ch->out_channel & link->channel_layout &&
281  !(ch->out_channel & inputs[i])) {
282  ch->input = i;
283  ch->in_channel = ch->out_channel;
284  inputs[i] |= ch->out_channel;
285  return;
286  }
287  }
288 }
289 
291  uint64_t *inputs)
292 {
293  int i;
294 
295  for (i = 0; i < ctx->nb_inputs; i++) {
296  AVFilterLink *link = ctx->inputs[i];
297 
298  if ((inputs[i] & link->channel_layout) != link->channel_layout) {
299  uint64_t unused = link->channel_layout & ~inputs[i];
300 
301  ch->input = i;
303  inputs[i] |= ch->in_channel;
304  return;
305  }
306  }
307 }
308 
309 static int join_config_output(AVFilterLink *outlink)
310 {
311  AVFilterContext *ctx = outlink->src;
312  JoinContext *s = ctx->priv;
313  uint64_t *inputs; // nth element tracks which channels are used from nth input
314  int i, ret = 0;
315 
316  /* initialize inputs to user-specified mappings */
317  if (!(inputs = av_mallocz(sizeof(*inputs) * ctx->nb_inputs)))
318  return AVERROR(ENOMEM);
319  for (i = 0; i < s->nb_channels; i++) {
320  ChannelMap *ch = &s->channels[i];
321  AVFilterLink *inlink;
322 
323  if (ch->input < 0)
324  continue;
325 
326  inlink = ctx->inputs[ch->input];
327 
328  if (!ch->in_channel)
330  ch->in_channel_idx);
331 
332  if (!(ch->in_channel & inlink->channel_layout)) {
333  av_log(ctx, AV_LOG_ERROR, "Requested channel %s is not present in "
334  "input stream #%d.\n", av_get_channel_name(ch->in_channel),
335  ch->input);
336  ret = AVERROR(EINVAL);
337  goto fail;
338  }
339 
340  inputs[ch->input] |= ch->in_channel;
341  }
342 
343  /* guess channel maps when not explicitly defined */
344  /* first try unused matching channels */
345  for (i = 0; i < s->nb_channels; i++) {
346  ChannelMap *ch = &s->channels[i];
347 
348  if (ch->input < 0)
349  guess_map_matching(ctx, ch, inputs);
350  }
351 
352  /* if the above failed, try to find _any_ unused input channel */
353  for (i = 0; i < s->nb_channels; i++) {
354  ChannelMap *ch = &s->channels[i];
355 
356  if (ch->input < 0)
357  guess_map_any(ctx, ch, inputs);
358 
359  if (ch->input < 0) {
360  av_log(ctx, AV_LOG_ERROR, "Could not find input channel for "
361  "output channel '%s'.\n",
363  goto fail;
364  }
365 
367  ch->in_channel);
368  }
369 
370  /* print mappings */
371  av_log(ctx, AV_LOG_VERBOSE, "mappings: ");
372  for (i = 0; i < s->nb_channels; i++) {
373  ChannelMap *ch = &s->channels[i];
374  av_log(ctx, AV_LOG_VERBOSE, "%d.%s => %s ", ch->input,
377  }
378  av_log(ctx, AV_LOG_VERBOSE, "\n");
379 
380  for (i = 0; i < ctx->nb_inputs; i++) {
381  if (!inputs[i])
382  av_log(ctx, AV_LOG_WARNING, "No channels are used from input "
383  "stream %d.\n", i);
384  }
385 
386 fail:
387  av_freep(&inputs);
388  return ret;
389 }
390 
391 static int join_request_frame(AVFilterLink *outlink)
392 {
393  AVFilterContext *ctx = outlink->src;
394  JoinContext *s = ctx->priv;
395  AVFrame *frame;
396  int linesize = INT_MAX;
397  int nb_samples = 0;
398  int nb_buffers = 0;
399  int i, j, ret;
400 
401  /* get a frame on each input */
402  for (i = 0; i < ctx->nb_inputs; i++) {
403  AVFilterLink *inlink = ctx->inputs[i];
404 
405  if (!s->input_frames[i] &&
406  (ret = ff_request_frame(inlink)) < 0)
407  return ret;
408 
409  /* request the same number of samples on all inputs */
410  if (i == 0) {
411  nb_samples = s->input_frames[0]->nb_samples;
412 
413  for (j = 1; !i && j < ctx->nb_inputs; j++)
414  ctx->inputs[j]->request_samples = nb_samples;
415  }
416  }
417 
418  /* setup the output frame */
419  frame = av_frame_alloc();
420  if (!frame)
421  return AVERROR(ENOMEM);
422  if (s->nb_channels > FF_ARRAY_ELEMS(frame->data)) {
423  frame->extended_data = av_mallocz(s->nb_channels *
424  sizeof(*frame->extended_data));
425  if (!frame->extended_data) {
426  ret = AVERROR(ENOMEM);
427  goto fail;
428  }
429  }
430 
431  /* copy the data pointers */
432  for (i = 0; i < s->nb_channels; i++) {
433  ChannelMap *ch = &s->channels[i];
434  AVFrame *cur = s->input_frames[ch->input];
435  AVBufferRef *buf;
436 
437  frame->extended_data[i] = cur->extended_data[ch->in_channel_idx];
438  linesize = FFMIN(linesize, cur->linesize[0]);
439 
440  /* add the buffer where this plan is stored to the list if it's
441  * not already there */
443  if (!buf) {
444  ret = AVERROR(EINVAL);
445  goto fail;
446  }
447  for (j = 0; j < nb_buffers; j++)
448  if (s->buffers[j]->buffer == buf->buffer)
449  break;
450  if (j == i)
451  s->buffers[nb_buffers++] = buf;
452  }
453 
454  /* create references to the buffers we copied to output */
455  if (nb_buffers > FF_ARRAY_ELEMS(frame->buf)) {
456  frame->nb_extended_buf = nb_buffers - FF_ARRAY_ELEMS(frame->buf);
457  frame->extended_buf = av_mallocz(sizeof(*frame->extended_buf) *
458  frame->nb_extended_buf);
459  if (!frame->extended_buf) {
460  frame->nb_extended_buf = 0;
461  ret = AVERROR(ENOMEM);
462  goto fail;
463  }
464  }
465  for (i = 0; i < FFMIN(FF_ARRAY_ELEMS(frame->buf), nb_buffers); i++) {
466  frame->buf[i] = av_buffer_ref(s->buffers[i]);
467  if (!frame->buf[i]) {
468  ret = AVERROR(ENOMEM);
469  goto fail;
470  }
471  }
472  for (i = 0; i < frame->nb_extended_buf; i++) {
473  frame->extended_buf[i] = av_buffer_ref(s->buffers[i +
474  FF_ARRAY_ELEMS(frame->buf)]);
475  if (!frame->extended_buf[i]) {
476  ret = AVERROR(ENOMEM);
477  goto fail;
478  }
479  }
480 
481  frame->nb_samples = nb_samples;
482  frame->channel_layout = outlink->channel_layout;
483  av_frame_set_channels(frame, outlink->channels);
484  frame->format = outlink->format;
485  frame->sample_rate = outlink->sample_rate;
486  frame->pts = s->input_frames[0]->pts;
487  frame->linesize[0] = linesize;
488  if (frame->data != frame->extended_data) {
489  memcpy(frame->data, frame->extended_data, sizeof(*frame->data) *
490  FFMIN(FF_ARRAY_ELEMS(frame->data), s->nb_channels));
491  }
492 
493  ret = ff_filter_frame(outlink, frame);
494 
495  for (i = 0; i < ctx->nb_inputs; i++)
496  av_frame_free(&s->input_frames[i]);
497 
498  return ret;
499 
500 fail:
501  av_frame_free(&frame);
502  return ret;
503 }
504 
506  {
507  .name = "default",
508  .type = AVMEDIA_TYPE_AUDIO,
509  .config_props = join_config_output,
510  .request_frame = join_request_frame,
511  },
512  { NULL }
513 };
514 
516  .name = "join",
517  .description = NULL_IF_CONFIG_SMALL("Join multiple audio streams into "
518  "multi-channel output."),
519  .priv_size = sizeof(JoinContext),
520  .priv_class = &join_class,
521 
522  .init = join_init,
523  .uninit = join_uninit,
525 
526  .inputs = NULL,
527  .outputs = avfilter_af_join_outputs,
528 
530 };
const char * name
Definition: avisynth_c.h:675
static int join_init(AVFilterContext *ctx)
Definition: af_join.c:190
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:205
const char * s
Definition: avisynth_c.h:668
uint64_t in_channel
layout describing the input channel
Definition: af_channelmap.c:41
This structure describes decoded (raw) audio or video data.
Definition: frame.h:76
AVOption.
Definition: opt.h:251
av_default_item_name
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
external API header
#define A
Definition: af_join.c:68
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:343
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:154
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition: avfilter.h:424
int nb_extended_buf
Number of elements in extended_buf.
Definition: frame.h:361
struct ChannelMap ChannelMap
enum AVMediaType type
AVFilterPad type.
#define FF_ARRAY_ELEMS(a)
static int query_formats(AVFilterContext *ctx)
Definition: af_aconvert.c:73
AVBufferRef ** buffers
Temporary storage for buffer references, for assembling the output frame.
Definition: af_join.c:64
char * map
Definition: af_join.c:49
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:198
const char * name
Pad name.
int nb_channels
Definition: af_join.c:53
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:55
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:532
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
it can be given away to ff_start_frame *A reference passed to ff_filter_frame(or the deprecated ff_start_frame) is given away and must no longer be used.*A reference created with avfilter_ref_buffer belongs to the code that created it.*A reference obtained with ff_get_video_buffer or ff_get_audio_buffer belongs to the code that requested it.*A reference given as return value by the get_video_buffer or get_audio_buffer method is given away and must no longer be used.Link reference fields---------------------The AVFilterLink structure has a few AVFilterBufferRef fields.The cur_buf and out_buf were used with the deprecated start_frame/draw_slice/end_frame API and should no longer be used.src_buf
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:334
AVOptions.
uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index)
Get the channel with the given index in channel_layout.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:159
void ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:427
static void join_uninit(AVFilterContext *ctx)
Definition: af_join.c:238
static void guess_map_matching(AVFilterContext *ctx, ChannelMap *ch, uint64_t *inputs)
Definition: af_join.c:272
int av_get_channel_layout_channel_index(uint64_t channel_layout, uint64_t channel)
Get the index of a channel in channel_layout.
int input
input stream index
Definition: af_join.c:39
void ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:545
frame
Definition: stft.m:14
static int join_query_formats(AVFilterContext *ctx)
Definition: af_join.c:253
A filter pad used for either input or output.
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:531
int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout)
Definition: formats.c:350
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
Definition: avfilter.h:545
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
void av_frame_set_channels(AVFrame *frame, int val)
AVBufferRef * av_frame_get_plane_buffer(AVFrame *frame, int plane)
Get the buffer reference a given data plane is stored in.
Definition: frame.c:489
simple assert() macros that are a bit more flexible than ISO C assert().
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
const char * av_get_channel_name(uint64_t channel)
Get the name of a given channel.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
uint64_t channel_layout
Channel layout of the audio data.
Definition: frame.h:331
#define AV_LOG_VERBOSE
Definition: log.h:157
static const AVOption join_options[]
Definition: af_join.c:70
audio channel layout utility functions
unsigned nb_inputs
number of input pads
Definition: avfilter.h:536
#define FFMIN(a, b)
Definition: common.h:58
AVBufferRef ** extended_buf
For planar audio which requires more than AV_NUM_DATA_POINTERS AVBufferRef pointers, this array will hold all the references which cannot fit into AVFrame.buf.
Definition: frame.h:357
ret
Definition: avfilter.c:821
static const AVClass join_class
Definition: af_join.c:80
struct JoinContext JoinContext
AVFilterFormats * ff_planar_sample_fmts(void)
Construct a formats list containing all planar sample formats.
Definition: formats.c:384
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
AVFilterChannelLayouts * ff_all_channel_layouts(void)
Construct an empty AVFilterChannelLayouts/AVFilterFormats struct – representing any channel layout (...
Definition: formats.c:402
static const AVFilterPad avfilter_af_join_outputs[]
Definition: af_join.c:505
int in_channel_idx
index of in_channel in the input stream data
Definition: af_channelmap.c:43
A list of supported channel layouts.
Definition: formats.h:85
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:134
NULL
Definition: eval.c:55
char * av_strdup(const char *s)
Duplicate the string s.
Definition: mem.c:220
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:101
int inputs
Definition: af_join.c:48
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
void * buf
Definition: avisynth_c.h:594
AVBuffer * buffer
Definition: buffer.h:82
Describe the class of an AVClass context structure.
Definition: log.h:50
int sample_rate
Sample rate of the audio data.
Definition: frame.h:326
#define PARSE_CHANNEL(str, var, inout)
Filter definition.
Definition: avfilter.h:436
synthesis window for stochastic i
uint64_t out_channel
layout describing the output channel
Definition: af_channelmap.c:42
const char * name
filter name
Definition: avfilter.h:437
#define snprintf
Definition: snprintf.h:34
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Buffer references ownership and permissions
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:539
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:396
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:95
static int flags
Definition: cpu.c:23
int(* filter_frame)(AVFilterLink *link, AVFrame *frame)
Filtering callback.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:87
AVFrame ** input_frames
Temporary storage for input frames, until we get one on each input.
Definition: af_join.c:59
ChannelMap * channels
Definition: af_join.c:54
#define F
Definition: af_join.c:69
void ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:533
A reference to a data buffer.
Definition: buffer.h:81
#define OFFSET(x)
Definition: af_join.c:67
void av_opt_free(void *obj)
Free all string and binary options in obj.
Definition: opt.c:1194
static void guess_map_any(AVFilterContext *ctx, ChannelMap *ch, uint64_t *inputs)
Definition: af_join.c:290
common internal and external API header
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:108
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
static int parse_maps(AVFilterContext *ctx)
Definition: af_join.c:103
static int join_request_frame(AVFilterLink *outlink)
Definition: af_join.c:391
char * channel_layout_str
Definition: af_join.c:50
AVFilter avfilter_af_join
Definition: af_join.c:515
static void ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.
uint64_t av_get_channel_layout(const char *name)
Return a channel layout id that matches name, or 0 if no match is found.
An instance of a filter.
Definition: avfilter.h:524
static int join_config_output(AVFilterLink *outlink)
Definition: af_join.c:309
int needs_fifo
The filter expects a fifo to be inserted on its input link, typically because it has a delay...
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:319
static int filter_frame(AVFilterLink *link, AVFrame *frame)
Definition: af_join.c:87
internal API functions
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:117
uint64_t channel_layout
Definition: af_join.c:51
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:127