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