36 #include "config_components.h"
100 #define OFFSET(x) offsetof(TestSourceContext, x)
101 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
102 #define FLAGSR AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
104 #define SIZE_OPTIONS \
105 { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\
106 { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\
108 #define COMMON_OPTIONS_NOSIZE \
109 { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS },\
110 { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS },\
111 { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },\
112 { "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },\
113 { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX, FLAGS },
115 #define COMMON_OPTIONS SIZE_OPTIONS COMMON_OPTIONS_NOSIZE
117 #define NOSIZE_OPTIONS_OFFSET 2
135 test->duration < 0 ? -1 : (
double)
test->duration/1000000,
152 outlink->
w =
test->w;
153 outlink->
h =
test->h;
177 if (
test->duration >= 0 &&
183 if (
test->draw_once) {
184 if (
test->draw_once_reset) {
186 test->draw_once_reset = 0;
204 #if FF_API_INTERLACED_FRAME
206 frame->interlaced_frame = 0;
212 if (!
test->draw_once)
221 #if CONFIG_COLOR_FILTER
223 static const AVOption color_options[] = {
243 test->fill_picture_fn = color_fill_picture;
274 static int color_process_command(
AVFilterContext *
ctx,
const char *cmd,
const char *args,
275 char *res,
int res_len,
int flags)
285 test->draw_once_reset = 1;
293 .config_props = color_config_props,
300 .priv_class = &color_class,
308 .process_command = color_process_command,
313 #if CONFIG_HALDCLUTSRC_FILTER
315 static const AVOption haldclutsrc_options[] = {
325 int i, j, k, x = 0, y = 0, is16bit = 0,
step;
330 const int w =
frame->width;
331 const int h =
frame->height;
333 const ptrdiff_t linesize =
frame->linesize[0];
335 const int depth =
desc->comp[0].depth;
344 alpha = (1 << depth) - 1;
350 #define LOAD_CLUT(nbits) do { \
351 uint##nbits##_t *dst = ((uint##nbits##_t *)(data + y*linesize)) + x*step; \
352 dst[rgba_map[0]] = av_clip_uint##nbits(i * scale); \
353 dst[rgba_map[1]] = av_clip_uint##nbits(j * scale); \
354 dst[rgba_map[2]] = av_clip_uint##nbits(k * scale); \
356 dst[rgba_map[3]] = alpha; \
359 #define LOAD_CLUT_PLANAR(type, nbits) do { \
360 type *dst = ((type *)(frame->data[2] + y*frame->linesize[2])) + x; \
361 dst[0] = av_clip_uintp2(i * scale, nbits); \
362 dst = ((type *)(frame->data[0] + y*frame->linesize[0])) + x; \
363 dst[0] = av_clip_uintp2(j * scale, nbits); \
364 dst = ((type *)(frame->data[1] + y*frame->linesize[1])) + x; \
365 dst[0] = av_clip_uintp2(k * scale, nbits); \
367 dst = ((type *)(frame->data[3] + y*linesize)) + x; \
373 for (k = 0; k <
level; k++) {
374 for (j = 0; j <
level; j++) {
383 case 8: LOAD_CLUT_PLANAR(uint8_t, 8);
break;
384 case 9: LOAD_CLUT_PLANAR(uint16_t, 9);
break;
385 case 10: LOAD_CLUT_PLANAR(uint16_t,10);
break;
386 case 12: LOAD_CLUT_PLANAR(uint16_t,12);
break;
387 case 14: LOAD_CLUT_PLANAR(uint16_t,14);
break;
388 case 16: LOAD_CLUT_PLANAR(uint16_t,16);
break;
425 static int haldclutsrc_config_props(
AVFilterLink *outlink)
438 .config_props = haldclutsrc_config_props,
443 .
name =
"haldclutsrc",
445 .priv_class = &haldclutsrc_class,
447 .
init = haldclutsrc_init,
458 #if CONFIG_NULLSRC_FILTER
466 test->fill_picture_fn = nullsrc_fill_picture;
473 .priv_class = &nullsrc_yuvtestsrc_class,
474 .init = nullsrc_init,
484 #if CONFIG_TESTSRC_FILTER
486 static const AVOption testsrc_options[] = {
507 static void draw_rectangle(
unsigned val, uint8_t *dst, ptrdiff_t dst_linesize,
int segment_width,
508 int x,
int y,
int w,
int h)
513 dst += segment_width * (
step * x + y * dst_linesize);
514 w *= segment_width *
step;
516 for (
i = 0;
i <
h;
i++) {
522 static void draw_digit(
int digit, uint8_t *dst, ptrdiff_t dst_linesize,
528 #define LEFT_TOP_VBAR 8
529 #define LEFT_BOT_VBAR 16
530 #define RIGHT_TOP_VBAR 32
531 #define RIGHT_BOT_VBAR 64
543 static const unsigned char masks[10] = {
544 TOP_HBAR |BOT_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
545 RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
546 TOP_HBAR|MID_HBAR|BOT_HBAR|LEFT_BOT_VBAR |RIGHT_TOP_VBAR,
547 TOP_HBAR|MID_HBAR|BOT_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
548 MID_HBAR |LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
549 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_BOT_VBAR,
550 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR |RIGHT_BOT_VBAR,
551 TOP_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
552 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
553 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
555 unsigned mask = masks[digit];
562 segments[
i].x, segments[
i].y, segments[
i].
w, segments[
i].
h);
565 #define GRADIENT_SIZE (6 * 256)
572 int color, color_rest;
576 int dquad_x, dquad_y;
577 int grad, dgrad, rgrad, drgrad;
590 for (y = 0; y <
height; y++) {
596 for (x = 0; x <
width; x++) {
602 *(p++) = icolor & 1 ? 255 : 0;
603 *(p++) = icolor & 2 ? 255 : 0;
604 *(p++) = icolor & 4 ? 255 : 0;
606 if (color_rest >=
width) {
613 p0 +=
frame->linesize[0];
618 grad = (256 *
test->nb_frame *
test->time_base.num /
test->time_base.den) %
621 dgrad = GRADIENT_SIZE /
width;
622 drgrad = GRADIENT_SIZE %
width;
623 for (x = 0; x <
width; x++) {
625 grad < 256 || grad >= 5 * 256 ? 255 :
626 grad >= 2 * 256 && grad < 4 * 256 ? 0 :
627 grad < 2 * 256 ? 2 * 256 - 1 - grad : grad - 4 * 256;
629 grad >= 4 * 256 ? 0 :
630 grad >= 1 * 256 && grad < 3 * 256 ? 255 :
631 grad < 1 * 256 ? grad : 4 * 256 - 1 - grad;
634 grad >= 3 * 256 && grad < 5 * 256 ? 255 :
635 grad < 3 * 256 ? grad - 2 * 256 : 6 * 256 - 1 - grad;
638 if (rgrad >= GRADIENT_SIZE) {
640 rgrad -= GRADIENT_SIZE;
642 if (grad >= GRADIENT_SIZE)
643 grad -= GRADIENT_SIZE;
646 for (y =
height / 8; y > 0; y--) {
648 p +=
frame->linesize[0];
652 seg_size =
width / 80;
653 if (seg_size >= 1 &&
height >= 13 * seg_size) {
654 int64_t p10decimals = 1;
660 for (x = 0; x <
test->nb_decimals; x++)
665 y = (
height - seg_size * 13) / 2;
666 p =
data + (x*3 + y *
frame->linesize[0]);
667 for (
i = 0;
i < 8;
i++) {
668 p -= 3 * 8 * seg_size;
669 draw_digit(second % 10, p,
frame->linesize[0], seg_size);
681 test->fill_picture_fn = test_fill_picture;
689 .priv_class = &testsrc_class,
700 #if CONFIG_TESTSRC2_FILTER
702 static const AVOption testsrc2_options[] = {
712 uint8_t rgba[4] = { (argb >> 16) & 0xFF,
715 (argb >> 24) & 0xFF, };
719 static uint32_t color_gradient(
unsigned index)
721 unsigned si =
index & 0xFF, sd = 0xFF - si;
722 switch (
index >> 8) {
723 case 0:
return 0xFF0000 + (si << 8);
724 case 1:
return 0x00FF00 + (sd << 16);
725 case 2:
return 0x00FF00 + (si << 0);
726 case 3:
return 0x0000FF + (sd << 8);
727 case 4:
return 0x0000FF + (si << 16);
728 case 5:
return 0xFF0000 + (sd << 0);
734 int x0,
int y0,
const uint8_t *text)
738 for (; *text; text++) {
755 unsigned alpha = (uint32_t)
s->alpha << 24;
759 unsigned i, x = 0, x2;
765 set_color(
s, &
color, ((
i & 1) ? 0xFF0000 : 0) |
766 ((
i & 2) ? 0x00FF00 : 0) |
767 ((
i & 4) ? 0x0000FF : 0) |
770 x, 0, x2 - x,
frame->height);
778 unsigned x, dx, y0, y, g0,
g;
783 for (x = 0; x <
s->w; x += dx) {
787 y %= 2 * (
s->h - 16);
789 y = 2 * (
s->h - 16) - y;
797 if (
s->w >= 64 &&
s->h >= 64) {
798 int l = (
FFMIN(
s->w,
s->h) - 32) >> 1;
800 int xc = (
s->w >> 2) + (
s->w >> 1);
801 int yc = (
s->h >> 2);
806 for (
c = 0;
c < 3;
c++) {
807 set_color(
s, &
color, (0xBBBBBB ^ (0xFF << (
c << 3))) |
alpha);
811 pos < 3 * l ? 3 * l -
pos : 0;
812 yh =
pos < 1 * l ? 0 :
830 if (
s->w >= 64 &&
s->h >= 64) {
831 int l = (
FFMIN(
s->w,
s->h) - 16) >> 2;
833 int xc = (
s->w >> 2);
834 int yc = (
s->h >> 2) + (
s->h >> 1);
847 set_color(
s, &
color, 0xFF808080);
854 x1, ym1, x2 - x1, ym2 - ym1);
857 xm1, y1, xm2 - xm1, y2 - y1);
860 x1, y1, x2 - x1, y2 - y1);
873 for (y = ymin; y + 15 < ymax; y += 16) {
874 for (x = xmin; x + 15 < xmax; x += 16) {
877 for (
i = 0;
i < 256;
i++) {
878 r =
r * 1664525 + 1013904223;
881 set_color(
s, &
color, 0xFF00FF80);
884 alpha, 16, 16, 16, 3, 0, x, y);
890 if (
s->w >= 16 &&
s->h >= 16) {
891 unsigned w =
s->w - 8;
892 unsigned h =
s->h - 8;
901 set_color(
s, &
color, 0xFF8000FF);
912 set_color(
s, &
color, 0xC0000000);
916 set_color(
s, &
color, 0xFFFF8000);
917 snprintf(buf,
sizeof(buf),
"%02d:%02d:%02d.%03d\n%12"PRIi64,
918 time / 3600000, (time / 60000) % 60, (time / 1000) % 60,
919 time % 1000,
s->pts);
927 s->fill_picture_fn = test2_fill_picture;
942 inlink->color_range, 0) >= 0);
950 static const AVFilterPad avfilter_vsrc_testsrc2_outputs[] = {
954 .config_props = test2_config_props,
962 .priv_class = &testsrc2_class,
973 #if CONFIG_RGBTESTSRC_FILTER
975 static const AVOption rgbtestsrc_options[] = {
989 static void rgbtest_put_pixel(uint8_t *dstp[4],
int dst_linesizep[4],
993 uint8_t *dst = dstp[0];
994 ptrdiff_t dst_linesize = dst_linesizep[0];
1000 case AV_PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
r >> 4) << 8) | ((
g >> 4) << 4) | (
b >> 4);
break;
1001 case AV_PIX_FMT_RGB444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
b >> 4) << 8) | ((
g >> 4) << 4) | (
r >> 4);
break;
1002 case AV_PIX_FMT_BGR555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
r>>3)<<10) | ((
g>>3)<<5) | (
b>>3);
break;
1003 case AV_PIX_FMT_RGB555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
b>>3)<<10) | ((
g>>3)<<5) | (
r>>3);
break;
1004 case AV_PIX_FMT_BGR565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
r>>3)<<11) | ((
g>>2)<<5) | (
b>>3);
break;
1005 case AV_PIX_FMT_RGB565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
b>>3)<<11) | ((
g>>2)<<5) | (
r>>3);
break;
1008 v = (
r << (rgba_map[
R]*8)) + (
g << (rgba_map[
G]*8)) + (
b << (rgba_map[
B]*8));
1009 p = dst + 3*x + y*dst_linesize;
1016 v = (
r << (rgba_map[
R]*8)) + (
g << (rgba_map[
G]*8)) + (
b << (rgba_map[
B]*8)) + (255
U << (rgba_map[
A]*8));
1017 p = dst + 4*x + y*dst_linesize;
1021 p = dstp[0] + x + y * dst_linesize;
1023 p = dstp[1] + x + y * dst_linesizep[1];
1025 p = dstp[2] + x + y * dst_linesizep[2];
1033 p16 = (uint16_t *)(dstp[0] + x*2 + y * dst_linesizep[0]);
1035 p16 = (uint16_t *)(dstp[1] + x*2 + y * dst_linesizep[1]);
1037 p16 = (uint16_t *)(dstp[2] + x*2 + y * dst_linesizep[2]);
1048 for (y = 0; y <
h; y++) {
1049 for (x = 0; x <
w; x++) {
1051 int r = 0,
g = 0,
b = 0;
1053 if (6*y <
h )
r =
c;
1054 else if (6*y < 2*
h)
g =
c,
b =
c;
1055 else if (6*y < 3*
h)
g =
c;
1056 else if (6*y < 4*
h)
r =
c,
b =
c;
1057 else if (6*y < 5*
h)
b =
c;
1060 rgbtest_put_pixel(
frame->data,
frame->linesize, x, y,
r,
g,
b,
1061 ctx->outputs[0]->format,
test->rgba_map);
1071 for (y = 0; y <
h; y++) {
1072 for (x = 0; x <
w; x++) {
1074 int r = 0,
g = 0,
b = 0;
1076 if (3*y <
h )
r =
c;
1077 else if (3*y < 2*
h)
g =
c;
1080 rgbtest_put_pixel(
frame->data,
frame->linesize, x, y,
r,
g,
b,
1081 ctx->outputs[0]->format,
test->rgba_map);
1090 test->draw_once = 1;
1091 test->fill_picture_fn =
test->complement ? rgbtest_fill_picture_complement : rgbtest_fill_picture;
1116 static const AVFilterPad avfilter_vsrc_rgbtestsrc_outputs[] = {
1120 .config_props = rgbtest_config_props,
1125 .
name =
"rgbtestsrc",
1128 .priv_class = &rgbtestsrc_class,
1129 .
init = rgbtest_init,
1139 #if CONFIG_YUVTESTSRC_FILTER
1146 const int mid = 1 << (
desc->comp[0].depth - 1);
1147 uint8_t *ydst =
frame->data[0];
1148 uint8_t *udst =
frame->data[1];
1149 uint8_t *vdst =
frame->data[2];
1150 ptrdiff_t ylinesize =
frame->linesize[0];
1151 ptrdiff_t ulinesize =
frame->linesize[1];
1152 ptrdiff_t vlinesize =
frame->linesize[2];
1154 for (y = 0; y <
h; y++) {
1155 for (x = 0; x <
w; x++) {
1169 for (; y <
h; y++) {
1170 for (x = 0; x <
w; x++) {
1183 for (; y <
frame->height; y++) {
1184 for (x = 0; x <
w; x++) {
1203 const int mid = 1 << (
desc->comp[0].depth - 1);
1204 uint16_t *ydst = (uint16_t *)
frame->data[0];
1205 uint16_t *udst = (uint16_t *)
frame->data[1];
1206 uint16_t *vdst = (uint16_t *)
frame->data[2];
1207 ptrdiff_t ylinesize =
frame->linesize[0] / 2;
1208 ptrdiff_t ulinesize =
frame->linesize[1] / 2;
1209 ptrdiff_t vlinesize =
frame->linesize[2] / 2;
1211 for (y = 0; y <
h; y++) {
1212 for (x = 0; x <
w; x++) {
1226 for (; y <
h; y++) {
1227 for (x = 0; x <
w; x++) {
1240 for (; y <
frame->height; y++) {
1241 for (x = 0; x <
w; x++) {
1259 test->draw_once = 1;
1276 test->fill_picture_fn =
desc->comp[0].depth > 8 ? yuvtest_fill_picture16 : yuvtest_fill_picture8;
1280 static const AVFilterPad avfilter_vsrc_yuvtestsrc_outputs[] = {
1284 .config_props = yuvtest_config_props,
1289 .
name =
"yuvtestsrc",
1292 .priv_class = &nullsrc_yuvtestsrc_class,
1293 .
init = yuvtest_init,
1303 #if CONFIG_PAL75BARS_FILTER || CONFIG_PAL100BARS_FILTER || CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER
1305 static const uint8_t rainbow[7][4] = {
1306 { 180, 128, 128, 255 },
1307 { 162, 44, 142, 255 },
1308 { 131, 156, 44, 255 },
1309 { 112, 72, 58, 255 },
1310 { 84, 184, 198, 255 },
1311 { 65, 100, 212, 255 },
1312 { 35, 212, 114, 255 },
1315 static const uint8_t rainbow100[7][4] = {
1316 { 235, 128, 128, 255 },
1317 { 210, 16, 146, 255 },
1318 { 170, 166, 16, 255 },
1319 { 145, 54, 34, 255 },
1320 { 106, 202, 222, 255 },
1321 { 81, 90, 240, 255 },
1322 { 41, 240, 110, 255 },
1325 static const uint8_t rainbowhd[7][4] = {
1326 { 180, 128, 128, 255 },
1327 { 168, 44, 136, 255 },
1328 { 145, 147, 44, 255 },
1329 { 133, 63, 52, 255 },
1330 { 63, 193, 204, 255 },
1331 { 51, 109, 212, 255 },
1332 { 28, 212, 120, 255 },
1335 static const uint8_t wobnair[7][4] = {
1336 { 35, 212, 114, 255 },
1337 { 19, 128, 128, 255 },
1338 { 84, 184, 198, 255 },
1339 { 19, 128, 128, 255 },
1340 { 131, 156, 44, 255 },
1341 { 19, 128, 128, 255 },
1342 { 180, 128, 128, 255 },
1345 static const uint8_t white[4] = { 235, 128, 128, 255 };
1348 static const uint8_t neg4ire[4] = { 7, 128, 128, 255 };
1349 static const uint8_t pos4ire[4] = { 24, 128, 128, 255 };
1352 static const uint8_t i_pixel[4] = { 57, 156, 97, 255 };
1353 static const uint8_t q_pixel[4] = { 44, 171, 147, 255 };
1355 static const uint8_t gray40[4] = { 104, 128, 128, 255 };
1356 static const uint8_t gray15[4] = { 49, 128, 128, 255 };
1357 static const uint8_t cyan[4] = { 188, 154, 16, 255 };
1358 static const uint8_t yellow[4] = { 219, 16, 138, 255 };
1359 static const uint8_t blue[4] = { 32, 240, 118, 255 };
1360 static const uint8_t red[4] = { 63, 102, 240, 255 };
1361 static const uint8_t black0[4] = { 16, 128, 128, 255 };
1362 static const uint8_t black2[4] = { 20, 128, 128, 255 };
1363 static const uint8_t black4[4] = { 25, 128, 128, 255 };
1364 static const uint8_t neg2[4] = { 12, 128, 128, 255 };
1367 int x,
int y,
int w,
int h,
1382 for (plane = 0;
frame->data[plane]; plane++) {
1383 const int c =
color[plane];
1384 const ptrdiff_t linesize =
frame->linesize[plane];
1385 int i, px, py, pw,
ph;
1387 if (plane == 1 || plane == 2) {
1388 px = x >>
desc->log2_chroma_w;
1390 py = y >>
desc->log2_chroma_h;
1399 p0 = p =
frame->data[plane] + py * linesize + px;
1402 for (
i = 1;
i <
ph;
i++, p += linesize)
1419 if (!strcmp(
ctx->name,
"smptehdbars")) {
1434 #if CONFIG_PAL75BARS_FILTER
1446 for (
i = 1;
i < 7;
i++) {
1457 test->fill_picture_fn = pal75bars_fill_picture;
1458 test->draw_once = 1;
1463 .
name =
"pal75bars",
1465 .priv_class = &palbars_class,
1467 .
init = pal75bars_init,
1477 #if CONFIG_PAL100BARS_FILTER
1487 for (
i = 0;
i < 7;
i++) {
1498 test->fill_picture_fn = pal100bars_fill_picture;
1499 test->draw_once = 1;
1504 .
name =
"pal100bars",
1506 .priv_class = &palbars_class,
1508 .
init = pal100bars_init,
1520 #if CONFIG_SMPTEBARS_FILTER
1525 int r_w, r_h, w_h, p_w, p_h,
i,
tmp, x = 0;
1532 p_h =
test->h - w_h - r_h;
1534 for (
i = 0;
i < 7;
i++) {
1540 draw_bar(
test, i_pixel, x, r_h + w_h, p_w, p_h, picref);
1544 draw_bar(
test, q_pixel, x, r_h + w_h, p_w, p_h, picref);
1563 test->fill_picture_fn = smptebars_fill_picture;
1564 test->draw_once = 1;
1569 .
name =
"smptebars",
1572 .priv_class = &smptebars_class,
1573 .
init = smptebars_init,
1583 #if CONFIG_SMPTEHDBARS_FILTER
1588 int d_w, r_w, r_h, l_w,
i,
tmp, x = 0, y = 0;
1597 for (
i = 0;
i < 7;
i++) {
1620 uint8_t yramp[4] = {0};
1622 yramp[0] =
i * 255 /
tmp;
1664 test->fill_picture_fn = smptehdbars_fill_picture;
1665 test->draw_once = 1;
1670 .
name =
"smptehdbars",
1672 .priv_class = &smptebars_class,
1674 .
init = smptehdbars_init,
1688 #if CONFIG_ALLYUV_FILTER
1692 const ptrdiff_t ys =
frame->linesize[0];
1693 const ptrdiff_t
us =
frame->linesize[1];
1694 const ptrdiff_t vs =
frame->linesize[2];
1697 for (y = 0; y < 4096; y++) {
1698 for (x = 0; x < 2048; x++) {
1699 frame->data[0][y * ys + x] = ((x / 8) % 256);
1700 frame->data[0][y * ys + 4095 - x] = ((x / 8) % 256);
1703 for (x = 0; x < 2048; x+=8) {
1704 for (j = 0; j < 8; j++) {
1705 frame->data[1][vs * y + x + j] = (y%16 + (j % 8) * 16);
1706 frame->data[1][vs * y + 4095 - x - j] = (128 + y%16 + (j % 8) * 16);
1710 for (x = 0; x < 4096; x++)
1711 frame->data[2][y *
us + x] = 256 * y / 4096;
1720 test->draw_once = 1;
1721 test->fill_picture_fn = allyuv_fill_picture;
1729 .priv_class = &allyuv_allrgb_class,
1730 .
init = allyuv_init,
1740 #if CONFIG_ALLRGB_FILTER
1745 const ptrdiff_t linesize =
frame->linesize[0];
1748 for (y = 0; y < 4096; y++) {
1749 uint8_t *dst =
line;
1751 for (x = 0; x < 4096; x++) {
1754 *dst++ = (x >> 8) | ((y >> 8) << 4);
1765 test->draw_once = 1;
1766 test->fill_picture_fn = allrgb_fill_picture;
1778 static const AVFilterPad avfilter_vsrc_allrgb_outputs[] = {
1782 .config_props = allrgb_config_props,
1790 .priv_class = &allyuv_allrgb_class,
1791 .
init = allrgb_init,
1801 #if CONFIG_COLORSPECTRUM_FILTER
1803 static const AVOption colorspectrum_options[] = {
1814 static inline float mix(
float a,
float b,
float mix)
1819 static void hsb2rgb(
const float *
c,
float *
rgb)
1832 const float w =
frame->width - 1.f;
1833 const float h =
frame->height - 1.f;
1836 for (
int y = 0; y <
frame->height; y++) {
1837 float *
r = (
float *)(
frame->data[2] + y *
frame->linesize[2]);
1838 float *
g = (
float *)(
frame->data[0] + y *
frame->linesize[0]);
1839 float *
b = (
float *)(
frame->data[1] + y *
frame->linesize[1]);
1840 const float yh = y /
h;
1842 c[1] =
test->type == 2 ? yh > 0.5f ? 2.f * (yh - 0.5f) : 1.
f - 2.
f * yh :
test->type == 1 ? 1.f - yh : yh;
1844 c[3] =
test->type == 1 ? 1.f :
test->type == 2 ? (yh > 0.5f ? 0.f : 1.f): 0.f;
1845 for (
int x = 0; x <
frame->width; x++) {
1862 test->draw_once = 1;
1863 test->fill_picture_fn = colorspectrum_fill_picture;
1868 .
name =
"colorspectrum",
1871 .priv_class = &colorspectrum_class,
1872 .
init = colorspectrum_init,
1882 #if CONFIG_COLORCHART_FILTER
1884 static const AVOption colorchart_options[] = {
1895 static const uint8_t reference_colors[][3] = {
1925 static const uint8_t skintones_colors[][3] = {
1955 typedef struct ColorChartPreset {
1957 const uint8_t (*colors)[3];
1960 static const ColorChartPreset colorchart_presets[] = {
1961 { 6, 4, reference_colors, },
1962 { 6, 4, skintones_colors, },
1971 inlink->color_range, 0) >= 0);
1981 const int w = colorchart_presets[
preset].w;
1982 const int h = colorchart_presets[
preset].h;
1983 const int pw =
test->pw;
1986 for (
int y = 0; y <
h; y++) {
1987 for (
int x = 0; x <
w; x++) {
1988 uint32_t pc =
AV_RB24(colorchart_presets[
preset].colors[y *
w + x]);
1993 x * pw, y *
ph, pw,
ph);
2002 const int w = colorchart_presets[
preset].w;
2003 const int h = colorchart_presets[
preset].h;
2007 test->draw_once = 1;
2008 test->fill_picture_fn = colorchart_fill_picture;
2012 static const AVFilterPad avfilter_vsrc_colorchart_outputs[] = {
2016 .config_props = colorchart_config_props,
2021 .
name =
"colorchart",
2024 .priv_class = &colorchart_class,
2025 .
init = colorchart_init,
2035 #if CONFIG_ZONEPLATE_FILTER
2037 static const AVOption zoneplate_options[] = {
2060 #define ZONEPLATE_SLICE(name, type) \
2061 static int zoneplate_fill_slice_##name(AVFilterContext *ctx, \
2062 void *arg, int job, \
2065 TestSourceContext *test = ctx->priv; \
2066 AVFrame *frame = arg; \
2067 const int w = frame->width; \
2068 const int h = frame->height; \
2069 const int kxt = test->kxt, kyt = test->kyt, kx2 = test->kx2; \
2070 const int t = test->pts + test->to, k0 = test->k0; \
2071 const int kt = test->kt, kt2 = test->kt2, ky2 = test->ky2; \
2072 const int ky = test->ky, kx = test->kx, kxy = test->kxy; \
2073 const int lut_mask = (1 << test->lut_precision) - 1; \
2074 const int nkt2t = kt2 * t * t, nktt = kt * t; \
2075 const int start = (h * job ) / nb_jobs; \
2076 const int end = (h * (job+1)) / nb_jobs; \
2077 const ptrdiff_t ylinesize = frame->linesize[0] / sizeof(type); \
2078 const ptrdiff_t ulinesize = frame->linesize[1] / sizeof(type); \
2079 const ptrdiff_t vlinesize = frame->linesize[2] / sizeof(type); \
2080 const int xreset = -(w / 2) - test->xo; \
2081 const int yreset = -(h / 2) - test->yo + start; \
2082 const int kU = test->kU, kV = test->kV; \
2083 const int skxy = 0xffff / (w / 2); \
2084 const int skx2 = 0xffff / w; \
2085 const int dkxt = kxt * t; \
2086 type *ydst = ((type *)frame->data[0]) + start * ylinesize; \
2087 type *udst = ((type *)frame->data[1]) + start * ulinesize; \
2088 type *vdst = ((type *)frame->data[2]) + start * vlinesize; \
2089 const type *lut = (const type *)test->lut; \
2090 int akx, akxt, aky, akyt; \
2093 akyt = start * kyt * t; \
2095 for (int j = start, y = yreset; j < end; j++, y++) { \
2096 const int dkxy = kxy * y * skxy; \
2097 const int nky2kt2 = (ky2 * y * y) / h + (nkt2t >> 1); \
2098 int akxy = dkxy * xreset; \
2105 for (int i = 0, x = xreset; i < w; i++, x++) { \
2106 int phase = k0, uphase = kU, vphase = kV; \
2109 phase += akx + aky + nktt; \
2113 phase += akxt + akyt; \
2114 phase += akxy >> 16; \
2115 phase += ((kx2 * x * x * skx2) >> 16) + nky2kt2; \
2119 ydst[i] = lut[phase & lut_mask]; \
2120 udst[i] = lut[uphase & lut_mask]; \
2121 vdst[i] = lut[vphase & lut_mask]; \
2124 ydst += ylinesize; \
2125 udst += ulinesize; \
2126 vdst += vlinesize; \
2132 ZONEPLATE_SLICE( 8, uint8_t)
2133 ZONEPLATE_SLICE( 9, uint16_t)
2134 ZONEPLATE_SLICE(10, uint16_t)
2135 ZONEPLATE_SLICE(12, uint16_t)
2136 ZONEPLATE_SLICE(14, uint16_t)
2137 ZONEPLATE_SLICE(16, uint16_t)
2146 static int zoneplate_config_props(
AVFilterLink *outlink)
2151 const int lut_size = 1 <<
test->lut_precision;
2152 const int depth =
desc->comp[0].depth;
2164 lut16 = (uint16_t *)
test->lut;
2167 for (
int i = 0;
i < lut_size;
i++)
2171 for (
int i = 0;
i < lut_size;
i++)
2172 lut16[
i] =
lrintf(((1 << depth) - 1) * (0.5f + 0.5f *
sinf((2.
f *
M_PI *
i) / lut_size)));
2176 test->draw_once = 0;
2177 test->fill_picture_fn = zoneplate_fill_picture;
2180 case 8:
test->fill_slice_fn = zoneplate_fill_slice_8;
break;
2181 case 9:
test->fill_slice_fn = zoneplate_fill_slice_9;
break;
2182 case 10:
test->fill_slice_fn = zoneplate_fill_slice_10;
break;
2183 case 12:
test->fill_slice_fn = zoneplate_fill_slice_12;
break;
2184 case 14:
test->fill_slice_fn = zoneplate_fill_slice_14;
break;
2185 case 16:
test->fill_slice_fn = zoneplate_fill_slice_16;
break;
2205 static const AVFilterPad avfilter_vsrc_zoneplate_outputs[] = {
2209 .config_props = zoneplate_config_props,
2214 .
name =
"zoneplate",
2217 .priv_class = &zoneplate_class,