FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 <float.h>
37 
38 #include "libavutil/avassert.h"
39 #include "libavutil/common.h"
40 #include "libavutil/ffmath.h"
41 #include "libavutil/opt.h"
42 #include "libavutil/imgutils.h"
43 #include "libavutil/intreadwrite.h"
44 #include "libavutil/parseutils.h"
46 #include "avfilter.h"
47 #include "drawutils.h"
48 #include "formats.h"
49 #include "internal.h"
50 #include "video.h"
51 
52 typedef struct TestSourceContext {
53  const AVClass *class;
54  int w, h;
55  unsigned int nb_frame;
57  int64_t pts;
58  int64_t duration; ///< duration expressed in microseconds
59  AVRational sar; ///< sample aspect ratio
60  int draw_once; ///< draw only the first frame, always put out the same picture
61  int draw_once_reset; ///< draw only the first frame or in case of reset
62  AVFrame *picref; ///< cached reference containing the painted picture
63 
65 
66  /* only used by testsrc */
68 
69  /* only used by color */
73 
74  /* only used by rgbtest */
76 
77  /* only used by haldclut */
78  int level;
80 
81 #define OFFSET(x) offsetof(TestSourceContext, x)
82 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
83 
84 #define SIZE_OPTIONS \
85  { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\
86  { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\
87 
88 #define COMMON_OPTIONS_NOSIZE \
89  { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS },\
90  { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS },\
91  { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },\
92  { "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },\
93  { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX, FLAGS },
94 
95 #define COMMON_OPTIONS SIZE_OPTIONS COMMON_OPTIONS_NOSIZE
96 
97 static const AVOption options[] = {
99  { NULL }
100 };
101 
103 {
104  TestSourceContext *test = ctx->priv;
105 
106  test->time_base = av_inv_q(test->frame_rate);
107  test->nb_frame = 0;
108  test->pts = 0;
109 
110  av_log(ctx, AV_LOG_VERBOSE, "size:%dx%d rate:%d/%d duration:%f sar:%d/%d\n",
111  test->w, test->h, test->frame_rate.num, test->frame_rate.den,
112  test->duration < 0 ? -1 : (double)test->duration/1000000,
113  test->sar.num, test->sar.den);
114  return 0;
115 }
116 
118 {
119  TestSourceContext *test = ctx->priv;
120 
121  av_frame_free(&test->picref);
122 }
123 
124 static int config_props(AVFilterLink *outlink)
125 {
126  TestSourceContext *test = outlink->src->priv;
127 
128  outlink->w = test->w;
129  outlink->h = test->h;
130  outlink->sample_aspect_ratio = test->sar;
131  outlink->frame_rate = test->frame_rate;
132  outlink->time_base = test->time_base;
133 
134  return 0;
135 }
136 
137 static int request_frame(AVFilterLink *outlink)
138 {
139  TestSourceContext *test = outlink->src->priv;
140  AVFrame *frame;
141 
142  if (test->duration >= 0 &&
143  av_rescale_q(test->pts, test->time_base, AV_TIME_BASE_Q) >= test->duration)
144  return AVERROR_EOF;
145 
146  if (test->draw_once) {
147  if (test->draw_once_reset) {
148  av_frame_free(&test->picref);
149  test->draw_once_reset = 0;
150  }
151  if (!test->picref) {
152  test->picref =
153  ff_get_video_buffer(outlink, test->w, test->h);
154  if (!test->picref)
155  return AVERROR(ENOMEM);
156  test->fill_picture_fn(outlink->src, test->picref);
157  }
158  frame = av_frame_clone(test->picref);
159  } else
160  frame = ff_get_video_buffer(outlink, test->w, test->h);
161 
162  if (!frame)
163  return AVERROR(ENOMEM);
164  frame->pts = test->pts;
165  frame->key_frame = 1;
166  frame->interlaced_frame = 0;
167  frame->pict_type = AV_PICTURE_TYPE_I;
168  frame->sample_aspect_ratio = test->sar;
169  if (!test->draw_once)
170  test->fill_picture_fn(outlink->src, frame);
171 
172  test->pts++;
173  test->nb_frame++;
174 
175  return ff_filter_frame(outlink, frame);
176 }
177 
178 #if CONFIG_COLOR_FILTER
179 
180 static const AVOption color_options[] = {
181  { "color", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
182  { "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
184  { NULL }
185 };
186 
188 
189 static void color_fill_picture(AVFilterContext *ctx, AVFrame *picref)
190 {
191  TestSourceContext *test = ctx->priv;
192  ff_fill_rectangle(&test->draw, &test->color,
193  picref->data, picref->linesize,
194  0, 0, test->w, test->h);
195 }
196 
197 static av_cold int color_init(AVFilterContext *ctx)
198 {
199  TestSourceContext *test = ctx->priv;
200  test->fill_picture_fn = color_fill_picture;
201  test->draw_once = 1;
202  return init(ctx);
203 }
204 
205 static int color_query_formats(AVFilterContext *ctx)
206 {
208 }
209 
210 static int color_config_props(AVFilterLink *inlink)
211 {
212  AVFilterContext *ctx = inlink->src;
213  TestSourceContext *test = ctx->priv;
214  int ret;
215 
216  ff_draw_init(&test->draw, inlink->format, 0);
217  ff_draw_color(&test->draw, &test->color, test->color_rgba);
218 
219  test->w = ff_draw_round_to_sub(&test->draw, 0, -1, test->w);
220  test->h = ff_draw_round_to_sub(&test->draw, 1, -1, test->h);
221  if (av_image_check_size(test->w, test->h, 0, ctx) < 0)
222  return AVERROR(EINVAL);
223 
224  if ((ret = config_props(inlink)) < 0)
225  return ret;
226 
227  return 0;
228 }
229 
230 static int color_process_command(AVFilterContext *ctx, const char *cmd, const char *args,
231  char *res, int res_len, int flags)
232 {
233  TestSourceContext *test = ctx->priv;
234  int ret;
235 
236  if (!strcmp(cmd, "color") || !strcmp(cmd, "c")) {
237  uint8_t color_rgba[4];
238 
239  ret = av_parse_color(color_rgba, args, -1, ctx);
240  if (ret < 0)
241  return ret;
242 
243  memcpy(test->color_rgba, color_rgba, sizeof(color_rgba));
244  ff_draw_color(&test->draw, &test->color, test->color_rgba);
245  test->draw_once_reset = 1;
246  return 0;
247  }
248 
249  return AVERROR(ENOSYS);
250 }
251 
252 static const AVFilterPad color_outputs[] = {
253  {
254  .name = "default",
255  .type = AVMEDIA_TYPE_VIDEO,
256  .request_frame = request_frame,
257  .config_props = color_config_props,
258  },
259  { NULL }
260 };
261 
262 AVFilter ff_vsrc_color = {
263  .name = "color",
264  .description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."),
265  .priv_class = &color_class,
266  .priv_size = sizeof(TestSourceContext),
267  .init = color_init,
268  .uninit = uninit,
269  .query_formats = color_query_formats,
270  .inputs = NULL,
271  .outputs = color_outputs,
272  .process_command = color_process_command,
273 };
274 
275 #endif /* CONFIG_COLOR_FILTER */
276 
277 #if CONFIG_HALDCLUTSRC_FILTER
278 
279 static const AVOption haldclutsrc_options[] = {
280  { "level", "set level", OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 6}, 2, 8, FLAGS },
282  { NULL }
283 };
284 
285 AVFILTER_DEFINE_CLASS(haldclutsrc);
286 
287 static void haldclutsrc_fill_picture(AVFilterContext *ctx, AVFrame *frame)
288 {
289  int i, j, k, x = 0, y = 0, is16bit = 0, step;
290  uint32_t alpha = 0;
291  const TestSourceContext *hc = ctx->priv;
292  int level = hc->level;
293  float scale;
294  const int w = frame->width;
295  const int h = frame->height;
296  const uint8_t *data = frame->data[0];
297  const int linesize = frame->linesize[0];
299  uint8_t rgba_map[4];
300 
301  av_assert0(w == h && w == level*level*level);
302 
303  ff_fill_rgba_map(rgba_map, frame->format);
304 
305  switch (frame->format) {
306  case AV_PIX_FMT_RGB48:
307  case AV_PIX_FMT_BGR48:
308  case AV_PIX_FMT_RGBA64:
309  case AV_PIX_FMT_BGRA64:
310  is16bit = 1;
311  alpha = 0xffff;
312  break;
313  case AV_PIX_FMT_RGBA:
314  case AV_PIX_FMT_BGRA:
315  case AV_PIX_FMT_ARGB:
316  case AV_PIX_FMT_ABGR:
317  alpha = 0xff;
318  break;
319  }
320 
321  step = av_get_padded_bits_per_pixel(desc) >> (3 + is16bit);
322  scale = ((float)(1 << (8*(is16bit+1))) - 1) / (level*level - 1);
323 
324 #define LOAD_CLUT(nbits) do { \
325  uint##nbits##_t *dst = ((uint##nbits##_t *)(data + y*linesize)) + x*step; \
326  dst[rgba_map[0]] = av_clip_uint##nbits(i * scale); \
327  dst[rgba_map[1]] = av_clip_uint##nbits(j * scale); \
328  dst[rgba_map[2]] = av_clip_uint##nbits(k * scale); \
329  if (step == 4) \
330  dst[rgba_map[3]] = alpha; \
331 } while (0)
332 
333  level *= level;
334  for (k = 0; k < level; k++) {
335  for (j = 0; j < level; j++) {
336  for (i = 0; i < level; i++) {
337  if (!is16bit)
338  LOAD_CLUT(8);
339  else
340  LOAD_CLUT(16);
341  if (++x == w) {
342  x = 0;
343  y++;
344  }
345  }
346  }
347  }
348 }
349 
350 static av_cold int haldclutsrc_init(AVFilterContext *ctx)
351 {
352  TestSourceContext *hc = ctx->priv;
353  hc->fill_picture_fn = haldclutsrc_fill_picture;
354  hc->draw_once = 1;
355  return init(ctx);
356 }
357 
358 static int haldclutsrc_query_formats(AVFilterContext *ctx)
359 {
360  static const enum AVPixelFormat pix_fmts[] = {
369  };
370 
371  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
372  if (!fmts_list)
373  return AVERROR(ENOMEM);
374  return ff_set_common_formats(ctx, fmts_list);
375 }
376 
377 static int haldclutsrc_config_props(AVFilterLink *outlink)
378 {
379  AVFilterContext *ctx = outlink->src;
380  TestSourceContext *hc = ctx->priv;
381 
382  hc->w = hc->h = hc->level * hc->level * hc->level;
383  return config_props(outlink);
384 }
385 
386 static const AVFilterPad haldclutsrc_outputs[] = {
387  {
388  .name = "default",
389  .type = AVMEDIA_TYPE_VIDEO,
390  .request_frame = request_frame,
391  .config_props = haldclutsrc_config_props,
392  },
393  { NULL }
394 };
395 
396 AVFilter ff_vsrc_haldclutsrc = {
397  .name = "haldclutsrc",
398  .description = NULL_IF_CONFIG_SMALL("Provide an identity Hald CLUT."),
399  .priv_class = &haldclutsrc_class,
400  .priv_size = sizeof(TestSourceContext),
401  .init = haldclutsrc_init,
402  .uninit = uninit,
403  .query_formats = haldclutsrc_query_formats,
404  .inputs = NULL,
405  .outputs = haldclutsrc_outputs,
406 };
407 #endif /* CONFIG_HALDCLUTSRC_FILTER */
408 
409 #if CONFIG_NULLSRC_FILTER
410 
411 #define nullsrc_options options
412 AVFILTER_DEFINE_CLASS(nullsrc);
413 
414 static void nullsrc_fill_picture(AVFilterContext *ctx, AVFrame *picref) { }
415 
416 static av_cold int nullsrc_init(AVFilterContext *ctx)
417 {
418  TestSourceContext *test = ctx->priv;
419 
420  test->fill_picture_fn = nullsrc_fill_picture;
421  return init(ctx);
422 }
423 
424 static const AVFilterPad nullsrc_outputs[] = {
425  {
426  .name = "default",
427  .type = AVMEDIA_TYPE_VIDEO,
428  .request_frame = request_frame,
429  .config_props = config_props,
430  },
431  { NULL },
432 };
433 
434 AVFilter ff_vsrc_nullsrc = {
435  .name = "nullsrc",
436  .description = NULL_IF_CONFIG_SMALL("Null video source, return unprocessed video frames."),
437  .init = nullsrc_init,
438  .uninit = uninit,
439  .priv_size = sizeof(TestSourceContext),
440  .priv_class = &nullsrc_class,
441  .inputs = NULL,
442  .outputs = nullsrc_outputs,
443 };
444 
445 #endif /* CONFIG_NULLSRC_FILTER */
446 
447 #if CONFIG_TESTSRC_FILTER
448 
449 static const AVOption testsrc_options[] = {
451  { "decimals", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS },
452  { "n", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS },
453  { NULL }
454 };
455 
456 AVFILTER_DEFINE_CLASS(testsrc);
457 
458 /**
459  * Fill a rectangle with value val.
460  *
461  * @param val the RGB value to set
462  * @param dst pointer to the destination buffer to fill
463  * @param dst_linesize linesize of destination
464  * @param segment_width width of the segment
465  * @param x horizontal coordinate where to draw the rectangle in the destination buffer
466  * @param y horizontal coordinate where to draw the rectangle in the destination buffer
467  * @param w width of the rectangle to draw, expressed as a number of segment_width units
468  * @param h height of the rectangle to draw, expressed as a number of segment_width units
469  */
470 static void draw_rectangle(unsigned val, uint8_t *dst, int dst_linesize, int segment_width,
471  int x, int y, int w, int h)
472 {
473  int i;
474  int step = 3;
475 
476  dst += segment_width * (step * x + y * dst_linesize);
477  w *= segment_width * step;
478  h *= segment_width;
479  for (i = 0; i < h; i++) {
480  memset(dst, val, w);
481  dst += dst_linesize;
482  }
483 }
484 
485 static void draw_digit(int digit, uint8_t *dst, int dst_linesize,
486  int segment_width)
487 {
488 #define TOP_HBAR 1
489 #define MID_HBAR 2
490 #define BOT_HBAR 4
491 #define LEFT_TOP_VBAR 8
492 #define LEFT_BOT_VBAR 16
493 #define RIGHT_TOP_VBAR 32
494 #define RIGHT_BOT_VBAR 64
495  struct segments {
496  int x, y, w, h;
497  } segments[] = {
498  { 1, 0, 5, 1 }, /* TOP_HBAR */
499  { 1, 6, 5, 1 }, /* MID_HBAR */
500  { 1, 12, 5, 1 }, /* BOT_HBAR */
501  { 0, 1, 1, 5 }, /* LEFT_TOP_VBAR */
502  { 0, 7, 1, 5 }, /* LEFT_BOT_VBAR */
503  { 6, 1, 1, 5 }, /* RIGHT_TOP_VBAR */
504  { 6, 7, 1, 5 } /* RIGHT_BOT_VBAR */
505  };
506  static const unsigned char masks[10] = {
507  /* 0 */ TOP_HBAR |BOT_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
508  /* 1 */ RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
509  /* 2 */ TOP_HBAR|MID_HBAR|BOT_HBAR|LEFT_BOT_VBAR |RIGHT_TOP_VBAR,
510  /* 3 */ TOP_HBAR|MID_HBAR|BOT_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
511  /* 4 */ MID_HBAR |LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
512  /* 5 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_BOT_VBAR,
513  /* 6 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR |RIGHT_BOT_VBAR,
514  /* 7 */ TOP_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
515  /* 8 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
516  /* 9 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
517  };
518  unsigned mask = masks[digit];
519  int i;
520 
521  draw_rectangle(0, dst, dst_linesize, segment_width, 0, 0, 8, 13);
522  for (i = 0; i < FF_ARRAY_ELEMS(segments); i++)
523  if (mask & (1<<i))
524  draw_rectangle(255, dst, dst_linesize, segment_width,
525  segments[i].x, segments[i].y, segments[i].w, segments[i].h);
526 }
527 
528 #define GRADIENT_SIZE (6 * 256)
529 
530 static void test_fill_picture(AVFilterContext *ctx, AVFrame *frame)
531 {
532  TestSourceContext *test = ctx->priv;
533  uint8_t *p, *p0;
534  int x, y;
535  int color, color_rest;
536  int icolor;
537  int radius;
538  int quad0, quad;
539  int dquad_x, dquad_y;
540  int grad, dgrad, rgrad, drgrad;
541  int seg_size;
542  int second;
543  int i;
544  uint8_t *data = frame->data[0];
545  int width = frame->width;
546  int height = frame->height;
547 
548  /* draw colored bars and circle */
549  radius = (width + height) / 4;
550  quad0 = width * width / 4 + height * height / 4 - radius * radius;
551  dquad_y = 1 - height;
552  p0 = data;
553  for (y = 0; y < height; y++) {
554  p = p0;
555  color = 0;
556  color_rest = 0;
557  quad = quad0;
558  dquad_x = 1 - width;
559  for (x = 0; x < width; x++) {
560  icolor = color;
561  if (quad < 0)
562  icolor ^= 7;
563  quad += dquad_x;
564  dquad_x += 2;
565  *(p++) = icolor & 1 ? 255 : 0;
566  *(p++) = icolor & 2 ? 255 : 0;
567  *(p++) = icolor & 4 ? 255 : 0;
568  color_rest += 8;
569  if (color_rest >= width) {
570  color_rest -= width;
571  color++;
572  }
573  }
574  quad0 += dquad_y;
575  dquad_y += 2;
576  p0 += frame->linesize[0];
577  }
578 
579  /* draw sliding color line */
580  p0 = p = data + frame->linesize[0] * (height * 3/4);
581  grad = (256 * test->nb_frame * test->time_base.num / test->time_base.den) %
582  GRADIENT_SIZE;
583  rgrad = 0;
584  dgrad = GRADIENT_SIZE / width;
585  drgrad = GRADIENT_SIZE % width;
586  for (x = 0; x < width; x++) {
587  *(p++) =
588  grad < 256 || grad >= 5 * 256 ? 255 :
589  grad >= 2 * 256 && grad < 4 * 256 ? 0 :
590  grad < 2 * 256 ? 2 * 256 - 1 - grad : grad - 4 * 256;
591  *(p++) =
592  grad >= 4 * 256 ? 0 :
593  grad >= 1 * 256 && grad < 3 * 256 ? 255 :
594  grad < 1 * 256 ? grad : 4 * 256 - 1 - grad;
595  *(p++) =
596  grad < 2 * 256 ? 0 :
597  grad >= 3 * 256 && grad < 5 * 256 ? 255 :
598  grad < 3 * 256 ? grad - 2 * 256 : 6 * 256 - 1 - grad;
599  grad += dgrad;
600  rgrad += drgrad;
601  if (rgrad >= GRADIENT_SIZE) {
602  grad++;
603  rgrad -= GRADIENT_SIZE;
604  }
605  if (grad >= GRADIENT_SIZE)
606  grad -= GRADIENT_SIZE;
607  }
608  p = p0;
609  for (y = height / 8; y > 0; y--) {
610  memcpy(p+frame->linesize[0], p, 3 * width);
611  p += frame->linesize[0];
612  }
613 
614  /* draw digits */
615  seg_size = width / 80;
616  if (seg_size >= 1 && height >= 13 * seg_size) {
617  int64_t p10decimals = 1;
618  double time = av_q2d(test->time_base) * test->nb_frame *
619  ff_exp10(test->nb_decimals);
620  if (time >= INT_MAX)
621  return;
622 
623  for (x = 0; x < test->nb_decimals; x++)
624  p10decimals *= 10;
625 
626  second = av_rescale_rnd(test->nb_frame * test->time_base.num, p10decimals, test->time_base.den, AV_ROUND_ZERO);
627  x = width - (width - seg_size * 64) / 2;
628  y = (height - seg_size * 13) / 2;
629  p = data + (x*3 + y * frame->linesize[0]);
630  for (i = 0; i < 8; i++) {
631  p -= 3 * 8 * seg_size;
632  draw_digit(second % 10, p, frame->linesize[0], seg_size);
633  second /= 10;
634  if (second == 0)
635  break;
636  }
637  }
638 }
639 
640 static av_cold int test_init(AVFilterContext *ctx)
641 {
642  TestSourceContext *test = ctx->priv;
643 
644  test->fill_picture_fn = test_fill_picture;
645  return init(ctx);
646 }
647 
648 static int test_query_formats(AVFilterContext *ctx)
649 {
650  static const enum AVPixelFormat pix_fmts[] = {
652  };
653 
654  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
655  if (!fmts_list)
656  return AVERROR(ENOMEM);
657  return ff_set_common_formats(ctx, fmts_list);
658 }
659 
660 static const AVFilterPad avfilter_vsrc_testsrc_outputs[] = {
661  {
662  .name = "default",
663  .type = AVMEDIA_TYPE_VIDEO,
664  .request_frame = request_frame,
665  .config_props = config_props,
666  },
667  { NULL }
668 };
669 
670 AVFilter ff_vsrc_testsrc = {
671  .name = "testsrc",
672  .description = NULL_IF_CONFIG_SMALL("Generate test pattern."),
673  .priv_size = sizeof(TestSourceContext),
674  .priv_class = &testsrc_class,
675  .init = test_init,
676  .uninit = uninit,
677  .query_formats = test_query_formats,
678  .inputs = NULL,
679  .outputs = avfilter_vsrc_testsrc_outputs,
680 };
681 
682 #endif /* CONFIG_TESTSRC_FILTER */
683 
684 #if CONFIG_TESTSRC2_FILTER
685 
686 static const AVOption testsrc2_options[] = {
688  { NULL }
689 };
690 
691 AVFILTER_DEFINE_CLASS(testsrc2);
692 
693 static void set_color(TestSourceContext *s, FFDrawColor *color, uint32_t argb)
694 {
695  uint8_t rgba[4] = { (argb >> 16) & 0xFF,
696  (argb >> 8) & 0xFF,
697  (argb >> 0) & 0xFF,
698  (argb >> 24) & 0xFF, };
699  ff_draw_color(&s->draw, color, rgba);
700 }
701 
702 static uint32_t color_gradient(unsigned index)
703 {
704  unsigned si = index & 0xFF, sd = 0xFF - si;
705  switch (index >> 8) {
706  case 0: return 0xFF0000 + (si << 8);
707  case 1: return 0x00FF00 + (sd << 16);
708  case 2: return 0x00FF00 + (si << 0);
709  case 3: return 0x0000FF + (sd << 8);
710  case 4: return 0x0000FF + (si << 16);
711  case 5: return 0xFF0000 + (sd << 0);
712  }
713  av_assert0(0);
714 }
715 
716 static void draw_text(TestSourceContext *s, AVFrame *frame, FFDrawColor *color,
717  int x0, int y0, const uint8_t *text)
718 {
719  int x = x0;
720 
721  for (; *text; text++) {
722  if (*text == '\n') {
723  x = x0;
724  y0 += 16;
725  continue;
726  }
727  ff_blend_mask(&s->draw, color, frame->data, frame->linesize,
728  frame->width, frame->height,
729  avpriv_vga16_font + *text * 16, 1, 8, 16, 0, 0, x, y0);
730  x += 8;
731  }
732 }
733 
734 static void test2_fill_picture(AVFilterContext *ctx, AVFrame *frame)
735 {
736  TestSourceContext *s = ctx->priv;
738 
739  /* colored background */
740  {
741  unsigned i, x = 0, x2;
742 
743  x = 0;
744  for (i = 1; i < 7; i++) {
745  x2 = av_rescale(i, s->w, 6);
746  x2 = ff_draw_round_to_sub(&s->draw, 0, 0, x2);
747  set_color(s, &color, ((i & 1) ? 0xFF0000 : 0) |
748  ((i & 2) ? 0x00FF00 : 0) |
749  ((i & 4) ? 0x0000FF : 0));
750  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
751  x, 0, x2 - x, frame->height);
752  x = x2;
753  }
754  }
755 
756  /* oblique gradient */
757  /* note: too slow if using blending */
758  if (s->h >= 64) {
759  unsigned x, dx, y0, y, g0, g;
760 
761  dx = ff_draw_round_to_sub(&s->draw, 0, +1, 1);
762  y0 = av_rescale_q(s->pts, s->time_base, av_make_q(2, s->h - 16));
763  g0 = av_rescale_q(s->pts, s->time_base, av_make_q(1, 128));
764  for (x = 0; x < s->w; x += dx) {
765  g = (av_rescale(x, 6 * 256, s->w) + g0) % (6 * 256);
766  set_color(s, &color, color_gradient(g));
767  y = y0 + av_rescale(x, s->h / 2, s->w);
768  y %= 2 * (s->h - 16);
769  if (y > s->h - 16)
770  y = 2 * (s->h - 16) - y;
771  y = ff_draw_round_to_sub(&s->draw, 1, 0, y);
772  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
773  x, y, dx, 16);
774  }
775  }
776 
777  /* top right: draw clock hands */
778  if (s->w >= 64 && s->h >= 64) {
779  int l = (FFMIN(s->w, s->h) - 32) >> 1;
780  int steps = FFMAX(4, l >> 5);
781  int xc = (s->w >> 2) + (s->w >> 1);
782  int yc = (s->h >> 2);
783  int cycle = l << 2;
784  int pos, xh, yh;
785  int c, i;
786 
787  for (c = 0; c < 3; c++) {
788  set_color(s, &color, 0xBBBBBB ^ (0xFF << (c << 3)));
789  pos = av_rescale_q(s->pts, s->time_base, av_make_q(64 >> (c << 1), cycle)) % cycle;
790  xh = pos < 1 * l ? pos :
791  pos < 2 * l ? l :
792  pos < 3 * l ? 3 * l - pos : 0;
793  yh = pos < 1 * l ? 0 :
794  pos < 2 * l ? pos - l :
795  pos < 3 * l ? l :
796  cycle - pos;
797  xh -= l >> 1;
798  yh -= l >> 1;
799  for (i = 1; i <= steps; i++) {
800  int x = av_rescale(xh, i, steps) + xc;
801  int y = av_rescale(yh, i, steps) + yc;
802  x = ff_draw_round_to_sub(&s->draw, 0, -1, x);
803  y = ff_draw_round_to_sub(&s->draw, 1, -1, y);
804  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
805  x, y, 8, 8);
806  }
807  }
808  }
809 
810  /* bottom left: beating rectangles */
811  if (s->w >= 64 && s->h >= 64) {
812  int l = (FFMIN(s->w, s->h) - 16) >> 2;
813  int cycle = l << 3;
814  int xc = (s->w >> 2);
815  int yc = (s->h >> 2) + (s->h >> 1);
816  int xm1 = ff_draw_round_to_sub(&s->draw, 0, -1, xc - 8);
817  int xm2 = ff_draw_round_to_sub(&s->draw, 0, +1, xc + 8);
818  int ym1 = ff_draw_round_to_sub(&s->draw, 1, -1, yc - 8);
819  int ym2 = ff_draw_round_to_sub(&s->draw, 1, +1, yc + 8);
820  int size, step, x1, x2, y1, y2;
821 
822  size = av_rescale_q(s->pts, s->time_base, av_make_q(4, cycle));
823  step = size / l;
824  size %= l;
825  if (step & 1)
826  size = l - size;
827  step = (step >> 1) & 3;
828  set_color(s, &color, 0xFF808080);
829  x1 = ff_draw_round_to_sub(&s->draw, 0, -1, xc - 4 - size);
830  x2 = ff_draw_round_to_sub(&s->draw, 0, +1, xc + 4 + size);
831  y1 = ff_draw_round_to_sub(&s->draw, 1, -1, yc - 4 - size);
832  y2 = ff_draw_round_to_sub(&s->draw, 1, +1, yc + 4 + size);
833  if (step == 0 || step == 2)
834  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
835  x1, ym1, x2 - x1, ym2 - ym1);
836  if (step == 1 || step == 2)
837  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
838  xm1, y1, xm2 - xm1, y2 - y1);
839  if (step == 3)
840  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
841  x1, y1, x2 - x1, y2 - y1);
842  }
843 
844  /* bottom right: checker with random noise */
845  {
846  unsigned xmin = av_rescale(5, s->w, 8);
847  unsigned xmax = av_rescale(7, s->w, 8);
848  unsigned ymin = av_rescale(5, s->h, 8);
849  unsigned ymax = av_rescale(7, s->h, 8);
850  unsigned x, y, i, r;
851  uint8_t alpha[256];
852 
853  r = s->pts;
854  for (y = ymin; y < ymax - 15; y += 16) {
855  for (x = xmin; x < xmax - 15; x += 16) {
856  if ((x ^ y) & 16)
857  continue;
858  for (i = 0; i < 256; i++) {
859  r = r * 1664525 + 1013904223;
860  alpha[i] = r >> 24;
861  }
862  set_color(s, &color, 0xFF00FF80);
863  ff_blend_mask(&s->draw, &color, frame->data, frame->linesize,
864  frame->width, frame->height,
865  alpha, 16, 16, 16, 3, 0, x, y);
866  }
867  }
868  }
869 
870  /* bouncing square */
871  if (s->w >= 16 && s->h >= 16) {
872  unsigned w = s->w - 8;
873  unsigned h = s->h - 8;
874  unsigned x = av_rescale_q(s->pts, s->time_base, av_make_q(233, 55 * w)) % (w << 1);
875  unsigned y = av_rescale_q(s->pts, s->time_base, av_make_q(233, 89 * h)) % (h << 1);
876  if (x > w)
877  x = (w << 1) - x;
878  if (y > h)
879  y = (h << 1) - y;
880  x = ff_draw_round_to_sub(&s->draw, 0, -1, x);
881  y = ff_draw_round_to_sub(&s->draw, 1, -1, y);
882  set_color(s, &color, 0xFF8000FF);
883  ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
884  x, y, 8, 8);
885  }
886 
887  /* top right: draw frame time and frame number */
888  {
889  char buf[256];
890  unsigned time;
891 
892  time = av_rescale_q(s->pts, s->time_base, av_make_q(1, 1000)) % 86400000;
893  set_color(s, &color, 0xC0000000);
894  ff_blend_rectangle(&s->draw, &color, frame->data, frame->linesize,
895  frame->width, frame->height,
896  2, 2, 100, 36);
897  set_color(s, &color, 0xFFFF8000);
898  snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%03d\n%12"PRIi64,
899  time / 3600000, (time / 60000) % 60, (time / 1000) % 60,
900  time % 1000, s->pts);
901  draw_text(s, frame, &color, 4, 4, buf);
902  }
903 }
904 static av_cold int test2_init(AVFilterContext *ctx)
905 {
906  TestSourceContext *s = ctx->priv;
907 
908  s->fill_picture_fn = test2_fill_picture;
909  return init(ctx);
910 }
911 
912 static int test2_query_formats(AVFilterContext *ctx)
913 {
915 }
916 
917 static int test2_config_props(AVFilterLink *inlink)
918 {
919  AVFilterContext *ctx = inlink->src;
920  TestSourceContext *s = ctx->priv;
921 
922  av_assert0(ff_draw_init(&s->draw, inlink->format, 0) >= 0);
923  s->w = ff_draw_round_to_sub(&s->draw, 0, -1, s->w);
924  s->h = ff_draw_round_to_sub(&s->draw, 1, -1, s->h);
925  if (av_image_check_size(s->w, s->h, 0, ctx) < 0)
926  return AVERROR(EINVAL);
927  return config_props(inlink);
928 }
929 
930 static const AVFilterPad avfilter_vsrc_testsrc2_outputs[] = {
931  {
932  .name = "default",
933  .type = AVMEDIA_TYPE_VIDEO,
934  .request_frame = request_frame,
935  .config_props = test2_config_props,
936  },
937  { NULL }
938 };
939 
940 AVFilter ff_vsrc_testsrc2 = {
941  .name = "testsrc2",
942  .description = NULL_IF_CONFIG_SMALL("Generate another test pattern."),
943  .priv_size = sizeof(TestSourceContext),
944  .priv_class = &testsrc2_class,
945  .init = test2_init,
946  .uninit = uninit,
947  .query_formats = test2_query_formats,
948  .inputs = NULL,
949  .outputs = avfilter_vsrc_testsrc2_outputs,
950 };
951 
952 #endif /* CONFIG_TESTSRC2_FILTER */
953 
954 #if CONFIG_RGBTESTSRC_FILTER
955 
956 #define rgbtestsrc_options options
957 AVFILTER_DEFINE_CLASS(rgbtestsrc);
958 
959 #define R 0
960 #define G 1
961 #define B 2
962 #define A 3
963 
964 static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize,
965  int x, int y, int r, int g, int b, enum AVPixelFormat fmt,
966  uint8_t rgba_map[4])
967 {
968  int32_t v;
969  uint8_t *p;
970 
971  switch (fmt) {
972  case AV_PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4); break;
973  case AV_PIX_FMT_RGB444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b >> 4) << 8) | ((g >> 4) << 4) | (r >> 4); break;
974  case AV_PIX_FMT_BGR555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<10) | ((g>>3)<<5) | (b>>3); break;
975  case AV_PIX_FMT_RGB555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<10) | ((g>>3)<<5) | (r>>3); break;
976  case AV_PIX_FMT_BGR565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<11) | ((g>>2)<<5) | (b>>3); break;
977  case AV_PIX_FMT_RGB565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<11) | ((g>>2)<<5) | (r>>3); break;
978  case AV_PIX_FMT_RGB24:
979  case AV_PIX_FMT_BGR24:
980  v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8));
981  p = dst + 3*x + y*dst_linesize;
982  AV_WL24(p, v);
983  break;
984  case AV_PIX_FMT_RGBA:
985  case AV_PIX_FMT_BGRA:
986  case AV_PIX_FMT_ARGB:
987  case AV_PIX_FMT_ABGR:
988  v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)) + (255 << (rgba_map[A]*8));
989  p = dst + 4*x + y*dst_linesize;
990  AV_WL32(p, v);
991  break;
992  }
993 }
994 
995 static void rgbtest_fill_picture(AVFilterContext *ctx, AVFrame *frame)
996 {
997  TestSourceContext *test = ctx->priv;
998  int x, y, w = frame->width, h = frame->height;
999 
1000  for (y = 0; y < h; y++) {
1001  for (x = 0; x < w; x++) {
1002  int c = 256*x/w;
1003  int r = 0, g = 0, b = 0;
1004 
1005  if (3*y < h ) r = c;
1006  else if (3*y < 2*h) g = c;
1007  else b = c;
1008 
1009  rgbtest_put_pixel(frame->data[0], frame->linesize[0], x, y, r, g, b,
1010  ctx->outputs[0]->format, test->rgba_map);
1011  }
1012  }
1013 }
1014 
1015 static av_cold int rgbtest_init(AVFilterContext *ctx)
1016 {
1017  TestSourceContext *test = ctx->priv;
1018 
1019  test->draw_once = 1;
1020  test->fill_picture_fn = rgbtest_fill_picture;
1021  return init(ctx);
1022 }
1023 
1024 static int rgbtest_query_formats(AVFilterContext *ctx)
1025 {
1026  static const enum AVPixelFormat pix_fmts[] = {
1033  };
1034 
1035  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
1036  if (!fmts_list)
1037  return AVERROR(ENOMEM);
1038  return ff_set_common_formats(ctx, fmts_list);
1039 }
1040 
1041 static int rgbtest_config_props(AVFilterLink *outlink)
1042 {
1043  TestSourceContext *test = outlink->src->priv;
1044 
1045  ff_fill_rgba_map(test->rgba_map, outlink->format);
1046  return config_props(outlink);
1047 }
1048 
1049 static const AVFilterPad avfilter_vsrc_rgbtestsrc_outputs[] = {
1050  {
1051  .name = "default",
1052  .type = AVMEDIA_TYPE_VIDEO,
1053  .request_frame = request_frame,
1054  .config_props = rgbtest_config_props,
1055  },
1056  { NULL }
1057 };
1058 
1059 AVFilter ff_vsrc_rgbtestsrc = {
1060  .name = "rgbtestsrc",
1061  .description = NULL_IF_CONFIG_SMALL("Generate RGB test pattern."),
1062  .priv_size = sizeof(TestSourceContext),
1063  .priv_class = &rgbtestsrc_class,
1064  .init = rgbtest_init,
1065  .uninit = uninit,
1066  .query_formats = rgbtest_query_formats,
1067  .inputs = NULL,
1068  .outputs = avfilter_vsrc_rgbtestsrc_outputs,
1069 };
1070 
1071 #endif /* CONFIG_RGBTESTSRC_FILTER */
1072 
1073 #if CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER
1074 
1075 static const uint8_t rainbow[7][4] = {
1076  { 180, 128, 128, 255 }, /* 75% white */
1077  { 162, 44, 142, 255 }, /* 75% yellow */
1078  { 131, 156, 44, 255 }, /* 75% cyan */
1079  { 112, 72, 58, 255 }, /* 75% green */
1080  { 84, 184, 198, 255 }, /* 75% magenta */
1081  { 65, 100, 212, 255 }, /* 75% red */
1082  { 35, 212, 114, 255 }, /* 75% blue */
1083 };
1084 
1085 static const uint8_t rainbowhd[7][4] = {
1086  { 180, 128, 128, 255 }, /* 75% white */
1087  { 168, 44, 136, 255 }, /* 75% yellow */
1088  { 145, 147, 44, 255 }, /* 75% cyan */
1089  { 133, 63, 52, 255 }, /* 75% green */
1090  { 63, 193, 204, 255 }, /* 75% magenta */
1091  { 51, 109, 212, 255 }, /* 75% red */
1092  { 28, 212, 120, 255 }, /* 75% blue */
1093 };
1094 
1095 static const uint8_t wobnair[7][4] = {
1096  { 35, 212, 114, 255 }, /* 75% blue */
1097  { 19, 128, 128, 255 }, /* 7.5% intensity black */
1098  { 84, 184, 198, 255 }, /* 75% magenta */
1099  { 19, 128, 128, 255 }, /* 7.5% intensity black */
1100  { 131, 156, 44, 255 }, /* 75% cyan */
1101  { 19, 128, 128, 255 }, /* 7.5% intensity black */
1102  { 180, 128, 128, 255 }, /* 75% white */
1103 };
1104 
1105 static const uint8_t white[4] = { 235, 128, 128, 255 };
1106 
1107 /* pluge pulses */
1108 static const uint8_t neg4ire[4] = { 7, 128, 128, 255 };
1109 static const uint8_t pos4ire[4] = { 24, 128, 128, 255 };
1110 
1111 /* fudged Q/-I */
1112 static const uint8_t i_pixel[4] = { 57, 156, 97, 255 };
1113 static const uint8_t q_pixel[4] = { 44, 171, 147, 255 };
1114 
1115 static const uint8_t gray40[4] = { 104, 128, 128, 255 };
1116 static const uint8_t gray15[4] = { 49, 128, 128, 255 };
1117 static const uint8_t cyan[4] = { 188, 154, 16, 255 };
1118 static const uint8_t yellow[4] = { 219, 16, 138, 255 };
1119 static const uint8_t blue[4] = { 32, 240, 118, 255 };
1120 static const uint8_t red[4] = { 63, 102, 240, 255 };
1121 static const uint8_t black0[4] = { 16, 128, 128, 255 };
1122 static const uint8_t black2[4] = { 20, 128, 128, 255 };
1123 static const uint8_t black4[4] = { 25, 128, 128, 255 };
1124 static const uint8_t neg2[4] = { 12, 128, 128, 255 };
1125 
1126 static void draw_bar(TestSourceContext *test, const uint8_t color[4],
1127  int x, int y, int w, int h,
1128  AVFrame *frame)
1129 {
1130  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
1131  uint8_t *p, *p0;
1132  int plane;
1133 
1134  x = FFMIN(x, test->w - 1);
1135  y = FFMIN(y, test->h - 1);
1136  w = FFMIN(w, test->w - x);
1137  h = FFMIN(h, test->h - y);
1138 
1139  av_assert0(x + w <= test->w);
1140  av_assert0(y + h <= test->h);
1141 
1142  for (plane = 0; frame->data[plane]; plane++) {
1143  const int c = color[plane];
1144  const int linesize = frame->linesize[plane];
1145  int i, px, py, pw, ph;
1146 
1147  if (plane == 1 || plane == 2) {
1148  px = x >> desc->log2_chroma_w;
1149  pw = AV_CEIL_RSHIFT(w, desc->log2_chroma_w);
1150  py = y >> desc->log2_chroma_h;
1151  ph = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
1152  } else {
1153  px = x;
1154  pw = w;
1155  py = y;
1156  ph = h;
1157  }
1158 
1159  p0 = p = frame->data[plane] + py * linesize + px;
1160  memset(p, c, pw);
1161  p += linesize;
1162  for (i = 1; i < ph; i++, p += linesize)
1163  memcpy(p, p0, pw);
1164  }
1165 }
1166 
1167 static int smptebars_query_formats(AVFilterContext *ctx)
1168 {
1169  static const enum AVPixelFormat pix_fmts[] = {
1174  };
1175 
1176  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
1177  if (!fmts_list)
1178  return AVERROR(ENOMEM);
1179  return ff_set_common_formats(ctx, fmts_list);
1180 }
1181 
1182 static const AVFilterPad smptebars_outputs[] = {
1183  {
1184  .name = "default",
1185  .type = AVMEDIA_TYPE_VIDEO,
1186  .request_frame = request_frame,
1187  .config_props = config_props,
1188  },
1189  { NULL }
1190 };
1191 
1192 #if CONFIG_SMPTEBARS_FILTER
1193 
1194 #define smptebars_options options
1195 AVFILTER_DEFINE_CLASS(smptebars);
1196 
1197 static void smptebars_fill_picture(AVFilterContext *ctx, AVFrame *picref)
1198 {
1199  TestSourceContext *test = ctx->priv;
1200  int r_w, r_h, w_h, p_w, p_h, i, tmp, x = 0;
1201  const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format);
1202 
1204 
1205  r_w = FFALIGN((test->w + 6) / 7, 1 << pixdesc->log2_chroma_w);
1206  r_h = FFALIGN(test->h * 2 / 3, 1 << pixdesc->log2_chroma_h);
1207  w_h = FFALIGN(test->h * 3 / 4 - r_h, 1 << pixdesc->log2_chroma_h);
1208  p_w = FFALIGN(r_w * 5 / 4, 1 << pixdesc->log2_chroma_w);
1209  p_h = test->h - w_h - r_h;
1210 
1211  for (i = 0; i < 7; i++) {
1212  draw_bar(test, rainbow[i], x, 0, r_w, r_h, picref);
1213  draw_bar(test, wobnair[i], x, r_h, r_w, w_h, picref);
1214  x += r_w;
1215  }
1216  x = 0;
1217  draw_bar(test, i_pixel, x, r_h + w_h, p_w, p_h, picref);
1218  x += p_w;
1219  draw_bar(test, white, x, r_h + w_h, p_w, p_h, picref);
1220  x += p_w;
1221  draw_bar(test, q_pixel, x, r_h + w_h, p_w, p_h, picref);
1222  x += p_w;
1223  tmp = FFALIGN(5 * r_w - x, 1 << pixdesc->log2_chroma_w);
1224  draw_bar(test, black0, x, r_h + w_h, tmp, p_h, picref);
1225  x += tmp;
1226  tmp = FFALIGN(r_w / 3, 1 << pixdesc->log2_chroma_w);
1227  draw_bar(test, neg4ire, x, r_h + w_h, tmp, p_h, picref);
1228  x += tmp;
1229  draw_bar(test, black0, x, r_h + w_h, tmp, p_h, picref);
1230  x += tmp;
1231  draw_bar(test, pos4ire, x, r_h + w_h, tmp, p_h, picref);
1232  x += tmp;
1233  draw_bar(test, black0, x, r_h + w_h, test->w - x, p_h, picref);
1234 }
1235 
1236 static av_cold int smptebars_init(AVFilterContext *ctx)
1237 {
1238  TestSourceContext *test = ctx->priv;
1239 
1240  test->fill_picture_fn = smptebars_fill_picture;
1241  test->draw_once = 1;
1242  return init(ctx);
1243 }
1244 
1245 AVFilter ff_vsrc_smptebars = {
1246  .name = "smptebars",
1247  .description = NULL_IF_CONFIG_SMALL("Generate SMPTE color bars."),
1248  .priv_size = sizeof(TestSourceContext),
1249  .priv_class = &smptebars_class,
1250  .init = smptebars_init,
1251  .uninit = uninit,
1252  .query_formats = smptebars_query_formats,
1253  .inputs = NULL,
1254  .outputs = smptebars_outputs,
1255 };
1256 
1257 #endif /* CONFIG_SMPTEBARS_FILTER */
1258 
1259 #if CONFIG_SMPTEHDBARS_FILTER
1260 
1261 #define smptehdbars_options options
1262 AVFILTER_DEFINE_CLASS(smptehdbars);
1263 
1264 static void smptehdbars_fill_picture(AVFilterContext *ctx, AVFrame *picref)
1265 {
1266  TestSourceContext *test = ctx->priv;
1267  int d_w, r_w, r_h, l_w, i, tmp, x = 0, y = 0;
1268  const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format);
1269 
1271 
1272  d_w = FFALIGN(test->w / 8, 1 << pixdesc->log2_chroma_w);
1273  r_h = FFALIGN(test->h * 7 / 12, 1 << pixdesc->log2_chroma_h);
1274  draw_bar(test, gray40, x, 0, d_w, r_h, picref);
1275  x += d_w;
1276 
1277  r_w = FFALIGN((((test->w + 3) / 4) * 3) / 7, 1 << pixdesc->log2_chroma_w);
1278  for (i = 0; i < 7; i++) {
1279  draw_bar(test, rainbowhd[i], x, 0, r_w, r_h, picref);
1280  x += r_w;
1281  }
1282  draw_bar(test, gray40, x, 0, test->w - x, r_h, picref);
1283  y = r_h;
1284  r_h = FFALIGN(test->h / 12, 1 << pixdesc->log2_chroma_h);
1285  draw_bar(test, cyan, 0, y, d_w, r_h, picref);
1286  x = d_w;
1287  draw_bar(test, i_pixel, x, y, r_w, r_h, picref);
1288  x += r_w;
1289  tmp = r_w * 6;
1290  draw_bar(test, rainbowhd[0], x, y, tmp, r_h, picref);
1291  x += tmp;
1292  l_w = x;
1293  draw_bar(test, blue, x, y, test->w - x, r_h, picref);
1294  y += r_h;
1295  draw_bar(test, yellow, 0, y, d_w, r_h, picref);
1296  x = d_w;
1297  draw_bar(test, q_pixel, x, y, r_w, r_h, picref);
1298  x += r_w;
1299 
1300  for (i = 0; i < tmp; i += 1 << pixdesc->log2_chroma_w) {
1301  uint8_t yramp[4] = {0};
1302 
1303  yramp[0] = i * 255 / tmp;
1304  yramp[1] = 128;
1305  yramp[2] = 128;
1306  yramp[3] = 255;
1307 
1308  draw_bar(test, yramp, x, y, 1 << pixdesc->log2_chroma_w, r_h, picref);
1309  x += 1 << pixdesc->log2_chroma_w;
1310  }
1311  draw_bar(test, red, x, y, test->w - x, r_h, picref);
1312  y += r_h;
1313  draw_bar(test, gray15, 0, y, d_w, test->h - y, picref);
1314  x = d_w;
1315  tmp = FFALIGN(r_w * 3 / 2, 1 << pixdesc->log2_chroma_w);
1316  draw_bar(test, black0, x, y, tmp, test->h - y, picref);
1317  x += tmp;
1318  tmp = FFALIGN(r_w * 2, 1 << pixdesc->log2_chroma_w);
1319  draw_bar(test, white, x, y, tmp, test->h - y, picref);
1320  x += tmp;
1321  tmp = FFALIGN(r_w * 5 / 6, 1 << pixdesc->log2_chroma_w);
1322  draw_bar(test, black0, x, y, tmp, test->h - y, picref);
1323  x += tmp;
1324  tmp = FFALIGN(r_w / 3, 1 << pixdesc->log2_chroma_w);
1325  draw_bar(test, neg2, x, y, tmp, test->h - y, picref);
1326  x += tmp;
1327  draw_bar(test, black0, x, y, tmp, test->h - y, picref);
1328  x += tmp;
1329  draw_bar(test, black2, x, y, tmp, test->h - y, picref);
1330  x += tmp;
1331  draw_bar(test, black0, x, y, tmp, test->h - y, picref);
1332  x += tmp;
1333  draw_bar(test, black4, x, y, tmp, test->h - y, picref);
1334  x += tmp;
1335  r_w = l_w - x;
1336  draw_bar(test, black0, x, y, r_w, test->h - y, picref);
1337  x += r_w;
1338  draw_bar(test, gray15, x, y, test->w - x, test->h - y, picref);
1339 }
1340 
1341 static av_cold int smptehdbars_init(AVFilterContext *ctx)
1342 {
1343  TestSourceContext *test = ctx->priv;
1344 
1345  test->fill_picture_fn = smptehdbars_fill_picture;
1346  test->draw_once = 1;
1347  return init(ctx);
1348 }
1349 
1350 AVFilter ff_vsrc_smptehdbars = {
1351  .name = "smptehdbars",
1352  .description = NULL_IF_CONFIG_SMALL("Generate SMPTE HD color bars."),
1353  .priv_size = sizeof(TestSourceContext),
1354  .priv_class = &smptehdbars_class,
1355  .init = smptehdbars_init,
1356  .uninit = uninit,
1357  .query_formats = smptebars_query_formats,
1358  .inputs = NULL,
1359  .outputs = smptebars_outputs,
1360 };
1361 
1362 #endif /* CONFIG_SMPTEHDBARS_FILTER */
1363 #endif /* CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER */
1364 
1365 #if CONFIG_ALLYUV_FILTER
1366 
1367 static const AVOption allyuv_options[] = {
1369  { NULL }
1370 };
1371 
1372 AVFILTER_DEFINE_CLASS(allyuv);
1373 
1374 static void allyuv_fill_picture(AVFilterContext *ctx, AVFrame *frame)
1375 {
1376  const int ys = frame->linesize[0];
1377  const int us = frame->linesize[1];
1378  const int vs = frame->linesize[2];
1379  int x, y, j;
1380 
1381  for (y = 0; y < 4096; y++) {
1382  for (x = 0; x < 2048; x++) {
1383  frame->data[0][y * ys + x] = ((x / 8) % 256);
1384  frame->data[0][y * ys + 4095 - x] = ((x / 8) % 256);
1385  }
1386 
1387  for (x = 0; x < 2048; x+=8) {
1388  for (j = 0; j < 8; j++) {
1389  frame->data[1][vs * y + x + j] = (y%16 + (j % 8) * 16);
1390  frame->data[1][vs * y + 4095 - x - j] = (128 + y%16 + (j % 8) * 16);
1391  }
1392  }
1393 
1394  for (x = 0; x < 4096; x++)
1395  frame->data[2][y * us + x] = 256 * y / 4096;
1396  }
1397 }
1398 
1399 static av_cold int allyuv_init(AVFilterContext *ctx)
1400 {
1401  TestSourceContext *test = ctx->priv;
1402 
1403  test->w = test->h = 4096;
1404  test->draw_once = 1;
1405  test->fill_picture_fn = allyuv_fill_picture;
1406  return init(ctx);
1407 }
1408 
1409 static int allyuv_query_formats(AVFilterContext *ctx)
1410 {
1411  static const enum AVPixelFormat pix_fmts[] = {
1414  };
1415 
1416  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
1417  if (!fmts_list)
1418  return AVERROR(ENOMEM);
1419  return ff_set_common_formats(ctx, fmts_list);
1420 }
1421 
1422 static const AVFilterPad avfilter_vsrc_allyuv_outputs[] = {
1423  {
1424  .name = "default",
1425  .type = AVMEDIA_TYPE_VIDEO,
1426  .request_frame = request_frame,
1427  .config_props = config_props,
1428  },
1429  { NULL }
1430 };
1431 
1432 AVFilter ff_vsrc_allyuv = {
1433  .name = "allyuv",
1434  .description = NULL_IF_CONFIG_SMALL("Generate all yuv colors."),
1435  .priv_size = sizeof(TestSourceContext),
1436  .priv_class = &allyuv_class,
1437  .init = allyuv_init,
1438  .uninit = uninit,
1439  .query_formats = allyuv_query_formats,
1440  .inputs = NULL,
1441  .outputs = avfilter_vsrc_allyuv_outputs,
1442 };
1443 
1444 #endif /* CONFIG_ALLYUV_FILTER */
1445 
1446 #if CONFIG_ALLRGB_FILTER
1447 
1448 static const AVOption allrgb_options[] = {
1450  { NULL }
1451 };
1452 
1453 AVFILTER_DEFINE_CLASS(allrgb);
1454 
1455 static void allrgb_fill_picture(AVFilterContext *ctx, AVFrame *frame)
1456 {
1457  unsigned x, y;
1458  const int linesize = frame->linesize[0];
1459  uint8_t *line = frame->data[0];
1460 
1461  for (y = 0; y < 4096; y++) {
1462  uint8_t *dst = line;
1463 
1464  for (x = 0; x < 4096; x++) {
1465  *dst++ = x;
1466  *dst++ = y;
1467  *dst++ = (x >> 8) | ((y >> 8) << 4);
1468  }
1469  line += linesize;
1470  }
1471 }
1472 
1473 static av_cold int allrgb_init(AVFilterContext *ctx)
1474 {
1475  TestSourceContext *test = ctx->priv;
1476 
1477  test->w = test->h = 4096;
1478  test->draw_once = 1;
1479  test->fill_picture_fn = allrgb_fill_picture;
1480  return init(ctx);
1481 }
1482 
1483 static int allrgb_config_props(AVFilterLink *outlink)
1484 {
1485  TestSourceContext *test = outlink->src->priv;
1486 
1487  ff_fill_rgba_map(test->rgba_map, outlink->format);
1488  return config_props(outlink);
1489 }
1490 
1491 static int allrgb_query_formats(AVFilterContext *ctx)
1492 {
1493  static const enum AVPixelFormat pix_fmts[] = {
1495  };
1496 
1497  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
1498  if (!fmts_list)
1499  return AVERROR(ENOMEM);
1500  return ff_set_common_formats(ctx, fmts_list);
1501 }
1502 
1503 static const AVFilterPad avfilter_vsrc_allrgb_outputs[] = {
1504  {
1505  .name = "default",
1506  .type = AVMEDIA_TYPE_VIDEO,
1507  .request_frame = request_frame,
1508  .config_props = allrgb_config_props,
1509  },
1510  { NULL }
1511 };
1512 
1513 AVFilter ff_vsrc_allrgb = {
1514  .name = "allrgb",
1515  .description = NULL_IF_CONFIG_SMALL("Generate all RGB colors."),
1516  .priv_size = sizeof(TestSourceContext),
1517  .priv_class = &allrgb_class,
1518  .init = allrgb_init,
1519  .uninit = uninit,
1520  .query_formats = allrgb_query_formats,
1521  .inputs = NULL,
1522  .outputs = avfilter_vsrc_allrgb_outputs,
1523 };
1524 
1525 #endif /* CONFIG_ALLRGB_FILTER */
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
Definition: pixfmt.h:436
int plane
Definition: avisynth_c.h:291
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
Definition: drawutils.c:715
#define NULL
Definition: coverity.c:32
const char const char void * val
Definition: avisynth_c.h:634
const char * s
Definition: avisynth_c.h:631
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2222
This structure describes decoded (raw) audio or video data.
Definition: frame.h:184
AVOption.
Definition: opt.h:245
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
const char * fmt
Definition: avisynth_c.h:632
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
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
misc image utilities
Main libavfilter public API header.
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:64
const char * g
Definition: vf_curves.c:108
const char * desc
Definition: nvenc.c:89
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:331
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
Definition: pixfmt.h:440
static void draw_rectangle(AVFormatContext *s)
Definition: xcbgrab.c:563
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:180
int num
numerator
Definition: rational.h:44
const char * b
Definition: vf_curves.c:109
static av_cold void uninit(AVFilterContext *ctx)
Definition: vsrc_testsrc.c:117
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:336
#define COMMON_OPTIONS_NOSIZE
Definition: vsrc_testsrc.c:88
const uint8_t avpriv_vga16_font[4096]
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:252
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:76
int draw_once
draw only the first frame, always put out the same picture
Definition: vsrc_testsrc.c:60
#define AV_PIX_FMT_RGB444
Definition: pixfmt.h:330
static AVRational av_make_q(int num, int den)
Create a rational.
Definition: rational.h:53
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
static av_cold int init(AVFilterContext *ctx)
Definition: vsrc_testsrc.c:102
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:703
const char * name
Pad name.
Definition: internal.h:59
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
int draw_once_reset
draw only the first frame or in case of reset
Definition: vsrc_testsrc.c:61
#define AV_WL24(p, d)
Definition: intreadwrite.h:464
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1180
uint8_t
#define av_cold
Definition: attributes.h:82
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:251
AVOptions.
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
Definition: log.c:94
Definition: vf_geq.c:46
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:268
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:95
static AVFrame * frame
#define height
static double av_q2d(AVRational a)
Convert rational to double.
Definition: rational.h:80
static int request_frame(AVFilterLink *outlink)
Definition: vsrc_testsrc.c:137
#define AVERROR_EOF
End of file.
Definition: error.h:55
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:332
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:318
ptrdiff_t size
Definition: opengl_enc.c:101
#define A(x)
Definition: vp56_arith.h:28
#define FFALIGN(x, a)
Definition: macros.h:48
#define av_log(a,...)
int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, void *log_ctx)
Put the RGBA values that correspond to color_string in rgba_color.
Definition: parseutils.c:349
A filter pad used for either input or output.
Definition: internal.h:53
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
static double alpha(void *priv, double x, double y)
Definition: vf_geq.c:99
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
Definition: ffmath.h:42
int width
width and height of the video frame
Definition: frame.h:236
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:568
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
static const uint16_t mask[17]
Definition: lzw.c:38
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:153
void av_frame_set_colorspace(AVFrame *frame, enum AVColorSpace val)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:96
const char * r
Definition: vf_curves.c:107
void * priv
private data for use by the filter
Definition: avfilter.h:320
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:2187
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
Definition: drawutils.c:221
Definition: graph2dot.c:48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:327
simple assert() macros that are a bit more flexible than ISO C assert().
#define COMMON_OPTIONS
Definition: vsrc_testsrc.c:95
#define FFMAX(a, b)
Definition: common.h:94
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:93
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:94
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
AVRational sar
sample aspect ratio
Definition: vsrc_testsrc.c:59
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:251
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:258
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
#define FFMIN(a, b)
Definition: common.h:96
Round toward zero.
Definition: mathematics.h:71
#define width
int64_t duration
duration expressed in microseconds
Definition: vsrc_testsrc.c:58
static void draw_text(DatascopeContext *s, AVFrame *frame, FFDrawColor *color, int x0, int y0, const uint8_t *text, int vertical)
Definition: vf_datascope.c:75
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
static int config_props(AVFilterLink *outlink)
Definition: vsrc_testsrc.c:124
int32_t
AVFormatContext * ctx
Definition: movenc.c:48
Definition: vf_geq.c:46
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:65
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:386
#define FLAGS
Definition: vsrc_testsrc.c:82
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:471
#define FF_ARRAY_ELEMS(a)
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:35
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:607
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:248
#define AV_PIX_FMT_BGR555
Definition: pixfmt.h:334
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:376
uint8_t color_rgba[4]
Definition: vsrc_testsrc.c:72
Definition: vf_geq.c:46
misc drawing utilities
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:252
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:215
static void test(const char *pattern, const char *host)
Definition: noproxy.c:23
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
uint8_t rgba_map[4]
Definition: vsrc_testsrc.c:75
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:263
void * buf
Definition: avisynth_c.h:553
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:68
AVRational frame_rate
Definition: vsrc_testsrc.c:56
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:142
int index
Definition: gxfenc.c:89
rational number numerator/denominator
Definition: rational.h:43
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:431
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:253
const char * name
Filter name.
Definition: avfilter.h:146
int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
Init a draw context.
Definition: drawutils.c:176
#define snprintf
Definition: snprintf.h:34
misc parsing utilities
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:317
FFDrawColor color
Definition: vsrc_testsrc.c:71
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:262
#define AV_PIX_FMT_BGR565
Definition: pixfmt.h:333
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:133
static int flags
Definition: cpu.c:47
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:198
uint8_t level
Definition: svq3.c:193
AVRational time_base
Definition: vsrc_testsrc.c:56
internal math functions header
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
static int query_formats(AVFilterContext *ctx)
Definition: aeval.c:244
common internal and external API header
unsigned int nb_frame
Definition: vsrc_testsrc.c:55
static double c[64]
#define AV_PIX_FMT_BGR444
Definition: pixfmt.h:335
static const AVOption options[]
Definition: vsrc_testsrc.c:97
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:329
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:69
int den
denominator
Definition: rational.h:45
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:339
static uint8_t tmp[8]
Definition: des.c:38
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:253
A list of supported formats for one end of a filter link.
Definition: formats.h:64
void(* fill_picture_fn)(AVFilterContext *ctx, AVFrame *frame)
Definition: vsrc_testsrc.c:64
#define OFFSET(x)
Definition: vsrc_testsrc.c:81
#define AV_PIX_FMT_RGB565
Definition: pixfmt.h:328
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:304
An instance of a filter.
Definition: avfilter.h:305
int height
Definition: frame.h:236
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:100
FFDrawContext draw
Definition: vsrc_testsrc.c:70
internal API functions
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:250
AVFrame * picref
cached reference containing the painted picture
Definition: vsrc_testsrc.c:62
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
CGA/EGA/VGA ROM font data.
#define AV_WL32(p, v)
Definition: intreadwrite.h:426
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58