87 #define OFFSET(x) offsetof(TestSourceContext, x) 88 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM 89 #define FLAGSR AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM 91 #define SIZE_OPTIONS \ 92 { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\ 93 { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\ 95 #define COMMON_OPTIONS_NOSIZE \ 96 { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS },\ 97 { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS },\ 98 { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },\ 99 { "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },\ 100 { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX, FLAGS }, 102 #define COMMON_OPTIONS SIZE_OPTIONS COMMON_OPTIONS_NOSIZE 104 #define NOSIZE_OPTIONS_OFFSET 2 138 outlink->
w = test->
w;
139 outlink->
h = test->
h;
193 #if CONFIG_COLOR_FILTER 195 static const AVOption color_options[] = {
209 0, 0, test->
w, test->
h);
245 static int color_process_command(
AVFilterContext *ctx,
const char *cmd,
const char *args,
246 char *res,
int res_len,
int flags)
264 .config_props = color_config_props,
272 .priv_class = &color_class,
285 #if CONFIG_HALDCLUTSRC_FILTER 287 static const AVOption haldclutsrc_options[] = {
297 int i, j, k, x = 0, y = 0, is16bit = 0,
step;
302 const int w = frame->
width;
305 const int linesize = frame->
linesize[0];
330 scale = ((float)(1 << (8*(is16bit+1))) - 1) / (level*level - 1);
332 #define LOAD_CLUT(nbits) do { \ 333 uint##nbits##_t *dst = ((uint##nbits##_t *)(data + y*linesize)) + x*step; \ 334 dst[rgba_map[0]] = av_clip_uint##nbits(i * scale); \ 335 dst[rgba_map[1]] = av_clip_uint##nbits(j * scale); \ 336 dst[rgba_map[2]] = av_clip_uint##nbits(k * scale); \ 338 dst[rgba_map[3]] = alpha; \ 342 for (k = 0; k <
level; k++) {
343 for (j = 0; j <
level; j++) {
344 for (i = 0; i <
level; i++) {
385 static int haldclutsrc_config_props(
AVFilterLink *outlink)
398 .config_props = haldclutsrc_config_props,
404 .
name =
"haldclutsrc",
406 .priv_class = &haldclutsrc_class,
408 .
init = haldclutsrc_init,
413 .
outputs = haldclutsrc_outputs,
417 #if CONFIG_NULLSRC_FILTER 419 #define nullsrc_options options 444 .init = nullsrc_init,
448 .priv_class = &nullsrc_class,
455 #if CONFIG_TESTSRC_FILTER 457 static const AVOption testsrc_options[] = {
479 int x,
int y,
int w,
int h)
484 dst += segment_width * (step * x + y * dst_linesize);
485 w *= segment_width *
step;
487 for (i = 0; i <
h; i++) {
493 static void draw_digit(
int digit,
uint8_t *dst,
int dst_linesize,
499 #define LEFT_TOP_VBAR 8 500 #define LEFT_BOT_VBAR 16 501 #define RIGHT_TOP_VBAR 32 502 #define RIGHT_BOT_VBAR 64 514 static const unsigned char masks[10] = {
515 TOP_HBAR |BOT_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
516 RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
517 TOP_HBAR|MID_HBAR|BOT_HBAR|LEFT_BOT_VBAR |RIGHT_TOP_VBAR,
518 TOP_HBAR|MID_HBAR|BOT_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
519 MID_HBAR |LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
520 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_BOT_VBAR,
521 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR |RIGHT_BOT_VBAR,
522 TOP_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
523 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
524 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
526 unsigned mask = masks[digit];
533 segments[i].x, segments[i].y, segments[i].
w, segments[i].
h);
536 #define GRADIENT_SIZE (6 * 256) 543 int color, color_rest;
547 int dquad_x, dquad_y;
548 int grad, dgrad, rgrad, drgrad;
557 radius = (width +
height) / 4;
558 quad0 = width * width / 4 + height * height / 4 - radius * radius;
561 for (y = 0; y <
height; y++) {
567 for (x = 0; x <
width; x++) {
573 *(p++) = icolor & 1 ? 255 : 0;
574 *(p++) = icolor & 2 ? 255 : 0;
575 *(p++) = icolor & 4 ? 255 : 0;
577 if (color_rest >= width) {
588 p0 = p = data + frame->
linesize[0] * (height * 3/4);
592 dgrad = GRADIENT_SIZE /
width;
593 drgrad = GRADIENT_SIZE %
width;
594 for (x = 0; x <
width; x++) {
596 grad < 256 || grad >= 5 * 256 ? 255 :
597 grad >= 2 * 256 && grad < 4 * 256 ? 0 :
598 grad < 2 * 256 ? 2 * 256 - 1 - grad : grad - 4 * 256;
600 grad >= 4 * 256 ? 0 :
601 grad >= 1 * 256 && grad < 3 * 256 ? 255 :
602 grad < 1 * 256 ? grad : 4 * 256 - 1 - grad;
605 grad >= 3 * 256 && grad < 5 * 256 ? 255 :
606 grad < 3 * 256 ? grad - 2 * 256 : 6 * 256 - 1 - grad;
609 if (rgrad >= GRADIENT_SIZE) {
611 rgrad -= GRADIENT_SIZE;
613 if (grad >= GRADIENT_SIZE)
614 grad -= GRADIENT_SIZE;
617 for (y = height / 8; y > 0; y--) {
618 memcpy(p+frame->
linesize[0], p, 3 * width);
623 seg_size = width / 80;
624 if (seg_size >= 1 && height >= 13 * seg_size) {
625 int64_t p10decimals = 1;
635 x = width - (width - seg_size * 64) / 2;
636 y = (height - seg_size * 13) / 2;
637 p = data + (x*3 + y * frame->
linesize[0]);
638 for (i = 0; i < 8; i++) {
639 p -= 3 * 8 * seg_size;
640 draw_digit(second % 10, p, frame->
linesize[0], seg_size);
668 static const AVFilterPad avfilter_vsrc_testsrc_outputs[] = {
681 .priv_class = &testsrc_class,
687 .
outputs = avfilter_vsrc_testsrc_outputs,
692 #if CONFIG_TESTSRC2_FILTER 694 static const AVOption testsrc2_options[] = {
704 uint8_t rgba[4] = { (argb >> 16) & 0xFF,
707 (argb >> 24) & 0xFF, };
711 static uint32_t color_gradient(
unsigned index)
713 unsigned si = index & 0xFF, sd = 0xFF - si;
714 switch (index >> 8) {
715 case 0:
return 0xFF0000 + (si << 8);
716 case 1:
return 0x00FF00 + (sd << 16);
717 case 2:
return 0x00FF00 + (si << 0);
718 case 3:
return 0x0000FF + (sd << 8);
719 case 4:
return 0x0000FF + (si << 16);
720 case 5:
return 0xFF0000 + (sd << 0);
726 int x0,
int y0,
const uint8_t *text)
730 for (; *text; text++) {
751 unsigned i, x = 0, x2;
754 for (i = 1; i < 7; i++) {
757 set_color(s, &color, ((i & 1) ? 0xFF0000 : 0) |
758 ((i & 2) ? 0x00FF00 : 0) |
759 ((i & 4) ? 0x0000FF : 0) |
762 x, 0, x2 - x, frame->
height);
770 unsigned x, dx, y0, y, g0,
g;
775 for (x = 0; x < s->
w; x += dx) {
776 g = (
av_rescale(x, 6 * 256, s->
w) + g0) % (6 * 256);
777 set_color(s, &color, color_gradient(g) |
alpha);
779 y %= 2 * (s->
h - 16);
781 y = 2 * (s->
h - 16) - y;
789 if (s->
w >= 64 && s->
h >= 64) {
790 int l = (
FFMIN(s->
w, s->
h) - 32) >> 1;
791 int steps =
FFMAX(4, l >> 5);
792 int xc = (s->
w >> 2) + (s->
w >> 1);
793 int yc = (s->
h >> 2);
798 for (c = 0; c < 3; c++) {
799 set_color(s, &color, (0xBBBBBB ^ (0xFF << (c << 3))) |
alpha);
801 xh = pos < 1 * l ? pos :
803 pos < 3 * l ? 3 * l - pos : 0;
804 yh = pos < 1 * l ? 0 :
805 pos < 2 * l ? pos - l :
810 for (i = 1; i <= steps; i++) {
822 if (s->
w >= 64 && s->
h >= 64) {
823 int l = (
FFMIN(s->
w, s->
h) - 16) >> 2;
825 int xc = (s->
w >> 2);
826 int yc = (s->
h >> 2) + (s->
h >> 1);
838 step = (step >> 1) & 3;
839 set_color(s, &color, 0xFF808080);
844 if (step == 0 || step == 2)
846 x1, ym1, x2 - x1, ym2 - ym1);
847 if (step == 1 || step == 2)
849 xm1, y1, xm2 - xm1, y2 - y1);
852 x1, y1, x2 - x1, y2 - y1);
865 for (y = ymin; y + 15 < ymax; y += 16) {
866 for (x = xmin; x + 15 < xmax; x += 16) {
869 for (i = 0; i < 256; i++) {
870 r = r * 1664525 + 1013904223;
873 set_color(s, &color, 0xFF00FF80);
876 alpha, 16, 16, 16, 3, 0, x, y);
882 if (s->
w >= 16 && s->
h >= 16) {
883 unsigned w = s->
w - 8;
884 unsigned h = s->
h - 8;
893 set_color(s, &color, 0xFF8000FF);
904 set_color(s, &color, 0xC0000000);
908 set_color(s, &color, 0xFFFF8000);
909 snprintf(buf,
sizeof(buf),
"%02d:%02d:%02d.%03d\n%12"PRIi64,
910 time / 3600000, (time / 60000) % 60, (time / 1000) % 60,
911 time % 1000, s->
pts);
941 static const AVFilterPad avfilter_vsrc_testsrc2_outputs[] = {
945 .config_props = test2_config_props,
954 .priv_class = &testsrc2_class,
960 .
outputs = avfilter_vsrc_testsrc2_outputs,
965 #if CONFIG_RGBTESTSRC_FILTER 967 static const AVOption rgbtestsrc_options[] = {
981 static void rgbtest_put_pixel(
uint8_t *dstp[4],
int dst_linesizep[4],
986 int dst_linesize = dst_linesizep[0];
992 case AV_PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
r >> 4) << 8) | ((
g >> 4) << 4) | (
b >> 4);
break;
993 case AV_PIX_FMT_RGB444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
b >> 4) << 8) | ((
g >> 4) << 4) | (
r >> 4);
break;
994 case AV_PIX_FMT_BGR555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
r>>3)<<10) | ((
g>>3)<<5) | (
b>>3);
break;
995 case AV_PIX_FMT_RGB555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
b>>3)<<10) | ((
g>>3)<<5) | (
r>>3);
break;
996 case AV_PIX_FMT_BGR565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
r>>3)<<11) | ((
g>>2)<<5) | (
b>>3);
break;
997 case AV_PIX_FMT_RGB565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
b>>3)<<11) | ((
g>>2)<<5) | (
r>>3);
break;
1000 v = (
r << (rgba_map[
R]*8)) + (
g << (rgba_map[
G]*8)) + (
b << (rgba_map[
B]*8));
1001 p = dst + 3*x + y*dst_linesize;
1008 v = (
r << (rgba_map[
R]*8)) + (
g << (rgba_map[
G]*8)) + (
b << (rgba_map[
B]*8)) + (255
U << (rgba_map[
A]*8));
1009 p = dst + 4*x + y*dst_linesize;
1013 p = dstp[0] + x + y * dst_linesizep[0];
1015 p = dstp[1] + x + y * dst_linesizep[1];
1017 p = dstp[2] + x + y * dst_linesizep[2];
1025 p16 = (uint16_t *)(dstp[0] + x*2 + y * dst_linesizep[0]);
1027 p16 = (uint16_t *)(dstp[1] + x*2 + y * dst_linesizep[1]);
1029 p16 = (uint16_t *)(dstp[2] + x*2 + y * dst_linesizep[2]);
1040 for (y = 0; y <
h; y++) {
1041 for (x = 0; x <
w; x++) {
1043 int r = 0,
g = 0,
b = 0;
1045 if (6*y < h ) r =
c;
1046 else if (6*y < 2*h)
g =
c,
b =
c;
1047 else if (6*y < 3*h)
g =
c;
1048 else if (6*y < 4*h) r =
c, b =
c;
1049 else if (6*y < 5*h) b =
c;
1052 rgbtest_put_pixel(frame->
data, frame->
linesize, x, y, r, g, b,
1063 for (y = 0; y <
h; y++) {
1064 for (x = 0; x <
w; x++) {
1066 int r = 0,
g = 0,
b = 0;
1068 if (3*y < h ) r =
c;
1069 else if (3*y < 2*h)
g =
c;
1116 static const AVFilterPad avfilter_vsrc_rgbtestsrc_outputs[] = {
1120 .config_props = rgbtest_config_props,
1126 .
name =
"rgbtestsrc",
1129 .priv_class = &rgbtestsrc_class,
1130 .
init = rgbtest_init,
1135 .
outputs = avfilter_vsrc_rgbtestsrc_outputs,
1140 #if CONFIG_YUVTESTSRC_FILTER 1142 #define yuvtestsrc_options options 1150 const int mid = 1 << (desc->
comp[0].
depth - 1);
1154 int ylinesize = frame->
linesize[0];
1155 int ulinesize = frame->
linesize[1];
1156 int vlinesize = frame->
linesize[2];
1158 for (y = 0; y <
h; y++) {
1159 for (x = 0; x <
w; x++) {
1160 int c = factor * x /
w;
1173 for (; y <
h; y++) {
1174 for (x = 0; x <
w; x++) {
1175 int c = factor * x /
w;
1187 for (; y < frame->
height; y++) {
1188 for (x = 0; x <
w; x++) {
1189 int c = factor * x /
w;
1207 const int mid = 1 << (desc->
comp[0].
depth - 1);
1208 uint16_t *ydst = (uint16_t *)frame->
data[0];
1209 uint16_t *udst = (uint16_t *)frame->
data[1];
1210 uint16_t *vdst = (uint16_t *)frame->
data[2];
1211 int ylinesize = frame->
linesize[0] / 2;
1212 int ulinesize = frame->
linesize[1] / 2;
1213 int vlinesize = frame->
linesize[2] / 2;
1215 for (y = 0; y <
h; y++) {
1216 for (x = 0; x <
w; x++) {
1217 int c = factor * x /
w;
1230 for (; y <
h; y++) {
1231 for (x = 0; x <
w; x++) {
1232 int c = factor * x /
w;
1244 for (; y < frame->
height; y++) {
1245 for (x = 0; x <
w; x++) {
1246 int c = factor * x /
w;
1292 static const AVFilterPad avfilter_vsrc_yuvtestsrc_outputs[] = {
1296 .config_props = yuvtest_config_props,
1302 .
name =
"yuvtestsrc",
1305 .priv_class = &yuvtestsrc_class,
1306 .
init = yuvtest_init,
1311 .
outputs = avfilter_vsrc_yuvtestsrc_outputs,
1316 #if CONFIG_PAL75BARS_FILTER || CONFIG_PAL100BARS_FILTER || CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER 1318 static const uint8_t rainbow[7][4] = {
1319 { 180, 128, 128, 255 },
1320 { 162, 44, 142, 255 },
1321 { 131, 156, 44, 255 },
1322 { 112, 72, 58, 255 },
1323 { 84, 184, 198, 255 },
1324 { 65, 100, 212, 255 },
1325 { 35, 212, 114, 255 },
1328 static const uint8_t rainbow100[7][4] = {
1329 { 235, 128, 128, 255 },
1330 { 210, 16, 146, 255 },
1331 { 170, 166, 16, 255 },
1332 { 145, 54, 34, 255 },
1333 { 106, 202, 222, 255 },
1334 { 81, 90, 240, 255 },
1335 { 41, 240, 110, 255 },
1338 static const uint8_t rainbowhd[7][4] = {
1339 { 180, 128, 128, 255 },
1340 { 168, 44, 136, 255 },
1341 { 145, 147, 44, 255 },
1342 { 133, 63, 52, 255 },
1343 { 63, 193, 204, 255 },
1344 { 51, 109, 212, 255 },
1345 { 28, 212, 120, 255 },
1348 static const uint8_t wobnair[7][4] = {
1349 { 35, 212, 114, 255 },
1350 { 19, 128, 128, 255 },
1351 { 84, 184, 198, 255 },
1352 { 19, 128, 128, 255 },
1353 { 131, 156, 44, 255 },
1354 { 19, 128, 128, 255 },
1355 { 180, 128, 128, 255 },
1358 static const uint8_t white[4] = { 235, 128, 128, 255 };
1361 static const uint8_t neg4ire[4] = { 7, 128, 128, 255 };
1362 static const uint8_t pos4ire[4] = { 24, 128, 128, 255 };
1365 static const uint8_t i_pixel[4] = { 57, 156, 97, 255 };
1366 static const uint8_t q_pixel[4] = { 44, 171, 147, 255 };
1368 static const uint8_t gray40[4] = { 104, 128, 128, 255 };
1369 static const uint8_t gray15[4] = { 49, 128, 128, 255 };
1370 static const uint8_t cyan[4] = { 188, 154, 16, 255 };
1371 static const uint8_t yellow[4] = { 219, 16, 138, 255 };
1372 static const uint8_t blue[4] = { 32, 240, 118, 255 };
1373 static const uint8_t red[4] = { 63, 102, 240, 255 };
1374 static const uint8_t black0[4] = { 16, 128, 128, 255 };
1375 static const uint8_t black2[4] = { 20, 128, 128, 255 };
1376 static const uint8_t black4[4] = { 25, 128, 128, 255 };
1377 static const uint8_t neg2[4] = { 12, 128, 128, 255 };
1380 int x,
int y,
int w,
int h,
1387 x =
FFMIN(x, test->
w - 1);
1388 y =
FFMIN(y, test->
h - 1);
1395 for (plane = 0; frame->
data[plane]; plane++) {
1396 const int c = color[plane];
1397 const int linesize = frame->
linesize[plane];
1398 int i, px, py, pw, ph;
1400 if (plane == 1 || plane == 2) {
1412 p0 = p = frame->
data[plane] + py * linesize + px;
1415 for (i = 1; i < ph; i++, p += linesize)
1444 #if CONFIG_PAL75BARS_FILTER 1446 #define pal75bars_options options 1460 draw_bar(test, white, x, 0, r_w, test->
h, picref);
1462 for (i = 1; i < 7; i++) {
1463 draw_bar(test, rainbow[i], x, 0, r_w, test->
h, picref);
1466 draw_bar(test, black0, x, 0, r_w, test->
h, picref);
1479 .
name =
"pal75bars",
1482 .priv_class = &pal75bars_class,
1483 .
init = pal75bars_init,
1493 #if CONFIG_PAL100BARS_FILTER 1495 #define pal100bars_options options 1509 for (i = 0; i < 7; i++) {
1510 draw_bar(test, rainbow100[i], x, 0, r_w, test->
h, picref);
1513 draw_bar(test, black0, x, 0, r_w, test->
h, picref);
1526 .
name =
"pal100bars",
1529 .priv_class = &pal100bars_class,
1530 .
init = pal100bars_init,
1540 #if CONFIG_SMPTEBARS_FILTER 1542 #define smptebars_options options 1548 int r_w, r_h, w_h, p_w, p_h,
i,
tmp, x = 0;
1557 p_h = test->
h - w_h - r_h;
1559 for (i = 0; i < 7; i++) {
1560 draw_bar(test, rainbow[i], x, 0, r_w, r_h, picref);
1561 draw_bar(test, wobnair[i], x, r_h, r_w, w_h, picref);
1565 draw_bar(test, i_pixel, x, r_h + w_h, p_w, p_h, picref);
1567 draw_bar(test, white, x, r_h + w_h, p_w, p_h, picref);
1569 draw_bar(test, q_pixel, x, r_h + w_h, p_w, p_h, picref);
1572 draw_bar(test, black0, x, r_h + w_h, tmp, p_h, picref);
1575 draw_bar(test, neg4ire, x, r_h + w_h, tmp, p_h, picref);
1577 draw_bar(test, black0, x, r_h + w_h, tmp, p_h, picref);
1579 draw_bar(test, pos4ire, x, r_h + w_h, tmp, p_h, picref);
1581 draw_bar(test, black0, x, r_h + w_h, test->
w - x, p_h, picref);
1594 .
name =
"smptebars",
1597 .priv_class = &smptebars_class,
1598 .
init = smptebars_init,
1608 #if CONFIG_SMPTEHDBARS_FILTER 1610 #define smptehdbars_options options 1616 int d_w, r_w, r_h, l_w,
i,
tmp, x = 0, y = 0;
1623 draw_bar(test, gray40, x, 0, d_w, r_h, picref);
1627 for (i = 0; i < 7; i++) {
1628 draw_bar(test, rainbowhd[i], x, 0, r_w, r_h, picref);
1631 draw_bar(test, gray40, x, 0, test->
w - x, r_h, picref);
1634 draw_bar(test, cyan, 0, y, d_w, r_h, picref);
1636 draw_bar(test, i_pixel, x, y, r_w, r_h, picref);
1639 draw_bar(test, rainbowhd[0], x, y, tmp, r_h, picref);
1642 draw_bar(test, blue, x, y, test->
w - x, r_h, picref);
1644 draw_bar(test, yellow, 0, y, d_w, r_h, picref);
1646 draw_bar(test, q_pixel, x, y, r_w, r_h, picref);
1652 yramp[0] = i * 255 /
tmp;
1657 draw_bar(test, yramp, x, y, 1 << pixdesc->
log2_chroma_w, r_h, picref);
1660 draw_bar(test, red, x, y, test->
w - x, r_h, picref);
1662 draw_bar(test, gray15, 0, y, d_w, test->
h - y, picref);
1665 draw_bar(test, black0, x, y, tmp, test->
h - y, picref);
1668 draw_bar(test, white, x, y, tmp, test->
h - y, picref);
1671 draw_bar(test, black0, x, y, tmp, test->
h - y, picref);
1674 draw_bar(test, neg2, x, y, tmp, test->
h - y, picref);
1676 draw_bar(test, black0, x, y, tmp, test->
h - y, picref);
1678 draw_bar(test, black2, x, y, tmp, test->
h - y, picref);
1680 draw_bar(test, black0, x, y, tmp, test->
h - y, picref);
1682 draw_bar(test, black4, x, y, tmp, test->
h - y, picref);
1685 draw_bar(test, black0, x, y, r_w, test->
h - y, picref);
1687 draw_bar(test, gray15, x, y, test->
w - x, test->
h - y, picref);
1700 .
name =
"smptehdbars",
1703 .priv_class = &smptehdbars_class,
1704 .
init = smptehdbars_init,
1715 #if CONFIG_ALLYUV_FILTER 1717 #define allyuv_options &options[NOSIZE_OPTIONS_OFFSET] 1727 for (y = 0; y < 4096; y++) {
1728 for (x = 0; x < 2048; x++) {
1729 frame->
data[0][y * ys + x] = ((x / 8) % 256);
1730 frame->
data[0][y * ys + 4095 - x] = ((x / 8) % 256);
1733 for (x = 0; x < 2048; x+=8) {
1734 for (j = 0; j < 8; j++) {
1735 frame->
data[1][vs * y + x + j] = (y%16 + (j % 8) * 16);
1736 frame->
data[1][vs * y + 4095 - x - j] = (128 + y%16 + (j % 8) * 16);
1740 for (x = 0; x < 4096; x++)
1741 frame->
data[2][y * us + x] = 256 * y / 4096;
1749 test->
w = test->
h = 4096;
1768 static const AVFilterPad avfilter_vsrc_allyuv_outputs[] = {
1781 .priv_class = &allyuv_class,
1782 .
init = allyuv_init,
1787 .
outputs = avfilter_vsrc_allyuv_outputs,
1792 #if CONFIG_ALLRGB_FILTER 1794 #define allrgb_options &options[NOSIZE_OPTIONS_OFFSET] 1800 const int linesize = frame->
linesize[0];
1803 for (y = 0; y < 4096; y++) {
1806 for (x = 0; x < 4096; x++) {
1809 *dst++ = (x >> 8) | ((y >> 8) << 4);
1819 test->
w = test->
h = 4096;
1845 static const AVFilterPad avfilter_vsrc_allrgb_outputs[] = {
1849 .config_props = allrgb_config_props,
1858 .priv_class = &allrgb_class,
1859 .
init = allrgb_init,
1864 .
outputs = avfilter_vsrc_allrgb_outputs,
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
AVFilter ff_vsrc_smptehdbars
ptrdiff_t const GLvoid * data
#define AV_PIX_FMT_YUV444P14
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Main libavfilter public API header.
packed RGB 8:8:8, 24bpp, RGBRGB...
#define AV_PIX_FMT_RGBA64
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
int h
agreed upon image height
static void draw_rectangle(AVFormatContext *s)
#define AV_PIX_FMT_GBRP10
AVFilter ff_vsrc_pal100bars
#define us(width, name, range_min, range_max, subs,...)
static av_cold void uninit(AVFilterContext *ctx)
#define AV_PIX_FMT_BGRA64
#define COMMON_OPTIONS_NOSIZE
const uint8_t avpriv_vga16_font[4096]
#define FF_ARRAY_ELEMS(a)
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
int draw_once
draw only the first frame, always put out the same picture
#define AV_PIX_FMT_RGB444
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
static av_cold int init(AVFilterContext *ctx)
int ff_draw_round_to_sub(FFDrawContext *draw, int sub_dir, int round_dir, int value)
Round a dimension according to subsampling.
const char * name
Pad name.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int draw_once_reset
draw only the first frame or in case of reset
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_PIX_FMT_YUV444P16
int interlaced_frame
The content of the picture is interlaced.
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function.If this function returns true
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0, will be automatically copied from the first input of the source filter if it exists.
AVFilter ff_vsrc_pal75bars
static const uint16_t mask[17]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options...
void * priv
private data for use by the filter
int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel for the pixel format described by pixdesc, including any padding ...
enum AVColorRange color_range
MPEG vs JPEG YUV range.
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
enum AVColorSpace colorspace
YUV colorspace type.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert().
#define AV_PIX_FMT_YUV444P10
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
AVRational sar
sample aspect ratio
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
enum AVPictureType pict_type
Picture type of the frame.
#define AV_PIX_FMT_GBRP16
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
int64_t duration
duration expressed in microseconds
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
static int config_props(AVFilterLink *outlink)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
packed RGB 8:8:8, 24bpp, BGRBGR...
AVFilterContext * src
source filter
AVFilter ff_vsrc_testsrc2
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_GBRP14
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
static const AVFilterPad outputs[]
int format
agreed upon media format
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, const uint8_t *mask, int mask_linesize, int mask_w, int mask_h, int l2depth, unsigned endianness, int x0, int y0)
Blend an alpha mask with an uniform color.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
#define AV_PIX_FMT_BGR555
void(* fill_picture_fn)(AVFilterContext *ctx, AVFrame *frame)
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static void draw_text(FFDrawContext *draw, AVFrame *frame, FFDrawColor *color, int x0, int y0, const uint8_t *text, int vertical)
static void test(const char *pattern, const char *host)
static AVRational av_make_q(int num, int den)
Create an AVRational.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
AVFilter ff_vsrc_haldclutsrc
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, int x0, int y0, int w, int h)
Blend a rectangle with an uniform color.
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
static const int factor[16]
const char * name
Filter name.
int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
Init a draw context.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilter ff_vsrc_smptebars
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
#define AV_PIX_FMT_BGR565
#define AV_PIX_FMT_GBRP12
#define flags(name, subs,...)
AVFilter ff_vsrc_yuvtestsrc
#define AV_PIX_FMT_YUV444P12
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int activate(AVFilterContext *ctx)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Narrow or limited range content.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
internal math functions header
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
The official guide to swscale for confused that consecutive non overlapping rectangles of slice_bottom special converter These generally are unscaled converters of common like for each output line the vertical scaler pulls lines from a ring buffer When the ring buffer does not contain the wanted line
static int query_formats(AVFilterContext *ctx)
common internal and external API header
#define AV_PIX_FMT_BGR444
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
static const AVOption options[]
#define AV_PIX_FMT_RGB555
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define AVFILTER_DEFINE_CLASS(fname)
int key_frame
1 -> keyframe, 0-> not
#define AV_PIX_FMT_RGB565
void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_x, int dst_y, int w, int h)
Fill a rectangle with an uniform color.
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
int depth
Number of bits in the component.
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
AVFrame * picref
cached reference containing the painted picture
AVPixelFormat
Pixel format.
static double val(void *priv, double ch)
AVFilter ff_vsrc_rgbtestsrc
CGA/EGA/VGA ROM font data.
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
#define AV_CEIL_RSHIFT(a, b)