Skip to content

Commit cd1ec35

Browse files
committed
avfilter/vsrc_testsrc: also fill alpha planes with a test pattern in {rgb,yuv}testsrc
And add support for more formats. Signed-off-by: James Almer <[email protected]>
1 parent ca48e7b commit cd1ec35

File tree

5 files changed

+58
-30
lines changed

5 files changed

+58
-30
lines changed

libavfilter/vsrc_testsrc.c

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ AVFILTER_DEFINE_CLASS(rgbtestsrc);
988988
#define A 3
989989

990990
static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],
991-
int x, int y, unsigned r, unsigned g, unsigned b, enum AVPixelFormat fmt,
991+
int x, int y, unsigned r, unsigned g, unsigned b, unsigned a, enum AVPixelFormat fmt,
992992
uint8_t rgba_map[4])
993993
{
994994
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
@@ -1027,13 +1027,13 @@ static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],
10271027
*p16++ = v16 >> 32;
10281028
*p16++ = v16 >> 16;
10291029
*p16++ = v16;
1030-
*p16++ = 0xffff;
1030+
*p16++ = a;
10311031
break;
10321032
case AV_PIX_FMT_RGBA:
10331033
case AV_PIX_FMT_BGRA:
10341034
case AV_PIX_FMT_ARGB:
10351035
case AV_PIX_FMT_ABGR:
1036-
v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)) + (255U << (rgba_map[A]*8));
1036+
v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)) + (a << (rgba_map[A]*8));
10371037
p = dst + 4*x + y*dst_linesize;
10381038
AV_WL32A(p, v);
10391039
break;
@@ -1046,6 +1046,10 @@ static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],
10461046
p = dst + 4*x + y*dst_linesize;
10471047
AV_WL32A(p, v);
10481048
break;
1049+
case AV_PIX_FMT_GBRAP:
1050+
p = dstp[3] + x + y * dst_linesizep[3];
1051+
p[0] = a;
1052+
// fall-through
10491053
case AV_PIX_FMT_GBRP:
10501054
p = dstp[0] + x + y * dst_linesize;
10511055
p[0] = g;
@@ -1054,6 +1058,13 @@ static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],
10541058
p = dstp[2] + x + y * dst_linesizep[2];
10551059
p[0] = r;
10561060
break;
1061+
case AV_PIX_FMT_GBRAP10:
1062+
case AV_PIX_FMT_GBRAP12:
1063+
case AV_PIX_FMT_GBRAP14:
1064+
case AV_PIX_FMT_GBRAP16:
1065+
p16 = (uint16_t *)(dstp[3] + x*2 + y * dst_linesizep[3]);
1066+
p16[0] = a;
1067+
// fall-through
10571068
case AV_PIX_FMT_GBRP9:
10581069
case AV_PIX_FMT_GBRP10:
10591070
case AV_PIX_FMT_GBRP12:
@@ -1086,7 +1097,7 @@ static void rgbtest_fill_picture_complement(AVFilterContext *ctx, AVFrame *frame
10861097
else if (6*y < 5*h) b = c;
10871098
else r = c, g = c;
10881099

1089-
rgbtest_put_pixel(frame->data, frame->linesize, x, y, r, g, b,
1100+
rgbtest_put_pixel(frame->data, frame->linesize, x, y, r, g, b, c,
10901101
ctx->outputs[0]->format, test->rgba_map);
10911102
}
10921103
}
@@ -1106,7 +1117,7 @@ static void rgbtest_fill_picture(AVFilterContext *ctx, AVFrame *frame)
11061117
else if (3*y < 2*h) g = c;
11071118
else b = c;
11081119

