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

Showing the changes to libavfilter (1 of 5 files). Show all

Unified · Split

libavfilter/vsrc_testsrc.c+38−10
@@ -988,7 +988,7 @@ AVFILTER_DEFINE_CLASS(rgbtestsrc); · 987 unmodified lines
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], · 32 unmodified lines
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], · 6 unmodified lines
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], · 2 unmodified lines
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 · 26 unmodified lines
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) · 13 unmodified lines
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[] = { · 18 unmodified lines
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 = { · 43 unmodified lines
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], · 14 unmodified lines
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) · 40 unmodified lines
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[] = { · 13 unmodified lines
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,

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