FFmpeg  4.4.8
vf_mix.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Paul B Mahol
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. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/avstring.h"
22 #include "libavutil/imgutils.h"
23 #include "libavutil/intreadwrite.h"
24 #include "libavutil/opt.h"
25 #include "libavutil/pixdesc.h"
26 
27 #include "avfilter.h"
28 #include "filters.h"
29 #include "formats.h"
30 #include "internal.h"
31 #include "framesync.h"
32 #include "video.h"
33 
34 typedef struct MixContext {
35  const AVClass *class;
37  char *weights_str;
38  int nb_inputs;
39  int duration;
40  float *weights;
41  float scale;
42  float wfactor;
43 
44  int tmix;
45  int nb_frames;
46 
47  int depth;
48  int max;
49  int nb_planes;
50  int linesize[4];
51  int height[4];
52 
55 } MixContext;
56 
58 {
60  int ret;
61 
66  if (ret < 0)
67  return ret;
69 }
70 
72 {
73  MixContext *s = ctx->priv;
74  char *p, *arg, *saveptr = NULL;
75  int i, last = 0;
76 
77  s->wfactor = 0.f;
78  p = s->weights_str;
79  for (i = 0; i < s->nb_inputs; i++) {
80  if (!(arg = av_strtok(p, " |", &saveptr)))
81  break;
82 
83  p = NULL;
84  if (av_sscanf(arg, "%f", &s->weights[i]) != 1) {
85  av_log(ctx, AV_LOG_ERROR, "Invalid syntax for weights[%d].\n", i);
86  return AVERROR(EINVAL);
87  }
88  s->wfactor += s->weights[i];
89  last = i;
90  }
91 
92  for (; i < s->nb_inputs; i++) {
93  s->weights[i] = s->weights[last];
94  s->wfactor += s->weights[i];
95  }
96  if (s->scale == 0) {
97  s->wfactor = 1 / s->wfactor;
98  } else {
99  s->wfactor = s->scale;
100  }
101 
102  return 0;
103 }
104 
106 {
107  MixContext *s = ctx->priv;
108  int ret;
109 
110  s->tmix = !strcmp(ctx->filter->name, "tmix");
111 
112  s->frames = av_calloc(s->nb_inputs, sizeof(*s->frames));
113  if (!s->frames)
114  return AVERROR(ENOMEM);
115 
116  s->weights = av_calloc(s->nb_inputs, sizeof(*s->weights));
117  if (!s->weights)
118  return AVERROR(ENOMEM);
119 
120  if (!s->tmix) {
121  for (int i = 0; i < s->nb_inputs; i++) {
122  AVFilterPad pad = { 0 };
123 
124  pad.type = AVMEDIA_TYPE_VIDEO;
125  pad.name = av_asprintf("input%d", i);
126  if (!pad.name)
127  return AVERROR(ENOMEM);
128 
129  if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0) {
130  av_freep(&pad.name);
131  return ret;
132  }
133  }
134  }
135 
136  return parse_weights(ctx);
137 }
138 
139 typedef struct ThreadData {
140  AVFrame **in, *out;
141 } ThreadData;
142 
143 static int mix_frames(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
144 {
145  MixContext *s = ctx->priv;
146  ThreadData *td = arg;
147  AVFrame **in = td->in;
148  AVFrame *out = td->out;
149  int i, p, x, y;
150 
151  if (s->depth <= 8) {
152  for (p = 0; p < s->nb_planes; p++) {
153  const int slice_start = ff_slice_pos(s->height[p], jobnr, nb_jobs);
154  const int slice_end = ff_slice_pos(s->height[p], jobnr + 1, nb_jobs);
155  uint8_t *dst = out->data[p] + slice_start * out->linesize[p];
156 
157  for (y = slice_start; y < slice_end; y++) {
158  for (x = 0; x < s->linesize[p]; x++) {
159  int val = 0;
160 
161  for (i = 0; i < s->nb_inputs; i++) {
162  uint8_t src = in[i]->data[p][y * in[i]->linesize[p] + x];
163 
164  val += src * s->weights[i];
165  }
166 
167  dst[x] = av_clip_uint8(val * s->wfactor);
168  }
169 
170  dst += out->linesize[p];
171  }
172  }
173  } else {
174  for (p = 0; p < s->nb_planes; p++) {
175  const int slice_start = ff_slice_pos(s->height[p], jobnr, nb_jobs);
176  const int slice_end = ff_slice_pos(s->height[p], jobnr + 1, nb_jobs);
177  uint16_t *dst = (uint16_t *)(out->data[p] + slice_start * out->linesize[p]);
178 
179  for (y = slice_start; y < slice_end; y++) {
180  for (x = 0; x < s->linesize[p] / 2; x++) {
181  int val = 0;
182 
183  for (i = 0; i < s->nb_inputs; i++) {
184  uint16_t src = AV_RN16(in[i]->data[p] + y * in[i]->linesize[p] + x * 2);
185 
186  val += src * s->weights[i];
187  }
188 
189  dst[x] = av_clip(val * s->wfactor, 0, s->max);
190  }
191 
192  dst += out->linesize[p] / 2;
193  }
194  }
195  }
196 
197  return 0;
198 }
199 
201 {
202  AVFilterContext *ctx = fs->parent;
203  AVFilterLink *outlink = ctx->outputs[0];
204  MixContext *s = fs->opaque;
205  AVFrame **in = s->frames;
206  AVFrame *out;
207  ThreadData td;
208  int i, ret;
209 
210  for (i = 0; i < s->nb_inputs; i++) {
211  if ((ret = ff_framesync_get_frame(&s->fs, i, &in[i], 0)) < 0)
212  return ret;
213  }
214 
215  if (ctx->is_disabled) {
216  out = av_frame_clone(s->frames[0]);
217  if (!out)
218  return AVERROR(ENOMEM);
219  out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
220  return ff_filter_frame(outlink, out);
221  }
222 
223  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
224  if (!out)
225  return AVERROR(ENOMEM);
226  out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
227 
228  td.in = in;
229  td.out = out;
230  ctx->internal->execute(ctx, mix_frames, &td, NULL, FFMIN(s->height[0], ff_filter_get_nb_threads(ctx)));
231 
232  return ff_filter_frame(outlink, out);
233 }
234 
235 static int config_output(AVFilterLink *outlink)
236 {
237  AVFilterContext *ctx = outlink->src;
238  MixContext *s = ctx->priv;
239  AVRational frame_rate = ctx->inputs[0]->frame_rate;
240  AVRational sar = ctx->inputs[0]->sample_aspect_ratio;
241  AVFilterLink *inlink = ctx->inputs[0];
242  int height = ctx->inputs[0]->h;
243  int width = ctx->inputs[0]->w;
244  FFFrameSyncIn *in;
245  int i, ret;
246 
247  if (!s->tmix) {
248  for (i = 1; i < s->nb_inputs; i++) {
249  if (ctx->inputs[i]->h != height || ctx->inputs[i]->w != width) {
250  av_log(ctx, AV_LOG_ERROR, "Input %d size (%dx%d) does not match input %d size (%dx%d).\n", i, ctx->inputs[i]->w, ctx->inputs[i]->h, 0, width, height);
251  return AVERROR(EINVAL);
252  }
253  }
254  }
255 
256  s->desc = av_pix_fmt_desc_get(outlink->format);
257  if (!s->desc)
258  return AVERROR_BUG;
259  s->nb_planes = av_pix_fmt_count_planes(outlink->format);
260  s->depth = s->desc->comp[0].depth;
261  s->max = (1 << s->depth) - 1;
262 
263  if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
264  return ret;
265 
266  s->height[1] = s->height[2] = AV_CEIL_RSHIFT(inlink->h, s->desc->log2_chroma_h);
267  s->height[0] = s->height[3] = inlink->h;
268 
269  if (s->tmix)
270  return 0;
271 
272  outlink->w = width;
273  outlink->h = height;
274  outlink->frame_rate = frame_rate;
275  outlink->sample_aspect_ratio = sar;
276 
277  if ((ret = ff_framesync_init(&s->fs, ctx, s->nb_inputs)) < 0)
278  return ret;
279 
280  in = s->fs.in;
281  s->fs.opaque = s;
282  s->fs.on_event = process_frame;
283 
284  for (i = 0; i < s->nb_inputs; i++) {
285  AVFilterLink *inlink = ctx->inputs[i];
286 
287  in[i].time_base = inlink->time_base;
288  in[i].sync = 1;
289  in[i].before = EXT_STOP;
290  in[i].after = (s->duration == 1 || (s->duration == 2 && i == 0)) ? EXT_STOP : EXT_INFINITY;
291  }
292 
293  ret = ff_framesync_configure(&s->fs);
294  outlink->time_base = s->fs.time_base;
295 
296  return ret;
297 }
298 
300 {
301  MixContext *s = ctx->priv;
302  int i;
303 
304  ff_framesync_uninit(&s->fs);
305  av_freep(&s->weights);
306 
307  if (!s->tmix) {
308  for (i = 0; i < ctx->nb_inputs; i++)
309  av_freep(&ctx->input_pads[i].name);
310  } else {
311  for (i = 0; i < s->nb_frames && s->frames; i++)
312  av_frame_free(&s->frames[i]);
313  }
314  av_freep(&s->frames);
315 }
316 
317 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
318  char *res, int res_len, int flags)
319 {
320  int ret;
321 
322  ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
323  if (ret < 0)
324  return ret;
325 
326  return parse_weights(ctx);
327 }
328 
330 {
331  MixContext *s = ctx->priv;
332  return ff_framesync_activate(&s->fs);
333 }
334 
335 #define OFFSET(x) offsetof(MixContext, x)
336 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
337 #define TFLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
338 
339 static const AVOption mix_options[] = {
340  { "inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=2}, 2, INT16_MAX, .flags = FLAGS },
341  { "weights", "set weight for each input", OFFSET(weights_str), AV_OPT_TYPE_STRING, {.str="1 1"}, 0, 0, .flags = TFLAGS },
342  { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, INT16_MAX, .flags = TFLAGS },
343  { "duration", "how to determine end of stream", OFFSET(duration), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, .flags = FLAGS, "duration" },
344  { "longest", "Duration of longest input", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "duration" },
345  { "shortest", "Duration of shortest input", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "duration" },
346  { "first", "Duration of first input", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "duration" },
347  { NULL },
348 };
349 
350 static const AVFilterPad outputs[] = {
351  {
352  .name = "default",
353  .type = AVMEDIA_TYPE_VIDEO,
354  .config_props = config_output,
355  },
356  { NULL }
357 };
358 
359 #if CONFIG_MIX_FILTER
361 
363  .name = "mix",
364  .description = NULL_IF_CONFIG_SMALL("Mix video inputs."),
365  .priv_size = sizeof(MixContext),
366  .priv_class = &mix_class,
368  .outputs = outputs,
369  .init = init,
370  .uninit = uninit,
371  .activate = activate,
375 };
376 
377 #endif /* CONFIG_MIX_FILTER */
378 
379 #if CONFIG_TMIX_FILTER
380 static int tmix_filter_frame(AVFilterLink *inlink, AVFrame *in)
381 {
382  AVFilterContext *ctx = inlink->dst;
383  AVFilterLink *outlink = ctx->outputs[0];
384  MixContext *s = ctx->priv;
385  ThreadData td;
386  AVFrame *out;
387 
388  if (s->nb_inputs == 1)
389  return ff_filter_frame(outlink, in);
390 
391  if (s->nb_frames < s->nb_inputs) {
392  s->frames[s->nb_frames] = in;
393  s->nb_frames++;
394  if (s->nb_frames < s->nb_inputs)
395  return 0;
396  } else {
397  av_frame_free(&s->frames[0]);
398  memmove(&s->frames[0], &s->frames[1], sizeof(*s->frames) * (s->nb_inputs - 1));
399  s->frames[s->nb_inputs - 1] = in;
400  }
401 
402  if (ctx->is_disabled) {
403  out = av_frame_clone(s->frames[0]);
404  if (!out)
405  return AVERROR(ENOMEM);
406  return ff_filter_frame(outlink, out);
407  }
408 
409  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
410  if (!out)
411  return AVERROR(ENOMEM);
412  out->pts = s->frames[0]->pts;
413 
414  td.out = out;
415  td.in = s->frames;
416  ctx->internal->execute(ctx, mix_frames, &td, NULL, FFMIN(s->height[0], ff_filter_get_nb_threads(ctx)));
417 
418  return ff_filter_frame(outlink, out);
419 }
420 
421 static const AVOption tmix_options[] = {
422  { "frames", "set number of successive frames to mix", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=3}, 1, 128, .flags = FLAGS },
423  { "weights", "set weight for each frame", OFFSET(weights_str), AV_OPT_TYPE_STRING, {.str="1 1 1"}, 0, 0, .flags = TFLAGS },
424  { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, INT16_MAX, .flags = TFLAGS },
425  { NULL },
426 };
427 
428 static const AVFilterPad inputs[] = {
429  {
430  .name = "default",
431  .type = AVMEDIA_TYPE_VIDEO,
432  .filter_frame = tmix_filter_frame,
433  },
434  { NULL }
435 };
436 
438 
440  .name = "tmix",
441  .description = NULL_IF_CONFIG_SMALL("Mix successive video frames."),
442  .priv_size = sizeof(MixContext),
443  .priv_class = &tmix_class,
445  .outputs = outputs,
446  .inputs = inputs,
447  .init = init,
448  .uninit = uninit,
451 };
452 
453 #endif /* CONFIG_TMIX_FILTER */
static double val(void *priv, double ch)
Definition: aeval.c:76
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
AVFilter ff_vf_tmix
AVFilter ff_vf_mix
#define av_cold
Definition: attributes.h:88
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
uint8_t
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1096
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:882
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:802
Main libavfilter public API header.
char * av_asprintf(const char *fmt,...)
Definition: avstring.c:113
#define flags(name, subs,...)
Definition: cbs_av1.c:572
#define s(width, name)
Definition: cbs_vp9.c:257
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:259
#define FFMIN(a, b)
Definition: common.h:105
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
#define av_clip
Definition: common.h:122
#define av_clip_uint8
Definition: common.h:128
#define NULL
Definition: coverity.c:32
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
Definition: filters.h:271
int ff_formats_pixdesc_filter(AVFilterFormats **rfmts, unsigned want, unsigned rej)
Construct a formats list containing all pixel formats with certain properties.
Definition: formats.c:367
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:587
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:124
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition: framesync.c:341
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
Definition: framesync.c:253
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:290
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
Definition: framesync.c:84
@ EXT_STOP
Completely stop all streams with this one.
Definition: framesync.h:65
@ EXT_INFINITY
Extend the frame to infinity.
Definition: framesync.h:75
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
@ AV_OPT_TYPE_INT
Definition: opt.h:225
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:134
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition: avfilter.h:106
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:50
#define AVERROR(e)
Definition: error.h:43
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:540
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:245
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition: imgutils.c:89
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
Definition: avstring.c:186
int av_sscanf(const char *string, const char *format,...)
See libc sscanf manual for more information.
Definition: avsscanf.c:962
misc image utilities
int i
Definition: input.c:407
#define AV_RN16(p)
Definition: intreadwrite.h:360
static int mix(int c0, int c1)
Definition: 4xm.c:715
const char * arg
Definition: jacosubdec.c:66
static int ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.
Definition: internal.h:240
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:288
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2033
const char data[16]
Definition: mxf.c:142
AVOptions.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2613
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
Definition: pixdesc.h:136
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:140
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Definition: pixdesc.h:132
#define td
Definition: regdef.h:70
formats
Definition: signature.h:48
Describe the class of an AVClass context structure.
Definition: log.h:67
An instance of a filter.
Definition: avfilter.h:341
A list of supported formats for one end of a filter link.
Definition: formats.h:65
A filter pad used for either input or output.
Definition: internal.h:54
enum AVMediaType type
AVFilterPad type.
Definition: internal.h:65
const char * name
Pad name.
Definition: internal.h:60
Filter definition.
Definition: avfilter.h:145
const char * name
Filter name.
Definition: avfilter.h:149
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1699
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
AVOption.
Definition: opt.h:248
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
Rational number (pair of numerator and denominator).
Definition: rational.h:58
Input stream structure.
Definition: framesync.h:81
Frame sync structure.
Definition: framesync.h:146
int nb_inputs
number of inputs
Definition: af_amix.c:162
int height[4]
Definition: vf_mix.c:51
int max
Definition: vf_mix.c:48
const AVPixFmtDescriptor * desc
Definition: vf_mix.c:36
int nb_frames
Definition: vf_mix.c:45
FFFrameSync fs
Definition: vf_mix.c:54
float scale
Definition: vf_mix.c:41
int depth
Definition: vf_mix.c:47
int duration
Definition: vf_mix.c:39
float wfactor
Definition: vf_mix.c:42
char * weights_str
string for custom weights for every input
Definition: af_amix.c:166
float * weights
custom weights for every input
Definition: af_amix.c:175
int linesize[4]
Definition: vf_mix.c:50
int tmix
Definition: vf_mix.c:44
AVFrame ** frames
Definition: vf_mix.c:53
int nb_planes
Definition: vf_mix.c:49
Used for passing data between threads.
Definition: dsddec.c:67
AVFrame * out
Definition: af_adeclick.c:502
AVFrame * in
Definition: af_adenorm.c:223
#define av_freep(p)
#define av_log(a,...)
#define src
Definition: vp8dsp.c:255
FILE * out
Definition: movenc.c:54
int64_t duration
Definition: movenc.c:64
AVFormatContext * ctx
Definition: movenc.c:48
#define height
#define width
#define TFLAGS
Definition: vf_mix.c:337
static int query_formats(AVFilterContext *ctx)
Definition: vf_mix.c:57
#define FLAGS
Definition: vf_mix.c:336
static const AVFilterPad outputs[]
Definition: vf_mix.c:350
static int parse_weights(AVFilterContext *ctx)
Definition: vf_mix.c:71
static const AVOption mix_options[]
Definition: vf_mix.c:339
static int mix_frames(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_mix.c:143
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_mix.c:317
static int activate(AVFilterContext *ctx)
Definition: vf_mix.c:329
static av_cold int init(AVFilterContext *ctx)
Definition: vf_mix.c:105
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_mix.c:299
#define OFFSET(x)
Definition: vf_mix.c:335
static int config_output(AVFilterLink *outlink)
Definition: vf_mix.c:235
static int process_frame(FFFrameSync *fs)
Definition: vf_mix.c:200
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:104