1109-
rgbtest_put_pixel(frame->data, frame->linesize, x, y, r, g, b,
1120+
rgbtest_put_pixel(frame->data, frame->linesize, x, y, r, g, b, c,
11101121
ctx->outputs[0]->format, test->rgba_map);
11111122
}
11121123
}
@@ -1131,6 +1142,8 @@ static const enum AVPixelFormat rgbtest_pix_fmts[] = {
11311142
AV_PIX_FMT_RGBA64, AV_PIX_FMT_BGRA64,
11321143
AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
11331144
AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
1145+
AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10,
1146+
AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP14, AV_PIX_FMT_GBRAP16,
11341147
AV_PIX_FMT_X2RGB10LE, AV_PIX_FMT_X2BGR10LE,
11351148
AV_PIX_FMT_NONE
11361149
};
@@ -1180,7 +1193,7 @@ const FFFilter ff_vsrc_rgbtestsrc = {
11801193
#define A 3
11811194

11821195
static void yuvtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],
1183-
int i, int j, unsigned y, unsigned u, unsigned v, enum AVPixelFormat fmt,
1196+
int i, int j, unsigned y, unsigned u, unsigned v, unsigned a, enum AVPixelFormat fmt,
11841197
uint8_t ayuv_map[4])
11851198
{
11861199
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
@@ -1201,25 +1214,38 @@ static void yuvtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],
12011214
break;
12021215
case AV_PIX_FMT_XV36:
12031216
case AV_PIX_FMT_XV48:
1217+
a = UINT16_MAX;
1218+
// fall-through
12041219
case AV_PIX_FMT_AYUV64:
12051220
AV_WN16A(&dstp[0][i*8 + ayuv_map[Y]*2 + j*dst_linesizep[0]], y << desc->comp[0].shift);
12061221
AV_WN16A(&dstp[0][i*8 + ayuv_map[U]*2 + j*dst_linesizep[0]], u << desc->comp[1].shift);
12071222
AV_WN16A(&dstp[0][i*8 + ayuv_map[V]*2 + j*dst_linesizep[0]], v << desc->comp[2].shift);
1208-
AV_WN16A(&dstp[0][i*8 + ayuv_map[A]*2 + j*dst_linesizep[0]], UINT16_MAX << desc->comp[3].shift);
1223+
AV_WN16A(&dstp[0][i*8 + ayuv_map[A]*2 + j*dst_linesizep[0]], a << desc->comp[3].shift);
12091224
break;
1225+
case AV_PIX_FMT_VUYX:
1226+
a = UINT8_MAX;
1227+
// fall-through
12101228
case AV_PIX_FMT_UYVA:
12111229
case AV_PIX_FMT_VUYA:
1212-
case AV_PIX_FMT_VUYX:
12131230
case AV_PIX_FMT_AYUV:
1214-
n = (y << (ayuv_map[Y]*8)) + (u << (ayuv_map[U]*8)) + (v << (ayuv_map[V]*8)) + (255U << (ayuv_map[A]*8));
1231+
n = (y << (ayuv_map[Y]*8)) + (u << (ayuv_map[U]*8)) + (v << (ayuv_map[V]*8)) + (a << (ayuv_map[A]*8));
12151232
AV_WL32A(&dstp[0][i*4 + j*dst_linesizep[0]], n);
12161233
break;
1234+
case AV_PIX_FMT_YUVA444P:
1235+
dstp[3][i + j*dst_linesizep[3]] = a;
1236+
// fall-through
12171237
case AV_PIX_FMT_YUV444P:
12181238
case AV_PIX_FMT_YUVJ444P:
12191239
dstp[0][i + j*dst_linesizep[0]] = y;
12201240
dstp[1][i + j*dst_linesizep[1]] = u;
12211241
dstp[2][i + j*dst_linesizep[2]] = v;
12221242
break;
1243+
case AV_PIX_FMT_YUVA444P9:
1244+
case AV_PIX_FMT_YUVA444P10:
1245+
case AV_PIX_FMT_YUVA444P12:
1246+
case AV_PIX_FMT_YUVA444P16:
1247+
AV_WN16A(&dstp[3][i*2 + j*dst_linesizep[3]], a);
1248+
// fall-through
12231249
case AV_PIX_FMT_YUV444P9:
12241250
case AV_PIX_FMT_YUV444P10:
12251251
case AV_PIX_FMT_YUV444P12:
@@ -1266,7 +1292,7 @@ static void yuvtest_fill_picture(AVFilterContext *ctx, AVFrame *frame)
12661292
else if (3*j < 2*h) u = c;
12671293
else v = c;
12681294

