History

avfilter/vsrc_testsrc: add planar support to rgbtestsrc

Paul B Mahol committed 5 years ago

Commit 79f2bca1 parent 1ed6b801 file · +30 −3Browse files

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

Unified · Split

libavfilter/vsrc_testsrc.c+30−3
@@ -77,6 +77,7 @@ typedef struct TestSourceContext { · 76 unmodified lines
7777
7878 /* only used by rgbtest */
7979 uint8_t rgba_map[4];
80+ int depth;
8081
8182 /* only used by haldclut */
8283 int level;
@@ -970,12 +971,15 @@ AVFILTER_DEFINE_CLASS(rgbtestsrc); · 887 unmodified lines
970971 #define B 2
971972 #define A 3
972973
973−static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize,
974+static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],
974975 int x, int y, unsigned r, unsigned g, unsigned b, enum AVPixelFormat fmt,
975976 uint8_t rgba_map[4])
976977 {
978+ uint8_t *dst = dstp[0];
979+ int dst_linesize = dst_linesizep[0];
977980 uint32_t v;
978981 uint8_t *p;
982+ uint16_t *p16;
979983
980984 switch (fmt) {
981985 case AV_PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4); break;
@@ -998,6 +1002,25 @@ static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize, · 16 unmodified lines
9981002 p = dst + 4*x + y*dst_linesize;
9991003 AV_WL32(p, v);
10001004 break;
1005+ case AV_PIX_FMT_GBRP:
1006+ p = dstp[0] + x + y * dst_linesizep[0];
1007+ p[0] = g;
1008+ p = dstp[1] + x + y * dst_linesizep[1];
1009+ p[0] = b;
1010+ p = dstp[2] + x + y * dst_linesizep[2];
1011+ p[0] = r;
1012+ case AV_PIX_FMT_GBRP9:
1013+ case AV_PIX_FMT_GBRP10:
1014+ case AV_PIX_FMT_GBRP12:
1015+ case AV_PIX_FMT_GBRP14:
1016+ case AV_PIX_FMT_GBRP16:
1017+ p16 = (uint16_t *)(dstp[0] + x*2 + y * dst_linesizep[0]);
1018+ p16[0] = g;
1019+ p16 = (uint16_t *)(dstp[1] + x*2 + y * dst_linesizep[1]);
1020+ p16[0] = b;
1021+ p16 = (uint16_t *)(dstp[2] + x*2 + y * dst_linesizep[2]);
1022+ p16[0] = r;
1023+ break;
10011024 }
10021025 }
10031026
@@ -1008,14 +1031,14 @@ static void rgbtest_fill_picture(AVFilterContext *ctx, AVFrame *frame) · 4 unmodified lines
10081031
10091032 for (y = 0; y < h; y++) {
10101033 for (x = 0; x < w; x++) {
1011− int c = 256*x/w;
1034+ int c = (1 << FFMAX(test->depth, 8))*x/w;
10121035 int r = 0, g = 0, b = 0;
10131036
10141037 if (3*y < h ) r = c;
10151038 else if (3*y < 2*h) g = c;
10161039 else b = c;
10171040
1018− rgbtest_put_pixel(frame->data[0], frame->linesize[0], x, y, r, g, b,
1041+ rgbtest_put_pixel(frame->data, frame->linesize, x, y, r, g, b,
10191042 ctx->outputs[0]->format, test->rgba_map);
10201043 }
10211044 }
@@ -1038,6 +1061,8 @@ static int rgbtest_query_formats(AVFilterContext *ctx) · 16 unmodified lines
10381061 AV_PIX_FMT_RGB444, AV_PIX_FMT_BGR444,
10391062 AV_PIX_FMT_RGB565, AV_PIX_FMT_BGR565,
10401063 AV_PIX_FMT_RGB555, AV_PIX_FMT_BGR555,
1064+ AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
1065+ AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
10411066 AV_PIX_FMT_NONE
10421067 };
10431068
@@ -1050,7 +1075,9 @@ static int rgbtest_query_formats(AVFilterContext *ctx) · 6 unmodified lines
10501075 static int rgbtest_config_props(AVFilterLink *outlink)
10511076 {
10521077 TestSourceContext *test = outlink->src->priv;
1078+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
10531079
1080+ test->depth = desc->comp[0].depth;
10541081 ff_fill_rgba_map(test->rgba_map, outlink->format);
10551082 return config_props(outlink);
10561083 }

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