FFmpeg
vsrc_testsrc.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 Nicolas George <nicolas.george@normalesup.org>
3  * Copyright (c) 2011 Stefano Sabatini
4  * Copyright (c) 2012 Paul B Mahol
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 /**
24  * @file
25  * Misc test sources.
26  *
27  * testsrc is based on the test pattern generator demuxer by Nicolas George:
28  * http://lists.ffmpeg.org/pipermail/ffmpeg-devel/2007-October/037845.html
29  *
30  * rgbtestsrc is ported from MPlayer libmpcodecs/vf_rgbtest.c by
31  * Michael Niedermayer.
32  *
33  * allyuv, smptebars and smptehdbars are by Paul B Mahol.
34  */
35 
36 #include "config_components.h"
37 
38 #include "libavutil/avassert.h"
39 #include "libavutil/common.h"
40 #include "libavutil/ffmath.h"
41 #include "libavutil/mem.h"
42 #include "libavutil/opt.h"
43 #include "libavutil/imgutils.h"
44 #include "libavutil/intreadwrite.h"
46 #include "avfilter.h"
47 #include "drawutils.h"
48 #include "filters.h"
49 #include "formats.h"
50 #include "internal.h"
51 #include "video.h"
52 
53 typedef struct TestSourceContext {
54  const AVClass *class;
55  int w, h;
56  int pw, ph;
57  unsigned int nb_frame;
59  int64_t pts;
60  int64_t duration; ///< duration expressed in microseconds
61  AVRational sar; ///< sample aspect ratio
62  int draw_once; ///< draw only the first frame, always put out the same picture
63  int draw_once_reset; ///< draw only the first frame or in case of reset
64  AVFrame *picref; ///< cached reference containing the painted picture
65 
67 
68  /* only used by testsrc */
70 
71  /* only used by testsrc2 */
72  int alpha;
73 
74  /* only used by colorspectrum */
75  int type;
76 
77  /* only used by color */
80  uint8_t color_rgba[4];
81 
82  /* only used by rgbtest */
83  uint8_t rgba_map[4];
85  int depth;
86 
87  /* only used by haldclut */
88  int level;
89 
90  /* only used by zoneplate */
91  int k0, kx, ky, kt;
92  int kxt, kyt, kxy;
93  int kx2, ky2, kt2;
94  int xo, yo, to, kU, kV;
96  uint8_t *lut;
97  int (*fill_slice_fn)(AVFilterContext *ctx, void *arg, int job, int nb_jobs);
99 
100 #define OFFSET(x) offsetof(TestSourceContext, x)
101 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
102 #define FLAGSR AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
103 
104 #define SIZE_OPTIONS \
105  { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\
106  { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\
107 
108 #define COMMON_OPTIONS_NOSIZE \
109  { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS },\
110  { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS },\
111  { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },\
112  { "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },\
113  { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX, FLAGS },
114 
115 #define COMMON_OPTIONS SIZE_OPTIONS COMMON_OPTIONS_NOSIZE
116 
117 #define NOSIZE_OPTIONS_OFFSET 2
118 /* Filters using COMMON_OPTIONS_NOSIZE also use the following options
119  * via &options[NOSIZE_OPTIONS_OFFSET]. So don't break it. */
120 static const AVOption options[] = {
122  { NULL }
123 };
124 
126 {
127  TestSourceContext *test = ctx->priv;
128 
129  test->time_base = av_inv_q(test->frame_rate);
130  test->nb_frame = 0;
131  test->pts = 0;
132 
133  av_log(ctx, AV_LOG_VERBOSE, "size:%dx%d rate:%d/%d duration:%f sar:%d/%d\n",
134  test->w, test->h, test->frame_rate.num, test->frame_rate.den,
135  test->duration < 0 ? -1 : (double)test->duration/1000000,
136  test->sar.num, test->sar.den);
137  return 0;
138 }
139 
141 {
142  TestSourceContext *test = ctx->priv;
143 
144  av_frame_free(&test->picref);
145  av_freep(&test->lut);
146 }
147 
148 static int config_props(AVFilterLink *outlink)
149 {
150  TestSourceContext *test = outlink->src->priv;
151 
152  outlink->w = test->w;
153  outlink->h = test->h;
154  outlink->sample_aspect_ratio = test->sar;
155  outlink->frame_rate = test->frame_rate;
156  outlink->time_base = test->time_base;
157 
158  return 0;
159 }
160 
161 static const AVFilterPad outputs[] = {
162  {
163  .name = "default",
164  .type = AVMEDIA_TYPE_VIDEO,
165  .config_props = config_props,
166  },
167 };
168 
170 {
171  AVFilterLink *outlink = ctx->outputs[0];
172  TestSourceContext *test = ctx->priv;
173  AVFrame *frame;
174 
175  if (!ff_outlink_frame_wanted(outlink))
176  return FFERROR_NOT_READY;
177  if (test->duration >= 0 &&
178  av_rescale_q(test->pts, test->time_base, AV_TIME_BASE_Q) >= test->duration) {
179  ff_outlink_set_status(outlink, AVERROR_EOF, test->pts);
180  return 0;
181  }
182 
183  if (test->draw_once) {
184  if (test->draw_once_reset) {
185  av_frame_free(&test->picref);
186  test->draw_once_reset = 0;
187  }
188  if (!test->picref) {
189  test->picref =
190  ff_get_video_buffer(outlink, test->w, test->h);
191  if (!test->picref)
192  return AVERROR(ENOMEM);
193  test->fill_picture_fn(outlink->src, test->picref);
194  }
195  frame = av_frame_clone(test->picref);
196  } else
197  frame = ff_get_video_buffer(outlink, test->w, test->h);
198 
199  if (!frame)
200  return AVERROR(ENOMEM);
201  frame->pts = test->pts;
202  frame->duration = 1;
203  frame->flags |= AV_FRAME_FLAG_KEY;
204 #if FF_API_INTERLACED_FRAME
206  frame->interlaced_frame = 0;
208 #endif
209  frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
210  frame->pict_type = AV_PICTURE_TYPE_I;
211  frame->sample_aspect_ratio = test->sar;
212  if (!test->draw_once)
213  test->fill_picture_fn(outlink->src, frame);
214 
215  test->pts++;
216  test->nb_frame++;
217 
218  return ff_filter_frame(outlink, frame);
219 }
220 
221 #if CONFIG_COLOR_FILTER
222 
223 static const AVOption color_options[] = {
224  { "color", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, 0, 0, FLAGSR },
225  { "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, 0, 0, FLAGSR },
227  { NULL }
228 };
229 
231 
232 static void color_fill_picture(AVFilterContext *ctx, AVFrame *picref)
233 {
234  TestSourceContext *test = ctx->priv;
235  ff_fill_rectangle(&test->draw, &test->color,
236  picref->data, picref->linesize,
237  0, 0, test->w, test->h);
238 }
239 
240 static av_cold int color_init(AVFilterContext *ctx)
241 {
242  TestSourceContext *test = ctx->priv;
243  test->fill_picture_fn = color_fill_picture;
244  test->draw_once = 1;
245  return init(ctx);
246 }
247 
248 static int color_query_formats(AVFilterContext *ctx)
249 {
251 }
252 
253 static int color_config_props(AVFilterLink *inlink)
254 {
255  AVFilterContext *ctx = inlink->src;
256  TestSourceContext *test = ctx->priv;
257  int ret;
258 
259  ff_draw_init2(&test->draw, inlink->format, inlink->colorspace,
260  inlink->color_range, 0);
261  ff_draw_color(&test->draw, &test->color, test->color_rgba);
262 
263  test->w = ff_draw_round_to_sub(&test->draw, 0, -1, test->w);
264  test->h = ff_draw_round_to_sub(&test->draw, 1, -1, test->h);
265  if (av_image_check_size(test->w, test->h, 0, ctx) < 0)
266  return AVERROR(EINVAL);
267 
268  if ((ret = config_props(inlink)) < 0)
269  return ret;
270 
271  return 0;
272 }
273 
274 static int color_process_command(AVFilterContext *ctx, const char *cmd, const char *args,
275  char *res, int res_len, int flags)
276 {
277  TestSourceContext *test = ctx->priv;
278  int ret;
279 
280  ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
281  if (ret < 0)
282  return ret;
283 
284  ff_draw_color(&test->draw, &test->color, test->color_rgba);
285  test->draw_once_reset = 1;
286  return 0;
287 }
288 
289 static const AVFilterPad color_outputs[] = {
290  {
291  .name = "default",
292  .type = AVMEDIA_TYPE_VIDEO,
293  .config_props = color_config_props,
294  },
295 };
296 
297 const AVFilter ff_vsrc_color = {
298  .name = "color",
299  .description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."),
300  .priv_class = &color_class,
301  .priv_size = sizeof(TestSourceContext),
302  .init = color_init,
303  .uninit = uninit,
304  .activate = activate,
305  .inputs = NULL,
306  FILTER_OUTPUTS(color_outputs),
307  FILTER_QUERY_FUNC(color_query_formats),
308  .process_command = color_process_command,
309 };
310 
311 #endif /* CONFIG_COLOR_FILTER */
312 
313 #if CONFIG_HALDCLUTSRC_FILTER
314 
315 static const AVOption haldclutsrc_options[] = {
316  { "level", "set level", OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 6}, 2, 16, FLAGS },
318  { NULL }
319 };
320 
321 AVFILTER_DEFINE_CLASS(haldclutsrc);
322 
323 static void haldclutsrc_fill_picture(AVFilterContext *ctx, AVFrame *frame)
324 {
325  int i, j, k, x = 0, y = 0, is16bit = 0, step;
326  uint32_t alpha = 0;
327  const TestSourceContext *hc = ctx->priv;
328  int level = hc->level;
329  float scale;
330  const int w = frame->width;
331  const int h = frame->height;
332  uint8_t *data = frame->data[0];
333  const ptrdiff_t linesize = frame->linesize[0];
335  const int depth = desc->comp[0].depth;
336  const int planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR;
337  const int planes = av_pix_fmt_count_planes(frame->format);
338  uint8_t rgba_map[4];
339 
340  av_assert0(w == h && w == level*level*level);
341 
342  ff_fill_rgba_map(rgba_map, frame->format);
343 
344  alpha = (1 << depth) - 1;
345  is16bit = depth > 8;
346 
347  step = av_get_padded_bits_per_pixel(desc) >> (3 + is16bit);
348  scale = ((float)alpha) / (level*level - 1);
349 
350 #define LOAD_CLUT(nbits) do { \
351  uint##nbits##_t *dst = ((uint##nbits##_t *)(data + y*linesize)) + x*step; \
352  dst[rgba_map[0]] = av_clip_uint##nbits(i * scale); \
353  dst[rgba_map[1]] = av_clip_uint##nbits(j * scale); \
354  dst[rgba_map[2]] = av_clip_uint##nbits(k * scale); \
355  if (step == 4) \
356  dst[rgba_map[3]] = alpha; \
357 } while (0)
358 
359 #define LOAD_CLUT_PLANAR(type, nbits) do { \
360  type *dst = ((type *)(frame->data[2] + y*frame->linesize[2])) + x; \
361  dst[0] = av_clip_uintp2(i * scale, nbits); \
362  dst = ((type *)(frame->data[0] + y*frame->linesize[0])) + x; \
363  dst[0] = av_clip_uintp2(j * scale, nbits); \
364  dst = ((type *)(frame->data[1] + y*frame->linesize[1])) + x; \
365  dst[0] = av_clip_uintp2(k * scale, nbits); \
366  if (planes == 4) { \
367  dst = ((type *)(frame->data[3] + y*linesize)) + x; \
368  dst[0] = alpha; \
369  } \
370 } while (0)
371 
372  level *= level;
373  for (k = 0; k < level; k++) {
374  for (j = 0; j < level; j++) {
375  for (i = 0; i < level; i++) {
376  if (!planar) {
377  if (!is16bit)
378  LOAD_CLUT(8);
379  else
380  LOAD_CLUT(16);
381  } else {
382  switch (depth) {
383  case 8: LOAD_CLUT_PLANAR(uint8_t, 8); break;
384  case 9: LOAD_CLUT_PLANAR(uint16_t, 9); break;
385  case 10: LOAD_CLUT_PLANAR(uint16_t,10); break;
386  case 12: LOAD_CLUT_PLANAR(uint16_t,12); break;
387  case 14: LOAD_CLUT_PLANAR(uint16_t,14); break;
388  case 16: LOAD_CLUT_PLANAR(uint16_t,16); break;
389  }
390  }
391  if (++x == w) {
392  x = 0;
393  y++;
394  }
395  }
396  }
397  }
398 }
399 
400 static av_cold int haldclutsrc_init(AVFilterContext *ctx)
401 {
402  TestSourceContext *hc = ctx->priv;
403  hc->fill_picture_fn = haldclutsrc_fill_picture;
404  hc->draw_once = 1;
405  return init(ctx);
406 }
407 
408 static const enum AVPixelFormat haldclutsrc_pix_fmts[] = {
423 };
424 
425 static int haldclutsrc_config_props(AVFilterLink *outlink)
426 {
427  AVFilterContext *ctx = outlink->src;
428  TestSourceContext *hc = ctx->priv;
429 
430  hc->w = hc->h = hc->level * hc->level * hc->level;
431  return config_props(outlink);
432 }
433 
434 static const AVFilterPad haldclutsrc_outputs[] = {
435  {
436  .name = "default",
437  .type = AVMEDIA_TYPE_VIDEO,
438  .config_props = haldclutsrc_config_props,
439  },
440 };
441 
443  .name = "haldclutsrc",
444  .description = NULL_IF_CONFIG_SMALL("Provide an identity Hald CLUT."),
445  .priv_class = &haldclutsrc_class,
446  .priv_size = sizeof(TestSourceContext),
447  .init = haldclutsrc_init,
448  .uninit = uninit,
449  .activate = activate,
450  .inputs = NULL,
451  FILTER_OUTPUTS(haldclutsrc_outputs),
452  FILTER_PIXFMTS_ARRAY(haldclutsrc_pix_fmts),
453 };
454 #endif /* CONFIG_HALDCLUTSRC_FILTER */
455 
456 AVFILTER_DEFINE_CLASS_EXT(nullsrc_yuvtestsrc, "nullsrc/yuvtestsrc", options);
457 
458 #if CONFIG_NULLSRC_FILTER
459 
460 static void nullsrc_fill_picture(AVFilterContext *ctx, AVFrame *picref) { }
461 
462 static av_cold int nullsrc_init(AVFilterContext *ctx)
463 {
464  TestSourceContext *test = ctx->priv;
465 
466  test->fill_picture_fn = nullsrc_fill_picture;
467  return init(ctx);
468 }
469 
470 const AVFilter ff_vsrc_nullsrc = {
471  .name = "nullsrc",
472  .description = NULL_IF_CONFIG_SMALL("Null video source, return unprocessed video frames."),
473  .priv_class = &nullsrc_yuvtestsrc_class,
474  .init = nullsrc_init,
475  .uninit = uninit,
476  .activate = activate,
477  .priv_size = sizeof(TestSourceContext),
478  .inputs = NULL,
480 };
481 
482 #endif /* CONFIG_NULLSRC_FILTER */
483 
484 #if CONFIG_TESTSRC_FILTER
485 
486 static const AVOption testsrc_options[] = {
488  { "decimals", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS },
489  { "n", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS },
490  { NULL }
491 };
492 
493 AVFILTER_DEFINE_CLASS(testsrc);
494 
495 /**
496  * Fill a rectangle with value val.
497  *
498  * @param val the RGB value to set
499  * @param dst pointer to the destination buffer to fill
500  * @param dst_linesize linesize of destination
501  * @param segment_width width of the segment
502  * @param x horizontal coordinate where to draw the rectangle in the destination buffer
503  * @param y horizontal coordinate where to draw the rectangle in the destination buffer
504  * @param w width of the rectangle to draw, expressed as a number of segment_width units
505  * @param h height of the rectangle to draw, expressed as a number of segment_width units
506  */
507 static void draw_rectangle(unsigned val, uint8_t *dst, ptrdiff_t dst_linesize, int segment_width,
508  int x, int y, int w, int h)
509 {
510  int i;
511  int step = 3;
512 
513  dst += segment_width * (step * x + y * dst_linesize);
514  w *= segment_width * step;
515  h *= segment_width;
516  for (i = 0; i < h; i++) {
517  memset(dst, val, w);
518  dst += dst_linesize;
519  }
520 }
521 
522 static void draw_digit(int digit, uint8_t *dst, ptrdiff_t dst_linesize,
523  int segment_width)
524 {
525 #define TOP_HBAR 1
526 #define MID_HBAR 2
527 #define BOT_HBAR 4
528 #define LEFT_TOP_VBAR 8
529 #define LEFT_BOT_VBAR 16
530 #define RIGHT_TOP_VBAR 32
531 #define RIGHT_BOT_VBAR 64
532  struct segments {
533  int x, y, w, h;
534  } segments[] = {
535  { 1, 0, 5, 1 }, /* TOP_HBAR */
536  { 1, 6, 5, 1 }, /* MID_HBAR */
537  { 1, 12, 5, 1 }, /* BOT_HBAR */
538  { 0, 1, 1, 5 }, /* LEFT_TOP_VBAR */
539  { 0, 7, 1, 5 }, /* LEFT_BOT_VBAR */
540  { 6, 1, 1, 5 }, /* RIGHT_TOP_VBAR */
541  { 6, 7, 1, 5 } /* RIGHT_BOT_VBAR */
542  };
543  static const unsigned char masks[10] = {
544  /* 0 */ TOP_HBAR |BOT_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
545  /* 1 */ RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
546  /* 2 */ TOP_HBAR|MID_HBAR|BOT_HBAR|LEFT_BOT_VBAR |RIGHT_TOP_VBAR,
547  /* 3 */ TOP_HBAR|MID_HBAR|BOT_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
548  /* 4 */ MID_HBAR |LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
549  /* 5 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_BOT_VBAR,
550  /* 6 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR |RIGHT_BOT_VBAR,
551  /* 7 */ TOP_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
552  /* 8 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
553  /* 9 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
554  };
555  unsigned mask = masks[digit];
556  int i;
557 
558  draw_rectangle(0, dst, dst_linesize, segment_width, 0, 0, 8, 13);
559  for (i = 0; i < FF_ARRAY_ELEMS(segments); i++)
560  if (mask & (1<<i))
561  draw_rectangle(255, dst, dst_linesize, segment_width,
562  segments[i].x, segments[i].y, segments[i].w, segments[i].h);
563 }
564 
565 #define GRADIENT_SIZE (6 * 256)
566 
567 static void test_fill_picture(AVFilterContext *ctx, AVFrame *frame)
568 {
569  TestSourceContext *test = ctx->priv;
570  uint8_t *p, *p0;
571  int x, y;
572  int color, color_rest;
573  int icolor;
574  int radius;
575  int quad0, quad;
576  int dquad_x, dquad_y;
577  int grad, dgrad, rgrad, drgrad;
578  int seg_size;
579  int second;
580  int i;
581  uint8_t *data = frame->data[0];
582  int width = frame->width;
583  int height = frame->height;
584 
585  /* draw colored bars and circle */
586  radius = (width + height) / 4;
587  quad0 = width * width / 4 + height * height / 4 - radius * radius;
588  dquad_y = 1 - height;
589  p0 = data;
590  for (y = 0; y < height; y++) {
591  p = p0;
592  color = 0;
593  color_rest = 0;
594  quad = quad0;
595  dquad_x = 1 - width;
596  for (x = 0; x < width; x++) {
597  icolor = color;
598  if (quad < 0)
599  icolor ^= 7;
600  quad += dquad_x;
601  dquad_x += 2;
602  *(p++) = icolor & 1 ? 255 : 0;
603  *(p++) = icolor & 2 ? 255 : 0;
604  *(p++) = icolor & 4 ? 255 : 0;
605  color_rest += 8;
606  if (color_rest >= width) {
607  color_rest -= width;
608  color++;
609  }
610  }
611  quad0 += dquad_y;
612  dquad_y += 2;
613  p0 += frame->linesize[0];
614  }
615 
616  /* draw sliding color line */
617  p0 = p = data + frame->linesize[0] * (height * 3/4);
618  grad = (256 * test->nb_frame * test->time_base.num / test->time_base.den) %
619  GRADIENT_SIZE;
620  rgrad = 0;
621  dgrad = GRADIENT_SIZE / width;
622  drgrad = GRADIENT_SIZE % width;
623  for (x = 0; x < width; x++) {
624  *(p++) =
625  grad < 256 || grad >= 5 * 256 ? 255 :
626  grad >= 2 * 256 && grad < 4 * 256 ? 0 :
627  grad < 2 * 256 ? 2 * 256 - 1 - grad : grad - 4 * 256;
628  *(p++) =
629  grad >= 4 * 256 ? 0 :
630  grad >= 1 * 256 && grad < 3 * 256 ? 255 :
631  grad < 1 * 256 ? grad : 4 * 256 - 1 - grad;
632  *(p++) =
633  grad < 2 * 256 ? 0 :
634  grad >= 3 * 256 && grad < 5 * 256 ? 255 :
635  grad < 3 * 256 ? grad - 2 * 256 : 6 * 256 - 1 - grad;
636  grad += dgrad;
637  rgrad += drgrad;
638  if (rgrad >= GRADIENT_SIZE) {
639  grad++;
640  rgrad -= GRADIENT_SIZE;
641  }
642  if (grad >= GRADIENT_SIZE)
643  grad -= GRADIENT_SIZE;
644  }
645  p = p0;
646  for (y = height / 8; y > 0; y--) {
647  memcpy(p+frame->linesize[0], p, 3 * width);
648  p += frame->linesize[0];
649  }
650 
651  /* draw digits */
652  seg_size = width / 80;
653  if (seg_size >= 1 && height >= 13 * seg_size) {
654  int64_t p10decimals = 1;
655  double time = av_q2d(test->time_base) * test->nb_frame *
656  ff_exp10(test->nb_decimals);
657  if (time >= INT_MAX)
658  return;
659 
660  for (x = 0; x < test->nb_decimals; x++)
661  p10decimals *= 10;
662 
663  second = av_rescale_rnd(test->nb_frame * test->time_base.num, p10decimals, test->time_base.den, AV_ROUND_ZERO);
664  x = width - (width - seg_size * 64) / 2;
665  y = (height - seg_size * 13) / 2;
666  p = data + (x*3 + y * frame->linesize[0]);
667  for (i = 0; i < 8; i++) {
668  p -= 3 * 8 * seg_size;
669  draw_digit(second % 10, p, frame->linesize[0], seg_size);
670  second /= 10;
671  if (second == 0)
672  break;
673  }
674  }
675 }
676 
677 static av_cold int test_init(AVFilterContext *ctx)
678 {
679  TestSourceContext *test = ctx->priv;
680 
681  test->fill_picture_fn = test_fill_picture;
682  return init(ctx);
683 }
684 
685 const AVFilter ff_vsrc_testsrc = {
686  .name = "testsrc",
687  .description = NULL_IF_CONFIG_SMALL("Generate test pattern."),
688  .priv_size = sizeof(TestSourceContext),
689  .priv_class = &testsrc_class,
690  .init = test_init,
691  .uninit = uninit,
692  .activate = activate,
693  .inputs = NULL,
696 };
697 
698 #endif /* CONFIG_TESTSRC_FILTER */
699 
700 #if CONFIG_TESTSRC2_FILTER
701 
702 static const AVOption testsrc2_options[] = {
704  { "alpha", "set global alpha (opacity)", OFFSET(alpha), AV_OPT_TYPE_INT, {.i64 = 255}, 0, 255, FLAGS },
705  { NULL }
706 };
707 
708 AVFILTER_DEFINE_CLASS(testsrc2);
709 
710 static void set_color(TestSourceContext *s, FFDrawColor *color, uint32_t argb)
711 {
712  uint8_t rgba[4] = { (argb >> 16) & 0xFF,
713  (argb >> 8) & 0xFF,
714  (argb >> 0) & 0xFF,
715  (argb >> 24) & 0xFF, };
716  ff_draw_color(&s->draw, color, rgba);
717 }
718 
719 static uint32_t color_gradient(unsigned index)
720 {
721  unsigned si = index & 0xFF, sd = 0xFF - si;
722  switch (index >> 8) {
723  case 0: return 0xFF0000 + (si << 8);
724  case 1: return 0x00FF00 + (sd << 16);
725  case 2: return 0x00FF00 + (si << 0);
726  case 3: return 0x0000FF + (sd << 8);
727  case 4: return 0x0000FF + (si << 16);
728  case 5: return 0xFF0000 + (sd << 0);
729  default: av_assert0(0); return 0;
730  }
731 }
732 
734  int x0, int y0, const uint8_t *text)
735 {
736  int x = x0;
737 
738  for (; *text; text++) {
739  if (*text == '\n') {
740  x = x0;
741  y0 += 16;
742  continue;
743  }
744  ff_blend_mask(&s->draw, color, frame->data, frame->linesize,
745  frame->width, frame->height,
746  avpriv_vga16_font + *text * 16, 1, 8, 16, 0, 0, x, y0);
747  x += 8;
748  }
749 }
750 
751 static void test2_fill_picture(AVFilterContext *ctx, AVFrame *frame)
752 {
753  TestSourceContext *s = ctx->priv;
755  unsigned alpha = (uint32_t)s->alpha << 24;
756 
757  /* colored background */
758  {
759  unsigned i, x = 0, x2;
760 
761  x = 0;
762  for (i = 1; i < 7; i++) {
763  x2 = av_rescale(i, s->w, 6);
764  x2 = ff_draw_round_to_sub(&s->draw, 0, 0, x2);
765  set_color(s, &color, ((i & 1) ? 0xFF0000 : 0) |
766  ((i & 2) ? 0x00FF00 : 0) |
767  ((i & 4) ? 0x0000FF : 0) |
768  alpha);
769  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
770  x, 0, x2 - x, frame->height);
771  x = x2;
772  }
773  }
774 
775  /* oblique gradient */
776  /* note: too slow if using blending */
777  if (s->h >= 64) {
778  unsigned x, dx, y0, y, g0, g;
779 
780  dx = ff_draw_round_to_sub(&s->draw, 0, +1, 1);
781  y0 = av_rescale_q(s->pts, s->time_base, av_make_q(2, s->h - 16));
782  g0 = av_rescale_q(s->pts, s->time_base, av_make_q(1, 128));
783  for (x = 0; x < s->w; x += dx) {
784  g = (av_rescale(x, 6 * 256, s->w) + g0) % (6 * 256);
785  set_color(s, &color, color_gradient(g) | alpha);
786  y = y0 + av_rescale(x, s->h / 2, s->w);
787  y %= 2 * (s->h - 16);
788  if (y > s->h - 16)
789  y = 2 * (s->h - 16) - y;
790  y = ff_draw_round_to_sub(&s->draw, 1, 0, y);
791  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
792  x, y, dx, 16);
793  }
794  }
795 
796  /* top right: draw clock hands */
797  if (s->w >= 64 && s->h >= 64) {
798  int l = (FFMIN(s->w, s->h) - 32) >> 1;
799  int steps = FFMAX(4, l >> 5);
800  int xc = (s->w >> 2) + (s->w >> 1);
801  int yc = (s->h >> 2);
802  int cycle = l << 2;
803  int pos, xh, yh;
804  int c, i;
805 
806  for (c = 0; c < 3; c++) {
807  set_color(s, &color, (0xBBBBBB ^ (0xFF << (c << 3))) | alpha);
808  pos = av_rescale_q(s->pts, s->time_base, av_make_q(64 >> (c << 1), cycle)) % cycle;
809  xh = pos < 1 * l ? pos :
810  pos < 2 * l ? l :
811  pos < 3 * l ? 3 * l - pos : 0;
812  yh = pos < 1 * l ? 0 :
813  pos < 2 * l ? pos - l :
814  pos < 3 * l ? l :
815  cycle - pos;
816  xh -= l >> 1;
817  yh -= l >> 1;
818  for (i = 1; i <= steps; i++) {
819  int x = av_rescale(xh, i, steps) + xc;
820  int y = av_rescale(yh, i, steps) + yc;
821  x = ff_draw_round_to_sub(&s->draw, 0, -1, x);
822  y = ff_draw_round_to_sub(&s->draw, 1, -1, y);
823  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
824  x, y, 8, 8);
825  }
826  }
827  }
828 
829  /* bottom left: beating rectangles */
830  if (s->w >= 64 && s->h >= 64) {
831  int l = (FFMIN(s->w, s->h) - 16) >> 2;
832  int cycle = l << 3;
833  int xc = (s->w >> 2);
834  int yc = (s->h >> 2) + (s->h >> 1);
835  int xm1 = ff_draw_round_to_sub(&s->draw, 0, -1, xc - 8);
836  int xm2 = ff_draw_round_to_sub(&s->draw, 0, +1, xc + 8);
837  int ym1 = ff_draw_round_to_sub(&s->draw, 1, -1, yc - 8);
838  int ym2 = ff_draw_round_to_sub(&s->draw, 1, +1, yc + 8);
839  int size, step, x1, x2, y1, y2;
840 
841  size = av_rescale_q(s->pts, s->time_base, av_make_q(4, cycle));
842  step = size / l;
843  size %= l;
844  if (step & 1)
845  size = l - size;
846  step = (step >> 1) & 3;
847  set_color(s, &color, 0xFF808080);
848  x1 = ff_draw_round_to_sub(&s->draw, 0, -1, xc - 4 - size);
849  x2 = ff_draw_round_to_sub(&s->draw, 0, +1, xc + 4 + size);
850  y1 = ff_draw_round_to_sub(&s->draw, 1, -1, yc - 4 - size);
851  y2 = ff_draw_round_to_sub(&s->draw, 1, +1, yc + 4 + size);
852  if (step == 0 || step == 2)
853  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
854  x1, ym1, x2 - x1, ym2 - ym1);
855  if (step == 1 || step == 2)
856  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
857  xm1, y1, xm2 - xm1, y2 - y1);
858  if (step == 3)
859  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
860  x1, y1, x2 - x1, y2 - y1);
861  }
862 
863  /* bottom right: checker with random noise */
864  {
865  unsigned xmin = av_rescale(5, s->w, 8);
866  unsigned xmax = av_rescale(7, s->w, 8);
867  unsigned ymin = av_rescale(5, s->h, 8);
868  unsigned ymax = av_rescale(7, s->h, 8);
869  unsigned x, y, i, r;
870  uint8_t alpha[256];
871 
872  r = s->pts;
873  for (y = ymin; y + 15 < ymax; y += 16) {
874  for (x = xmin; x + 15 < xmax; x += 16) {
875  if ((x ^ y) & 16)
876  continue;
877  for (i = 0; i < 256; i++) {
878  r = r * 1664525 + 1013904223;
879  alpha[i] = r >> 24;
880  }
881  set_color(s, &color, 0xFF00FF80);
882  ff_blend_mask(&s->draw, &color, frame->data, frame->linesize,
883  frame->width, frame->height,
884  alpha, 16, 16, 16, 3, 0, x, y);
885  }
886  }
887  }
888 
889  /* bouncing square */
890  if (s->w >= 16 && s->h >= 16) {
891  unsigned w = s->w - 8;
892  unsigned h = s->h - 8;
893  unsigned x = av_rescale_q(s->pts, s->time_base, av_make_q(233, 55 * w)) % (w << 1);
894  unsigned y = av_rescale_q(s->pts, s->time_base, av_make_q(233, 89 * h)) % (h << 1);
895  if (x > w)
896  x = (w << 1) - x;
897  if (y > h)
898  y = (h << 1) - y;
899  x = ff_draw_round_to_sub(&s->draw, 0, -1, x);
900  y = ff_draw_round_to_sub(&s->draw, 1, -1, y);
901  set_color(s, &color, 0xFF8000FF);
902  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
903  x, y, 8, 8);
904  }
905 
906  /* top right: draw frame time and frame number */
907  {
908  char buf[256];
909  unsigned time;
910 
911  time = av_rescale_q(s->pts, s->time_base, av_make_q(1, 1000)) % 86400000;
912  set_color(s, &color, 0xC0000000);
913  ff_blend_rectangle(&s->draw, &color, frame->data, frame->linesize,
914  frame->width, frame->height,
915  2, 2, 100, 36);
916  set_color(s, &color, 0xFFFF8000);
917  snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%03d\n%12"PRIi64,
918  time / 3600000, (time / 60000) % 60, (time / 1000) % 60,
919  time % 1000, s->pts);
920  draw_text(s, frame, &color, 4, 4, buf);
921  }
922 }
923 static av_cold int test2_init(AVFilterContext *ctx)
924 {
925  TestSourceContext *s = ctx->priv;
926 
927  s->fill_picture_fn = test2_fill_picture;
928  return init(ctx);
929 }
930 
931 static int test2_query_formats(AVFilterContext *ctx)
932 {
934 }
935 
936 static int test2_config_props(AVFilterLink *inlink)
937 {
938  AVFilterContext *ctx = inlink->src;
939  TestSourceContext *s = ctx->priv;
940 
941  av_assert0(ff_draw_init2(&s->draw, inlink->format, inlink->colorspace,
942  inlink->color_range, 0) >= 0);
943  s->w = ff_draw_round_to_sub(&s->draw, 0, -1, s->w);
944  s->h = ff_draw_round_to_sub(&s->draw, 1, -1, s->h);
945  if (av_image_check_size(s->w, s->h, 0, ctx) < 0)
946  return AVERROR(EINVAL);
947  return config_props(inlink);
948 }
949 
950 static const AVFilterPad avfilter_vsrc_testsrc2_outputs[] = {
951  {
952  .name = "default",
953  .type = AVMEDIA_TYPE_VIDEO,
954  .config_props = test2_config_props,
955  },
956 };
957 
958 const AVFilter ff_vsrc_testsrc2 = {
959  .name = "testsrc2",
960  .description = NULL_IF_CONFIG_SMALL("Generate another test pattern."),
961  .priv_size = sizeof(TestSourceContext),
962  .priv_class = &testsrc2_class,
963  .init = test2_init,
964  .uninit = uninit,
965  .activate = activate,
966  .inputs = NULL,
967  FILTER_OUTPUTS(avfilter_vsrc_testsrc2_outputs),
968  FILTER_QUERY_FUNC(test2_query_formats),
969 };
970 
971 #endif /* CONFIG_TESTSRC2_FILTER */
972 
973 #if CONFIG_RGBTESTSRC_FILTER
974 
975 static const AVOption rgbtestsrc_options[] = {
977  { "complement", "set complement colors", OFFSET(complement), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
978  { "co", "set complement colors", OFFSET(complement), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
979  { NULL }
980 };
981 
982 AVFILTER_DEFINE_CLASS(rgbtestsrc);
983 
984 #define R 0
985 #define G 1
986 #define B 2
987 #define A 3
988 
989 static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],
990  int x, int y, unsigned r, unsigned g, unsigned b, enum AVPixelFormat fmt,
991  uint8_t rgba_map[4])
992 {
993  uint8_t *dst = dstp[0];
994  ptrdiff_t dst_linesize = dst_linesizep[0];
995  uint32_t v;
996  uint8_t *p;
997  uint16_t *p16;
998 
999  switch (fmt) {
1000  case AV_PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4); break;
1001  case AV_PIX_FMT_RGB444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b >> 4) << 8) | ((g >> 4) << 4) | (r >> 4); break;
1002  case AV_PIX_FMT_BGR555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<10) | ((g>>3)<<5) | (b>>3); break;
1003  case AV_PIX_FMT_RGB555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<10) | ((g>>3)<<5) | (r>>3); break;
1004  case AV_PIX_FMT_BGR565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<11) | ((g>>2)<<5) | (b>>3); break;
1005  case AV_PIX_FMT_RGB565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<11) | ((g>>2)<<5) | (r>>3); break;
1006  case AV_PIX_FMT_RGB24:
1007  case AV_PIX_FMT_BGR24:
1008  v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8));
1009  p = dst + 3*x + y*dst_linesize;
1010  AV_WL24(p, v);
1011  break;
1012  case AV_PIX_FMT_RGBA:
1013  case AV_PIX_FMT_BGRA:
1014  case AV_PIX_FMT_ARGB:
1015  case AV_PIX_FMT_ABGR:
1016  v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)) + (255U << (rgba_map[A]*8));
1017  p = dst + 4*x + y*dst_linesize;
1018  AV_WL32(p, v);
1019  break;
1020  case AV_PIX_FMT_GBRP:
1021  p = dstp[0] + x + y * dst_linesize;
1022  p[0] = g;
1023  p = dstp[1] + x + y * dst_linesizep[1];
1024  p[0] = b;
1025  p = dstp[2] + x + y * dst_linesizep[2];
1026  p[0] = r;
1027  break;
1028  case AV_PIX_FMT_GBRP9:
1029  case AV_PIX_FMT_GBRP10:
1030  case AV_PIX_FMT_GBRP12:
1031  case AV_PIX_FMT_GBRP14:
1032  case AV_PIX_FMT_GBRP16:
1033  p16 = (uint16_t *)(dstp[0] + x*2 + y * dst_linesizep[0]);
1034  p16[0] = g;
1035  p16 = (uint16_t *)(dstp[1] + x*2 + y * dst_linesizep[1]);
1036  p16[0] = b;
1037  p16 = (uint16_t *)(dstp[2] + x*2 + y * dst_linesizep[2]);
1038  p16[0] = r;
1039  break;
1040  }
1041 }
1042 
1043 static void rgbtest_fill_picture_complement(AVFilterContext *ctx, AVFrame *frame)
1044 {
1045  TestSourceContext *test = ctx->priv;
1046  int x, y, w = frame->width, h = frame->height;
1047 
1048  for (y = 0; y < h; y++) {
1049  for (x = 0; x < w; x++) {
1050  int c = (1 << FFMAX(test->depth, 8))*x/w;
1051  int r = 0, g = 0, b = 0;
1052 
1053  if (6*y < h ) r = c;
1054  else if (6*y < 2*h) g = c, b = c;
1055  else if (6*y < 3*h) g = c;
1056  else if (6*y < 4*h) r = c, b = c;
1057  else if (6*y < 5*h) b = c;
1058  else r = c, g = c;
1059 
1060  rgbtest_put_pixel(frame->data, frame->linesize, x, y, r, g, b,
1061  ctx->outputs[0]->format, test->rgba_map);
1062  }
1063  }
1064 }
1065 
1066 static void rgbtest_fill_picture(AVFilterContext *ctx, AVFrame *frame)
1067 {
1068  TestSourceContext *test = ctx->priv;
1069  int x, y, w = frame->width, h = frame->height;
1070 
1071  for (y = 0; y < h; y++) {
1072  for (x = 0; x < w; x++) {
1073  int c = (1 << FFMAX(test->depth, 8))*x/w;
1074  int r = 0, g = 0, b = 0;
1075 
1076  if (3*y < h ) r = c;
1077  else if (3*y < 2*h) g = c;
1078  else b = c;
1079 
1080  rgbtest_put_pixel(frame->data, frame->linesize, x, y, r, g, b,
1081  ctx->outputs[0]->format, test->rgba_map);
1082  }
1083  }
1084 }
1085 
1086 static av_cold int rgbtest_init(AVFilterContext *ctx)
1087 {
1088  TestSourceContext *test = ctx->priv;
1089 
1090  test->draw_once = 1;
1091  test->fill_picture_fn = test->complement ? rgbtest_fill_picture_complement : rgbtest_fill_picture;
1092  return init(ctx);
1093 }
1094 
1095 static const enum AVPixelFormat rgbtest_pix_fmts[] = {
1104  };
1105 
1106 static int rgbtest_config_props(AVFilterLink *outlink)
1107 {
1108  TestSourceContext *test = outlink->src->priv;
1110 
1111  test->depth = desc->comp[0].depth;
1112  ff_fill_rgba_map(test->rgba_map, outlink->format);
1113  return config_props(outlink);
1114 }
1115 
1116 static const AVFilterPad avfilter_vsrc_rgbtestsrc_outputs[] = {
1117  {
1118  .name = "default",
1119  .type = AVMEDIA_TYPE_VIDEO,
1120  .config_props = rgbtest_config_props,
1121  },
1122 };
1123 
1124 const AVFilter ff_vsrc_rgbtestsrc = {
1125  .name = "rgbtestsrc",
1126  .description = NULL_IF_CONFIG_SMALL("Generate RGB test pattern."),
1127  .priv_size = sizeof(TestSourceContext),
1128  .priv_class = &rgbtestsrc_class,
1129  .init = rgbtest_init,
1130  .uninit = uninit,
1131  .activate = activate,
1132  .inputs = NULL,
1133  FILTER_OUTPUTS(avfilter_vsrc_rgbtestsrc_outputs),
1134  FILTER_PIXFMTS_ARRAY(rgbtest_pix_fmts),
1135 };
1136 
1137 #endif /* CONFIG_RGBTESTSRC_FILTER */
1138 
1139 #if CONFIG_YUVTESTSRC_FILTER
1140 
1141 static void yuvtest_fill_picture8(AVFilterContext *ctx, AVFrame *frame)
1142 {
1143  int x, y, w = frame->width, h = frame->height / 3;
1145  const int factor = 1 << desc->comp[0].depth;
1146  const int mid = 1 << (desc->comp[0].depth - 1);
1147  uint8_t *ydst = frame->data[0];
1148  uint8_t *udst = frame->data[1];
1149  uint8_t *vdst = frame->data[2];
1150  ptrdiff_t ylinesize = frame->linesize[0];
1151  ptrdiff_t ulinesize = frame->linesize[1];
1152  ptrdiff_t vlinesize = frame->linesize[2];
1153 
1154  for (y = 0; y < h; y++) {
1155  for (x = 0; x < w; x++) {
1156  int c = factor * x / w;
1157 
1158  ydst[x] = c;
1159  udst[x] = mid;
1160  vdst[x] = mid;
1161  }
1162 
1163  ydst += ylinesize;
1164  udst += ulinesize;
1165  vdst += vlinesize;
1166  }
1167 
1168  h += h;
1169  for (; y < h; y++) {
1170  for (x = 0; x < w; x++) {
1171  int c = factor * x / w;
1172 
1173  ydst[x] = mid;
1174  udst[x] = c;
1175  vdst[x] = mid;
1176  }
1177 
1178  ydst += ylinesize;
1179  udst += ulinesize;
1180  vdst += vlinesize;
1181  }
1182 
1183  for (; y < frame->height; y++) {
1184  for (x = 0; x < w; x++) {
1185  int c = factor * x / w;
1186 
1187  ydst[x] = mid;
1188  udst[x] = mid;
1189  vdst[x] = c;
1190  }
1191 
1192  ydst += ylinesize;
1193  udst += ulinesize;
1194  vdst += vlinesize;
1195  }
1196 }
1197 
1198 static void yuvtest_fill_picture16(AVFilterContext *ctx, AVFrame *frame)
1199 {
1200  int x, y, w = frame->width, h = frame->height / 3;
1202  const int factor = 1 << desc->comp[0].depth;
1203  const int mid = 1 << (desc->comp[0].depth - 1);
1204  uint16_t *ydst = (uint16_t *)frame->data[0];
1205  uint16_t *udst = (uint16_t *)frame->data[1];
1206  uint16_t *vdst = (uint16_t *)frame->data[2];
1207  ptrdiff_t ylinesize = frame->linesize[0] / 2;
1208  ptrdiff_t ulinesize = frame->linesize[1] / 2;
1209  ptrdiff_t vlinesize = frame->linesize[2] / 2;
1210 
1211  for (y = 0; y < h; y++) {
1212  for (x = 0; x < w; x++) {
1213  int c = factor * x / w;
1214 
1215  ydst[x] = c;
1216  udst[x] = mid;
1217  vdst[x] = mid;
1218  }
1219 
1220  ydst += ylinesize;
1221  udst += ulinesize;
1222  vdst += vlinesize;
1223  }
1224 
1225  h += h;
1226  for (; y < h; y++) {
1227  for (x = 0; x < w; x++) {
1228  int c = factor * x / w;
1229 
1230  ydst[x] = mid;
1231  udst[x] = c;
1232  vdst[x] = mid;
1233  }
1234 
1235  ydst += ylinesize;
1236  udst += ulinesize;
1237  vdst += vlinesize;
1238  }
1239 
1240  for (; y < frame->height; y++) {
1241  for (x = 0; x < w; x++) {
1242  int c = factor * x / w;
1243 
1244  ydst[x] = mid;
1245  udst[x] = mid;
1246  vdst[x] = c;
1247  }
1248 
1249  ydst += ylinesize;
1250  udst += ulinesize;
1251  vdst += vlinesize;
1252  }
1253 }
1254 
1255 static av_cold int yuvtest_init(AVFilterContext *ctx)
1256 {
1257  TestSourceContext *test = ctx->priv;
1258 
1259  test->draw_once = 1;
1260  return init(ctx);
1261 }
1262 
1263 static const enum AVPixelFormat yuvtest_pix_fmts[] = {
1269 };
1270 
1271 static int yuvtest_config_props(AVFilterLink *outlink)
1272 {
1273  TestSourceContext *test = outlink->src->priv;
1275 
1276  test->fill_picture_fn = desc->comp[0].depth > 8 ? yuvtest_fill_picture16 : yuvtest_fill_picture8;
1277  return config_props(outlink);
1278 }
1279 
1280 static const AVFilterPad avfilter_vsrc_yuvtestsrc_outputs[] = {
1281  {
1282  .name = "default",
1283  .type = AVMEDIA_TYPE_VIDEO,
1284  .config_props = yuvtest_config_props,
1285  },
1286 };
1287 
1288 const AVFilter ff_vsrc_yuvtestsrc = {
1289  .name = "yuvtestsrc",
1290  .description = NULL_IF_CONFIG_SMALL("Generate YUV test pattern."),
1291  .priv_size = sizeof(TestSourceContext),
1292  .priv_class = &nullsrc_yuvtestsrc_class,
1293  .init = yuvtest_init,
1294  .uninit = uninit,
1295  .activate = activate,
1296  .inputs = NULL,
1297  FILTER_OUTPUTS(avfilter_vsrc_yuvtestsrc_outputs),
1298  FILTER_PIXFMTS_ARRAY(yuvtest_pix_fmts),
1299 };
1300 
1301 #endif /* CONFIG_YUVTESTSRC_FILTER */
1302 
1303 #if CONFIG_PAL75BARS_FILTER || CONFIG_PAL100BARS_FILTER || CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER
1304 
1305 static const uint8_t rainbow[7][4] = {
1306  { 180, 128, 128, 255 }, /* 75% white */
1307  { 162, 44, 142, 255 }, /* 75% yellow */
1308  { 131, 156, 44, 255 }, /* 75% cyan */
1309  { 112, 72, 58, 255 }, /* 75% green */
1310  { 84, 184, 198, 255 }, /* 75% magenta */
1311  { 65, 100, 212, 255 }, /* 75% red */
1312  { 35, 212, 114, 255 }, /* 75% blue */
1313 };
1314 
1315 static const uint8_t rainbow100[7][4] = {
1316  { 235, 128, 128, 255 }, /* 100% white */
1317  { 210, 16, 146, 255 }, /* 100% yellow */
1318  { 170, 166, 16, 255 }, /* 100% cyan */
1319  { 145, 54, 34, 255 }, /* 100% green */
1320  { 106, 202, 222, 255 }, /* 100% magenta */
1321  { 81, 90, 240, 255 }, /* 100% red */
1322  { 41, 240, 110, 255 }, /* 100% blue */
1323 };
1324 
1325 static const uint8_t rainbowhd[7][4] = {
1326  { 180, 128, 128, 255 }, /* 75% white */
1327  { 168, 44, 136, 255 }, /* 75% yellow */
1328  { 145, 147, 44, 255 }, /* 75% cyan */
1329  { 133, 63, 52, 255 }, /* 75% green */
1330  { 63, 193, 204, 255 }, /* 75% magenta */
1331  { 51, 109, 212, 255 }, /* 75% red */
1332  { 28, 212, 120, 255 }, /* 75% blue */
1333 };
1334 
1335 static const uint8_t wobnair[7][4] = {
1336  { 35, 212, 114, 255 }, /* 75% blue */
1337  { 19, 128, 128, 255 }, /* 7.5% intensity black */
1338  { 84, 184, 198, 255 }, /* 75% magenta */
1339  { 19, 128, 128, 255 }, /* 7.5% intensity black */
1340  { 131, 156, 44, 255 }, /* 75% cyan */
1341  { 19, 128, 128, 255 }, /* 7.5% intensity black */
1342  { 180, 128, 128, 255 }, /* 75% white */
1343 };
1344 
1345 static const uint8_t white[4] = { 235, 128, 128, 255 };
1346 
1347 /* pluge pulses */
1348 static const uint8_t neg4ire[4] = { 7, 128, 128, 255 };
1349 static const uint8_t pos4ire[4] = { 24, 128, 128, 255 };
1350 
1351 /* fudged Q/-I */
1352 static const uint8_t i_pixel[4] = { 57, 156, 97, 255 };
1353 static const uint8_t q_pixel[4] = { 44, 171, 147, 255 };
1354 
1355 static const uint8_t gray40[4] = { 104, 128, 128, 255 };
1356 static const uint8_t gray15[4] = { 49, 128, 128, 255 };
1357 static const uint8_t cyan[4] = { 188, 154, 16, 255 };
1358 static const uint8_t yellow[4] = { 219, 16, 138, 255 };
1359 static const uint8_t blue[4] = { 32, 240, 118, 255 };
1360 static const uint8_t red[4] = { 63, 102, 240, 255 };
1361 static const uint8_t black0[4] = { 16, 128, 128, 255 };
1362 static const uint8_t black2[4] = { 20, 128, 128, 255 };
1363 static const uint8_t black4[4] = { 25, 128, 128, 255 };
1364 static const uint8_t neg2[4] = { 12, 128, 128, 255 };
1365 
1366 static void draw_bar(TestSourceContext *test, const uint8_t color[4],
1367  int x, int y, int w, int h,
1368  AVFrame *frame)
1369 {
1371  uint8_t *p, *p0;
1372  int plane;
1373 
1374  x = FFMIN(x, test->w - 1);
1375  y = FFMIN(y, test->h - 1);
1376  w = FFMAX(FFMIN(w, test->w - x), 0);
1377  h = FFMAX(FFMIN(h, test->h - y), 0);
1378 
1379  av_assert0(x + w <= test->w);
1380  av_assert0(y + h <= test->h);
1381 
1382  for (plane = 0; frame->data[plane]; plane++) {
1383  const int c = color[plane];
1384  const ptrdiff_t linesize = frame->linesize[plane];
1385  int i, px, py, pw, ph;
1386 
1387  if (plane == 1 || plane == 2) {
1388  px = x >> desc->log2_chroma_w;
1389  pw = AV_CEIL_RSHIFT(w, desc->log2_chroma_w);
1390  py = y >> desc->log2_chroma_h;
1391  ph = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
1392  } else {
1393  px = x;
1394  pw = w;
1395  py = y;
1396  ph = h;
1397  }
1398 
1399  p0 = p = frame->data[plane] + py * linesize + px;
1400  memset(p, c, pw);
1401  p += linesize;
1402  for (i = 1; i < ph; i++, p += linesize)
1403  memcpy(p, p0, pw);
1404  }
1405 }
1406 
1407 static const enum AVPixelFormat smptebars_pix_fmts[] = {
1412 };
1413 
1414 static int smptebars_query_formats(AVFilterContext *ctx)
1415 {
1416  enum AVColorSpace csp;
1417  int ret;
1418 
1419  if (!strcmp(ctx->name, "smptehdbars")) {
1420  csp = AVCOL_SPC_BT709;
1421  } else {
1422  csp = AVCOL_SPC_BT470BG;
1423  }
1424 
1426  return ret;
1428  return ret;
1429  return ff_set_common_formats_from_list(ctx, smptebars_pix_fmts);
1430 }
1431 
1432 AVFILTER_DEFINE_CLASS_EXT(palbars, "pal(75|100)bars", options);
1433 
1434 #if CONFIG_PAL75BARS_FILTER
1435 
1436 static void pal75bars_fill_picture(AVFilterContext *ctx, AVFrame *picref)
1437 {
1438  TestSourceContext *test = ctx->priv;
1439  int r_w, i, x = 0;
1440  const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format);
1441 
1442  r_w = FFALIGN((test->w + 7) / 8, 1 << pixdesc->log2_chroma_w);
1443 
1444  draw_bar(test, white, x, 0, r_w, test->h, picref);
1445  x += r_w;
1446  for (i = 1; i < 7; i++) {
1447  draw_bar(test, rainbow[i], x, 0, r_w, test->h, picref);
1448  x += r_w;
1449  }
1450  draw_bar(test, black0, x, 0, r_w, test->h, picref);
1451 }
1452 
1453 static av_cold int pal75bars_init(AVFilterContext *ctx)
1454 {
1455  TestSourceContext *test = ctx->priv;
1456 
1457  test->fill_picture_fn = pal75bars_fill_picture;
1458  test->draw_once = 1;
1459  return init(ctx);
1460 }
1461 
1462 const AVFilter ff_vsrc_pal75bars = {
1463  .name = "pal75bars",
1464  .description = NULL_IF_CONFIG_SMALL("Generate PAL 75% color bars."),
1465  .priv_class = &palbars_class,
1466  .priv_size = sizeof(TestSourceContext),
1467  .init = pal75bars_init,
1468  .uninit = uninit,
1469  .activate = activate,
1470  .inputs = NULL,
1472  FILTER_QUERY_FUNC(smptebars_query_formats),
1473 };
1474 
1475 #endif /* CONFIG_PAL75BARS_FILTER */
1476 
1477 #if CONFIG_PAL100BARS_FILTER
1478 
1479 static void pal100bars_fill_picture(AVFilterContext *ctx, AVFrame *picref)
1480 {
1481  TestSourceContext *test = ctx->priv;
1482  int r_w, i, x = 0;
1483  const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format);
1484 
1485  r_w = FFALIGN((test->w + 7) / 8, 1 << pixdesc->log2_chroma_w);
1486 
1487  for (i = 0; i < 7; i++) {
1488  draw_bar(test, rainbow100[i], x, 0, r_w, test->h, picref);
1489  x += r_w;
1490  }
1491  draw_bar(test, black0, x, 0, r_w, test->h, picref);
1492 }
1493 
1494 static av_cold int pal100bars_init(AVFilterContext *ctx)
1495 {
1496  TestSourceContext *test = ctx->priv;
1497 
1498  test->fill_picture_fn = pal100bars_fill_picture;
1499  test->draw_once = 1;
1500  return init(ctx);
1501 }
1502 
1503 const AVFilter ff_vsrc_pal100bars = {
1504  .name = "pal100bars",
1505  .description = NULL_IF_CONFIG_SMALL("Generate PAL 100% color bars."),
1506  .priv_class = &palbars_class,
1507  .priv_size = sizeof(TestSourceContext),
1508  .init = pal100bars_init,
1509  .uninit = uninit,
1510  .activate = activate,
1511  .inputs = NULL,
1513  FILTER_QUERY_FUNC(smptebars_query_formats),
1514 };
1515 
1516 #endif /* CONFIG_PAL100BARS_FILTER */
1517 
1518 AVFILTER_DEFINE_CLASS_EXT(smptebars, "smpte(hd)bars", options);
1519 
1520 #if CONFIG_SMPTEBARS_FILTER
1521 
1522 static void smptebars_fill_picture(AVFilterContext *ctx, AVFrame *picref)
1523 {
1524  TestSourceContext *test = ctx->priv;
1525  int r_w, r_h, w_h, p_w, p_h, i, tmp, x = 0;
1526  const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format);
1527 
1528  r_w = FFALIGN((test->w + 6) / 7, 1 << pixdesc->log2_chroma_w);
1529  r_h = FFALIGN(test->h * 2 / 3, 1 << pixdesc->log2_chroma_h);
1530  w_h = FFALIGN(test->h * 3 / 4 - r_h, 1 << pixdesc->log2_chroma_h);
1531  p_w = FFALIGN(r_w * 5 / 4, 1 << pixdesc->log2_chroma_w);
1532  p_h = test->h - w_h - r_h;
1533 
1534  for (i = 0; i < 7; i++) {
1535  draw_bar(test, rainbow[i], x, 0, r_w, r_h, picref);
1536  draw_bar(test, wobnair[i], x, r_h, r_w, w_h, picref);
1537  x += r_w;
1538  }
1539  x = 0;
1540  draw_bar(test, i_pixel, x, r_h + w_h, p_w, p_h, picref);
1541  x += p_w;
1542  draw_bar(test, white, x, r_h + w_h, p_w, p_h, picref);
1543  x += p_w;
1544  draw_bar(test, q_pixel, x, r_h + w_h, p_w, p_h, picref);
1545  x += p_w;
1546  tmp = FFALIGN(5 * r_w - x, 1 << pixdesc->log2_chroma_w);
1547  draw_bar(test, black0, x, r_h + w_h, tmp, p_h, picref);
1548  x += tmp;
1549  tmp = FFALIGN(r_w / 3, 1 << pixdesc->log2_chroma_w);
1550  draw_bar(test, neg4ire, x, r_h + w_h, tmp, p_h, picref);
1551  x += tmp;
1552  draw_bar(test, black0, x, r_h + w_h, tmp, p_h, picref);
1553  x += tmp;
1554  draw_bar(test, pos4ire, x, r_h + w_h, tmp, p_h, picref);
1555  x += tmp;
1556  draw_bar(test, black0, x, r_h + w_h, test->w - x, p_h, picref);
1557 }
1558 
1559 static av_cold int smptebars_init(AVFilterContext *ctx)
1560 {
1561  TestSourceContext *test = ctx->priv;
1562 
1563  test->fill_picture_fn = smptebars_fill_picture;
1564  test->draw_once = 1;
1565  return init(ctx);
1566 }
1567 
1568 const AVFilter ff_vsrc_smptebars = {
1569  .name = "smptebars",
1570  .description = NULL_IF_CONFIG_SMALL("Generate SMPTE color bars."),
1571  .priv_size = sizeof(TestSourceContext),
1572  .priv_class = &smptebars_class,
1573  .init = smptebars_init,
1574  .uninit = uninit,
1575  .activate = activate,
1576  .inputs = NULL,
1578  FILTER_QUERY_FUNC(smptebars_query_formats),
1579 };
1580 
1581 #endif /* CONFIG_SMPTEBARS_FILTER */
1582 
1583 #if CONFIG_SMPTEHDBARS_FILTER
1584 
1585 static void smptehdbars_fill_picture(AVFilterContext *ctx, AVFrame *picref)
1586 {
1587  TestSourceContext *test = ctx->priv;
1588  int d_w, r_w, r_h, l_w, i, tmp, x = 0, y = 0;
1589  const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format);
1590 
1591  d_w = FFALIGN(test->w / 8, 1 << pixdesc->log2_chroma_w);
1592  r_h = FFALIGN(test->h * 7 / 12, 1 << pixdesc->log2_chroma_h);
1593  draw_bar(test, gray40, x, 0, d_w, r_h, picref);
1594  x += d_w;
1595 
1596  r_w = FFALIGN((((test->w + 3) / 4) * 3) / 7, 1 << pixdesc->log2_chroma_w);
1597  for (i = 0; i < 7; i++) {
1598  draw_bar(test, rainbowhd[i], x, 0, r_w, r_h, picref);
1599  x += r_w;
1600  }
1601  draw_bar(test, gray40, x, 0, test->w - x, r_h, picref);
1602  y = r_h;
1603  r_h = FFALIGN(test->h / 12, 1 << pixdesc->log2_chroma_h);
1604  draw_bar(test, cyan, 0, y, d_w, r_h, picref);
1605  x = d_w;
1606  draw_bar(test, i_pixel, x, y, r_w, r_h, picref);
1607  x += r_w;
1608  tmp = r_w * 6;
1609  draw_bar(test, rainbowhd[0], x, y, tmp, r_h, picref);
1610  x += tmp;
1611  l_w = x;
1612  draw_bar(test, blue, x, y, test->w - x, r_h, picref);
1613  y += r_h;
1614  draw_bar(test, yellow, 0, y, d_w, r_h, picref);
1615  x = d_w;
1616  draw_bar(test, q_pixel, x, y, r_w, r_h, picref);
1617  x += r_w;
1618 
1619  for (i = 0; i < tmp; i += 1 << pixdesc->log2_chroma_w) {
1620  uint8_t yramp[4] = {0};
1621 
1622  yramp[0] = i * 255 / tmp;
1623  yramp[1] = 128;
1624  yramp[2] = 128;
1625  yramp[3] = 255;
1626 
1627  draw_bar(test, yramp, x, y, 1 << pixdesc->log2_chroma_w, r_h, picref);
1628  x += 1 << pixdesc->log2_chroma_w;
1629  }
1630  draw_bar(test, red, x, y, test->w - x, r_h, picref);
1631  y += r_h;
1632  draw_bar(test, gray15, 0, y, d_w, test->h - y, picref);
1633  x = d_w;
1634  tmp = FFALIGN(r_w * 3 / 2, 1 << pixdesc->log2_chroma_w);
1635  draw_bar(test, black0, x, y, tmp, test->h - y, picref);
1636  x += tmp;
1637  tmp = FFALIGN(r_w * 2, 1 << pixdesc->log2_chroma_w);
1638  draw_bar(test, white, x, y, tmp, test->h - y, picref);
1639  x += tmp;
1640  tmp = FFALIGN(r_w * 5 / 6, 1 << pixdesc->log2_chroma_w);
1641  draw_bar(test, black0, x, y, tmp, test->h - y, picref);
1642  x += tmp;
1643  tmp = FFALIGN(r_w / 3, 1 << pixdesc->log2_chroma_w);
1644  draw_bar(test, neg2, x, y, tmp, test->h - y, picref);
1645  x += tmp;
1646  draw_bar(test, black0, x, y, tmp, test->h - y, picref);
1647  x += tmp;
1648  draw_bar(test, black2, x, y, tmp, test->h - y, picref);
1649  x += tmp;
1650  draw_bar(test, black0, x, y, tmp, test->h - y, picref);
1651  x += tmp;
1652  draw_bar(test, black4, x, y, tmp, test->h - y, picref);
1653  x += tmp;
1654  r_w = l_w - x;
1655  draw_bar(test, black0, x, y, r_w, test->h - y, picref);
1656  x += r_w;
1657  draw_bar(test, gray15, x, y, test->w - x, test->h - y, picref);
1658 }
1659 
1660 static av_cold int smptehdbars_init(AVFilterContext *ctx)
1661 {
1662  TestSourceContext *test = ctx->priv;
1663 
1664  test->fill_picture_fn = smptehdbars_fill_picture;
1665  test->draw_once = 1;
1666  return init(ctx);
1667 }
1668 
1669 const AVFilter ff_vsrc_smptehdbars = {
1670  .name = "smptehdbars",
1671  .description = NULL_IF_CONFIG_SMALL("Generate SMPTE HD color bars."),
1672  .priv_class = &smptebars_class,
1673  .priv_size = sizeof(TestSourceContext),
1674  .init = smptehdbars_init,
1675  .uninit = uninit,
1676  .activate = activate,
1677  .inputs = NULL,
1679  FILTER_QUERY_FUNC(smptebars_query_formats),
1680 };
1681 
1682 #endif /* CONFIG_SMPTEHDBARS_FILTER */
1683 #endif /* CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER */
1684 
1685 AVFILTER_DEFINE_CLASS_EXT(allyuv_allrgb, "allyuv/allrgb",
1687 
1688 #if CONFIG_ALLYUV_FILTER
1689 
1690 static void allyuv_fill_picture(AVFilterContext *ctx, AVFrame *frame)
1691 {
1692  const ptrdiff_t ys = frame->linesize[0];
1693  const ptrdiff_t us = frame->linesize[1];
1694  const ptrdiff_t vs = frame->linesize[2];
1695  int x, y, j;
1696 
1697  for (y = 0; y < 4096; y++) {
1698  for (x = 0; x < 2048; x++) {
1699  frame->data[0][y * ys + x] = ((x / 8) % 256);
1700  frame->data[0][y * ys + 4095 - x] = ((x / 8) % 256);
1701  }
1702 
1703  for (x = 0; x < 2048; x+=8) {
1704  for (j = 0; j < 8; j++) {
1705  frame->data[1][vs * y + x + j] = (y%16 + (j % 8) * 16);
1706  frame->data[1][vs * y + 4095 - x - j] = (128 + y%16 + (j % 8) * 16);
1707  }
1708  }
1709 
1710  for (x = 0; x < 4096; x++)
1711  frame->data[2][y * us + x] = 256 * y / 4096;
1712  }
1713 }
1714 
1715 static av_cold int allyuv_init(AVFilterContext *ctx)
1716 {
1717  TestSourceContext *test = ctx->priv;
1718 
1719  test->w = test->h = 4096;
1720  test->draw_once = 1;
1721  test->fill_picture_fn = allyuv_fill_picture;
1722  return init(ctx);
1723 }
1724 
1725 const AVFilter ff_vsrc_allyuv = {
1726  .name = "allyuv",
1727  .description = NULL_IF_CONFIG_SMALL("Generate all yuv colors."),
1728  .priv_size = sizeof(TestSourceContext),
1729  .priv_class = &allyuv_allrgb_class,
1730  .init = allyuv_init,
1731  .uninit = uninit,
1732  .activate = activate,
1733  .inputs = NULL,
1736 };
1737 
1738 #endif /* CONFIG_ALLYUV_FILTER */
1739 
1740 #if CONFIG_ALLRGB_FILTER
1741 
1742 static void allrgb_fill_picture(AVFilterContext *ctx, AVFrame *frame)
1743 {
1744  unsigned x, y;
1745  const ptrdiff_t linesize = frame->linesize[0];
1746  uint8_t *line = frame->data[0];
1747 
1748  for (y = 0; y < 4096; y++) {
1749  uint8_t *dst = line;
1750 
1751  for (x = 0; x < 4096; x++) {
1752  *dst++ = x;
1753  *dst++ = y;
1754  *dst++ = (x >> 8) | ((y >> 8) << 4);
1755  }
1756  line += linesize;
1757  }
1758 }
1759 
1760 static av_cold int allrgb_init(AVFilterContext *ctx)
1761 {
1762  TestSourceContext *test = ctx->priv;
1763 
1764  test->w = test->h = 4096;
1765  test->draw_once = 1;
1766  test->fill_picture_fn = allrgb_fill_picture;
1767  return init(ctx);
1768 }
1769 
1770 static int allrgb_config_props(AVFilterLink *outlink)
1771 {
1772  TestSourceContext *test = outlink->src->priv;
1773 
1774  ff_fill_rgba_map(test->rgba_map, outlink->format);
1775  return config_props(outlink);
1776 }
1777 
1778 static const AVFilterPad avfilter_vsrc_allrgb_outputs[] = {
1779  {
1780  .name = "default",
1781  .type = AVMEDIA_TYPE_VIDEO,
1782  .config_props = allrgb_config_props,
1783  },
1784 };
1785 
1786 const AVFilter ff_vsrc_allrgb = {
1787  .name = "allrgb",
1788  .description = NULL_IF_CONFIG_SMALL("Generate all RGB colors."),
1789  .priv_size = sizeof(TestSourceContext),
1790  .priv_class = &allyuv_allrgb_class,
1791  .init = allrgb_init,
1792  .uninit = uninit,
1793  .activate = activate,
1794  .inputs = NULL,
1795  FILTER_OUTPUTS(avfilter_vsrc_allrgb_outputs),
1797 };
1798 
1799 #endif /* CONFIG_ALLRGB_FILTER */
1800 
1801 #if CONFIG_COLORSPECTRUM_FILTER
1802 
1803 static const AVOption colorspectrum_options[] = {
1805  { "type", "set the color spectrum type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, .unit = "type" },
1806  { "black","fade to black", 0, AV_OPT_TYPE_CONST,{.i64=0},0, 0, FLAGS, .unit = "type" },
1807  { "white","fade to white", 0, AV_OPT_TYPE_CONST,{.i64=1},0, 0, FLAGS, .unit = "type" },
1808  { "all", "white to black", 0, AV_OPT_TYPE_CONST,{.i64=2},0, 0, FLAGS, .unit = "type" },
1809  { NULL }
1810 };
1811 
1812 AVFILTER_DEFINE_CLASS(colorspectrum);
1813 
1814 static inline float mix(float a, float b, float mix)
1815 {
1816  return a * mix + b * (1.f - mix);
1817 }
1818 
1819 static void hsb2rgb(const float *c, float *rgb)
1820 {
1821  rgb[0] = av_clipf(fabsf(fmodf(c[0] * 6.f + 0.f, 6.f) - 3.f) - 1.f, 0.f, 1.f);
1822  rgb[1] = av_clipf(fabsf(fmodf(c[0] * 6.f + 4.f, 6.f) - 3.f) - 1.f, 0.f, 1.f);
1823  rgb[2] = av_clipf(fabsf(fmodf(c[0] * 6.f + 2.f, 6.f) - 3.f) - 1.f, 0.f, 1.f);
1824  rgb[0] = mix(c[3], (rgb[0] * rgb[0] * (3.f - 2.f * rgb[0])), c[1]) * c[2];
1825  rgb[1] = mix(c[3], (rgb[1] * rgb[1] * (3.f - 2.f * rgb[1])), c[1]) * c[2];
1826  rgb[2] = mix(c[3], (rgb[2] * rgb[2] * (3.f - 2.f * rgb[2])), c[1]) * c[2];
1827 }
1828 
1829 static void colorspectrum_fill_picture(AVFilterContext *ctx, AVFrame *frame)
1830 {
1831  TestSourceContext *test = ctx->priv;
1832  const float w = frame->width - 1.f;
1833  const float h = frame->height - 1.f;
1834  float c[4];
1835 
1836  for (int y = 0; y < frame->height; y++) {
1837  float *r = (float *)(frame->data[2] + y * frame->linesize[2]);
1838  float *g = (float *)(frame->data[0] + y * frame->linesize[0]);
1839  float *b = (float *)(frame->data[1] + y * frame->linesize[1]);
1840  const float yh = y / h;
1841 
1842  c[1] = test->type == 2 ? yh > 0.5f ? 2.f * (yh - 0.5f) : 1.f - 2.f * yh : test->type == 1 ? 1.f - yh : yh;
1843  c[2] = 1.f;
1844  c[3] = test->type == 1 ? 1.f : test->type == 2 ? (yh > 0.5f ? 0.f : 1.f): 0.f;
1845  for (int x = 0; x < frame->width; x++) {
1846  float rgb[3];
1847 
1848  c[0] = x / w;
1849  hsb2rgb(c, rgb);
1850 
1851  r[x] = rgb[0];
1852  g[x] = rgb[1];
1853  b[x] = rgb[2];
1854  }
1855  }
1856 }
1857 
1858 static av_cold int colorspectrum_init(AVFilterContext *ctx)
1859 {
1860  TestSourceContext *test = ctx->priv;
1861 
1862  test->draw_once = 1;
1863  test->fill_picture_fn = colorspectrum_fill_picture;
1864  return init(ctx);
1865 }
1866 
1868  .name = "colorspectrum",
1869  .description = NULL_IF_CONFIG_SMALL("Generate colors spectrum."),
1870  .priv_size = sizeof(TestSourceContext),
1871  .priv_class = &colorspectrum_class,
1872  .init = colorspectrum_init,
1873  .uninit = uninit,
1874  .activate = activate,
1875  .inputs = NULL,
1878 };
1879 
1880 #endif /* CONFIG_COLORSPECTRUM_FILTER */
1881 
1882 #if CONFIG_COLORCHART_FILTER
1883 
1884 static const AVOption colorchart_options[] = {
1886  { "patch_size", "set the single patch size", OFFSET(pw), AV_OPT_TYPE_IMAGE_SIZE, {.str="64x64"}, 0, 0, FLAGS },
1887  { "preset", "set the color checker chart preset", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, .unit = "preset" },
1888  { "reference", "reference", 0, AV_OPT_TYPE_CONST,{.i64=0}, 0, 0, FLAGS, .unit = "preset" },
1889  { "skintones", "skintones", 0, AV_OPT_TYPE_CONST,{.i64=1}, 0, 0, FLAGS, .unit = "preset" },
1890  { NULL }
1891 };
1892 
1893 AVFILTER_DEFINE_CLASS(colorchart);
1894 
1895 static const uint8_t reference_colors[][3] = {
1896  { 115, 82, 68 }, // dark skin
1897  { 194, 150, 130 }, // light skin
1898  { 98, 122, 157 }, // blue sky
1899  { 87, 108, 67 }, // foliage
1900  { 133, 128, 177 }, // blue flower
1901  { 103, 189, 170 }, // bluish green
1902 
1903  { 214, 126, 44 }, // orange
1904  { 80, 91, 166 }, // purple red
1905  { 193, 90, 99 }, // moderate red
1906  { 94, 60, 108 }, // purple
1907  { 157, 188, 64 }, // yellow green
1908  { 224, 163, 46 }, // orange yellow
1909 
1910  { 56, 61, 150 }, // blue
1911  { 70, 148, 73 }, // green
1912  { 175, 54, 60 }, // red
1913  { 231, 199, 31 }, // yellow
1914  { 187, 86, 149 }, // magenta
1915  { 8, 133, 161 }, // cyan
1916 
1917  { 243, 243, 242 }, // white
1918  { 200, 200, 200 }, // neutral 8
1919  { 160, 160, 160 }, // neutral 65
1920  { 122, 122, 121 }, // neutral 5
1921  { 85, 85, 85 }, // neutral 35
1922  { 52, 52, 52 }, // black
1923 };
1924 
1925 static const uint8_t skintones_colors[][3] = {
1926  { 54, 38, 43 },
1927  { 105, 43, 42 },
1928  { 147, 43, 43 },
1929  { 77, 41, 42 },
1930  { 134, 43, 41 },
1931  { 201, 134, 118 },
1932 
1933  { 59, 41, 41 },
1934  { 192, 103, 76 },
1935  { 208, 156, 141 },
1936  { 152, 82, 61 },
1937  { 162, 132, 118 },
1938  { 212, 171, 150 },
1939 
1940  { 205, 91, 31 },
1941  { 164, 100, 55 },
1942  { 204, 136, 95 },
1943  { 178, 142, 116 },
1944  { 210, 152, 108 },
1945  { 217, 167, 131 },
1946 
1947  { 206, 166, 126 },
1948  { 208, 163, 97 },
1949  { 245, 180, 0 },
1950  { 212, 184, 125 },
1951  { 179, 165, 150 },
1952  { 196, 184, 105 },
1953 };
1954 
1955 typedef struct ColorChartPreset {
1956  int w, h;
1957  const uint8_t (*colors)[3];
1958 } ColorChartPreset;
1959 
1960 static const ColorChartPreset colorchart_presets[] = {
1961  { 6, 4, reference_colors, },
1962  { 6, 4, skintones_colors, },
1963 };
1964 
1965 static int colorchart_config_props(AVFilterLink *inlink)
1966 {
1967  AVFilterContext *ctx = inlink->src;
1968  TestSourceContext *s = ctx->priv;
1969 
1970  av_assert0(ff_draw_init2(&s->draw, inlink->format, inlink->colorspace,
1971  inlink->color_range, 0) >= 0);
1972  if (av_image_check_size(s->w, s->h, 0, ctx) < 0)
1973  return AVERROR(EINVAL);
1974  return config_props(inlink);
1975 }
1976 
1977 static void colorchart_fill_picture(AVFilterContext *ctx, AVFrame *frame)
1978 {
1979  TestSourceContext *test = ctx->priv;
1980  const int preset = test->type;
1981  const int w = colorchart_presets[preset].w;
1982  const int h = colorchart_presets[preset].h;
1983  const int pw = test->pw;
1984  const int ph = test->ph;
1985 
1986  for (int y = 0; y < h; y++) {
1987  for (int x = 0; x < w; x++) {
1988  uint32_t pc = AV_RB24(colorchart_presets[preset].colors[y * w + x]);
1990 
1991  set_color(test, &color, pc);
1992  ff_fill_rectangle(&test->draw, &color, frame->data, frame->linesize,
1993  x * pw, y * ph, pw, ph);
1994  }
1995  }
1996 }
1997 
1998 static av_cold int colorchart_init(AVFilterContext *ctx)
1999 {
2000  TestSourceContext *test = ctx->priv;
2001  const int preset = test->type;
2002  const int w = colorchart_presets[preset].w;
2003  const int h = colorchart_presets[preset].h;
2004 
2005  test->w = w * test->pw;
2006  test->h = h * test->ph;
2007  test->draw_once = 1;
2008  test->fill_picture_fn = colorchart_fill_picture;
2009  return init(ctx);
2010 }
2011 
2012 static const AVFilterPad avfilter_vsrc_colorchart_outputs[] = {
2013  {
2014  .name = "default",
2015  .type = AVMEDIA_TYPE_VIDEO,
2016  .config_props = colorchart_config_props,
2017  },
2018 };
2019 
2020 const AVFilter ff_vsrc_colorchart = {
2021  .name = "colorchart",
2022  .description = NULL_IF_CONFIG_SMALL("Generate color checker chart."),
2023  .priv_size = sizeof(TestSourceContext),
2024  .priv_class = &colorchart_class,
2025  .init = colorchart_init,
2026  .uninit = uninit,
2027  .activate = activate,
2028  .inputs = NULL,
2029  FILTER_OUTPUTS(avfilter_vsrc_colorchart_outputs),
2031 };
2032 
2033 #endif /* CONFIG_COLORCHART_FILTER */
2034 
2035 #if CONFIG_ZONEPLATE_FILTER
2036 
2037 static const AVOption zoneplate_options[] = {
2039  { "precision", "set LUT precision", OFFSET(lut_precision), AV_OPT_TYPE_INT, {.i64=10}, 4, 16, FLAGS },
2040  { "xo", "set X-axis offset", OFFSET(xo), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2041  { "yo", "set Y-axis offset", OFFSET(yo), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2042  { "to", "set T-axis offset", OFFSET(to), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2043  { "k0", "set 0-order phase", OFFSET(k0), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2044  { "kx", "set 1-order X-axis phase", OFFSET(kx), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2045  { "ky", "set 1-order Y-axis phase", OFFSET(ky), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2046  { "kt", "set 1-order T-axis phase", OFFSET(kt), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2047  { "kxt", "set X-axis*T-axis product phase", OFFSET(kxt), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2048  { "kyt", "set Y-axis*T-axis product phase", OFFSET(kyt), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2049  { "kxy", "set X-axis*Y-axis product phase", OFFSET(kxy), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2050  { "kx2", "set 2-order X-axis phase", OFFSET(kx2), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2051  { "ky2", "set 2-order Y-axis phase", OFFSET(ky2), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2052  { "kt2", "set 2-order T-axis phase", OFFSET(kt2), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2053  { "ku", "set 0-order U-color phase", OFFSET(kU), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2054  { "kv", "set 0-order V-color phase", OFFSET(kV), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGSR },
2055  { NULL }
2056 };
2057 
2058 AVFILTER_DEFINE_CLASS(zoneplate);
2059 
2060 #define ZONEPLATE_SLICE(name, type) \
2061 static int zoneplate_fill_slice_##name(AVFilterContext *ctx, \
2062  void *arg, int job, \
2063  int nb_jobs) \
2064 { \
2065  TestSourceContext *test = ctx->priv; \
2066  AVFrame *frame = arg; \
2067  const int w = frame->width; \
2068  const int h = frame->height; \
2069  const int kxt = test->kxt, kyt = test->kyt, kx2 = test->kx2; \
2070  const int t = test->pts + test->to, k0 = test->k0; \
2071  const int kt = test->kt, kt2 = test->kt2, ky2 = test->ky2; \
2072  const int ky = test->ky, kx = test->kx, kxy = test->kxy; \
2073  const int lut_mask = (1 << test->lut_precision) - 1; \
2074  const int nkt2t = kt2 * t * t, nktt = kt * t; \
2075  const int start = (h * job ) / nb_jobs; \
2076  const int end = (h * (job+1)) / nb_jobs; \
2077  const ptrdiff_t ylinesize = frame->linesize[0] / sizeof(type); \
2078  const ptrdiff_t ulinesize = frame->linesize[1] / sizeof(type); \
2079  const ptrdiff_t vlinesize = frame->linesize[2] / sizeof(type); \
2080  const int xreset = -(w / 2) - test->xo; \
2081  const int yreset = -(h / 2) - test->yo + start; \
2082  const int kU = test->kU, kV = test->kV; \
2083  const int skxy = 0xffff / (w / 2); \
2084  const int skx2 = 0xffff / w; \
2085  const int dkxt = kxt * t; \
2086  type *ydst = ((type *)frame->data[0]) + start * ylinesize; \
2087  type *udst = ((type *)frame->data[1]) + start * ulinesize; \
2088  type *vdst = ((type *)frame->data[2]) + start * vlinesize; \
2089  const type *lut = (const type *)test->lut; \
2090  int akx, akxt, aky, akyt; \
2091  \
2092  aky = start * ky; \
2093  akyt = start * kyt * t; \
2094  \
2095  for (int j = start, y = yreset; j < end; j++, y++) { \
2096  const int dkxy = kxy * y * skxy; \
2097  const int nky2kt2 = (ky2 * y * y) / h + (nkt2t >> 1); \
2098  int akxy = dkxy * xreset; \
2099  \
2100  akx = 0; \
2101  akxt = 0; \
2102  aky += ky; \
2103  akyt += kyt * t; \
2104  \
2105  for (int i = 0, x = xreset; i < w; i++, x++) { \
2106  int phase = k0, uphase = kU, vphase = kV; \
2107  \
2108  akx += kx; \
2109  phase += akx + aky + nktt; \
2110  \
2111  akxt += dkxt; \
2112  akxy += dkxy; \
2113  phase += akxt + akyt; \
2114  phase += akxy >> 16; \
2115  phase += ((kx2 * x * x * skx2) >> 16) + nky2kt2; \
2116  uphase += phase; \
2117  vphase += phase; \
2118  \
2119  ydst[i] = lut[phase & lut_mask]; \
2120  udst[i] = lut[uphase & lut_mask]; \
2121  vdst[i] = lut[vphase & lut_mask]; \
2122  } \
2123  \
2124  ydst += ylinesize; \
2125  udst += ulinesize; \
2126  vdst += vlinesize; \
2127  } \
2128  \
2129  return 0; \
2130 }
2131 
2132 ZONEPLATE_SLICE( 8, uint8_t)
2133 ZONEPLATE_SLICE( 9, uint16_t)
2134 ZONEPLATE_SLICE(10, uint16_t)
2135 ZONEPLATE_SLICE(12, uint16_t)
2136 ZONEPLATE_SLICE(14, uint16_t)
2137 ZONEPLATE_SLICE(16, uint16_t)
2138 
2139 static void zoneplate_fill_picture(AVFilterContext *ctx, AVFrame *frame)
2140 {
2141  TestSourceContext *test = ctx->priv;
2142  ff_filter_execute(ctx, test->fill_slice_fn, frame, NULL,
2144 }
2145 
2146 static int zoneplate_config_props(AVFilterLink *outlink)
2147 {
2148  AVFilterContext *ctx = outlink->src;
2149  TestSourceContext *test = ctx->priv;
2151  const int lut_size = 1 << test->lut_precision;
2152  const int depth = desc->comp[0].depth;
2153  uint16_t *lut16;
2154  uint8_t *lut8;
2155 
2156  if (av_image_check_size(test->w, test->h, 0, ctx) < 0)
2157  return AVERROR(EINVAL);
2158 
2159  test->lut = av_calloc(lut_size, sizeof(*test->lut) * ((depth + 7) / 8));
2160  if (!test->lut)
2161  return AVERROR(ENOMEM);
2162 
2163  lut8 = test->lut;
2164  lut16 = (uint16_t *)test->lut;
2165  switch (depth) {
2166  case 8:
2167  for (int i = 0; i < lut_size; i++)
2168  lut8[i] = lrintf(255.f * (0.5f + 0.5f * sinf((2.f * M_PI * i) / lut_size)));
2169  break;
2170  default:
2171  for (int i = 0; i < lut_size; i++)
2172  lut16[i] = lrintf(((1 << depth) - 1) * (0.5f + 0.5f * sinf((2.f * M_PI * i) / lut_size)));
2173  break;
2174  }
2175 
2176  test->draw_once = 0;
2177  test->fill_picture_fn = zoneplate_fill_picture;
2178 
2179  switch (depth) {
2180  case 8: test->fill_slice_fn = zoneplate_fill_slice_8; break;
2181  case 9: test->fill_slice_fn = zoneplate_fill_slice_9; break;
2182  case 10: test->fill_slice_fn = zoneplate_fill_slice_10; break;
2183  case 12: test->fill_slice_fn = zoneplate_fill_slice_12; break;
2184  case 14: test->fill_slice_fn = zoneplate_fill_slice_14; break;
2185  case 16: test->fill_slice_fn = zoneplate_fill_slice_16; break;
2186  }
2187  return config_props(outlink);
2188 }
2189 
2190 static const enum AVPixelFormat zoneplate_pix_fmts[] = {
2195 };
2196 
2197 static int zoneplate_query_formats(AVFilterContext *ctx)
2198 {
2199  int ret;
2201  return ret;
2202  return ff_set_common_formats_from_list(ctx, zoneplate_pix_fmts);
2203 }
2204 
2205 static const AVFilterPad avfilter_vsrc_zoneplate_outputs[] = {
2206  {
2207  .name = "default",
2208  .type = AVMEDIA_TYPE_VIDEO,
2209  .config_props = zoneplate_config_props,
2210  },
2211 };
2212 
2213 const AVFilter ff_vsrc_zoneplate = {
2214  .name = "zoneplate",
2215  .description = NULL_IF_CONFIG_SMALL("Generate zone-plate."),
2216  .priv_size = sizeof(TestSourceContext),
2217  .priv_class = &zoneplate_class,
2218  .init = init,
2219  .uninit = uninit,
2220  .activate = activate,
2221  .inputs = NULL,
2222  FILTER_OUTPUTS(avfilter_vsrc_zoneplate_outputs),
2223  FILTER_QUERY_FUNC(zoneplate_query_formats),
2224  .flags = AVFILTER_FLAG_SLICE_THREADS,
2225  .process_command = ff_filter_process_command,
2226 };
2227 
2228 #endif /* CONFIG_ZONEPLATE_FILTER */
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:112
A
#define A(x)
Definition: vpx_arith.h:28
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:501
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:73
FFDrawColor
Definition: drawutils.h:50
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
ff_exp10
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
Definition: ffmath.h:42
level
uint8_t level
Definition: svq3.c:205
mix
static int mix(int c0, int c1)
Definition: 4xm.c:716
r
const char * r
Definition: vf_curves.c:127
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
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:424
color
Definition: vf_paletteuse.c:512
TestSourceContext::kV
int kV
Definition: vsrc_testsrc.c:94
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1015
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2965
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vsrc_testsrc.c:140
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:162
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:264
TestSourceContext::kxt
int kxt
Definition: vsrc_testsrc.c:92
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
TestSourceContext::k0
int k0
Definition: vsrc_testsrc.c:91
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:160
ph
static int FUNC() ph(CodedBitstreamContext *ctx, RWContext *rw, H266RawPH *current)
Definition: cbs_h266_syntax_template.c:3003
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
ff_vsrc_color
const AVFilter ff_vsrc_color
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
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:686
AVOption
AVOption.
Definition: opt.h:346
b
#define b
Definition: input.c:41
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
data
const char data[16]
Definition: mxf.c:148
R
#define R
Definition: huffyuv.h:44
test
Definition: idctdsp.c:35
ff_vsrc_pal75bars
const AVFilter ff_vsrc_pal75bars
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:102
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
init
static av_cold int init(AVFilterContext *ctx)
Definition: vsrc_testsrc.c:125
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
video.h
ff_make_formats_list_singleton
AVFilterFormats * ff_make_formats_list_singleton(int fmt)
Equivalent to ff_make_format_list({const int[]}{ fmt, -1 })
Definition: formats.c:530
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:395
formats.h
ff_vsrc_haldclutsrc
const AVFilter ff_vsrc_haldclutsrc
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3005
AVCOL_SPC_BT470BG
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
Definition: pixfmt.h:615
rgb
Definition: rpzaenc.c:60
ff_vsrc_yuvtestsrc
const AVFilter ff_vsrc_yuvtestsrc
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:496
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:422
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:494
TestSourceContext::kyt
int kyt
Definition: vsrc_testsrc.c:92
draw_rectangle
static void draw_rectangle(AVFormatContext *s)
Definition: xcbgrab.c:649
val
static double val(void *priv, double ch)
Definition: aeval.c:78
type
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 type
Definition: writing_filters.txt:86
TestSourceContext::kxy
int kxy
Definition: vsrc_testsrc.c:92
TestSourceContext::xo
int xo
Definition: vsrc_testsrc.c:94
us
#define us(width, name, range_min, range_max, subs,...)
Definition: cbs_h2645.c:263
ff_vsrc_allrgb
const AVFilter ff_vsrc_allrgb
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:534
fabsf
static __device__ float fabsf(float a)
Definition: cuda_runtime.h:181
planar
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1<< 16)) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(UINT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out->ch+ch,(const uint8_t **) in->ch+ch, off *(out-> planar
Definition: audioconvert.c:56
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
TestSourceContext::rgba_map
uint8_t rgba_map[4]
Definition: vsrc_testsrc.c:83
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:481
preset
preset
Definition: vf_curves.c:47
avassert.h
ff_vsrc_pal100bars
const AVFilter ff_vsrc_pal100bars
TestSourceContext::duration
int64_t duration
duration expressed in microseconds
Definition: vsrc_testsrc.c:60
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
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:868
AV_FRAME_FLAG_KEY
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition: frame.h:625
mask
static const uint16_t mask[17]
Definition: lzw.c:38
TestSourceContext::type
int type
Definition: vsrc_testsrc.c:75
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:498
float
float
Definition: af_crystalizer.c:121
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
TestSourceContext::kt
int kt
Definition: vsrc_testsrc.c:91
width
#define width
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:499
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:491
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:59
g
const char * g
Definition: vf_curves.c:128
av_q2d
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
TestSourceContext::ph
int ph
Definition: vsrc_testsrc.c:56
TestSourceContext::time_base
AVRational time_base
Definition: vsrc_testsrc.c:58
to
const char * to
Definition: webvttdec.c:35
ff_set_common_formats_from_list
int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts)
Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))
Definition: formats.c:874
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
filters.h
B
#define B
Definition: huffyuv.h:42
ctx
AVFormatContext * ctx
Definition: movenc.c:49
FLAGSR
#define FLAGSR
Definition: vsrc_testsrc.c:102
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:593
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
TestSourceContext::color_rgba
uint8_t color_rgba[4]
Definition: vsrc_testsrc.c:80
AVPixFmtDescriptor::log2_chroma_w
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
ff_vsrc_testsrc2
const AVFilter ff_vsrc_testsrc2
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:87
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
arg
const char * arg
Definition: jacosubdec.c:67
TestSourceContext::kt2
int kt2
Definition: vsrc_testsrc.c:93
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:497
TestSourceContext::sar
AVRational sar
sample aspect ratio
Definition: vsrc_testsrc.c:61
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:468
FLAGS
#define FLAGS
Definition: vsrc_testsrc.c:101
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
AV_PIX_FMT_BGR48
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:469
NULL
#define NULL
Definition: coverity.c:32
ff_vsrc_colorspectrum
const AVFilter ff_vsrc_colorspectrum
TestSourceContext::lut_precision
int lut_precision
Definition: vsrc_testsrc.c:95
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
TestSourceContext::color
FFDrawColor color
Definition: vsrc_testsrc.c:79
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Definition: opt.h:250
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:245
AV_WL24
#define AV_WL24(p, d)
Definition: intreadwrite.h:462
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:279
NOSIZE_OPTIONS_OFFSET
#define NOSIZE_OPTIONS_OFFSET
Definition: vsrc_testsrc.c:117
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:265
sinf
#define sinf(x)
Definition: libm.h:419
av_clipf
av_clipf
Definition: af_crystalizer.c:121
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
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:493
ff_vsrc_colorchart
const AVFilter ff_vsrc_colorchart
ff_vsrc_allyuv
const AVFilter ff_vsrc_allyuv
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:101
index
int index
Definition: gxfenc.c:90
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
TestSourceContext::picref
AVFrame * picref
cached reference containing the painted picture
Definition: vsrc_testsrc.c:64
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
f
f
Definition: af_crystalizer.c:121
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
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
config_props
static int config_props(AVFilterLink *outlink)
Definition: vsrc_testsrc.c:148
ff_vsrc_smptehdbars
const AVFilter ff_vsrc_smptehdbars
av_get_padded_bits_per_pixel
int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel for the pixel format described by pixdesc, including any padding ...
Definition: pixdesc.c:2930
FILTER_PIXFMTS
#define FILTER_PIXFMTS(...)
Definition: internal.h:168
ff_blend_rectangle
void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, int x0, int y0, int w, int h)
Blend a rectangle with an uniform color.
Definition: drawutils.c:353
AV_ROUND_ZERO
@ AV_ROUND_ZERO
Round toward zero.
Definition: mathematics.h:131
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:80
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
TestSourceContext::frame_rate
AVRational frame_rate
Definition: vsrc_testsrc.c:58
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:508
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:464
size
int size
Definition: twinvq_data.h:10344
color
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
Definition: log.c:94
COMMON_OPTIONS
#define COMMON_OPTIONS
Definition: vsrc_testsrc.c:115
av_make_q
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition: rational.h:71
AV_PIX_FMT_BGR555
#define AV_PIX_FMT_BGR555
Definition: pixfmt.h:471
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:231
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:485
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:461
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:887
height
#define height
TestSourceContext::level
int level
Definition: vsrc_testsrc.c:88
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
TestSourceContext::nb_decimals
int nb_decimals
Definition: vsrc_testsrc.c:69
TestSourceContext::lut
uint8_t * lut
Definition: vsrc_testsrc.c:96
draw_bar
static void draw_bar(ShowCWTContext *s, int y, float Y, float U, float V)
Definition: avf_showcwt.c:389
line
Definition: graph2dot.c:48
AV_PIX_FMT_RGB0
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:263
xga_font_data.h
M_PI
#define M_PI
Definition: mathematics.h:67
TestSourceContext
Definition: vsrc_testsrc.c:53
internal.h
AVFILTER_DEFINE_CLASS
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:323
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:99
TestSourceContext::nb_frame
unsigned int nb_frame
Definition: vsrc_testsrc.c:57
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:172
ff_set_common_color_ranges
int ff_set_common_color_ranges(AVFilterContext *ctx, AVFilterFormats *color_ranges)
Definition: formats.c:845
TestSourceContext::draw_once
int draw_once
draw only the first frame, always put out the same picture
Definition: vsrc_testsrc.c:62
AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:473
TestSourceContext::h
int h
Definition: vsrc_testsrc.c:55
avpriv_vga16_font
const uint8_t avpriv_vga16_font[4096]
Definition: xga_font_data.c:160
lrintf
#define lrintf(x)
Definition: libm_mips.h:72
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
ff_vsrc_nullsrc
const AVFilter ff_vsrc_nullsrc
TestSourceContext::complement
int complement
Definition: vsrc_testsrc.c:84
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:647
ff_vsrc_zoneplate
const AVFilter ff_vsrc_zoneplate
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:495
AVColorSpace
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:609
AV_PIX_FMT_BGR444
#define AV_PIX_FMT_BGR444
Definition: pixfmt.h:472
common.h
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:827
AV_PIX_FMT_RGB555
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:466
ff_draw_round_to_sub
int ff_draw_round_to_sub(FFDrawContext *draw, int sub_dir, int round_dir, int value)
Round a dimension according to subsampling.
Definition: drawutils.c:635
TestSourceContext::ky
int ky
Definition: vsrc_testsrc.c:91
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
ff_vsrc_smptebars
const AVFilter ff_vsrc_smptebars
FFDrawContext
Definition: drawutils.h:35
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AV_PIX_FMT_BGR565
#define AV_PIX_FMT_BGR565
Definition: pixfmt.h:470
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
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
AV_FRAME_FLAG_INTERLACED
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
Definition: frame.h:633
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:669
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:264
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:477
OFFSET
#define OFFSET(x)
Definition: vsrc_testsrc.c:100
AV_PIX_FMT_RGB565
#define AV_PIX_FMT_RGB565
Definition: pixfmt.h:465
ff_draw_color
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
Definition: drawutils.c:156
AVFilter
Filter definition.
Definition: avfilter.h:166
ret
ret
Definition: filter_design.txt:187
AV_PIX_FMT_0BGR
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:264
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
TestSourceContext::kU
int kU
Definition: vsrc_testsrc.c:94
ff_set_common_color_spaces
int ff_set_common_color_spaces(AVFilterContext *ctx, AVFilterFormats *color_spaces)
Definition: formats.c:827
pos
unsigned int pos
Definition: spdifenc.c:414
U
#define U(x)
Definition: vpx_arith.h:37
outputs
static const AVFilterPad outputs[]
Definition: vsrc_testsrc.c:161
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
steps
static const int16_t steps[16]
Definition: misc4.c:30
ff_vsrc_rgbtestsrc
const AVFilter ff_vsrc_rgbtestsrc
TestSourceContext::to
int to
Definition: vsrc_testsrc.c:94
TestSourceContext::alpha
int alpha
Definition: vsrc_testsrc.c:72
activate
static int activate(AVFilterContext *ctx)
Definition: vsrc_testsrc.c:169
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
TestSourceContext::yo
int yo
Definition: vsrc_testsrc.c:94
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
avfilter.h
TestSourceContext::ky2
int ky2
Definition: vsrc_testsrc.c:93
AVFILTER_DEFINE_CLASS_EXT
AVFILTER_DEFINE_CLASS_EXT(nullsrc_yuvtestsrc, "nullsrc/yuvtestsrc", options)
AV_PIX_FMT_FLAG_PLANAR
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition: pixdesc.h:132
ffmath.h
planes
static const struct @400 planes[]
G
#define G
Definition: huffyuv.h:43
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
factor
static const int factor[16]
Definition: vf_pp7.c:79
TestSourceContext::pts
int64_t pts
Definition: vsrc_testsrc.c:59
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:72
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
desc
const char * desc
Definition: libsvtav1.c:75
TestSourceContext::fill_slice_fn
int(* fill_slice_fn)(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
Definition: vsrc_testsrc.c:97
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
mem.h
ff_vsrc_testsrc
const AVFilter ff_vsrc_testsrc
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
TestSourceContext::kx
int kx
Definition: vsrc_testsrc.c:91
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:291
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
ff_fill_rgba_map
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:35
TestSourceContext::draw_once_reset
int draw_once_reset
draw only the first frame or in case of reset
Definition: vsrc_testsrc.c:63
TestSourceContext::kx2
int kx2
Definition: vsrc_testsrc.c:93
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:419
AV_PIX_FMT_0RGB
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:262
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
TestSourceContext::w
int w
Definition: vsrc_testsrc.c:55
h
h
Definition: vp9dsp_template.c:2038
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
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:488
av_image_check_size
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
Definition: imgutils.c:318
TestSourceContext::draw
FFDrawContext draw
Definition: vsrc_testsrc.c:78
drawutils.h
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:134
AV_RB24
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
Definition: bytestream.h:97
AVCOL_SPC_BT709
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition: pixfmt.h:611
int
int
Definition: ffmpeg_filter.c:424
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
snprintf
#define snprintf
Definition: snprintf.h:34
TestSourceContext::fill_picture_fn
void(* fill_picture_fn)(AVFilterContext *ctx, AVFrame *frame)
Definition: vsrc_testsrc.c:66
AVPixFmtDescriptor::log2_chroma_h
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
line
The official guide to swscale for confused that consecutive non overlapping rectangles of slice_bottom special converter These generally are unscaled converters of common like for each output line the vertical scaler pulls lines from a ring buffer When the ring buffer does not contain the wanted line
Definition: swscale.txt:40
TestSourceContext::pw
int pw
Definition: vsrc_testsrc.c:56
TestSourceContext::depth
int depth
Definition: vsrc_testsrc.c:85
COMMON_OPTIONS_NOSIZE
#define COMMON_OPTIONS_NOSIZE
Definition: vsrc_testsrc.c:108
options
static const AVOption options[]
Definition: vsrc_testsrc.c:120
AV_PIX_FMT_RGB444
#define AV_PIX_FMT_RGB444
Definition: pixfmt.h:467