FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/vsrc_testsrc.c
Date: 2026-05-03 08:24:11
Exec Total Coverage
Lines: 689 917 75.1%
Functions: 42 65 64.6%
Branches: 229 392 58.4%

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