History

avfilter/vsrc_testsrc: also fill alpha planes with a test pattern in {rgb,yuv}testsrc

And add support for more formats.

James Almer committed 1 year ago

Commit cd1ec351 parent ca48e7b5 files · +58 −30Browse files

Unified · Split

5 files
  1. libavfilter/vsrc_testsrc.c +38 −10
  2. tests/ref/fate/filter-rgbtestsrc-rgba +5 −5
  3. tests/ref/fate/filter-yuvtestsrc-ayuv +5 −5
  4. tests/ref/fate/filter-yuvtestsrc-ayuv64 +5 −5
  5. tests/ref/fate/filter-yuvtestsrc-vuya +5 −5
libavfilter/vsrc_testsrc.c+38−10
@@ -988,7 +988,7 @@ AVFILTER_DEFINE_CLASS(rgbtestsrc); · 987 unmodified lines
988#define A 3988#define A 3
989 989
990static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],990static 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,
992 uint8_t rgba_map[4])992 uint8_t rgba_map[4])
993{993{
994 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);994 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], · 32 unmodified lines
1027 *p16++ = v16 >> 32;1027 *p16++ = v16 >> 32;
1028 *p16++ = v16 >> 16;1028 *p16++ = v16 >> 16;
1029 *p16++ = v16;1029 *p16++ = v16;
1030 *p16++ = 0xffff;1030 *p16++ = a;
1031 break;1031 break;
1032 case AV_PIX_FMT_RGBA:1032 case AV_PIX_FMT_RGBA:
1033 case AV_PIX_FMT_BGRA:1033 case AV_PIX_FMT_BGRA:
1034 case AV_PIX_FMT_ARGB:1034 case AV_PIX_FMT_ARGB:
1035 case AV_PIX_FMT_ABGR:1035 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));
1037 p = dst + 4*x + y*dst_linesize;1037 p = dst + 4*x + y*dst_linesize;
1038 AV_WL32A(p, v);1038 AV_WL32A(p, v);
1039 break;1039 break;
@@ -1046,6 +1046,10 @@ static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4], · 6 unmodified lines
1046 p = dst + 4*x + y*dst_linesize;1046 p = dst + 4*x + y*dst_linesize;
1047 AV_WL32A(p, v);1047 AV_WL32A(p, v);
1048 break;1048 break;
1049 case AV_PIX_FMT_GBRAP:
1050 p = dstp[3] + x + y * dst_linesizep[3];
1051 p[0] = a;
1052 // fall-through
1049 case AV_PIX_FMT_GBRP:1053 case AV_PIX_FMT_GBRP:
1050 p = dstp[0] + x + y * dst_linesize;1054 p = dstp[0] + x + y * dst_linesize;
1051 p[0] = g;1055 p[0] = g;
@@ -1054,6 +1058,13 @@ static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4], · 2 unmodified lines
1054 p = dstp[2] + x + y * dst_linesizep[2];1058 p = dstp[2] + x + y * dst_linesizep[2];
1055 p[0] = r;1059 p[0] = r;
1056 break;1060 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
1057 case AV_PIX_FMT_GBRP9:1068 case AV_PIX_FMT_GBRP9:
1058 case AV_PIX_FMT_GBRP10:1069 case AV_PIX_FMT_GBRP10:
1059 case AV_PIX_FMT_GBRP12:1070 case AV_PIX_FMT_GBRP12:
@@ -1086,7 +1097,7 @@ static void rgbtest_fill_picture_complement(AVFilterContext *ctx, AVFrame *frame · 26 unmodified lines
1086 else if (6*y < 5*h) b = c;1097 else if (6*y < 5*h) b = c;
1087 else r = c, g = c;1098 else r = c, g = c;
1088 1099
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,
1090 ctx->outputs[0]->format, test->rgba_map);1101 ctx->outputs[0]->format, test->rgba_map);
1091 }1102 }
1092 }1103 }
@@ -1106,7 +1117,7 @@ static void rgbtest_fill_picture(AVFilterContext *ctx, AVFrame *frame) · 13 unmodified lines
1106 else if (3*y < 2*h) g = c;1117 else if (3*y < 2*h) g = c;
1107 else b = c;1118 else b = c;
1108 1119
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,
1110 ctx->outputs[0]->format, test->rgba_map);1121 ctx->outputs[0]->format, test->rgba_map);
1111 }1122 }
1112 }1123 }
@@ -1131,6 +1142,8 @@ static const enum AVPixelFormat rgbtest_pix_fmts[] = { · 18 unmodified lines
1131 AV_PIX_FMT_RGBA64, AV_PIX_FMT_BGRA64,1142 AV_PIX_FMT_RGBA64, AV_PIX_FMT_BGRA64,
1132 AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,1143 AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
1133 AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,1144 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,
1134 AV_PIX_FMT_X2RGB10LE, AV_PIX_FMT_X2BGR10LE,1147 AV_PIX_FMT_X2RGB10LE, AV_PIX_FMT_X2BGR10LE,
1135 AV_PIX_FMT_NONE1148 AV_PIX_FMT_NONE
1136 };1149 };
@@ -1180,7 +1193,7 @@ const FFFilter ff_vsrc_rgbtestsrc = { · 43 unmodified lines
1180#define A 31193#define A 3
1181 1194
1182static void yuvtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],1195static 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,
1184 uint8_t ayuv_map[4])1197 uint8_t ayuv_map[4])
1185{1198{
1186 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);1199 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], · 14 unmodified lines
1201 break;1214 break;
1202 case AV_PIX_FMT_XV36:1215 case AV_PIX_FMT_XV36:
1203 case AV_PIX_FMT_XV48:1216 case AV_PIX_FMT_XV48:
1217 a = UINT16_MAX;
1218 // fall-through
1204 case AV_PIX_FMT_AYUV64:1219 case AV_PIX_FMT_AYUV64:
1205 AV_WN16A(&dstp[0][i*8 + ayuv_map[Y]*2 + j*dst_linesizep[0]], y << desc->comp[0].shift);1220 AV_WN16A(&dstp[0][i*8 + ayuv_map[Y]*2 + j*dst_linesizep[0]], y << desc->comp[0].shift);
1206 AV_WN16A(&dstp[0][i*8 + ayuv_map[U]*2 + j*dst_linesizep[0]], u << desc->comp[1].shift);1221 AV_WN16A(&dstp[0][i*8 + ayuv_map[U]*2 + j*dst_linesizep[0]], u << desc->comp[1].shift);
1207 AV_WN16A(&dstp[0][i*8 + ayuv_map[V]*2 + j*dst_linesizep[0]], v << desc->comp[2].shift);1222 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);
1209 break;1224 break;
1225 case AV_PIX_FMT_VUYX:
1226 a = UINT8_MAX;
1227 // fall-through
1210 case AV_PIX_FMT_UYVA:1228 case AV_PIX_FMT_UYVA:
1211 case AV_PIX_FMT_VUYA:1229 case AV_PIX_FMT_VUYA:
1212 case AV_PIX_FMT_VUYX:
1213 case AV_PIX_FMT_AYUV:1230 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));
1215 AV_WL32A(&dstp[0][i*4 + j*dst_linesizep[0]], n);1232 AV_WL32A(&dstp[0][i*4 + j*dst_linesizep[0]], n);
1216 break;1233 break;
1234 case AV_PIX_FMT_YUVA444P:
1235 dstp[3][i + j*dst_linesizep[3]] = a;
1236 // fall-through
1217 case AV_PIX_FMT_YUV444P:1237 case AV_PIX_FMT_YUV444P:
1218 case AV_PIX_FMT_YUVJ444P:1238 case AV_PIX_FMT_YUVJ444P:
1219 dstp[0][i + j*dst_linesizep[0]] = y;1239 dstp[0][i + j*dst_linesizep[0]] = y;
1220 dstp[1][i + j*dst_linesizep[1]] = u;1240 dstp[1][i + j*dst_linesizep[1]] = u;
1221 dstp[2][i + j*dst_linesizep[2]] = v;1241 dstp[2][i + j*dst_linesizep[2]] = v;
1222 break;1242 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
1223 case AV_PIX_FMT_YUV444P9:1249 case AV_PIX_FMT_YUV444P9:
1224 case AV_PIX_FMT_YUV444P10:1250 case AV_PIX_FMT_YUV444P10:
1225 case AV_PIX_FMT_YUV444P12:1251 case AV_PIX_FMT_YUV444P12:
@@ -1266,7 +1292,7 @@ static void yuvtest_fill_picture(AVFilterContext *ctx, AVFrame *frame) · 40 unmodified lines
1266 else if (3*j < 2*h) u = c;1292 else if (3*j < 2*h) u = c;
1267 else v = c;1293 else v = c;
1268 1294
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,
1270 ctx->outputs[0]->format, test->ayuv_map);1296 ctx->outputs[0]->format, test->ayuv_map);
1271 }1297 }
1272 }1298 }
@@ -1286,6 +1312,8 @@ static const enum AVPixelFormat yuvtest_pix_fmts[] = { · 13 unmodified lines
1286 AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUV444P10,1312 AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUV444P10,
1287 AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV444P14,1313 AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV444P14,
1288 AV_PIX_FMT_YUV444P16, AV_PIX_FMT_VYU444,1314 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,
1289 AV_PIX_FMT_AYUV, AV_PIX_FMT_UYVA, AV_PIX_FMT_AYUV64,1317 AV_PIX_FMT_AYUV, AV_PIX_FMT_UYVA, AV_PIX_FMT_AYUV64,
1290 AV_PIX_FMT_VUYA, AV_PIX_FMT_VUYX, AV_PIX_FMT_XV48,1318 AV_PIX_FMT_VUYA, AV_PIX_FMT_VUYX, AV_PIX_FMT_XV48,
1291 AV_PIX_FMT_XV30LE, AV_PIX_FMT_V30XLE, AV_PIX_FMT_XV36,1319 AV_PIX_FMT_XV30LE, AV_PIX_FMT_V30XLE, AV_PIX_FMT_XV36,
tests/ref/fate/filter-rgbtestsrc-rgba+5−5
@@ -3,8 +3,8 @@ · 2 unmodified lines
3#codec_id 0: rawvideo3#codec_id 0: rawvideo
4#dimensions 0: 320x2404#dimensions 0: 320x240
5#sar 0: 1/15#sar 0: 1/1
60, 0, 0, 1, 307200, 0xf238fe3160, 0, 0, 1, 307200, 0x546b3176
70, 1, 1, 1, 307200, 0xf238fe3170, 1, 1, 1, 307200, 0x546b3176
80, 2, 2, 1, 307200, 0xf238fe3180, 2, 2, 1, 307200, 0x546b3176
90, 3, 3, 1, 307200, 0xf238fe3190, 3, 3, 1, 307200, 0x546b3176
100, 4, 4, 1, 307200, 0xf238fe31100, 4, 4, 1, 307200, 0x546b3176
tests/ref/fate/filter-yuvtestsrc-ayuv+5−5
@@ -3,8 +3,8 @@ · 2 unmodified lines
3#codec_id 0: rawvideo3#codec_id 0: rawvideo
4#dimensions 0: 320x2404#dimensions 0: 320x240
5#sar 0: 1/15#sar 0: 1/1
60, 0, 0, 1, 307200, 0xd4270fd460, 0, 0, 1, 307200, 0xcffc430a
70, 1, 1, 1, 307200, 0xd4270fd470, 1, 1, 1, 307200, 0xcffc430a
80, 2, 2, 1, 307200, 0xd4270fd480, 2, 2, 1, 307200, 0xcffc430a
90, 3, 3, 1, 307200, 0xd4270fd490, 3, 3, 1, 307200, 0xcffc430a
100, 4, 4, 1, 307200, 0xd4270fd4100, 4, 4, 1, 307200, 0xcffc430a
tests/ref/fate/filter-yuvtestsrc-ayuv64+5−5
@@ -3,8 +3,8 @@ · 2 unmodified lines
3#codec_id 0: rawvideo3#codec_id 0: rawvideo
4#dimensions 0: 320x2404#dimensions 0: 320x240
5#sar 0: 1/15#sar 0: 1/1
60, 0, 0, 1, 614400, 0xcf4f845260, 0, 0, 1, 614400, 0x8722610b
70, 1, 1, 1, 614400, 0xcf4f845270, 1, 1, 1, 614400, 0x8722610b
80, 2, 2, 1, 614400, 0xcf4f845280, 2, 2, 1, 614400, 0x8722610b
90, 3, 3, 1, 614400, 0xcf4f845290, 3, 3, 1, 614400, 0x8722610b
100, 4, 4, 1, 614400, 0xcf4f8452100, 4, 4, 1, 614400, 0x8722610b
tests/ref/fate/filter-yuvtestsrc-vuya+5−5
@@ -3,8 +3,8 @@ · 2 unmodified lines
3#codec_id 0: rawvideo3#codec_id 0: rawvideo
4#dimensions 0: 320x2404#dimensions 0: 320x240
5#sar 0: 1/15#sar 0: 1/1
60, 0, 0, 1, 307200, 0x4df60fd460, 0, 0, 1, 307200, 0xb01a430a
70, 1, 1, 1, 307200, 0x4df60fd470, 1, 1, 1, 307200, 0xb01a430a
80, 2, 2, 1, 307200, 0x4df60fd480, 2, 2, 1, 307200, 0xb01a430a
90, 3, 3, 1, 307200, 0x4df60fd490, 3, 3, 1, 307200, 0xb01a430a
100, 4, 4, 1, 307200, 0x4df60fd4100, 4, 4, 1, 307200, 0xb01a430a

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t