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