avf_concat.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Nicolas George
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * concat audio-video filter
24  */
25 
26 #include "libavutil/avassert.h"
27 #include "libavutil/avstring.h"
29 #include "libavutil/opt.h"
30 #include "avfilter.h"
31 #define FF_BUFQUEUE_SIZE 256
32 #include "bufferqueue.h"
33 #include "internal.h"
34 #include "video.h"
35 #include "audio.h"
36 
37 #define TYPE_ALL 2
38 
39 typedef struct {
40  const AVClass *class;
41  unsigned nb_streams[TYPE_ALL]; /**< number of out streams of each type */
42  unsigned nb_segments;
43  unsigned cur_idx; /**< index of the first input of current segment */
44  int64_t delta_ts; /**< timestamp to add to produce output timestamps */
45  unsigned nb_in_active; /**< number of active inputs in current segment */
46  unsigned unsafe;
47  struct concat_in {
48  int64_t pts;
49  int64_t nb_frames;
50  unsigned eof;
51  struct FFBufQueue queue;
52  } *in;
54 
55 #define OFFSET(x) offsetof(ConcatContext, x)
56 #define A AV_OPT_FLAG_AUDIO_PARAM
57 #define F AV_OPT_FLAG_FILTERING_PARAM
58 #define V AV_OPT_FLAG_VIDEO_PARAM
59 
60 static const AVOption concat_options[] = {
61  { "n", "specify the number of segments", OFFSET(nb_segments),
62  AV_OPT_TYPE_INT, { .i64 = 2 }, 2, INT_MAX, V|A|F},
63  { "v", "specify the number of video streams",
64  OFFSET(nb_streams[AVMEDIA_TYPE_VIDEO]),
65  AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, V|F },
66  { "a", "specify the number of audio streams",
67  OFFSET(nb_streams[AVMEDIA_TYPE_AUDIO]),
68  AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, A|F},
69  { "unsafe", "enable unsafe mode",
70  OFFSET(unsafe),
71  AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, A|A|F},
72  { 0 }
73 };
74 
75 AVFILTER_DEFINE_CLASS(concat);
76 
78 {
79  ConcatContext *cat = ctx->priv;
80  unsigned type, nb_str, idx0 = 0, idx, str, seg;
83 
84  for (type = 0; type < TYPE_ALL; type++) {
85  nb_str = cat->nb_streams[type];
86  for (str = 0; str < nb_str; str++) {
87  idx = idx0;
88 
89  /* Set the output formats */
90  formats = ff_all_formats(type);
91  if (!formats)
92  return AVERROR(ENOMEM);
93  ff_formats_ref(formats, &ctx->outputs[idx]->in_formats);
94  if (type == AVMEDIA_TYPE_AUDIO) {
95  rates = ff_all_samplerates();
96  if (!rates)
97  return AVERROR(ENOMEM);
98  ff_formats_ref(rates, &ctx->outputs[idx]->in_samplerates);
99  layouts = ff_all_channel_layouts();
100  if (!layouts)
101  return AVERROR(ENOMEM);
102  ff_channel_layouts_ref(layouts, &ctx->outputs[idx]->in_channel_layouts);
103  }
104 
105  /* Set the same formats for each corresponding input */
106  for (seg = 0; seg < cat->nb_segments; seg++) {
107  ff_formats_ref(formats, &ctx->inputs[idx]->out_formats);
108  if (type == AVMEDIA_TYPE_AUDIO) {
109  ff_formats_ref(rates, &ctx->inputs[idx]->out_samplerates);
110  ff_channel_layouts_ref(layouts, &ctx->inputs[idx]->out_channel_layouts);
111  }
112  idx += ctx->nb_outputs;
113  }
114 
115  idx0++;
116  }
117  }
118  return 0;
119 }
120 
121 static int config_output(AVFilterLink *outlink)
122 {
123  AVFilterContext *ctx = outlink->src;
124  ConcatContext *cat = ctx->priv;
125  unsigned out_no = FF_OUTLINK_IDX(outlink);
126  unsigned in_no = out_no, seg;
127  AVFilterLink *inlink = ctx->inputs[in_no];
128 
129  /* enhancement: find a common one */
130  outlink->time_base = AV_TIME_BASE_Q;
131  outlink->w = inlink->w;
132  outlink->h = inlink->h;
133  outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
134  outlink->format = inlink->format;
135  for (seg = 1; seg < cat->nb_segments; seg++) {
136  inlink = ctx->inputs[in_no += ctx->nb_outputs];
137  /* possible enhancement: unsafe mode, do not check */
138  if (outlink->w != inlink->w ||
139  outlink->h != inlink->h ||
140  outlink->sample_aspect_ratio.num != inlink->sample_aspect_ratio.num ||
141  outlink->sample_aspect_ratio.den != inlink->sample_aspect_ratio.den) {
142  av_log(ctx, AV_LOG_ERROR, "Input link %s parameters "
143  "(size %dx%d, SAR %d:%d) do not match the corresponding "
144  "output link %s parameters (%dx%d, SAR %d:%d)\n",
145  ctx->input_pads[in_no].name, inlink->w, inlink->h,
146  inlink->sample_aspect_ratio.num,
147  inlink->sample_aspect_ratio.den,
148  ctx->input_pads[out_no].name, outlink->w, outlink->h,
149  outlink->sample_aspect_ratio.num,
150  outlink->sample_aspect_ratio.den);
151  if (!cat->unsafe)
152  return AVERROR(EINVAL);
153  }
154  }
155 
156  return 0;
157 }
158 
159 static int push_frame(AVFilterContext *ctx, unsigned in_no, AVFrame *buf)
160 {
161  ConcatContext *cat = ctx->priv;
162  unsigned out_no = in_no % ctx->nb_outputs;
163  AVFilterLink * inlink = ctx-> inputs[ in_no];
164  AVFilterLink *outlink = ctx->outputs[out_no];
165  struct concat_in *in = &cat->in[in_no];
166 
167  buf->pts = av_rescale_q(buf->pts, inlink->time_base, outlink->time_base);
168  in->pts = buf->pts;
169  in->nb_frames++;
170  /* add duration to input PTS */
171  if (inlink->sample_rate)
172  /* use number of audio samples */
173  in->pts += av_rescale_q(buf->nb_samples,
174  (AVRational){ 1, inlink->sample_rate },
175  outlink->time_base);
176  else if (in->nb_frames >= 2)
177  /* use mean duration */
178  in->pts = av_rescale(in->pts, in->nb_frames, in->nb_frames - 1);
179 
180  buf->pts += cat->delta_ts;
181  return ff_filter_frame(outlink, buf);
182 }
183 
184 static int process_frame(AVFilterLink *inlink, AVFrame *buf)
185 {
186  AVFilterContext *ctx = inlink->dst;
187  ConcatContext *cat = ctx->priv;
188  unsigned in_no = FF_INLINK_IDX(inlink);
189 
190  if (in_no < cat->cur_idx) {
191  av_log(ctx, AV_LOG_ERROR, "Frame after EOF on input %s\n",
192  ctx->input_pads[in_no].name);
193  av_frame_free(&buf);
194  } else if (in_no >= cat->cur_idx + ctx->nb_outputs) {
195  ff_bufqueue_add(ctx, &cat->in[in_no].queue, buf);
196  } else {
197  return push_frame(ctx, in_no, buf);
198  }
199  return 0;
200 }
201 
202 static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h)
203 {
204  AVFilterContext *ctx = inlink->dst;
205  unsigned in_no = FF_INLINK_IDX(inlink);
206  AVFilterLink *outlink = ctx->outputs[in_no % ctx->nb_outputs];
207 
208  return ff_get_video_buffer(outlink, w, h);
209 }
210 
211 static AVFrame *get_audio_buffer(AVFilterLink *inlink, int nb_samples)
212 {
213  AVFilterContext *ctx = inlink->dst;
214  unsigned in_no = FF_INLINK_IDX(inlink);
215  AVFilterLink *outlink = ctx->outputs[in_no % ctx->nb_outputs];
216 
217  return ff_get_audio_buffer(outlink, nb_samples);
218 }
219 
220 static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
221 {
222  return process_frame(inlink, buf);
223 }
224 
225 static void close_input(AVFilterContext *ctx, unsigned in_no)
226 {
227  ConcatContext *cat = ctx->priv;
228 
229  cat->in[in_no].eof = 1;
230  cat->nb_in_active--;
231  av_log(ctx, AV_LOG_VERBOSE, "EOF on %s, %d streams left in segment.\n",
232  ctx->input_pads[in_no].name, cat->nb_in_active);
233 }
234 
235 static void find_next_delta_ts(AVFilterContext *ctx, int64_t *seg_delta)
236 {
237  ConcatContext *cat = ctx->priv;
238  unsigned i = cat->cur_idx;
239  unsigned imax = i + ctx->nb_outputs;
240  int64_t pts;
241 
242  pts = cat->in[i++].pts;
243  for (; i < imax; i++)
244  pts = FFMAX(pts, cat->in[i].pts);
245  cat->delta_ts += pts;
246  *seg_delta = pts;
247 }
248 
249 static int send_silence(AVFilterContext *ctx, unsigned in_no, unsigned out_no,
250  int64_t seg_delta)
251 {
252  ConcatContext *cat = ctx->priv;
253  AVFilterLink *outlink = ctx->outputs[out_no];
254  int64_t base_pts = cat->in[in_no].pts + cat->delta_ts - seg_delta;
255  int64_t nb_samples, sent = 0;
256  int frame_nb_samples, ret;
257  AVRational rate_tb = { 1, ctx->inputs[in_no]->sample_rate };
258  AVFrame *buf;
260 
261  if (!rate_tb.den)
262  return AVERROR_BUG;
263  nb_samples = av_rescale_q(seg_delta - cat->in[in_no].pts,
264  outlink->time_base, rate_tb);
265  frame_nb_samples = FFMAX(9600, rate_tb.den / 5); /* arbitrary */
266  while (nb_samples) {
267  frame_nb_samples = FFMIN(frame_nb_samples, nb_samples);
268  buf = ff_get_audio_buffer(outlink, frame_nb_samples);
269  if (!buf)
270  return AVERROR(ENOMEM);
271  av_samples_set_silence(buf->extended_data, 0, frame_nb_samples,
272  nb_channels, outlink->format);
273  buf->pts = base_pts + av_rescale_q(sent, rate_tb, outlink->time_base);
274  ret = ff_filter_frame(outlink, buf);
275  if (ret < 0)
276  return ret;
277  sent += frame_nb_samples;
278  nb_samples -= frame_nb_samples;
279  }
280  return 0;
281 }
282 
284 {
285  int ret;
286  ConcatContext *cat = ctx->priv;
287  unsigned str, str_max;
288  int64_t seg_delta;
289 
290  find_next_delta_ts(ctx, &seg_delta);
291  cat->cur_idx += ctx->nb_outputs;
292  cat->nb_in_active = ctx->nb_outputs;
293  av_log(ctx, AV_LOG_VERBOSE, "Segment finished at pts=%"PRId64"\n",
294  cat->delta_ts);
295 
296  if (cat->cur_idx < ctx->nb_inputs) {
297  /* pad audio streams with silence */
298  str = cat->nb_streams[AVMEDIA_TYPE_VIDEO];
299  str_max = str + cat->nb_streams[AVMEDIA_TYPE_AUDIO];
300  for (; str < str_max; str++) {
301  ret = send_silence(ctx, cat->cur_idx - ctx->nb_outputs + str, str,
302  seg_delta);
303  if (ret < 0)
304  return ret;
305  }
306  /* flush queued buffers */
307  /* possible enhancement: flush in PTS order */
308  str_max = cat->cur_idx + ctx->nb_outputs;
309  for (str = cat->cur_idx; str < str_max; str++) {
310  while (cat->in[str].queue.available) {
311  ret = push_frame(ctx, str, ff_bufqueue_get(&cat->in[str].queue));
312  if (ret < 0)
313  return ret;
314  }
315  }
316  }
317  return 0;
318 }
319 
320 static int request_frame(AVFilterLink *outlink)
321 {
322  AVFilterContext *ctx = outlink->src;
323  ConcatContext *cat = ctx->priv;
324  unsigned out_no = FF_OUTLINK_IDX(outlink);
325  unsigned in_no = out_no + cat->cur_idx;
326  unsigned str, str_max;
327  int ret;
328 
329  while (1) {
330  if (in_no >= ctx->nb_inputs)
331  return AVERROR_EOF;
332  if (!cat->in[in_no].eof) {
333  ret = ff_request_frame(ctx->inputs[in_no]);
334  if (ret != AVERROR_EOF)
335  return ret;
336  close_input(ctx, in_no);
337  }
338  /* cycle on all inputs to finish the segment */
339  /* possible enhancement: request in PTS order */
340  str_max = cat->cur_idx + ctx->nb_outputs - 1;
341  for (str = cat->cur_idx; cat->nb_in_active;
342  str = str == str_max ? cat->cur_idx : str + 1) {
343  if (cat->in[str].eof)
344  continue;
345  ret = ff_request_frame(ctx->inputs[str]);
346  if (ret == AVERROR_EOF)
347  close_input(ctx, str);
348  else if (ret < 0)
349  return ret;
350  }
351  ret = flush_segment(ctx);
352  if (ret < 0)
353  return ret;
354  in_no += ctx->nb_outputs;
355  }
356 }
357 
358 static av_cold int init(AVFilterContext *ctx)
359 {
360  ConcatContext *cat = ctx->priv;
361  unsigned seg, type, str;
362 
363  /* create input pads */
364  for (seg = 0; seg < cat->nb_segments; seg++) {
365  for (type = 0; type < TYPE_ALL; type++) {
366  for (str = 0; str < cat->nb_streams[type]; str++) {
367  AVFilterPad pad = {
368  .type = type,
369  .get_video_buffer = get_video_buffer,
370  .get_audio_buffer = get_audio_buffer,
371  .filter_frame = filter_frame,
372  };
373  pad.name = av_asprintf("in%d:%c%d", seg, "va"[type], str);
374  ff_insert_inpad(ctx, ctx->nb_inputs, &pad);
375  }
376  }
377  }
378  /* create output pads */
379  for (type = 0; type < TYPE_ALL; type++) {
380  for (str = 0; str < cat->nb_streams[type]; str++) {
381  AVFilterPad pad = {
382  .type = type,
383  .config_props = config_output,
384  .request_frame = request_frame,
385  };
386  pad.name = av_asprintf("out:%c%d", "va"[type], str);
387  ff_insert_outpad(ctx, ctx->nb_outputs, &pad);
388  }
389  }
390 
391  cat->in = av_calloc(ctx->nb_inputs, sizeof(*cat->in));
392  if (!cat->in)
393  return AVERROR(ENOMEM);
394  cat->nb_in_active = ctx->nb_outputs;
395  return 0;
396 }
397 
398 static av_cold void uninit(AVFilterContext *ctx)
399 {
400  ConcatContext *cat = ctx->priv;
401  unsigned i;
402 
403  for (i = 0; i < ctx->nb_inputs; i++) {
404  av_freep(&ctx->input_pads[i].name);
405  ff_bufqueue_discard_all(&cat->in[i].queue);
406  }
407  for (i = 0; i < ctx->nb_outputs; i++)
408  av_freep(&ctx->output_pads[i].name);
409  av_free(cat->in);
410 }
411 
413  .name = "concat",
414  .description = NULL_IF_CONFIG_SMALL("Concatenate audio and video streams."),
415  .init = init,
416  .uninit = uninit,
417  .query_formats = query_formats,
418  .priv_size = sizeof(ConcatContext),
419  .inputs = NULL,
420  .outputs = NULL,
421  .priv_class = &concat_class,
423 };
static AVFrame * ff_bufqueue_get(struct FFBufQueue *queue)
Get the first buffer from the queue and remove it.
Definition: bufferqueue.h:98
static AVFrame * get_audio_buffer(AVFilterLink *inlink, int nb_samples)
Definition: avf_concat.c:211
static int flush_segment(AVFilterContext *ctx)
Definition: avf_concat.c:283
static int send_silence(AVFilterContext *ctx, unsigned in_no, unsigned out_no, int64_t seg_delta)
Definition: avf_concat.c:249
This structure describes decoded (raw) audio or video data.
Definition: frame.h:76
static av_cold int init(AVFilterContext *ctx)
Definition: avf_concat.c:358
AVOption.
Definition: opt.h:251
unsigned nb_streams[TYPE_ALL]
number of out streams of each type
Definition: avf_concat.c:41
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
external API header
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition: avfilter.h:424
static int request_frame(AVFilterLink *outlink)
Definition: avf_concat.c:320
int num
numerator
Definition: rational.h:44
About Git write you should know how to use GIT properly Luckily Git comes with excellent documentation git help man git shows you the available git< command > help man git< command > shows information about the subcommand< command > The most comprehensive manual is the website Git Reference visit they are quite exhaustive You do not need a special username or password All you need is to provide a ssh public key to the Git server admin What follows now is a basic introduction to Git and some FFmpeg specific guidelines Read it at least if you are granted commit privileges to the FFmpeg project you are expected to be familiar with these rules I if not You can get git from etc no matter how small Every one of them has been saved from looking like a fool by this many times It s very easy for stray debug output or cosmetic modifications to slip in
Definition: git-howto.txt:5
enum AVMediaType type
AVFilterPad type.
#define FF_OUTLINK_IDX(link)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:143
output residual component w
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
#define V
Definition: avf_concat.c:58
Structure holding the queue.
Definition: bufferqueue.h:49
static av_cold void uninit(AVFilterContext *ctx)
Definition: avf_concat.c:398
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:532
AVFilterPad * output_pads
array of output pads
Definition: avfilter.h:538
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
#define av_cold
Definition: attributes.h:78
AVOptions.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:159
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
Definition: avf_concat.c:202
void ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:427
static int push_frame(AVFilterContext *ctx, unsigned in_no, AVFrame *buf)
Definition: avf_concat.c:159
#define AVERROR_EOF
End of file.
Definition: error.h:55
#define AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
Definition: avfilter.h:430
AVFilterFormats * ff_all_formats(enum AVMediaType type)
Return a list of all formats supported by FFmpeg for the given media type.
Definition: formats.c:357
static const int rates[]
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:130
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:531
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
Definition: mem.c:183
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:84
unsigned nb_outputs
number of output pads
Definition: avfilter.h:543
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
Definition: avf_concat.c:220
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.
#define A
Definition: avf_concat.c:56
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
#define FFMAX(a, b)
Definition: common.h:56
char * av_asprintf(const char *fmt,...)
Definition: avstring.c:112
AVFrame * queue[FF_BUFQUEUE_SIZE]
Definition: bufferqueue.h:50
#define AV_LOG_VERBOSE
Definition: log.h:157
int64_t delta_ts
timestamp to add to produce output timestamps
Definition: avf_concat.c:44
audio channel layout utility functions
static int process_frame(AVFilterLink *inlink, AVFrame *buf)
Definition: avf_concat.c:184
unsigned nb_inputs
number of input pads
Definition: avfilter.h:536
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:118
#define FFMIN(a, b)
Definition: common.h:58
int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
Definition: samplefmt.c:249
static void close_input(AVFilterContext *ctx, unsigned in_no)
Definition: avf_concat.c:225
ret
Definition: avfilter.c:821
static void find_next_delta_ts(AVFilterContext *ctx, int64_t *seg_delta)
Definition: avf_concat.c:235
static void ff_insert_outpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new output pad for the filter.
unsigned nb_segments
Definition: avf_concat.c:42
static const AVClass concat_class
Definition: concatdec.c:387
static void ff_bufqueue_discard_all(struct FFBufQueue *queue)
Unref and remove all buffers from the queue.
Definition: bufferqueue.h:111
struct FFBufQueue queue
Definition: avf_concat.c:51
AVFilterChannelLayouts * ff_all_channel_layouts(void)
Construct an empty AVFilterChannelLayouts/AVFilterFormats struct – representing any channel layout (...
Definition: formats.c:402
A list of supported channel layouts.
Definition: formats.h:85
NULL
Definition: eval.c:55
void ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:432
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:202
unsigned short available
number of available buffers
Definition: bufferqueue.h:52
AVFilter avfilter_avf_concat
Definition: avf_concat.c:412
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
unsigned cur_idx
index of the first input of current segment
Definition: avf_concat.c:43
void * buf
Definition: avisynth_c.h:594
#define OFFSET(x)
Definition: avf_concat.c:55
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:50
Describe the class of an AVClass context structure.
Definition: log.h:50
Filter definition.
Definition: avfilter.h:436
synthesis window for stochastic i
rational number numerator/denominator
Definition: rational.h:43
unsigned nb_in_active
number of active inputs in current segment
Definition: avf_concat.c:45
const char * name
filter name
Definition: avfilter.h:437
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
#define type
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
void * av_calloc(size_t nmemb, size_t size)
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
Definition: mem.c:213
static int flags
Definition: cpu.c:23
#define FF_INLINK_IDX(link)
Find the index of a link.
The official guide to swscale for confused that consecutive non overlapping rectangles of slice_bottom special converter These generally are unscaled converters of common formats
Definition: swscale.txt:33
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:108
static int query_formats(AVFilterContext *ctx)
Definition: avf_concat.c:77
#define TYPE_ALL
Definition: avf_concat.c:37
#define F
Definition: avf_concat.c:57
unsigned unsafe
Definition: avf_concat.c:46
int den
denominator
Definition: rational.h:45
static int config_output(AVFilterLink *outlink)
Definition: avf_concat.c:121
struct ConcatContext::concat_in * in
static void ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.
A list of supported formats for one end of a filter link.
Definition: formats.h:64
An instance of a filter.
Definition: avfilter.h:524
AVFILTER_DEFINE_CLASS(concat)
static const AVOption concat_options[]
Definition: avf_concat.c:60
static void ff_bufqueue_add(void *log, struct FFBufQueue *queue, AVFrame *buf)
Add a buffer to the queue.
Definition: bufferqueue.h:71
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:319
int nb_channels
internal API functions
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:117
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