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