History

avfilter/vsrc_testsrc: add planar support to rgbtestsrc

Paul B Mahol committed 5 years ago

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

Unified · Split

libavfilter/vsrc_testsrc.c+30−3
@@ -77,6 +77,7 @@ typedef struct TestSourceContext { · 76 unmodified lines
77 77
78 /* only used by rgbtest */78 /* only used by rgbtest */
79 uint8_t rgba_map[4];79 uint8_t rgba_map[4];
80 int depth;
80 81
81 /* only used by haldclut */82 /* only used by haldclut */
82 int level;83 int level;
@@ -970,12 +971,15 @@ AVFILTER_DEFINE_CLASS(rgbtestsrc); · 887 unmodified lines
970#define B 2971#define B 2
971#define A 3972#define A 3
972 973
973static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize,974static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],
974 int x, int y, unsigned r, unsigned g, unsigned b, enum AVPixelFormat fmt,975 int x, int y, unsigned r, unsigned g, unsigned b, enum AVPixelFormat fmt,
975 uint8_t rgba_map[4])976 uint8_t rgba_map[4])
976{977{
978 uint8_t *dst = dstp[0];
979 int dst_linesize = dst_linesizep[0];
977 uint32_t v;980 uint32_t v;
978 uint8_t *p;981 uint8_t *p;
982 uint16_t *p16;
979 983
980 switch (fmt) {984 switch (fmt) {
981 case AV_PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4); break;985 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
998 p = dst + 4*x + y*dst_linesize;1002 p = dst + 4*x + y*dst_linesize;
999 AV_WL32(p, v);1003 AV_WL32(p, v);
1000 break;1004 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;
1001 }1024 }
1002}1025}
1003 1026
@@ -1008,14 +1031,14 @@ static void rgbtest_fill_picture(AVFilterContext *ctx, AVFrame *frame) · 4 unmodified lines
1008 1031
1009 for (y = 0; y < h; y++) {1032 for (y = 0; y < h; y++) {
1010 for (x = 0; x < w; x++) {1033 for (x = 0; x < w; x++) {
1011 int c = 256*x/w;1034 int c = (1 << FFMAX(test->depth, 8))*x/w;
1012 int r = 0, g = 0, b = 0;1035 int r = 0, g = 0, b = 0;
1013 1036
1014 if (3*y < h ) r = c;1037 if (3*y < h ) r = c;
1015 else if (3*y < 2*h) g = c;1038 else if (3*y < 2*h) g = c;
1016 else b = c;1039 else b = c;
1017 1040
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,
1019 ctx->outputs[0]->format, test->rgba_map);1042 ctx->outputs[0]->format, test->rgba_map);
1020 }1043 }
1021 }1044 }
@@ -1038,6 +1061,8 @@ static int rgbtest_query_formats(AVFilterContext *ctx) · 16 unmodified lines
1038 AV_PIX_FMT_RGB444, AV_PIX_FMT_BGR444,1061 AV_PIX_FMT_RGB444, AV_PIX_FMT_BGR444,
1039 AV_PIX_FMT_RGB565, AV_PIX_FMT_BGR565,1062 AV_PIX_FMT_RGB565, AV_PIX_FMT_BGR565,
1040 AV_PIX_FMT_RGB555, AV_PIX_FMT_BGR555,1063 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,
1041 AV_PIX_FMT_NONE1066 AV_PIX_FMT_NONE
1042 };1067 };
1043 1068
@@ -1050,7 +1075,9 @@ static int rgbtest_query_formats(AVFilterContext *ctx) · 6 unmodified lines
1050static int rgbtest_config_props(AVFilterLink *outlink)1075static int rgbtest_config_props(AVFilterLink *outlink)
1051{1076{
1052 TestSourceContext *test = outlink->src->priv;1077 TestSourceContext *test = outlink->src->priv;
1078 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
1053 1079
1080 test->depth = desc->comp[0].depth;
1054 ff_fill_rgba_map(test->rgba_map, outlink->format);1081 ff_fill_rgba_map(test->rgba_map, outlink->format);
1055 return config_props(outlink);1082 return config_props(outlink);
1056}1083}

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