36#include "config_components.h"
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
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 },\
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 },
119#define COMMON_OPTIONS SIZE_OPTIONS COMMON_OPTIONS_NOSIZE
121#define NOSIZE_OPTIONS_OFFSET 2
139 test->duration < 0 ? -1 : (
double)
test->duration/1000000,
157 outlink->
w =
test->w;
158 outlink->
h =
test->h;
182 if (
test->duration >= 0 &&
188 if (
test->draw_once) {
189 if (
test->draw_once_reset) {
191 test->draw_once_reset = 0;
212 if (!
test->draw_once)
221#if CONFIG_COLOR_FILTER
223static const AVOption color_options[] = {
243 test->fill_picture_fn = color_fill_picture;
278static int color_process_command(
AVFilterContext *
ctx,
const char *cmd,
const char *args,
279 char *res,
int res_len,
int flags)
289 test->draw_once_reset = 1;
297 .config_props = color_config_props,
304 .p.priv_class = &color_class,
311 .process_command = color_process_command,
316#if CONFIG_HALDCLUTSRC_FILTER
318static const AVOption haldclutsrc_options[] = {
328 int i, j, k, x = 0, y = 0, is16bit = 0, step;
333 const int w =
frame->width;
334 const int h =
frame->height;
336 const ptrdiff_t linesize =
frame->linesize[0];
338 const int depth =
desc->comp[0].depth;
347 alpha = (1 << depth) - 1;
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); \
359 dst[rgba_map[3]] = alpha; \
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); \
370 dst = ((type *)(frame->data[3] + y*linesize)) + x; \
376 for (k = 0; k <
level; k++) {
377 for (j = 0; j <
level; j++) {
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;
428static int haldclutsrc_config_props(
AVFilterLink *outlink)
441 .config_props = haldclutsrc_config_props,
446 .p.name =
"haldclutsrc",
448 .p.priv_class = &haldclutsrc_class,
450 .
init = haldclutsrc_init,
460#if CONFIG_NULLSRC_FILTER
468 test->fill_picture_fn = nullsrc_fill_picture;
475 .p.priv_class= &nullsrc_yuvtestsrc_class,
476 .init = nullsrc_init,
485#if CONFIG_TESTSRC_FILTER
487static const AVOption testsrc_options[] = {
508static void draw_rectangle(
unsigned val, uint8_t *
dst, ptrdiff_t dst_linesize,
int segment_width,
509 int x,
int y,
int w,
int h)
514 dst += segment_width * (step * x + y * dst_linesize);
515 w *= segment_width * step;
517 for (
i = 0;
i <
h;
i++) {
523static void draw_digit(
int digit, uint8_t *
dst, ptrdiff_t dst_linesize,
529#define LEFT_TOP_VBAR 8
530#define LEFT_BOT_VBAR 16
531#define RIGHT_TOP_VBAR 32
532#define RIGHT_BOT_VBAR 64
544 static const unsigned char masks[10] = {
545 TOP_HBAR |BOT_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
546 RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
547 TOP_HBAR|MID_HBAR|BOT_HBAR|LEFT_BOT_VBAR |RIGHT_TOP_VBAR,
548 TOP_HBAR|MID_HBAR|BOT_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
549 MID_HBAR |LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
550 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_BOT_VBAR,
551 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR |RIGHT_BOT_VBAR,
552 TOP_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
553 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
554 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
556 unsigned mask = masks[digit];
563 segments[
i].x, segments[
i].y, segments[
i].
w, segments[
i].
h);
566#define GRADIENT_SIZE (6 * 256)
573 int color, color_rest;
577 int dquad_x, dquad_y;
578 int grad, dgrad, rgrad, drgrad;
591 for (y = 0; y <
height; y++) {
597 for (x = 0; x <
width; x++) {
603 *(
p++) = icolor & 1 ? 255 : 0;
604 *(
p++) = icolor & 2 ? 255 : 0;
605 *(
p++) = icolor & 4 ? 255 : 0;
607 if (color_rest >=
width) {
614 p0 +=
frame->linesize[0];
622 dgrad = GRADIENT_SIZE /
width;
623 drgrad = GRADIENT_SIZE %
width;
624 for (x = 0; x <
width; x++) {
627 grad >= 2 * 256 &&
grad < 4 * 256 ? 0 :
630 grad >= 4 * 256 ? 0 :
631 grad >= 1 * 256 &&
grad < 3 * 256 ? 255 :
635 grad >= 3 * 256 &&
grad < 5 * 256 ? 255 :
639 if (rgrad >= GRADIENT_SIZE) {
641 rgrad -= GRADIENT_SIZE;
643 if (
grad >= GRADIENT_SIZE)
644 grad -= GRADIENT_SIZE;
647 for (y =
height / 8; y > 0; y--) {
653 seg_size =
width / 80;
654 if (seg_size >= 1 &&
height >= 13 * seg_size) {
661 for (x = 0; x <
test->nb_decimals; x++)
666 y = (
height - seg_size * 13) / 2;
668 for (
i = 0;
i < 8;
i++) {
669 p -= 3 * 8 * seg_size;
670 draw_digit(second % 10, p,
frame->linesize[0], seg_size);
682 test->fill_picture_fn = test_fill_picture;
689 .p.priv_class = &testsrc_class,
702 uint8_t rgba[4] = { (argb >> 16) & 0xFF,
705 (argb >> 24) & 0xFF, };
709#if CONFIG_TESTSRC2_FILTER
711static const AVOption testsrc2_options[] = {
719static 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)
739 for (; *text; text++) {
747 &
vga16_font[*text * 16], 1, 8, 16, 0, 0, x, y0);
756 unsigned alpha = (uint32_t)
s->alpha << 24;
760 unsigned i, x = 0, x2;
763 for (
i = 1;
i < 7;
i++) {
767 ((
i & 2) ? 0x00FF00 : 0) |
768 ((
i & 4) ? 0x0000FF : 0) |
771 x, 0, x2 - x,
frame->height);
779 unsigned x, dx, y0, y, g0,
g;
784 for (x = 0; x <
s->w; x += dx) {
788 y %= 2 * (
s->h - 16);
790 y = 2 * (
s->h - 16) - y;
798 if (
s->w >= 64 &&
s->h >= 64) {
799 int l = (
FFMIN(
s->w,
s->h) - 32) >> 1;
801 int xc = (
s->w >> 2) + (
s->w >> 1);
802 int yc = (
s->h >> 2);
807 for (
c = 0;
c < 3;
c++) {
812 pos < 3 * l ? 3 * l -
pos : 0;
813 yh =
pos < 1 * l ? 0 :
831 if (
s->w >= 64 &&
s->h >= 64) {
832 int l = (
FFMIN(
s->w,
s->h) - 16) >> 2;
834 int xc = (
s->w >> 2);
835 int yc = (
s->h >> 2) + (
s->h >> 1);
840 int size, step, x1, x2, y1, y2;
847 step = (step >> 1) & 3;
853 if (step == 0 || step == 2)
855 x1, ym1, x2 - x1, ym2 - ym1);
856 if (step == 1 || step == 2)
858 xm1, y1, xm2 - xm1, y2 - y1);
861 x1, y1, x2 - x1, y2 - y1);
874 for (y = ymin; y + 15 < ymax; y += 16) {
875 for (x = xmin; x + 15 < xmax; x += 16) {
878 for (
i = 0;
i < 256;
i++) {
879 r =
r * 1664525 + 1013904223;
885 alpha, 16, 16, 16, 3, 0, x, y);
891 if (
s->w >= 16 &&
s->h >= 16) {
892 unsigned w =
s->w - 8;
893 unsigned h =
s->h - 8;
918 snprintf(buf,
sizeof(buf),
"%02d:%02d:%02d.%03d\n%12"PRIi64,
919 time / 3600000, (time / 60000) % 60, (time / 1000) % 60,
920 time % 1000,
s->pts);
928 s->fill_picture_fn = test2_fill_picture;
952static const AVFilterPad avfilter_vsrc_testsrc2_outputs[] = {
956 .config_props = test2_config_props,
961 .p.name =
"testsrc2",
963 .p.priv_class = &testsrc2_class,
974#if CONFIG_RGBTESTSRC_FILTER
976static const AVOption rgbtestsrc_options[] = {
990static 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,
995 uint8_t *
dst = dstp[0];
996 ptrdiff_t dst_linesize = dst_linesizep[0];
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;
1011 v = (
r << (rgba_map[
R]*8)) + (
g << (rgba_map[
G]*8)) + (
b << (rgba_map[
B]*8));
1012 p =
dst + 3*x + y*dst_linesize;
1017 v16 = ((uint64_t)
r << (rgba_map[
R]*16)) + ((uint64_t)
g << (rgba_map[
G]*16)) + ((uint64_t)
b << (rgba_map[
B]*16));
1018 p16 = (uint16_t *)(
dst + 6*x + y*dst_linesize);
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);
1036 v = (
r << (rgba_map[
R]*8)) + (
g << (rgba_map[
G]*8)) + (
b << (rgba_map[
B]*8)) + (
a << (rgba_map[
A]*8));
1037 p =
dst + 4*x + y*dst_linesize;
1042 v = (
r << ((
desc->comp[0].offset*8) +
desc->comp[0].shift)) +
1043 (
g << ((
desc->comp[1].offset*8) +
desc->comp[1].shift)) +
1044 (
b << ((
desc->comp[2].offset*8) +
desc->comp[2].shift)) +
1045 (3U << ((
desc->comp[3].offset*8) +
desc->comp[3].shift));
1046 p =
dst + 4*x + y*dst_linesize;
1050 p = dstp[3] + x + y * dst_linesizep[3];
1054 p = dstp[0] + x + y * dst_linesize;
1056 p = dstp[1] + x + y * dst_linesizep[1];
1058 p = dstp[2] + x + y * dst_linesizep[2];
1065 p16 = (uint16_t *)(dstp[3] + x*2 + y * dst_linesizep[3]);
1073 p16 = (uint16_t *)(dstp[0] + x*2 + y * dst_linesizep[0]);
1075 p16 = (uint16_t *)(dstp[1] + x*2 + y * dst_linesizep[1]);
1077 p16 = (uint16_t *)(dstp[2] + x*2 + y * dst_linesizep[2]);
1088 for (y = 0; y <
h; y++) {
1089 for (x = 0; x <
w; x++) {
1091 int r = 0,
g = 0,
b = 0;
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;
1100 rgbtest_put_pixel(
frame->data,
frame->linesize, x, y,
r,
g,
b,
c,
1101 ctx->outputs[0]->format,
test->rgba_map);
1111 for (y = 0; y <
h; y++) {
1112 for (x = 0; x <
w; x++) {
1114 int r = 0,
g = 0,
b = 0;
1116 if (3*y <
h )
r =
c;
1117 else if (3*y < 2*
h)
g =
c;
1120 rgbtest_put_pixel(
frame->data,
frame->linesize, x, y,
r,
g,
b,
c,
1121 ctx->outputs[0]->format,
test->rgba_map);
1130 test->draw_once = 1;
1131 test->fill_picture_fn =
test->complement ? rgbtest_fill_picture_complement : rgbtest_fill_picture;
1161static const AVFilterPad avfilter_vsrc_rgbtestsrc_outputs[] = {
1165 .config_props = rgbtest_config_props,
1170 .p.name =
"rgbtestsrc",
1172 .p.priv_class = &rgbtestsrc_class,
1174 .
init = rgbtest_init,
1188#if CONFIG_YUVTESTSRC_FILTER
1195static 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])
1204 n = (y << (ayuv_map[
Y]*8)) + (
u << (ayuv_map[
U]*8)) + (v << (ayuv_map[
V]*8));
1205 AV_WL24(&dstp[0][
i*3 + j*dst_linesizep[0]], n);
1209 n = (y << ((
desc->comp[0].offset*8) +
desc->comp[0].shift)) +
1210 (
u << ((
desc->comp[1].offset*8) +
desc->comp[1].shift)) +
1211 (v << ((
desc->comp[2].offset*8) +
desc->comp[2].shift)) +
1212 (3U << ((
desc->comp[3].offset*8) +
desc->comp[3].shift));
1213 AV_WL32A(&dstp[0][
i*4 + j*dst_linesizep[0]], n);
1220 AV_WN16A(&dstp[0][
i*8 + ayuv_map[
Y]*2 + j*dst_linesizep[0]], y <<
desc->comp[0].shift);
1221 AV_WN16A(&dstp[0][
i*8 + ayuv_map[
U]*2 + j*dst_linesizep[0]],
u <<
desc->comp[1].shift);
1222 AV_WN16A(&dstp[0][
i*8 + ayuv_map[
V]*2 + j*dst_linesizep[0]], v <<
desc->comp[2].shift);
1223 AV_WN16A(&dstp[0][
i*8 + ayuv_map[
A]*2 + j*dst_linesizep[0]],
a <<
desc->comp[3].shift);
1231 n = (y << (ayuv_map[
Y]*8)) + (
u << (ayuv_map[
U]*8)) + (v << (ayuv_map[
V]*8)) + (
a << (ayuv_map[
A]*8));
1232 AV_WL32A(&dstp[0][
i*4 + j*dst_linesizep[0]], n);
1235 dstp[3][
i + j*dst_linesizep[3]] =
a;
1239 dstp[0][
i + j*dst_linesizep[0]] = y;
1240 dstp[1][
i + j*dst_linesizep[1]] =
u;
1241 dstp[2][
i + j*dst_linesizep[2]] = v;
1247 AV_WN16A(&dstp[3][
i*2 + j*dst_linesizep[3]],
a);
1254 AV_WN16A(&dstp[0][
i*2 + j*dst_linesizep[0]], y);
1255 AV_WN16A(&dstp[1][
i*2 + j*dst_linesizep[1]],
u);
1256 AV_WN16A(&dstp[2][
i*2 + j*dst_linesizep[2]], v);
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);
1265 dstp[0][
i + j*dst_linesizep[0] + 0] = y;
1266 dstp[1][
i*2 + j*dst_linesizep[1] + 0] =
u;
1267 dstp[1][
i*2 + j*dst_linesizep[1] + 1] = v;
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;
1277 AV_WN16A(&dstp[0][
i*2 + j*dst_linesizep[0] + 0], y << (16 -
desc->comp[0].depth));
1278 AV_WN16A(&dstp[1][
i*4 + j*dst_linesizep[1] + 0],
u << (16 -
desc->comp[1].depth));
1279 AV_WN16A(&dstp[1][
i*4 + j*dst_linesizep[1] + 2], v << (16 -
desc->comp[1].depth));
1290 const int mid = 1 << (
desc->comp[0].depth - 1);
1292 for (j = 0; j <
h; j++) {
1293 for (
i = 0;
i <
w;
i++) {
1295 int y = mid,
u = mid, v = mid;
1297 if (3*j <
h ) y =
c;
1298 else if (3*j < 2*
h)
u =
c;
1301 yuvtest_put_pixel(
frame->data,
frame->linesize,
i, j, y,
u, v,
c,
1302 ctx->outputs[0]->format,
test->ayuv_map);
1311 test->draw_once = 1;
1312 test->fill_picture_fn = yuvtest_fill_picture;
1340static const AVFilterPad avfilter_vsrc_yuvtestsrc_outputs[] = {
1344 .config_props = yuvtest_config_props,
1349 .p.name =
"yuvtestsrc",
1351 .p.priv_class = &nullsrc_yuvtestsrc_class,
1353 .
init = yuvtest_init,
1367#if CONFIG_PAL75BARS_FILTER || CONFIG_PAL100BARS_FILTER || CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER
1369static const uint8_t rainbow[7][4] = {
1370 { 180, 128, 128, 255 },
1371 { 162, 44, 142, 255 },
1372 { 131, 156, 44, 255 },
1373 { 112, 72, 58, 255 },
1374 { 84, 184, 198, 255 },
1375 { 65, 100, 212, 255 },
1376 { 35, 212, 114, 255 },
1379static const uint8_t rainbow100[7][4] = {
1380 { 235, 128, 128, 255 },
1381 { 210, 16, 146, 255 },
1382 { 170, 166, 16, 255 },
1383 { 145, 54, 34, 255 },
1384 { 106, 202, 222, 255 },
1385 { 81, 90, 240, 255 },
1386 { 41, 240, 110, 255 },
1389static const uint8_t rainbowhd[7][4] = {
1390 { 180, 128, 128, 255 },
1391 { 168, 44, 136, 255 },
1392 { 145, 147, 44, 255 },
1393 { 133, 63, 52, 255 },
1394 { 63, 193, 204, 255 },
1395 { 51, 109, 212, 255 },
1396 { 28, 212, 120, 255 },
1399static const uint8_t wobnair[7][4] = {
1400 { 35, 212, 114, 255 },
1401 { 19, 128, 128, 255 },
1402 { 84, 184, 198, 255 },
1403 { 19, 128, 128, 255 },
1404 { 131, 156, 44, 255 },
1405 { 19, 128, 128, 255 },
1406 { 180, 128, 128, 255 },
1409static const uint8_t white[4] = { 235, 128, 128, 255 };
1412static const uint8_t neg4ire[4] = { 7, 128, 128, 255 };
1413static const uint8_t pos4ire[4] = { 24, 128, 128, 255 };
1416static const uint8_t i_pixel[4] = { 57, 156, 97, 255 };
1417static const uint8_t q_pixel[4] = { 44, 171, 147, 255 };
1419static const uint8_t gray40[4] = { 104, 128, 128, 255 };
1420static const uint8_t gray15[4] = { 49, 128, 128, 255 };
1421static const uint8_t cyan[4] = { 188, 154, 16, 255 };
1422static const uint8_t yellow[4] = { 219, 16, 138, 255 };
1423static const uint8_t blue[4] = { 32, 240, 118, 255 };
1424static const uint8_t red[4] = { 63, 102, 240, 255 };
1425static const uint8_t black0[4] = { 16, 128, 128, 255 };
1426static const uint8_t black2[4] = { 20, 128, 128, 255 };
1427static const uint8_t black4[4] = { 25, 128, 128, 255 };
1428static const uint8_t neg2[4] = { 12, 128, 128, 255 };
1431 int x,
int y,
int w,
int h,
1446 for (plane = 0;
frame->data[plane]; plane++) {
1447 const int c =
color[plane];
1448 const ptrdiff_t linesize =
frame->linesize[plane];
1449 int i, px, py, pw,
ph;
1451 if (plane == 1 || plane == 2) {
1452 px = x >>
desc->log2_chroma_w;
1454 py = y >>
desc->log2_chroma_h;
1463 p0 =
p =
frame->data[plane] + py * linesize + px;
1466 for (
i = 1;
i <
ph;
i++,
p += linesize)
1485 if (!strcmp(
ctx->name,
"smptehdbars")) {
1502#if CONFIG_PAL75BARS_FILTER
1514 for (
i = 1;
i < 7;
i++) {
1525 test->fill_picture_fn = pal75bars_fill_picture;
1526 test->draw_once = 1;
1531 .p.name =
"pal75bars",
1533 .p.priv_class = &palbars_class,
1535 .
init = pal75bars_init,
1544#if CONFIG_PAL100BARS_FILTER
1554 for (
i = 0;
i < 7;
i++) {
1565 test->fill_picture_fn = pal100bars_fill_picture;
1566 test->draw_once = 1;
1571 .p.name =
"pal100bars",
1573 .p.priv_class = &palbars_class,
1575 .
init = pal100bars_init,
1586#if CONFIG_SMPTEBARS_FILTER
1591 int r_w, r_h, w_h, p_w, p_h,
i,
tmp, x = 0;
1598 p_h =
test->h - w_h - r_h;
1600 for (
i = 0;
i < 7;
i++) {
1606 draw_bar(
test, i_pixel, x, r_h + w_h, p_w, p_h, picref);
1610 draw_bar(
test, q_pixel, x, r_h + w_h, p_w, p_h, picref);
1629 test->fill_picture_fn = smptebars_fill_picture;
1630 test->draw_once = 1;
1635 .p.name =
"smptebars",
1637 .p.priv_class = &smptebars_class,
1639 .
init = smptebars_init,
1648#if CONFIG_SMPTEHDBARS_FILTER
1653 int d_w, r_w, r_h, l_w,
i,
tmp, x = 0, y = 0;
1662 for (
i = 0;
i < 7;
i++) {
1685 uint8_t yramp[4] = {0};
1687 yramp[0] =
i * 255 /
tmp;
1729 test->fill_picture_fn = smptehdbars_fill_picture;
1730 test->draw_once = 1;
1735 .p.name =
"smptehdbars",
1737 .p.priv_class = &smptebars_class,
1739 .
init = smptehdbars_init,
1752#if CONFIG_ALLYUV_FILTER
1756 const ptrdiff_t ys =
frame->linesize[0];
1757 const ptrdiff_t
us =
frame->linesize[1];
1758 const ptrdiff_t vs =
frame->linesize[2];
1761 for (y = 0; y < 4096; y++) {
1762 for (x = 0; x < 2048; x++) {
1763 frame->data[0][y * ys + x] = ((x / 8) % 256);
1764 frame->data[0][y * ys + 4095 - x] = ((x / 8) % 256);
1767 for (x = 0; x < 2048; x+=8) {
1768 for (j = 0; j < 8; j++) {
1769 frame->data[1][vs * y + x + j] = (y%16 + (j % 8) * 16);
1770 frame->data[1][vs * y + 4095 - x - j] = (128 + y%16 + (j % 8) * 16);
1774 for (x = 0; x < 4096; x++)
1775 frame->data[2][y *
us + x] = 256 * y / 4096;
1784 test->draw_once = 1;
1785 test->fill_picture_fn = allyuv_fill_picture;
1792 .p.priv_class = &allyuv_allrgb_class,
1794 .
init = allyuv_init,
1803#if CONFIG_ALLRGB_FILTER
1808 const ptrdiff_t linesize =
frame->linesize[0];
1811 for (y = 0; y < 4096; y++) {
1814 for (x = 0; x < 4096; x++) {
1817 *
dst++ = (x >> 8) | ((y >> 8) << 4);
1828 test->draw_once = 1;
1829 test->fill_picture_fn = allrgb_fill_picture;
1841static const AVFilterPad avfilter_vsrc_allrgb_outputs[] = {
1845 .config_props = allrgb_config_props,
1852 .p.priv_class = &allyuv_allrgb_class,
1854 .
init = allrgb_init,
1863#if CONFIG_COLORSPECTRUM_FILTER
1865static const AVOption colorspectrum_options[] = {
1876static inline float mix(
float a,
float b,
float mix)
1881static void hsb2rgb(
const float *
c,
float *
rgb)
1894 const float w =
frame->width - 1.f;
1895 const float h =
frame->height - 1.f;
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;
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;
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++) {
1924 test->draw_once = 1;
1925 test->fill_picture_fn = colorspectrum_fill_picture;
1930 .p.name =
"colorspectrum",
1932 .p.priv_class = &colorspectrum_class,
1934 .
init = colorspectrum_init,
1943#if CONFIG_COLORCHART_FILTER
1945static const AVOption colorchart_options[] = {
1956static const uint8_t reference_colors[][3] = {
1986static const uint8_t skintones_colors[][3] = {
2016typedef struct ColorChartPreset {
2018 const uint8_t (*colors)[3];
2021static const ColorChartPreset colorchart_presets[] = {
2022 { 6, 4, reference_colors, },
2023 { 6, 4, skintones_colors, },
2026static int colorchart_config_props(
AVFilterLink *inlink)
2041 const int w = colorchart_presets[
preset].w;
2042 const int h = colorchart_presets[
preset].h;
2043 const int pw =
test->pw;
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]);
2053 x * pw, y *
ph, pw,
ph);
2062 const int w = colorchart_presets[
preset].w;
2063 const int h = colorchart_presets[
preset].h;
2067 test->draw_once = 1;
2068 test->fill_picture_fn = colorchart_fill_picture;
2072static const AVFilterPad avfilter_vsrc_colorchart_outputs[] = {
2076 .config_props = colorchart_config_props,
2081 .p.name =
"colorchart",
2083 .p.priv_class = &colorchart_class,
2085 .
init = colorchart_init,
2094#if CONFIG_ZONEPLATE_FILTER
2096static const AVOption zoneplate_options[] = {
2119#define ZONEPLATE_SLICE(name, type) \
2120static int zoneplate_fill_slice_##name(AVFilterContext *ctx, \
2121 void *arg, int job, \
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; \
2152 akyt = start * kyt * t; \
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; \
2164 for (int i = 0, x = xreset; i < w; i++, x++) { \
2165 int phase = k0, uphase = kU, vphase = kV; \
2168 phase += akx + aky + nktt; \
2172 phase += akxt + akyt; \
2173 phase += akxy >> 16; \
2174 phase += ((kx2 * x * x * skx2) >> 16) + nky2kt2; \
2178 ydst[i] = lut[phase & lut_mask]; \
2179 udst[i] = lut[uphase & lut_mask]; \
2180 vdst[i] = lut[vphase & lut_mask]; \
2183 ydst += ylinesize; \
2184 udst += ulinesize; \
2185 vdst += vlinesize; \
2191ZONEPLATE_SLICE( 8, uint8_t)
2192ZONEPLATE_SLICE( 9, uint16_t)
2193ZONEPLATE_SLICE(10, uint16_t)
2194ZONEPLATE_SLICE(12, uint16_t)
2195ZONEPLATE_SLICE(14, uint16_t)
2196ZONEPLATE_SLICE(16, uint16_t)
2205static int zoneplate_config_props(
AVFilterLink *outlink)
2210 const int lut_size = 1 <<
test->lut_precision;
2211 const int depth =
desc->comp[0].depth;
2223 lut16 = (uint16_t *)
test->lut;
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)));
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)));
2235 test->draw_once = 0;
2236 test->fill_picture_fn = zoneplate_fill_picture;
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;
2267static const AVFilterPad avfilter_vsrc_zoneplate_outputs[] = {
2271 .config_props = zoneplate_config_props,
2276 .p.name =
"zoneplate",
2278 .p.priv_class = &zoneplate_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double val(void *priv, double ch)
static const AVFilterPad outputs[]
const FFFilter ff_vsrc_allrgb
const FFFilter ff_vsrc_smptebars
const FFFilter ff_vsrc_colorspectrum
const FFFilter ff_vsrc_haldclutsrc
const FFFilter ff_vsrc_testsrc2
const FFFilter ff_vsrc_rgbtestsrc
const FFFilter ff_vsrc_smptehdbars
const FFFilter ff_vsrc_color
const FFFilter ff_vsrc_pal100bars
const FFFilter ff_vsrc_colorchart
const FFFilter ff_vsrc_allyuv
const FFFilter ff_vsrc_pal75bars
const FFFilter ff_vsrc_yuvtestsrc
const FFFilter ff_vsrc_zoneplate
const FFFilter ff_vsrc_nullsrc
const FFFilter ff_vsrc_testsrc
static AVFormatContext * ctx
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi > >8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1<< 16)) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi > >24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi > >56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(UINT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out->ch+ch,(const uint8_t **) in->ch+ch, off *(out-> planar
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void draw_bar(ShowCWTContext *s, int y, float Y, float U, float V)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
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.
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Main libavfilter public API header.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int FUNC ph(CodedBitstreamContext *ctx, RWContext *rw, H266RawPH *current)
common internal and external API header
#define AV_CEIL_RSHIFT(a, b)
static __device__ float fabsf(float a)
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.
int ff_fill_ayuv_map(uint8_t *ayuv_map, enum AVPixelFormat pix_fmt)
int ff_draw_round_to_sub(FFDrawContext *draw, int sub_dir, int round_dir, int value)
Round a dimension according to subsampling.
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
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.
int ff_draw_init_from_link(FFDrawContext *draw, const AVFilterLink *link, unsigned flags)
Init a draw context, taking the format, colorspace and range from the given filter link.
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(* init)(AVBSFContext *ctx)
internal math functions header
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
#define AVERROR_EOF
End of file.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static AVRational av_make_q(int num, int den)
Create an AVRational.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
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.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AV_ROUND_ZERO
Round toward zero.
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...
@ AV_PICTURE_TYPE_I
Intra.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static const int16_t alpha[]
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
static int mix(int c0, int c1)
#define u(width, name, range_min, range_max)
#define us(width, name, range_min, range_max, subs,...)
#define FILTER_OUTPUTS(array)
#define FILTER_PIXFMTS_ARRAY(array)
#define FILTER_PIXFMTS(...)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
#define AVFILTER_DEFINE_CLASS_EXT(name, desc, options)
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
static const int factor[16]
Macro definitions for various function/variable attributes.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const struct @257111027162314367033347246032313251342043035002 planes[]
static const uint16_t mask[17]
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
static const int16_t steps[16]
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
static double grad(int hash, double x, double y, double z)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
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 ...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_GBRAP16
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_BGR444
#define AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_BGR555
#define AV_PIX_FMT_GBRAP14
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUV444P12MSB
#define AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_GBRP12
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_UYVA
packed UYVA 4:4:4:4, 32bpp (1 Cr & Cb sample per 1x1 Y & A samples), UYVAUYVA...
@ AV_PIX_FMT_V30XLE
packed VYUX 4:4:4 like XV30, 32bpp, (msb)10V 10Y 10U 2X(lsb), little-endian
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_NV42
as above, but U and V bytes are swapped
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_XV30LE
packed XVYU 4:4:4, 32bpp, (msb)2X 10V 10Y 10U(lsb), little-endian, variant of Y410 where alpha channe...
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
@ AV_PIX_FMT_VUYX
packed VUYX 4:4:4:4, 32bpp, Variant of VUYA where alpha channel is left undefined
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_X2BGR10LE
packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), little-endian, X=unused/undefined
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_NV24
planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
@ AV_PIX_FMT_AYUV
packed AYUV 4:4:4:4, 32bpp (1 Cr & Cb sample per 1x1 Y & A samples), AYUVAYUV...
@ AV_PIX_FMT_X2RGB10LE
packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), little-endian, X=unused/undefined
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_VUYA
packed VUYA 4:4:4:4, 32bpp (1 Cr & Cb sample per 1x1 Y & A samples), VUYAVUYA...
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ AV_PIX_FMT_VYU444
packed VYU 4:4:4, 24bpp (1 Cr & Cb sample per 1x1 Y), VYUVYU...
#define AV_PIX_FMT_BGR565
#define AV_PIX_FMT_RGB565
#define AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_RGB444
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10MSB
#define AV_PIX_FMT_AYUV64
#define AV_PIX_FMT_RGB555
#define AV_PIX_FMT_YUV444P10
AVColorSpace
YUV colorspace type.
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
#define FF_ARRAY_ELEMS(a)
static int config_props(AVBitStreamFilterLink *link)
static void draw_text(FFDrawContext *draw, AVFrame *out, FFDrawColor *color, int x0, int y0, const uint8_t *text)
Describe the class of an AVClass context structure.
void * priv
private data for use by the filter
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Rational number (pair of numerator and denominator).
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
AVRational sar
sample aspect ratio
int64_t duration
duration expressed in microseconds
int draw_once
draw only the first frame, always put out the same picture
int draw_once_reset
draw only the first frame or in case of reset
AVFrame * picref
cached reference containing the painted picture
void(* fill_picture_fn)(AVFilterContext *ctx, AVFrame *frame)
int(* fill_slice_fn)(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
static void test_init(void)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static av_unused void set_color(TestSourceContext *s, FFDrawColor *color, uint32_t argb)
static int config_props(AVFilterLink *outlink)
static int activate(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
#define NOSIZE_OPTIONS_OFFSET
#define COMMON_OPTIONS_NOSIZE
static void draw_rectangle(AVFormatContext *s)
const uint8_t * avpriv_vga16_font_get(void)
static const uint8_t vga16_font[4096]
CGA/EGA/VGA ROM font data.