FFmpeg
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/avstring.h"
29 #include "libavutil/common.h"
30 #include "libavutil/opt.h"
31 
32 #include "audio.h"
33 #include "avfilter.h"
34 #include "formats.h"
35 #include "filters.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 
81 
83 {
84  JoinContext *s = ctx->priv;
85  char separator = '|';
86  char *cur = s->map;
87 
88  while (cur && *cur) {
89  char *sep, *next, *p;
90  uint64_t in_channel = 0, out_channel = 0;
91  int input_idx, out_ch_idx, in_ch_idx;
92 
93  next = strchr(cur, separator);
94  if (next)
95  *next++ = 0;
96 
97  /* split the map into input and output parts */
98  if (!(sep = strchr(cur, '-'))) {
99  av_log(ctx, AV_LOG_ERROR, "Missing separator '-' in channel "
100  "map '%s'\n", cur);
101  return AVERROR(EINVAL);
102  }
103  *sep++ = 0;
104 
105 #define PARSE_CHANNEL(str, var, inout) \
106  if (!(var = av_get_channel_layout(str))) { \
107  av_log(ctx, AV_LOG_ERROR, "Invalid " inout " channel: %s.\n", str);\
108  return AVERROR(EINVAL); \
109  } \
110  if (av_get_channel_layout_nb_channels(var) != 1) { \
111  av_log(ctx, AV_LOG_ERROR, "Channel map describes more than one " \
112  inout " channel.\n"); \
113  return AVERROR(EINVAL); \
114  }
115 
116  /* parse output channel */
117  PARSE_CHANNEL(sep, out_channel, "output");
118  if (!(out_channel & s->channel_layout)) {
119  av_log(ctx, AV_LOG_ERROR, "Output channel '%s' is not present in "
120  "requested channel layout.\n", sep);
121  return AVERROR(EINVAL);
122  }
123 
124  out_ch_idx = av_get_channel_layout_channel_index(s->channel_layout,
125  out_channel);
126  if (s->channels[out_ch_idx].input >= 0) {
127  av_log(ctx, AV_LOG_ERROR, "Multiple maps for output channel "
128  "'%s'.\n", sep);
129  return AVERROR(EINVAL);
130  }
131 
132  /* parse input channel */
133  input_idx = strtol(cur, &cur, 0);
134  if (input_idx < 0 || input_idx >= s->inputs) {
135  av_log(ctx, AV_LOG_ERROR, "Invalid input stream index: %d.\n",
136  input_idx);
137  return AVERROR(EINVAL);
138  }
139 
140  if (*cur)
141  cur++;
142 
143  in_ch_idx = strtol(cur, &p, 0);
144  if (p == cur) {
145  /* channel specifier is not a number,
146  * try to parse as channel name */
147  PARSE_CHANNEL(cur, in_channel, "input");
148  }
149 
150  s->channels[out_ch_idx].input = input_idx;
151  if (in_channel)
152  s->channels[out_ch_idx].in_channel = in_channel;
153  else
154  s->channels[out_ch_idx].in_channel_idx = in_ch_idx;
155 
156  cur = next;
157  }
158  return 0;
159 }
160 
162 {
163  JoinContext *s = ctx->priv;
164  int ret, i;
165 
166  if (!(s->channel_layout = av_get_channel_layout(s->channel_layout_str))) {
167  av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout '%s'.\n",
168  s->channel_layout_str);
169  return AVERROR(EINVAL);
170  }
171 
172  s->nb_channels = av_get_channel_layout_nb_channels(s->channel_layout);
173  s->channels = av_mallocz_array(s->nb_channels, sizeof(*s->channels));
174  s->buffers = av_mallocz_array(s->nb_channels, sizeof(*s->buffers));
175  s->input_frames = av_mallocz_array(s->inputs, sizeof(*s->input_frames));
176  if (!s->channels || !s->buffers|| !s->input_frames)
177  return AVERROR(ENOMEM);
178 
179  for (i = 0; i < s->nb_channels; i++) {
180  s->channels[i].out_channel = av_channel_layout_extract_channel(s->channel_layout, i);
181  s->channels[i].input = -1;
182  }
183 
184  if ((ret = parse_maps(ctx)) < 0)
185  return ret;
186 
187  for (i = 0; i < s->inputs; i++) {
188  AVFilterPad pad = { 0 };
189 
190  pad.type = AVMEDIA_TYPE_AUDIO;
191  pad.name = av_asprintf("input%d", i);
192  if (!pad.name)
193  return AVERROR(ENOMEM);
194 
195  if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0) {
196  av_freep(&pad.name);
197  return ret;
198  }
199  }
200 
201  return 0;
202 }
203 
205 {
206  JoinContext *s = ctx->priv;
207  int i;
208 
209  for (i = 0; i < s->inputs && s->input_frames; i++) {
210  av_frame_free(&s->input_frames[i]);
211  }
212 
213  for (i = 0; i < ctx->nb_inputs; i++) {
214  av_freep(&ctx->input_pads[i].name);
215  }
216 
217  av_freep(&s->channels);
218  av_freep(&s->buffers);
219  av_freep(&s->input_frames);
220 }
221 
223 {
224  JoinContext *s = ctx->priv;
226  int i, ret;
227 
228  if ((ret = ff_add_channel_layout(&layouts, s->channel_layout)) < 0 ||
229  (ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0)
230  return ret;
231 
232  for (i = 0; i < ctx->nb_inputs; i++) {
234  if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[i]->outcfg.channel_layouts)) < 0)
235  return ret;
236  }
237 
240  return ret;
241 
242  return 0;
243 }
244 
246  uint64_t *inputs)
247 {
248  int i;
249 
250  for (i = 0; i < ctx->nb_inputs; i++) {
251  AVFilterLink *link = ctx->inputs[i];
252 
253  if (ch->out_channel & link->channel_layout &&
254  !(ch->out_channel & inputs[i])) {
255  ch->input = i;
256  ch->in_channel = ch->out_channel;
257  inputs[i] |= ch->out_channel;
258  return;
259  }
260  }
261 }
262 
264  uint64_t *inputs)
265 {
266  int i;
267 
268  for (i = 0; i < ctx->nb_inputs; i++) {
269  AVFilterLink *link = ctx->inputs[i];
270 
271  if ((inputs[i] & link->channel_layout) != link->channel_layout) {
272  uint64_t unused = link->channel_layout & ~inputs[i];
273 
274  ch->input = i;
276  inputs[i] |= ch->in_channel;
277  return;
278  }
279  }
280 }
281 
282 static int join_config_output(AVFilterLink *outlink)
283 {
284  AVFilterContext *ctx = outlink->src;
285  JoinContext *s = ctx->priv;
286  uint64_t *inputs; // nth element tracks which channels are used from nth input
287  int i, ret = 0;
288 
289  /* initialize inputs to user-specified mappings */
290  if (!(inputs = av_mallocz_array(ctx->nb_inputs, sizeof(*inputs))))
291  return AVERROR(ENOMEM);
292  for (i = 0; i < s->nb_channels; i++) {
293  ChannelMap *ch = &s->channels[i];
295 
296  if (ch->input < 0)
297  continue;
298 
299  inlink = ctx->inputs[ch->input];
300 
301  if (!ch->in_channel)
303  ch->in_channel_idx);
304 
305  if (!(ch->in_channel & inlink->channel_layout)) {
306  av_log(ctx, AV_LOG_ERROR, "Requested channel %s is not present in "
307  "input stream #%d.\n", av_get_channel_name(ch->in_channel),
308  ch->input);
309  ret = AVERROR(EINVAL);
310  goto fail;
311  }
312 
313  inputs[ch->input] |= ch->in_channel;
314  }
315 
316  /* guess channel maps when not explicitly defined */
317  /* first try unused matching channels */
318  for (i = 0; i < s->nb_channels; i++) {
319  ChannelMap *ch = &s->channels[i];
320 
321  if (ch->input < 0)
323  }
324 
325  /* if the above failed, try to find _any_ unused input channel */
326  for (i = 0; i < s->nb_channels; i++) {
327  ChannelMap *ch = &s->channels[i];
328 
329  if (ch->input < 0)
330  guess_map_any(ctx, ch, inputs);
331 
332  if (ch->input < 0) {
333  av_log(ctx, AV_LOG_ERROR, "Could not find input channel for "
334  "output channel '%s'.\n",
336  goto fail;
337  }
338 
339  ch->in_channel_idx = av_get_channel_layout_channel_index(ctx->inputs[ch->input]->channel_layout,
340  ch->in_channel);
341  }
342 
343  /* print mappings */
344  av_log(ctx, AV_LOG_VERBOSE, "mappings: ");
345  for (i = 0; i < s->nb_channels; i++) {
346  ChannelMap *ch = &s->channels[i];
347  av_log(ctx, AV_LOG_VERBOSE, "%d.%s => %s ", ch->input,
350  }
351  av_log(ctx, AV_LOG_VERBOSE, "\n");
352 
353  for (i = 0; i < ctx->nb_inputs; i++) {
354  if (!inputs[i])
355  av_log(ctx, AV_LOG_WARNING, "No channels are used from input "
356  "stream %d.\n", i);
357  }
358 
359 fail:
360  av_freep(&inputs);
361  return ret;
362 }
363 
365 {
366  AVFilterLink *outlink = ctx->outputs[0];
367  JoinContext *s = ctx->priv;
368  AVFrame *frame;
369  int linesize = INT_MAX;
370  int nb_samples = INT_MAX;
371  int nb_buffers = 0;
372  int i, j, ret;
373 
374  for (i = 0; i < ctx->nb_inputs; i++) {
375  if (!s->input_frames[i])
376  return 0;
377  nb_samples = FFMIN(nb_samples, s->input_frames[i]->nb_samples);
378  }
379  if (!nb_samples)
380  return 0;
381 
382  /* setup the output frame */
383  frame = av_frame_alloc();
384  if (!frame)
385  return AVERROR(ENOMEM);
386  if (s->nb_channels > FF_ARRAY_ELEMS(frame->data)) {
387  frame->extended_data = av_mallocz_array(s->nb_channels,
388  sizeof(*frame->extended_data));
389  if (!frame->extended_data) {
390  ret = AVERROR(ENOMEM);
391  goto fail;
392  }
393  }
394 
395  /* copy the data pointers */
396  for (i = 0; i < s->nb_channels; i++) {
397  ChannelMap *ch = &s->channels[i];
398  AVFrame *cur = s->input_frames[ch->input];
399  AVBufferRef *buf;
400 
401  frame->extended_data[i] = cur->extended_data[ch->in_channel_idx];
402  linesize = FFMIN(linesize, cur->linesize[0]);
403 
404  /* add the buffer where this plan is stored to the list if it's
405  * not already there */
407  if (!buf) {
408  ret = AVERROR(EINVAL);
409  goto fail;
410  }
411  for (j = 0; j < nb_buffers; j++)
412  if (s->buffers[j]->buffer == buf->buffer)
413  break;
414  if (j == i)
415  s->buffers[nb_buffers++] = buf;
416  }
417 
418  /* create references to the buffers we copied to output */
419  if (nb_buffers > FF_ARRAY_ELEMS(frame->buf)) {
420  frame->nb_extended_buf = nb_buffers - FF_ARRAY_ELEMS(frame->buf);
421  frame->extended_buf = av_mallocz_array(frame->nb_extended_buf,
422  sizeof(*frame->extended_buf));
423  if (!frame->extended_buf) {
424  frame->nb_extended_buf = 0;
425  ret = AVERROR(ENOMEM);
426  goto fail;
427  }
428  }
429  for (i = 0; i < FFMIN(FF_ARRAY_ELEMS(frame->buf), nb_buffers); i++) {
430  frame->buf[i] = av_buffer_ref(s->buffers[i]);
431  if (!frame->buf[i]) {
432  ret = AVERROR(ENOMEM);
433  goto fail;
434  }
435  }
436  for (i = 0; i < frame->nb_extended_buf; i++) {
437  frame->extended_buf[i] = av_buffer_ref(s->buffers[i +
438  FF_ARRAY_ELEMS(frame->buf)]);
439  if (!frame->extended_buf[i]) {
440  ret = AVERROR(ENOMEM);
441  goto fail;
442  }
443  }
444 
445  frame->nb_samples = nb_samples;
446  frame->channel_layout = outlink->channel_layout;
447  frame->channels = outlink->channels;
448  frame->sample_rate = outlink->sample_rate;
449  frame->format = outlink->format;
450  frame->pts = s->input_frames[0]->pts;
451  frame->linesize[0] = linesize;
452  if (frame->data != frame->extended_data) {
453  memcpy(frame->data, frame->extended_data, sizeof(*frame->data) *
454  FFMIN(FF_ARRAY_ELEMS(frame->data), s->nb_channels));
455  }
456 
457  ret = ff_filter_frame(outlink, frame);
458 
459  for (i = 0; i < ctx->nb_inputs; i++)
460  av_frame_free(&s->input_frames[i]);
461 
462  return ret;
463 
464 fail:
466  return ret;
467 }
468 
470 {
471  JoinContext *s = ctx->priv;
472  int i, ret, status;
473  int nb_samples = 0;
474  int64_t pts;
475 
477 
478  if (!s->input_frames[0]) {
479  ret = ff_inlink_consume_frame(ctx->inputs[0], &s->input_frames[0]);
480  if (ret < 0) {
481  return ret;
482  } else if (ff_inlink_acknowledge_status(ctx->inputs[0], &status, &pts)) {
483  ff_outlink_set_status(ctx->outputs[0], status, pts);
484  return 0;
485  } else {
486  if (ff_outlink_frame_wanted(ctx->outputs[0]) && !s->input_frames[0]) {
487  ff_inlink_request_frame(ctx->inputs[0]);
488  return 0;
489  }
490  }
491  if (!s->input_frames[0]) {
492  return 0;
493  }
494  }
495 
496  nb_samples = s->input_frames[0]->nb_samples;
497 
498  for (i = 1; i < ctx->nb_inputs && nb_samples > 0; i++) {
499  if (s->input_frames[i])
500  continue;
501 
502  if (ff_inlink_check_available_samples(ctx->inputs[i], nb_samples) > 0) {
503  ret = ff_inlink_consume_samples(ctx->inputs[i], nb_samples, nb_samples, &s->input_frames[i]);
504  if (ret < 0) {
505  return ret;
506  } else if (ff_inlink_acknowledge_status(ctx->inputs[i], &status, &pts)) {
507  ff_outlink_set_status(ctx->outputs[0], status, pts);
508  return 0;
509  }
510  } else {
511  if (ff_outlink_frame_wanted(ctx->outputs[0])) {
512  ff_inlink_request_frame(ctx->inputs[i]);
513  return 0;
514  }
515  }
516  }
517 
518  return try_push_frame(ctx);
519 }
520 
522  {
523  .name = "default",
524  .type = AVMEDIA_TYPE_AUDIO,
525  .config_props = join_config_output,
526  },
527  { NULL }
528 };
529 
531  .name = "join",
532  .description = NULL_IF_CONFIG_SMALL("Join multiple audio streams into "
533  "multi-channel output."),
534  .priv_size = sizeof(JoinContext),
535  .priv_class = &join_class,
536  .init = join_init,
537  .uninit = join_uninit,
538  .activate = activate,
540  .inputs = NULL,
543 };
ChannelMap::in_channel
uint64_t in_channel
layout describing the input channel
Definition: af_channelmap.c:41
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:85
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
status
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame 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. Frame references ownership and permissions
opt.h
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:979
ff_channel_layouts_ref
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:454
layouts
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
guess_map_matching
static void guess_map_matching(AVFilterContext *ctx, ChannelMap *ch, uint64_t *inputs)
Definition: af_join.c:245
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_asprintf
char * av_asprintf(const char *fmt,...)
Definition: avstring.c:113
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:112
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
AVOption
AVOption.
Definition: opt.h:247
av_mallocz_array
void * av_mallocz_array(size_t nmemb, size_t size)
Definition: mem.c:196
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
av_get_channel_layout
uint64_t av_get_channel_layout(const char *name)
Return a channel layout id that matches name, or 0 if no match is found.
Definition: channel_layout.c:145
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:149
formats.h
ff_insert_inpad
static int ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.
Definition: internal.h:238
ff_inlink_consume_frame
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:1377
FF_FILTER_FORWARD_STATUS_BACK_ALL
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
Definition: filters.h:212
fail
#define fail()
Definition: checkasm.h:136
ChannelMap::input
int input
input stream index
Definition: af_join.c:39
join_query_formats
static int join_query_formats(AVFilterContext *ctx)
Definition: af_join.c:222
pts
static int64_t pts
Definition: transcode_aac.c:653
AVFILTER_FLAG_DYNAMIC_INPUTS
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition: avfilter.h:106
JoinContext::buffers
AVBufferRef ** buffers
Temporary storage for buffer references, for assembling the output frame.
Definition: af_join.c:64
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:52
JoinContext::input_frames
AVFrame ** input_frames
Temporary storage for input frames, until we get one on each input.
Definition: af_join.c:59
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:99
parse_maps
static int parse_maps(AVFilterContext *ctx)
Definition: af_join.c:82
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
ff_inlink_check_available_samples
int ff_inlink_check_available_samples(AVFilterLink *link, unsigned min)
Test if enough samples are available on the link.
Definition: avfilter.c:1362
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
inputs
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
Definition: filter_design.txt:243
ff_set_common_formats
int 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:580
ff_outlink_set_status
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:189
ff_add_channel_layout
int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout)
Definition: formats.c:331
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1494
s
#define s(width, name)
Definition: cbs_vp9.c:257
JoinContext::nb_channels
int nb_channels
Definition: af_join.c:53
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
filters.h
av_get_channel_name
const char * av_get_channel_name(uint64_t channel)
Get the name of a given channel.
Definition: channel_layout.c:249
ctx
AVFormatContext * ctx
Definition: movenc.c:48
link
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame 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
Definition: filter_design.txt:23
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
ff_inlink_consume_samples
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:1396
NULL
#define NULL
Definition: coverity.c:32
join_options
static const AVOption join_options[]
Definition: af_join.c:70
ff_inlink_acknowledge_status
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:1332
av_get_channel_layout_nb_channels
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
Definition: channel_layout.c:226
JoinContext::channel_layout_str
char * channel_layout_str
Definition: af_join.c:50
F
#define F
Definition: af_join.c:69
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:116
ChannelMap::out_channel
uint64_t out_channel
layout describing the output channel
Definition: af_channelmap.c:42
PARSE_CHANNEL
#define PARSE_CHANNEL(str, var, inout)
A
#define A
Definition: af_join.c:68
AVFrame::channel_layout
uint64_t channel_layout
Channel layout of the audio data.
Definition: frame.h:463
AVBufferRef::buffer
AVBuffer * buffer
Definition: buffer.h:83
ChannelMap::in_channel_idx
int in_channel_idx
index of in_channel in the input stream data
Definition: af_channelmap.c:43
ff_all_channel_layouts
AVFilterChannelLayouts * ff_all_channel_layouts(void)
Construct an empty AVFilterChannelLayouts/AVFilterFormats struct – representing any channel layout (w...
Definition: formats.c:420
JoinContext
Definition: af_join.c:45
internal.h
join_uninit
static av_cold void join_uninit(AVFilterContext *ctx)
Definition: af_join.c:204
OFFSET
#define OFFSET(x)
Definition: af_join.c:67
i
int i
Definition: input.c:406
av_channel_layout_extract_channel
uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index)
Get the channel with the given index in channel_layout.
Definition: channel_layout.c:271
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:350
common.h
av_get_channel_layout_channel_index
int av_get_channel_layout_channel_index(uint64_t channel_layout, uint64_t channel)
Get the index of a channel in channel_layout.
Definition: channel_layout.c:239
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
ff_planar_sample_fmts
AVFilterFormats * ff_planar_sample_fmts(void)
Construct a formats list containing all planar sample formats.
Definition: formats.c:401
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:58
activate
static int activate(AVFilterContext *ctx)
Definition: af_join.c:469
AVFilter
Filter definition.
Definition: avfilter.h:145
avfilter_af_join_outputs
static const AVFilterPad avfilter_af_join_outputs[]
Definition: af_join.c:521
ret
ret
Definition: filter_design.txt:187
AVFilterPad::type
enum AVMediaType type
AVFilterPad type.
Definition: internal.h:63
frame
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 the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
JoinContext::inputs
int inputs
Definition: af_join.c:48
ff_all_samplerates
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:414
channel_layout.h
JoinContext::map
char * map
Definition: af_join.c:49
JoinContext::channels
ChannelMap * channels
Definition: af_join.c:54
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avfilter.h
guess_map_any
static void guess_map_any(AVFilterContext *ctx, ChannelMap *ch, uint64_t *inputs)
Definition: af_join.c:263
av_buffer_ref
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:93
ChannelMap
Definition: opus.h:147
AVFilterContext
An instance of a filter.
Definition: avfilter.h:333
audio.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
join_config_output
static int join_config_output(AVFilterLink *outlink)
Definition: af_join.c:282
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
join_init
static av_cold int join_init(AVFilterContext *ctx)
Definition: af_join.c:161
ff_af_join
const AVFilter ff_af_join
Definition: af_join.c:530
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: aeval.c:243
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:334
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
av_frame_get_plane_buffer
AVBufferRef * av_frame_get_plane_buffer(AVFrame *frame, int plane)
Get the buffer reference a given data plane is stored in.
Definition: frame.c:542
ff_set_common_samplerates
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:568
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:279
ff_outlink_frame_wanted
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228
try_push_frame
static int try_push_frame(AVFilterContext *ctx)
Definition: af_join.c:364
JoinContext::channel_layout
uint64_t channel_layout
Definition: af_join.c:51
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(join)