75 #define OFFSET(x) offsetof(TestSourceContext, x)
76 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
121 "Option 'decimals' is ignored with source '%s'\n",
132 "Option 'color' is ignored with source '%s'\n",
160 outlink->
w = test->
w;
161 outlink->
h = test->
h;
193 outpicref->
pts = test->
pts;
208 #if CONFIG_COLOR_FILTER
210 #define color_options options
218 0, 0, test->
w, test->
h);
224 test->
class = &color_class;
228 return init(ctx, args);
264 .config_props = color_config_props,
280 .priv_class = &color_class,
285 #if CONFIG_NULLSRC_FILTER
287 #define nullsrc_options options
296 test->
class = &nullsrc_class;
298 return init(ctx, args);
314 .init = nullsrc_init,
319 .priv_class = &nullsrc_class,
324 #if CONFIG_TESTSRC_FILTER
326 #define testsrc_options options
341 static void draw_rectangle(
unsigned val,
uint8_t *
dst,
int dst_linesize,
unsigned segment_width,
342 unsigned x,
unsigned y,
unsigned w,
unsigned h)
347 dst += segment_width * (step * x + y * dst_linesize);
348 w *= segment_width * step;
350 for (i = 0; i < h; i++) {
356 static void draw_digit(
int digit,
uint8_t *dst,
unsigned dst_linesize,
357 unsigned segment_width)
362 #define LEFT_TOP_VBAR 8
363 #define LEFT_BOT_VBAR 16
364 #define RIGHT_TOP_VBAR 32
365 #define RIGHT_BOT_VBAR 64
377 static const unsigned char masks[10] = {
378 TOP_HBAR |BOT_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
379 RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
380 TOP_HBAR|MID_HBAR|BOT_HBAR|LEFT_BOT_VBAR |RIGHT_TOP_VBAR,
381 TOP_HBAR|MID_HBAR|BOT_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
382 MID_HBAR |LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
383 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_BOT_VBAR,
384 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR |RIGHT_BOT_VBAR,
385 TOP_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
386 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
387 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
389 unsigned mask = masks[digit];
392 draw_rectangle(0, dst, dst_linesize, segment_width, 0, 0, 8, 13);
395 draw_rectangle(255, dst, dst_linesize, segment_width,
396 segments[i].x, segments[i].y, segments[i].w, segments[i].h);
399 #define GRADIENT_SIZE (6 * 256)
406 int color, color_rest;
410 int dquad_x, dquad_y;
411 int grad, dgrad, rgrad, drgrad;
420 radius = (width +
height) / 4;
421 quad0 = width * width / 4 + height * height / 4 - radius * radius;
424 for (y = 0; y <
height; y++) {
430 for (x = 0; x <
width; x++) {
436 *(p++) = icolor & 1 ? 255 : 0;
437 *(p++) = icolor & 2 ? 255 : 0;
438 *(p++) = icolor & 4 ? 255 : 0;
440 if (color_rest >= width) {
451 p0 = p = data + picref->
linesize[0] * height * 3/4;
455 dgrad = GRADIENT_SIZE /
width;
456 drgrad = GRADIENT_SIZE %
width;
457 for (x = 0; x <
width; x++) {
459 grad < 256 || grad >= 5 * 256 ? 255 :
460 grad >= 2 * 256 && grad < 4 * 256 ? 0 :
461 grad < 2 * 256 ? 2 * 256 - 1 - grad : grad - 4 * 256;
463 grad >= 4 * 256 ? 0 :
464 grad >= 1 * 256 && grad < 3 * 256 ? 255 :
465 grad < 1 * 256 ? grad : 4 * 256 - 1 - grad;
468 grad >= 3 * 256 && grad < 5 * 256 ? 255 :
469 grad < 3 * 256 ? grad - 2 * 256 : 6 * 256 - 1 - grad;
472 if (rgrad >= GRADIENT_SIZE) {
474 rgrad -= GRADIENT_SIZE;
476 if (grad >= GRADIENT_SIZE)
477 grad -= GRADIENT_SIZE;
480 for (y = height / 8; y > 0; y--) {
481 memcpy(p+picref->
linesize[0], p, 3 * width);
486 seg_size = width / 80;
487 if (seg_size >= 1 && height >= 13 * seg_size) {
493 x = width - (width - seg_size * 64) / 2;
494 y = (height - seg_size * 13) / 2;
495 p = data + (x*3 + y * picref->
linesize[0]);
496 for (i = 0; i < 8; i++) {
497 p -= 3 * 8 * seg_size;
498 draw_digit(second % 10, p, picref->
linesize[0], seg_size);
510 test->
class = &testsrc_class;
512 return init(ctx, args);
524 static const AVFilterPad avfilter_vsrc_testsrc_outputs[] = {
544 .
outputs = avfilter_vsrc_testsrc_outputs,
545 .priv_class = &testsrc_class,
550 #if CONFIG_RGBTESTSRC_FILTER
552 #define rgbtestsrc_options options
560 static void rgbtest_put_pixel(
uint8_t *dst,
int dst_linesize,
568 case AV_PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4);
break;
569 case AV_PIX_FMT_RGB444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b >> 4) << 8) | ((g >> 4) << 4) | (r >> 4);
break;
570 case AV_PIX_FMT_BGR555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<10) | ((g>>3)<<5) | (b>>3);
break;
571 case AV_PIX_FMT_RGB555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<10) | ((g>>3)<<5) | (r>>3);
break;
572 case AV_PIX_FMT_BGR565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<11) | ((g>>2)<<5) | (b>>3);
break;
573 case AV_PIX_FMT_RGB565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<11) | ((g>>2)<<5) | (r>>3);
break;
576 v = (r << (rgba_map[
R]*8)) + (g << (rgba_map[
G]*8)) + (b << (rgba_map[
B]*8));
577 p = dst + 3*x + y*dst_linesize;
584 v = (r << (rgba_map[
R]*8)) + (g << (rgba_map[
G]*8)) + (b << (rgba_map[
B]*8)) + (255 << (rgba_map[
A]*8));
585 p = dst + 4*x + y*dst_linesize;
596 for (y = 0; y < h; y++) {
597 for (x = 0; x < picref->
video->
w; x++) {
599 int r = 0, g = 0, b = 0;
602 else if (3*y < 2*h) g =
c;
605 rgbtest_put_pixel(picref->
data[0], picref->
linesize[0], x, y, r, g, b,
616 test->
class = &rgbtestsrc_class;
618 return init(ctx, args);
643 static const AVFilterPad avfilter_vsrc_rgbtestsrc_outputs[] = {
648 .config_props = rgbtest_config_props,
653 AVFilter avfilter_vsrc_rgbtestsrc = {
654 .
name =
"rgbtestsrc",
657 .
init = rgbtest_init,
664 .
outputs = avfilter_vsrc_rgbtestsrc_outputs,
665 .priv_class = &rgbtestsrc_class,
670 #if CONFIG_SMPTEBARS_FILTER
672 #define smptebars_options options
675 static const uint8_t rainbow[7][4] = {
676 { 191, 191, 191, 255 },
677 { 191, 191, 0, 255 },
678 { 0, 191, 191, 255 },
680 { 191, 0, 191, 255 },
685 static const uint8_t wobnair[7][4] = {
688 { 191, 0, 191, 255 },
690 { 0, 191, 191, 255 },
692 { 191, 191, 191, 255 },
695 static const uint8_t white[4] = { 255, 255, 255, 255 };
696 static const uint8_t black[4] = { 19, 19, 19, 255 };
699 static const uint8_t neg4ire[4] = { 9, 9, 9, 255 };
700 static const uint8_t pos4ire[4] = { 29, 29, 29, 255 };
703 static const uint8_t i_pixel[4] = { 0, 68, 130, 255 };
704 static const uint8_t q_pixel[4] = { 67, 0, 130, 255 };
710 int r_w, r_h, w_h, p_w, p_h, i, x = 0;
712 r_w = (test->
w + 6) / 7;
713 r_h = test->
h * 2 / 3;
714 w_h = test->
h * 3 / 4 - r_h;
716 p_h = test->
h - w_h - r_h;
718 #define DRAW_COLOR(rgba, x, y, w, h) \
719 ff_draw_color(&test->draw, &color, rgba); \
720 ff_fill_rectangle(&test->draw, &color, \
721 picref->data, picref->linesize, x, y, w, h) \
723 for (i = 0; i < 7; i++) {
724 DRAW_COLOR(rainbow[i], x, 0,
FFMIN(r_w, test->
w - x), r_h);
725 DRAW_COLOR(wobnair[i], x, r_h,
FFMIN(r_w, test->
w - x), w_h);
729 DRAW_COLOR(i_pixel, x, r_h + w_h, p_w, p_h);
731 DRAW_COLOR(white, x, r_h + w_h, p_w, p_h);
733 DRAW_COLOR(q_pixel, x, r_h + w_h, p_w, p_h);
735 DRAW_COLOR(black, x, r_h + w_h, 5 * r_w - x, p_h);
737 DRAW_COLOR(neg4ire, x, r_h + w_h, r_w / 3, p_h);
739 DRAW_COLOR(black, x, r_h + w_h, r_w / 3, p_h);
741 DRAW_COLOR(pos4ire, x, r_h + w_h, r_w / 3, p_h);
743 DRAW_COLOR(black, x, r_h + w_h, test->
w - x, p_h);
750 test->
class = &smptebars_class;
753 return init(ctx, args);
762 static int smptebars_config_props(
AVFilterLink *outlink)
777 .config_props = smptebars_config_props,
782 AVFilter avfilter_vsrc_smptebars = {
786 .
init = smptebars_init,
792 .priv_class = &smptebars_class,