1269-
yuvtest_put_pixel(frame->data, frame->linesize, i, j, y, u, v,
1295+
yuvtest_put_pixel(frame->data, frame->linesize, i, j, y, u, v, c,
12701296
ctx->outputs[0]->format, test->ayuv_map);
12711297
}
12721298
}
@@ -1286,6 +1312,8 @@ static const enum AVPixelFormat yuvtest_pix_fmts[] = {
12861312
AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUV444P10,
12871313
AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV444P14,
12881314
AV_PIX_FMT_YUV444P16, AV_PIX_FMT_VYU444,
1315+
AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA444P9,
1316+
AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
12891317
AV_PIX_FMT_AYUV, AV_PIX_FMT_UYVA, AV_PIX_FMT_AYUV64,
12901318
AV_PIX_FMT_VUYA, AV_PIX_FMT_VUYX, AV_PIX_FMT_XV48,
12911319
AV_PIX_FMT_XV30LE, AV_PIX_FMT_V30XLE, AV_PIX_FMT_XV36,

tests/ref/fate/filter-rgbtestsrc-rgba

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#codec_id 0: rawvideo
44
#dimensions 0: 320x240
55
#sar 0: 1/1
6-
0, 0, 0, 1, 307200, 0xf238fe31
7-
0, 1, 1, 1, 307200, 0xf238fe31
8-
0, 2, 2, 1, 307200, 0xf238fe31
9-
0, 3, 3, 1, 307200, 0xf238fe31
10-
0, 4, 4, 1, 307200, 0xf238fe31
6+
0, 0, 0, 1, 307200, 0x546b3176
7+
0, 1, 1, 1, 307200, 0x546b3176
8+
0, 2, 2, 1, 307200, 0x546b3176
9+
0, 3, 3, 1, 307200, 0x546b3176
10+
0, 4, 4, 1, 307200, 0x546b3176

tests/ref/fate/filter-yuvtestsrc-ayuv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#codec_id 0: rawvideo
44
#dimensions 0: 320x240
55
#sar 0: 1/1
6-
0, 0, 0, 1, 307200, 0xd4270fd4
7-
0, 1, 1, 1, 307200, 0xd4270fd4
8-
0, 2, 2, 1, 307200, 0xd4270fd4
9-
0, 3, 3, 1, 307200, 0xd4270fd4
10-
0, 4, 4, 1, 307200, 0xd4270fd4
6+
0, 0, 0, 1, 307200, 0xcffc430a
7+
0, 1, 1, 1, 307200, 0xcffc430a
8+
0, 2, 2, 1, 307200, 0xcffc430a
9+
0, 3, 3, 1, 307200, 0xcffc430a
10+
0, 4, 4, 1, 307200, 0xcffc430a

tests/ref/fate/filter-yuvtestsrc-ayuv64

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#codec_id 0: rawvideo
44
#dimensions 0: 320x240
55
#sar 0: 1/1
6-
0, 0, 0, 1, 614400, 0xcf4f8452
7-
0, 1, 1, 1, 614400, 0xcf4f8452
8-
0, 2, 2, 1, 614400, 0xcf4f8452
9-
0, 3, 3, 1, 614400, 0xcf4f8452
10-
0, 4, 4, 1, 614400, 0xcf4f8452
6+
0, 0, 0, 1, 614400, 0x8722610b
7+
0, 1, 1, 1, 614400, 0x8722610b
8+
0, 2, 2, 1, 614400, 0x8722610b
9+
0, 3, 3, 1, 614400, 0x8722610b
10+
0, 4, 4, 1, 614400, 0x8722610b

tests/ref/fate/filter-yuvtestsrc-vuya

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#codec_id 0: rawvideo
44
#dimensions 0: 320x240
55
#sar 0: 1/1
6-
0, 0, 0, 1, 307200, 0x4df60fd4
7-
0, 1, 1, 1, 307200, 0x4df60fd4
8-
0, 2, 2, 1, 307200, 0x4df60fd4
9-
0, 3, 3, 1, 307200, 0x4df60fd4
10-
0, 4, 4, 1, 307200, 0x4df60fd4
6+
0, 0, 0, 1, 307200, 0xb01a430a
7+
0, 1, 1, 1, 307200, 0xb01a430a
8+
0, 2, 2, 1, 307200, 0xb01a430a
9+
0, 3, 3, 1, 307200, 0xb01a430a
10+
0, 4, 4, 1, 307200, 0xb01a430a

0 commit comments

Comments
 (0)