FFmpeg
src_avsynctest.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2022 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/avassert.h"
22 #include "libavutil/common.h"
24 #include "libavutil/ffmath.h"
25 #include "libavutil/opt.h"
26 #include "libavutil/imgutils.h"
27 #include "libavutil/intreadwrite.h"
28 #include "libavutil/parseutils.h"
29 #include "libavutil/timestamp.h"
31 #include "avfilter.h"
32 #include "drawutils.h"
33 #include "filters.h"
34 #include "formats.h"
35 #include "audio.h"
36 #include "video.h"
37 
38 typedef struct AVSyncTestContext {
39  const AVClass *class;
40 
41  int w, h;
46  float amplitude;
47  int period;
48  int delay;
49  int cycle;
50 
51  int beep;
53  int flash;
54  int dir;
58 
59  uint8_t rgba[3][4];
65 
66 #define OFFSET(x) offsetof(AVSyncTestContext, x)
67 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
68 #define V AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
69 #define R AV_OPT_FLAG_RUNTIME_PARAM
70 
71 static const AVOption avsynctest_options[] = {
72  {"size", "set frame size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, V },
73  {"s", "set frame size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, V },
74  {"framerate", "set frame rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="30"}, 0,INT_MAX, V },
75  {"fr", "set frame rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="30"}, 0,INT_MAX, V },
76  {"samplerate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100},8000,384000, A },
77  {"sr", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100},8000,384000, A },
78  {"amplitude", "set beep amplitude", OFFSET(amplitude), AV_OPT_TYPE_FLOAT, {.dbl=.7}, 0., 1., A|R },
79  {"a", "set beep amplitude", OFFSET(amplitude), AV_OPT_TYPE_FLOAT, {.dbl=.7}, 0., 1., A|R },
80  {"period", "set beep period", OFFSET(period), AV_OPT_TYPE_INT, {.i64=3}, 1, 99., A },
81  {"p", "set beep period", OFFSET(period), AV_OPT_TYPE_INT, {.i64=3}, 1, 99., A },
82  {"delay", "set flash delay", OFFSET(delay), AV_OPT_TYPE_INT, {.i64=0}, -30, 30, V|R },
83  {"dl", "set flash delay", OFFSET(delay), AV_OPT_TYPE_INT, {.i64=0}, -30, 30, V|R },
84  {"cycle", "set delay cycle", OFFSET(cycle), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, V|R },
85  {"c", "set delay cycle", OFFSET(cycle), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, V|R },
86  {"duration", "set duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT64_MAX, V|A },
87  {"d", "set duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT64_MAX, V|A },
88  {"fg", "set foreground color", OFFSET(rgba[0]), AV_OPT_TYPE_COLOR, {.str="white"}, 0, 0, V },
89  {"bg", "set background color", OFFSET(rgba[1]), AV_OPT_TYPE_COLOR, {.str="black"}, 0, 0, V },
90  {"ag", "set additional color", OFFSET(rgba[2]), AV_OPT_TYPE_COLOR, {.str="gray"}, 0, 0, V },
91  {NULL},
92 };
93 
94 AVFILTER_DEFINE_CLASS(avsynctest);
95 
97  AVFilterFormatsConfig **cfg_in,
98  AVFilterFormatsConfig **cfg_out)
99 {
100  const AVSyncTestContext *s = ctx->priv;
101  int sample_rates[] = { s->sample_rate, -1 };
102  static const enum AVSampleFormat sample_fmts[] = {
104  };
105  static const AVChannelLayout layouts[] = {
107  { .nb_channels = 0 },
108  };
110  int ret;
111 
113  if (!formats)
114  return AVERROR(ENOMEM);
115  if ((ret = ff_formats_ref(formats, &cfg_out[0]->formats)) < 0)
116  return ret;
117 
119  if (!formats)
120  return AVERROR(ENOMEM);
121  if ((ret = ff_formats_ref(formats, &cfg_out[1]->formats)) < 0)
122  return ret;
123 
125  if (ret < 0)
126  return ret;
127 
128  return ff_set_common_samplerates_from_list2(ctx, cfg_in, cfg_out, sample_rates);
129 }
130 
131 static av_cold int aconfig_props(AVFilterLink *outlink)
132 {
133  AVFilterContext *ctx = outlink->src;
134  AVSyncTestContext *s = ctx->priv;
135 
136  outlink->sample_rate = s->sample_rate;
137  outlink->time_base = (AVRational){1, s->sample_rate};
138 
139  s->beep_duration = av_rescale(s->sample_rate, s->frame_rate.den, s->frame_rate.num);
140  s->duration = av_rescale(s->duration, s->sample_rate, AV_TIME_BASE);
141 
142  return 0;
143 }
144 
145 static av_cold int config_props(AVFilterLink *outlink)
146 {
147  FilterLink *l = ff_filter_link(outlink);
148  AVFilterContext *ctx = outlink->src;
149  AVSyncTestContext *s = ctx->priv;
150 
151  outlink->w = s->w;
152  outlink->h = s->h;
153  outlink->time_base = av_inv_q(s->frame_rate);
154  l->frame_rate = s->frame_rate;
155  outlink->sample_aspect_ratio = (AVRational) {1, 1};
156  s->delay_min = av_mul_q(s->frame_rate, av_make_q(-1, 2));
157  s->delay_max = av_mul_q(s->delay_min, av_make_q(-1, 1));
158  s->delay_range = av_sub_q(s->delay_max, s->delay_min);
159  s->vdelay = av_make_q(s->delay, 1);
160  s->dir = 1;
161  s->prev_intpart = INT64_MIN;
162 
163  ff_draw_init2(&s->draw, outlink->format, outlink->colorspace, outlink->color_range, 0);
164 
165  ff_draw_color(&s->draw, &s->fg, s->rgba[0]);
166  ff_draw_color(&s->draw, &s->bg, s->rgba[1]);
167  ff_draw_color(&s->draw, &s->ag, s->rgba[2] );
168 
169  return 0;
170 }
171 
172 #define FPI 0x8000
173 
175 {
176  const double pi = M_PI;
177  const int32_t a = ((2.0 * pi) * (1 << 24));
178  const int32_t b = (1 << 7) * (12.0 / pi - 1.0 - pi) * (1 << 24);
179  const int32_t c = (1 << 9) * 3.0 * (2.0 + pi - 16.0 / pi) * (1 << 24);
180  int64_t x2, result;
181  int32_t t1, t2;
182 
183  x &= 2 * FPI - 1;
184 
185  if (x >= (3 * FPI / 2))
186  x = x - 2 * FPI;
187  else if (x > FPI / 2)
188  x = FPI - x;
189 
190  x2 = x * x;
191  t1 = (x2 * c) >> 32;
192  t2 = ((b + t1) * x2) >> 32;
193  x = x << 8;
194 
195  result = a + t2;
196  result *= x;
197  result += (1U << 31);
198  result >>= 17;
199  result = av_rescale(result, scale.num, scale.den);
200 
201  return result;
202 }
203 
204 static int audio_frame(AVFilterLink *outlink)
205 {
206  AVFilterContext *ctx = outlink->src;
207  AVSyncTestContext *s = ctx->priv;
208  const AVRational a = av_d2q(s->amplitude, 32768);
209  int64_t duration[2];
210  int64_t delta;
211  AVFrame *out;
212  int32_t *dst;
213 
214  delta = av_rescale_q(s->vpts, av_make_q(s->sample_rate, 1), s->frame_rate) - s->apts;
215  if (delta < 0)
216  return 1;
217 
218  duration[0] = av_rescale_rnd(s->sample_rate, s->frame_rate.den, s->frame_rate.num, AV_ROUND_DOWN);
219  duration[1] = av_rescale_rnd(s->sample_rate, s->frame_rate.den, s->frame_rate.num, AV_ROUND_UP);
220 
221  delta = duration[delta > 0];
222  out = ff_get_audio_buffer(outlink, delta);
223  if (!out)
224  return AVERROR(ENOMEM);
225 
226  out->pts = s->apts;
227  dst = (int32_t *)out->data[0];
228 
229  for (int i = 0; i < delta; i++) {
230  if (((s->apts + i) % (s->period * s->sample_rate)) == 0)
231  s->beep = 1;
232  if (s->beep) {
233  dst[i] = sin32(av_rescale_q(800LL * 2LL * FPI, outlink->time_base, av_make_q(1, s->apts + i)), a);
234  s->beep++;
235  } else {
236  dst[i] = 0;
237  }
238  if (s->beep >= s->beep_duration) {
239  s->beep = 0;
240  }
241  }
242  s->apts += out->nb_samples;
243 
244  return ff_filter_frame(outlink, out);
245 }
246 
248  int x0, int y0, const uint8_t *text)
249 {
250  int x = x0;
251 
252  for (; *text; text++) {
253  if (*text == '\n') {
254  x = x0;
255  y0 += 8;
256  continue;
257  }
258  ff_blend_mask(draw, color, out->data, out->linesize,
259  out->width, out->height,
260  avpriv_cga_font + *text * 8, 1, 8, 8, 0, 0, x, y0);
261  x += 8;
262  }
263 }
264 
265 static int offset(int x, int num, int den)
266 {
267  return av_rescale_rnd(x, num, den, AV_ROUND_UP);
268 }
269 
270 static int video_frame(AVFilterLink *outlink)
271 {
272  AVFilterContext *ctx = outlink->src;
273  AVSyncTestContext *s = ctx->priv;
274  const int w = outlink->w;
275  const int h = outlink->h;
276  const int step = av_rescale_rnd(w, s->delay_range.den, s->delay_range.num, AV_ROUND_DOWN);
277  char text[128];
278  int new_offset;
279  int64_t delta, temp, intpart;
280  AVFrame *out;
281 
282  if (!s->cycle)
283  s->vdelay = av_make_q(s->delay, 1);
284 
285  delta = av_rescale_q(s->apts, s->frame_rate, av_make_q(s->sample_rate, 1)) - s->vpts;
286  if (delta < 0)
287  return 1;
288 
289  out = ff_get_video_buffer(outlink, w, h);
290  if (!out)
291  return AVERROR(ENOMEM);
292 
293  ff_fill_rectangle(&s->draw, &s->bg, out->data, out->linesize, 0, 0, w, h);
294 
295  snprintf(text, sizeof(text), "FRN: %"PRId64"", s->vpts);
296  draw_text(&s->draw, out, &s->fg, offset(w, 1, 10), offset(h, 1, 10), text);
297 
298  snprintf(text, sizeof(text), "SEC: %s", av_ts2timestr(s->vpts, &outlink->time_base));
299  draw_text(&s->draw, out, &s->fg, offset(w, 1, 10), offset(h, 9, 10), text);
300 
301  snprintf(text, sizeof(text), "DLY: %d", s->vdelay.num);
302  draw_text(&s->draw, out, &s->fg, offset(w, 9, 10) - strlen(text) * 8, offset(h, 9, 10), text);
303 
304  snprintf(text, sizeof(text), "FPS: %d/%d", s->frame_rate.num, s->frame_rate.den);
305  draw_text(&s->draw, out, &s->fg, offset(w, 9, 10) - strlen(text) * 8, offset(h, 1, 10), text);
306 
307  snprintf(text, sizeof(text), "P: %d", s->period);
308  draw_text(&s->draw, out, &s->ag, offset(w, 1, 2) - strlen(text) * 4, offset(h, 9, 10), text);
309 
310  snprintf(text, sizeof(text), "SR: %d", s->sample_rate);
311  draw_text(&s->draw, out, &s->ag, offset(w, 1, 2) - strlen(text) * 4, offset(h, 1, 10), text);
312 
313  snprintf(text, sizeof(text), "A: %1.2f", s->amplitude);
314  draw_text(&s->draw, out, &s->ag, offset(w, 1, 10), offset(h, 1, 2), text);
315 
316  snprintf(text, sizeof(text), "WxH: %dx%d", w, h);
317  draw_text(&s->draw, out, &s->ag, offset(w, 9, 10) - strlen(text) * 8, offset(h, 1, 2), text);
318 
319  temp = s->vpts + s->vdelay.num;
320  intpart = av_rescale_rnd(temp, outlink->time_base.num, outlink->time_base.den, AV_ROUND_NEAR_INF);
321  intpart = temp - av_rescale_rnd(intpart, outlink->time_base.den, outlink->time_base.num, AV_ROUND_NEAR_INF);
322 
323  new_offset = offset(w, 1, 2);
324  ff_fill_rectangle(&s->draw, &s->fg, out->data, out->linesize,
325  av_clip(new_offset + step * intpart, 0, w - 2),
326  offset(h, 141, 200), offset(step, 2, 3), offset(h, 1, 25));
327 
328  if (intpart == 0 && s->prev_intpart != intpart) {
329  if (s->flash >= s->period) {
330  int result;
331 
332  if (s->cycle)
333  s->vdelay = av_add_q(s->vdelay, av_make_q(s->dir, 1));
334  result = av_cmp_q(s->vdelay, s->delay_max);
335  if (result >= 0)
336  s->dir = -1;
337  result = av_cmp_q(s->vdelay, s->delay_min);
338  if (result <= 0)
339  s->dir = 1;
340  ff_fill_rectangle(&s->draw, &s->fg, out->data, out->linesize,
341  offset(w, 1, 3), offset(h, 1, 3), offset(w, 1, 3), offset(h, 1, 4));
342  s->flash = 0;
343  }
344  s->flash++;
345  }
346  s->prev_intpart = intpart;
347 
348  for (int i = av_rescale(s->delay_min.num, 1, s->delay_min.den);
349  i < av_rescale(s->delay_max.num, 1, s->delay_max.den); i++) {
350  ff_fill_rectangle(&s->draw, &s->fg, out->data, out->linesize,
351  av_clip(new_offset + step * i, 0, w - 2),
352  offset(h, 7, 10), 1, offset(h, 1, 20));
353  }
354 
355  out->pts = s->vpts++;
356  out->duration = 1;
357 
358  return ff_filter_frame(outlink, out);
359 }
360 
362 {
363  AVSyncTestContext *s = ctx->priv;
364  AVFilterLink *aoutlink = ctx->outputs[0];
365  AVFilterLink *voutlink = ctx->outputs[1];
366  int ret = FFERROR_NOT_READY;
367 
368  if (!ff_outlink_frame_wanted(aoutlink) &&
369  !ff_outlink_frame_wanted(voutlink))
370  return ret;
371 
372  if (s->duration > 0 && s->apts >= s->duration) {
373  ff_outlink_set_status(aoutlink, AVERROR_EOF, s->apts);
374  ff_outlink_set_status(voutlink, AVERROR_EOF, s->vpts);
375  return 0;
376  }
377 
378  ret = audio_frame(aoutlink);
379  if (ret < 0)
380  return ret;
381  ret = video_frame(voutlink);
382 
383  return ret;
384 }
385 
386 static const AVFilterPad avsynctest_outputs[] = {
387  {
388  .name = "audio",
389  .type = AVMEDIA_TYPE_AUDIO,
390  .config_props = aconfig_props,
391  },
392  {
393  .name = "video",
394  .type = AVMEDIA_TYPE_VIDEO,
395  .config_props = config_props,
396  },
397 };
398 
400  .name = "avsynctest",
401  .description = NULL_IF_CONFIG_SMALL("Generate an Audio Video Sync Test."),
402  .priv_size = sizeof(AVSyncTestContext),
403  .priv_class = &avsynctest_class,
404  .inputs = NULL,
405  .activate = activate,
408  .process_command = ff_filter_process_command,
409 };
formats
formats
Definition: signature.h:47
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:116
AV_ROUND_UP
@ AV_ROUND_UP
Round toward +infinity.
Definition: mathematics.h:134
ff_get_audio_buffer
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:98
avsynctest_outputs
static const AVFilterPad avsynctest_outputs[]
Definition: src_avsynctest.c:386
FFDrawColor
Definition: drawutils.h:51
AVSyncTestContext::amplitude
float amplitude
Definition: src_avsynctest.c:46
av_clip
#define av_clip
Definition: common.h:100
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_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:435
out
FILE * out
Definition: movenc.c:55
color
Definition: vf_paletteuse.c:513
AVSyncTestContext::fg
FFDrawColor fg
Definition: src_avsynctest.c:61
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1061
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:948
layouts
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:335
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition: opt.h:315
int64_t
long long int64_t
Definition: coverity.c:34
sample_rates
static const int sample_rates[]
Definition: dcaenc.h:34
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
w
uint8_t w
Definition: llviddspenc.c:38
AVSyncTestContext::apts
int64_t apts
Definition: src_avsynctest.c:45
AVOption
AVOption.
Definition: opt.h:429
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(avsynctest)
b
#define b
Definition: input.c:41
AV_OPT_TYPE_DURATION
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
Definition: opt.h:319
ff_set_common_channel_layouts_from_list2
int ff_set_common_channel_layouts_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const AVChannelLayout *fmts)
Definition: formats.c:920
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
av_sub_q
AVRational av_sub_q(AVRational b, AVRational c)
Subtract one rational from another.
Definition: rational.c:101
AVSyncTestContext::dir
int dir
Definition: src_avsynctest.c:54
video.h
AVSyncTestContext::beep_duration
int beep_duration
Definition: src_avsynctest.c:52
AVSyncTestContext::prev_intpart
int64_t prev_intpart
Definition: src_avsynctest.c:57
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
AVSyncTestContext::period
int period
Definition: src_avsynctest.c:47
formats.h
AVSyncTestContext::cycle
int cycle
Definition: src_avsynctest.c:49
ff_blend_mask
void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, const uint8_t *mask, int mask_linesize, int mask_w, int mask_h, int l2depth, unsigned endianness, int x0, int y0)
Blend an alpha mask with an uniform color.
Definition: drawutils.c:549
AVRational::num
int num
Numerator.
Definition: rational.h:59
AVSyncTestContext::beep
int beep
Definition: src_avsynctest.c:51
AVSyncTestContext::duration
int64_t duration
Definition: src_avsynctest.c:44
AVSyncTestContext::ag
FFDrawColor ag
Definition: src_avsynctest.c:63
AVSyncTestContext::delay_min
AVRational delay_min
Definition: src_avsynctest.c:55
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
avassert.h
av_cold
#define av_cold
Definition: attributes.h:90
duration
int64_t duration
Definition: movenc.c:65
FPI
#define FPI
Definition: src_avsynctest.c:172
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:424
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVSyncTestContext::delay_range
AVRational delay_range
Definition: src_avsynctest.c:56
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:678
filters.h
AVSyncTestContext::draw
FFDrawContext draw
Definition: src_avsynctest.c:60
ff_set_common_samplerates_from_list2
int ff_set_common_samplerates_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const int *samplerates)
Definition: formats.c:944
ctx
AVFormatContext * ctx
Definition: movenc.c:49
av_rescale_q
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
AV_ROUND_NEAR_INF
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
Definition: mathematics.h:135
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
AVSyncTestContext::delay_max
AVRational delay_max
Definition: src_avsynctest.c:55
if
if(ret)
Definition: filter_design.txt:179
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
result
and forward the result(frame or status change) to the corresponding input. If nothing is possible
NULL
#define NULL
Definition: coverity.c:32
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
period
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without period
Definition: writing_filters.txt:89
query_formats
static av_cold int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: src_avsynctest.c:96
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
Definition: opt.h:323
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition: opt.h:303
parseutils.h
AVSyncTestContext::frame_rate
AVRational frame_rate
Definition: src_avsynctest.c:42
AVSyncTestContext::h
int h
Definition: src_avsynctest.c:41
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
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
AVFilterFormatsConfig
Lists of formats / etc.
Definition: avfilter.h:111
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:197
AVSyncTestContext::rgba
uint8_t rgba[3][4]
Definition: src_avsynctest.c:59
aconfig_props
static av_cold int aconfig_props(AVFilterLink *outlink)
Definition: src_avsynctest.c:131
AV_ROUND_DOWN
@ AV_ROUND_DOWN
Round toward -infinity.
Definition: mathematics.h:133
av_rescale_rnd
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
Definition: mathematics.c:58
ff_avsrc_avsynctest
const AVFilter ff_avsrc_avsynctest
Definition: src_avsynctest.c:399
av_ts2timestr
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: timestamp.h:83
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:94
AVSyncTestContext::w
int w
Definition: src_avsynctest.c:41
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:317
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
video_frame
static int video_frame(AVFilterLink *outlink)
Definition: src_avsynctest.c:270
ff_draw_init2
int ff_draw_init2(FFDrawContext *draw, enum AVPixelFormat format, enum AVColorSpace csp, enum AVColorRange range, unsigned flags)
Init a draw context.
Definition: drawutils.c:95
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
offset
static int offset(int x, int num, int den)
Definition: src_avsynctest.c:265
avsynctest_options
static const AVOption avsynctest_options[]
Definition: src_avsynctest.c:71
av_make_q
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition: rational.h:71
ff_fill_rectangle
void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_x, int dst_y, int w, int h)
Fill a rectangle with an uniform color.
Definition: drawutils.c:246
AVSyncTestContext::vpts
int64_t vpts
Definition: src_avsynctest.c:45
ff_filter_process_command
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:900
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
xga_font_data.h
M_PI
#define M_PI
Definition: mathematics.h:67
draw
static int draw(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: avf_showcwt.c:440
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
activate
static int activate(AVFilterContext *ctx)
Definition: src_avsynctest.c:361
AVSyncTestContext::bg
FFDrawColor bg
Definition: src_avsynctest.c:62
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
ff_draw_supported_pixel_formats
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
Definition: drawutils.c:662
common.h
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
delta
float delta
Definition: vorbis_enc_data.h:430
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
av_d2q
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
Definition: rational.c:106
FFDrawContext
Definition: drawutils.h:36
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
av_rescale
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:129
V
#define V
Definition: src_avsynctest.c:68
ff_draw_color
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
Definition: drawutils.c:171
av_cmp_q
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition: rational.h:89
AVFilter
Filter definition.
Definition: avfilter.h:201
ret
ret
Definition: filter_design.txt:187
AVSyncTestContext::delay
int delay
Definition: src_avsynctest.c:48
AVSyncTestContext::sample_rate
int sample_rate
Definition: src_avsynctest.c:43
U
#define U(x)
Definition: vpx_arith.h:37
draw_text
static void draw_text(FFDrawContext *draw, AVFrame *out, FFDrawColor *color, int x0, int y0, const uint8_t *text)
Definition: src_avsynctest.c:247
AVSyncTestContext
Definition: src_avsynctest.c:38
channel_layout.h
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
A
#define A
Definition: src_avsynctest.c:67
temp
else temp
Definition: vf_mcdeint.c:263
ffmath.h
av_mul_q
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
R
#define R
Definition: src_avsynctest.c:69
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
audio.h
AVSyncTestContext::flash
int flash
Definition: src_avsynctest.c:53
AV_CHANNEL_LAYOUT_MONO
#define AV_CHANNEL_LAYOUT_MONO
Definition: channel_layout.h:392
avpriv_cga_font
const uint8_t avpriv_cga_font[2048]
Definition: xga_font_data.c:29
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:291
sin32
static int32_t sin32(int32_t x, AVRational scale)
Definition: src_avsynctest.c:174
av_add_q
AVRational av_add_q(AVRational b, AVRational c)
Add two rationals.
Definition: rational.c:93
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
int32_t
int32_t
Definition: audioconvert.c:56
imgutils.h
OFFSET
#define OFFSET(x)
Definition: src_avsynctest.c:66
timestamp.h
audio_frame
static int audio_frame(AVFilterLink *outlink)
Definition: src_avsynctest.c:204
h
h
Definition: vp9dsp_template.c:2070
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
drawutils.h
AVSyncTestContext::vdelay
AVRational vdelay
Definition: src_avsynctest.c:55
AV_SAMPLE_FMT_S32
@ AV_SAMPLE_FMT_S32
signed 32 bits
Definition: samplefmt.h:59
snprintf
#define snprintf
Definition: snprintf.h:34
config_props
static av_cold int config_props(AVFilterLink *outlink)
Definition: src_avsynctest.c:145