You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

569 lines
19KB

  1. /*
  2. * Copyright (c) 2007 Nicolas George <nicolas.george@normalesup.org>
  3. * Copyright (c) 2011 Stefano Sabatini
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * Misc test sources.
  24. *
  25. * testsrc is based on the test pattern generator demuxer by Nicolas George:
  26. * http://lists.ffmpeg.org/pipermail/ffmpeg-devel/2007-October/037845.html
  27. *
  28. * rgbtestsrc is ported from MPlayer libmpcodecs/vf_rgbtest.c by
  29. * Michael Niedermayer.
  30. */
  31. #include <float.h>
  32. #include "libavutil/opt.h"
  33. #include "libavutil/intreadwrite.h"
  34. #include "libavutil/parseutils.h"
  35. #include "avfilter.h"
  36. #include "formats.h"
  37. #include "internal.h"
  38. #include "video.h"
  39. typedef struct {
  40. const AVClass *class;
  41. int w, h;
  42. unsigned int nb_frame;
  43. AVRational time_base;
  44. int64_t pts, max_pts;
  45. char *rate; ///< video frame rate
  46. char *duration; ///< total duration of the generated video
  47. AVRational sar; ///< sample aspect ratio
  48. int nb_decimals;
  49. int draw_once; ///< draw only the first frame, always put out the same picture
  50. AVFilterBufferRef *picref; ///< cached reference containing the painted picture
  51. void (* fill_picture_fn)(AVFilterContext *ctx, AVFilterBufferRef *picref);
  52. /* only used by rgbtest */
  53. int rgba_map[4];
  54. } TestSourceContext;
  55. #define OFFSET(x) offsetof(TestSourceContext, x)
  56. static const AVOption testsrc_options[]= {
  57. { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0 },
  58. { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0 },
  59. { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0 },
  60. { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0 },
  61. { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0 },
  62. { "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0 },
  63. { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX },
  64. /* only used by testsrc */
  65. { "decimals", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX },
  66. { "n", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX },
  67. { NULL },
  68. };
  69. static av_cold int init(AVFilterContext *ctx, const char *args)
  70. {
  71. TestSourceContext *test = ctx->priv;
  72. AVRational frame_rate_q;
  73. int64_t duration = -1;
  74. int ret = 0;
  75. av_opt_set_defaults(test);
  76. if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0) {
  77. av_log(ctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
  78. return ret;
  79. }
  80. if ((ret = av_parse_video_rate(&frame_rate_q, test->rate)) < 0) {
  81. av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n", test->rate);
  82. return ret;
  83. }
  84. if (test->duration && (ret = av_parse_time(&duration, test->duration, 1)) < 0) {
  85. av_log(ctx, AV_LOG_ERROR, "Invalid duration: '%s'\n", test->duration);
  86. return ret;
  87. }
  88. if (test->nb_decimals && strcmp(ctx->filter->name, "testsrc")) {
  89. av_log(ctx, AV_LOG_WARNING,
  90. "Option 'decimals' is ignored with source '%s'\n",
  91. ctx->filter->name);
  92. }
  93. test->time_base.num = frame_rate_q.den;
  94. test->time_base.den = frame_rate_q.num;
  95. test->max_pts = duration >= 0 ?
  96. av_rescale_q(duration, AV_TIME_BASE_Q, test->time_base) : -1;
  97. test->nb_frame = 0;
  98. test->pts = 0;
  99. av_log(ctx, AV_LOG_VERBOSE, "size:%dx%d rate:%d/%d duration:%f sar:%d/%d\n",
  100. test->w, test->h, frame_rate_q.num, frame_rate_q.den,
  101. duration < 0 ? -1 : test->max_pts * av_q2d(test->time_base),
  102. test->sar.num, test->sar.den);
  103. return 0;
  104. }
  105. static av_cold void uninit(AVFilterContext *ctx)
  106. {
  107. TestSourceContext *test = ctx->priv;
  108. av_opt_free(test);
  109. avfilter_unref_bufferp(&test->picref);
  110. }
  111. static int config_props(AVFilterLink *outlink)
  112. {
  113. TestSourceContext *test = outlink->src->priv;
  114. outlink->w = test->w;
  115. outlink->h = test->h;
  116. outlink->sample_aspect_ratio = test->sar;
  117. outlink->time_base = test->time_base;
  118. return 0;
  119. }
  120. static int request_frame(AVFilterLink *outlink)
  121. {
  122. TestSourceContext *test = outlink->src->priv;
  123. AVFilterBufferRef *outpicref;
  124. int ret = 0;
  125. if (test->max_pts >= 0 && test->pts >= test->max_pts)
  126. return AVERROR_EOF;
  127. if (test->draw_once) {
  128. if (!test->picref) {
  129. test->picref =
  130. ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_PRESERVE|AV_PERM_REUSE,
  131. test->w, test->h);
  132. if (!test->picref)
  133. return AVERROR(ENOMEM);
  134. test->fill_picture_fn(outlink->src, test->picref);
  135. }
  136. outpicref = avfilter_ref_buffer(test->picref, ~AV_PERM_WRITE);
  137. } else
  138. outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE, test->w, test->h);
  139. if (!outpicref)
  140. return AVERROR(ENOMEM);
  141. outpicref->pts = test->pts;
  142. outpicref->pos = -1;
  143. outpicref->video->key_frame = 1;
  144. outpicref->video->interlaced = 0;
  145. outpicref->video->pict_type = AV_PICTURE_TYPE_I;
  146. outpicref->video->sample_aspect_ratio = test->sar;
  147. if (!test->draw_once)
  148. test->fill_picture_fn(outlink->src, outpicref);
  149. test->pts++;
  150. test->nb_frame++;
  151. if ((ret = ff_start_frame(outlink, outpicref)) < 0 ||
  152. (ret = ff_draw_slice(outlink, 0, test->h, 1)) < 0 ||
  153. (ret = ff_end_frame(outlink)) < 0)
  154. return ret;
  155. return 0;
  156. }
  157. #if CONFIG_NULLSRC_FILTER
  158. static const AVClass nullsrc_class = {
  159. .class_name = "nullsrc",
  160. .item_name = av_default_item_name,
  161. .option = testsrc_options,
  162. .version = LIBAVUTIL_VERSION_INT,
  163. .category = AV_CLASS_CATEGORY_FILTER,
  164. };
  165. static void nullsrc_fill_picture(AVFilterContext *ctx, AVFilterBufferRef *picref) { }
  166. static av_cold int nullsrc_init(AVFilterContext *ctx, const char *args)
  167. {
  168. TestSourceContext *test = ctx->priv;
  169. test->class = &nullsrc_class;
  170. test->fill_picture_fn = nullsrc_fill_picture;
  171. return init(ctx, args);
  172. }
  173. AVFilter avfilter_vsrc_nullsrc = {
  174. .name = "nullsrc",
  175. .description = NULL_IF_CONFIG_SMALL("Null video source, return unprocessed video frames."),
  176. .init = nullsrc_init,
  177. .uninit = uninit,
  178. .priv_size = sizeof(TestSourceContext),
  179. .inputs = (const AVFilterPad[]) {{ .name = NULL}},
  180. .outputs = (const AVFilterPad[]) {{ .name = "default",
  181. .type = AVMEDIA_TYPE_VIDEO,
  182. .request_frame = request_frame,
  183. .config_props = config_props, },
  184. { .name = NULL}},
  185. };
  186. #endif /* CONFIG_NULLSRC_FILTER */
  187. #if CONFIG_TESTSRC_FILTER
  188. AVFILTER_DEFINE_CLASS(testsrc);
  189. /**
  190. * Fill a rectangle with value val.
  191. *
  192. * @param val the RGB value to set
  193. * @param dst pointer to the destination buffer to fill
  194. * @param dst_linesize linesize of destination
  195. * @param segment_width width of the segment
  196. * @param x horizontal coordinate where to draw the rectangle in the destination buffer
  197. * @param y horizontal coordinate where to draw the rectangle in the destination buffer
  198. * @param w width of the rectangle to draw, expressed as a number of segment_width units
  199. * @param h height of the rectangle to draw, expressed as a number of segment_width units
  200. */
  201. static void draw_rectangle(unsigned val, uint8_t *dst, int dst_linesize, unsigned segment_width,
  202. unsigned x, unsigned y, unsigned w, unsigned h)
  203. {
  204. int i;
  205. int step = 3;
  206. dst += segment_width * (step * x + y * dst_linesize);
  207. w *= segment_width * step;
  208. h *= segment_width;
  209. for (i = 0; i < h; i++) {
  210. memset(dst, val, w);
  211. dst += dst_linesize;
  212. }
  213. }
  214. static void draw_digit(int digit, uint8_t *dst, unsigned dst_linesize,
  215. unsigned segment_width)
  216. {
  217. #define TOP_HBAR 1
  218. #define MID_HBAR 2
  219. #define BOT_HBAR 4
  220. #define LEFT_TOP_VBAR 8
  221. #define LEFT_BOT_VBAR 16
  222. #define RIGHT_TOP_VBAR 32
  223. #define RIGHT_BOT_VBAR 64
  224. struct {
  225. int x, y, w, h;
  226. } segments[] = {
  227. { 1, 0, 5, 1 }, /* TOP_HBAR */
  228. { 1, 6, 5, 1 }, /* MID_HBAR */
  229. { 1, 12, 5, 1 }, /* BOT_HBAR */
  230. { 0, 1, 1, 5 }, /* LEFT_TOP_VBAR */
  231. { 0, 7, 1, 5 }, /* LEFT_BOT_VBAR */
  232. { 6, 1, 1, 5 }, /* RIGHT_TOP_VBAR */
  233. { 6, 7, 1, 5 } /* RIGHT_BOT_VBAR */
  234. };
  235. static const unsigned char masks[10] = {
  236. /* 0 */ TOP_HBAR |BOT_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  237. /* 1 */ RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  238. /* 2 */ TOP_HBAR|MID_HBAR|BOT_HBAR|LEFT_BOT_VBAR |RIGHT_TOP_VBAR,
  239. /* 3 */ TOP_HBAR|MID_HBAR|BOT_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  240. /* 4 */ MID_HBAR |LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  241. /* 5 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_BOT_VBAR,
  242. /* 6 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR |RIGHT_BOT_VBAR,
  243. /* 7 */ TOP_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  244. /* 8 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  245. /* 9 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  246. };
  247. unsigned mask = masks[digit];
  248. int i;
  249. draw_rectangle(0, dst, dst_linesize, segment_width, 0, 0, 8, 13);
  250. for (i = 0; i < FF_ARRAY_ELEMS(segments); i++)
  251. if (mask & (1<<i))
  252. draw_rectangle(255, dst, dst_linesize, segment_width,
  253. segments[i].x, segments[i].y, segments[i].w, segments[i].h);
  254. }
  255. #define GRADIENT_SIZE (6 * 256)
  256. static void test_fill_picture(AVFilterContext *ctx, AVFilterBufferRef *picref)
  257. {
  258. TestSourceContext *test = ctx->priv;
  259. uint8_t *p, *p0;
  260. int x, y;
  261. int color, color_rest;
  262. int icolor;
  263. int radius;
  264. int quad0, quad;
  265. int dquad_x, dquad_y;
  266. int grad, dgrad, rgrad, drgrad;
  267. int seg_size;
  268. int second;
  269. int i;
  270. uint8_t *data = picref->data[0];
  271. int width = picref->video->w;
  272. int height = picref->video->h;
  273. /* draw colored bars and circle */
  274. radius = (width + height) / 4;
  275. quad0 = width * width / 4 + height * height / 4 - radius * radius;
  276. dquad_y = 1 - height;
  277. p0 = data;
  278. for (y = 0; y < height; y++) {
  279. p = p0;
  280. color = 0;
  281. color_rest = 0;
  282. quad = quad0;
  283. dquad_x = 1 - width;
  284. for (x = 0; x < width; x++) {
  285. icolor = color;
  286. if (quad < 0)
  287. icolor ^= 7;
  288. quad += dquad_x;
  289. dquad_x += 2;
  290. *(p++) = icolor & 1 ? 255 : 0;
  291. *(p++) = icolor & 2 ? 255 : 0;
  292. *(p++) = icolor & 4 ? 255 : 0;
  293. color_rest += 8;
  294. if (color_rest >= width) {
  295. color_rest -= width;
  296. color++;
  297. }
  298. }
  299. quad0 += dquad_y;
  300. dquad_y += 2;
  301. p0 += picref->linesize[0];
  302. }
  303. /* draw sliding color line */
  304. p0 = p = data + picref->linesize[0] * height * 3/4;
  305. grad = (256 * test->nb_frame * test->time_base.num / test->time_base.den) %
  306. GRADIENT_SIZE;
  307. rgrad = 0;
  308. dgrad = GRADIENT_SIZE / width;
  309. drgrad = GRADIENT_SIZE % width;
  310. for (x = 0; x < width; x++) {
  311. *(p++) =
  312. grad < 256 || grad >= 5 * 256 ? 255 :
  313. grad >= 2 * 256 && grad < 4 * 256 ? 0 :
  314. grad < 2 * 256 ? 2 * 256 - 1 - grad : grad - 4 * 256;
  315. *(p++) =
  316. grad >= 4 * 256 ? 0 :
  317. grad >= 1 * 256 && grad < 3 * 256 ? 255 :
  318. grad < 1 * 256 ? grad : 4 * 256 - 1 - grad;
  319. *(p++) =
  320. grad < 2 * 256 ? 0 :
  321. grad >= 3 * 256 && grad < 5 * 256 ? 255 :
  322. grad < 3 * 256 ? grad - 2 * 256 : 6 * 256 - 1 - grad;
  323. grad += dgrad;
  324. rgrad += drgrad;
  325. if (rgrad >= GRADIENT_SIZE) {
  326. grad++;
  327. rgrad -= GRADIENT_SIZE;
  328. }
  329. if (grad >= GRADIENT_SIZE)
  330. grad -= GRADIENT_SIZE;
  331. }
  332. p = p0;
  333. for (y = height / 8; y > 0; y--) {
  334. memcpy(p+picref->linesize[0], p, 3 * width);
  335. p += picref->linesize[0];
  336. }
  337. /* draw digits */
  338. seg_size = width / 80;
  339. if (seg_size >= 1 && height >= 13 * seg_size) {
  340. double time = av_q2d(test->time_base) * test->nb_frame *
  341. pow(10, test->nb_decimals);
  342. if (time > INT_MAX)
  343. return;
  344. second = (int)time;
  345. x = width - (width - seg_size * 64) / 2;
  346. y = (height - seg_size * 13) / 2;
  347. p = data + (x*3 + y * picref->linesize[0]);
  348. for (i = 0; i < 8; i++) {
  349. p -= 3 * 8 * seg_size;
  350. draw_digit(second % 10, p, picref->linesize[0], seg_size);
  351. second /= 10;
  352. if (second == 0)
  353. break;
  354. }
  355. }
  356. }
  357. static av_cold int test_init(AVFilterContext *ctx, const char *args)
  358. {
  359. TestSourceContext *test = ctx->priv;
  360. test->class = &testsrc_class;
  361. test->fill_picture_fn = test_fill_picture;
  362. return init(ctx, args);
  363. }
  364. static int test_query_formats(AVFilterContext *ctx)
  365. {
  366. static const enum PixelFormat pix_fmts[] = {
  367. PIX_FMT_RGB24, PIX_FMT_NONE
  368. };
  369. ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
  370. return 0;
  371. }
  372. AVFilter avfilter_vsrc_testsrc = {
  373. .name = "testsrc",
  374. .description = NULL_IF_CONFIG_SMALL("Generate test pattern."),
  375. .priv_size = sizeof(TestSourceContext),
  376. .init = test_init,
  377. .uninit = uninit,
  378. .query_formats = test_query_formats,
  379. .inputs = (const AVFilterPad[]) {{ .name = NULL}},
  380. .outputs = (const AVFilterPad[]) {{ .name = "default",
  381. .type = AVMEDIA_TYPE_VIDEO,
  382. .request_frame = request_frame,
  383. .config_props = config_props, },
  384. { .name = NULL }},
  385. };
  386. #endif /* CONFIG_TESTSRC_FILTER */
  387. #if CONFIG_RGBTESTSRC_FILTER
  388. static const AVClass rgbtestsrc_class = {
  389. .class_name = "rgbtestsrc",
  390. .item_name = av_default_item_name,
  391. .option = testsrc_options,
  392. .version = LIBAVUTIL_VERSION_INT,
  393. .category = AV_CLASS_CATEGORY_FILTER,
  394. };
  395. #define R 0
  396. #define G 1
  397. #define B 2
  398. #define A 3
  399. static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize,
  400. int x, int y, int r, int g, int b, enum PixelFormat fmt,
  401. int rgba_map[4])
  402. {
  403. int32_t v;
  404. uint8_t *p;
  405. switch (fmt) {
  406. case PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4); break;
  407. case PIX_FMT_RGB444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b >> 4) << 8) | ((g >> 4) << 4) | (r >> 4); break;
  408. case PIX_FMT_BGR555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<10) | ((g>>3)<<5) | (b>>3); break;
  409. case PIX_FMT_RGB555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<10) | ((g>>3)<<5) | (r>>3); break;
  410. case PIX_FMT_BGR565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<11) | ((g>>2)<<5) | (b>>3); break;
  411. case PIX_FMT_RGB565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<11) | ((g>>2)<<5) | (r>>3); break;
  412. case PIX_FMT_RGB24:
  413. case PIX_FMT_BGR24:
  414. v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8));
  415. p = dst + 3*x + y*dst_linesize;
  416. AV_WL24(p, v);
  417. break;
  418. case PIX_FMT_RGBA:
  419. case PIX_FMT_BGRA:
  420. case PIX_FMT_ARGB:
  421. case PIX_FMT_ABGR:
  422. v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)) + (255 << (rgba_map[A]*8));
  423. p = dst + 4*x + y*dst_linesize;
  424. AV_WL32(p, v);
  425. break;
  426. }
  427. }
  428. static void rgbtest_fill_picture(AVFilterContext *ctx, AVFilterBufferRef *picref)
  429. {
  430. TestSourceContext *test = ctx->priv;
  431. int x, y, w = picref->video->w, h = picref->video->h;
  432. for (y = 0; y < h; y++) {
  433. for (x = 0; x < picref->video->w; x++) {
  434. int c = 256*x/w;
  435. int r = 0, g = 0, b = 0;
  436. if (3*y < h ) r = c;
  437. else if (3*y < 2*h) g = c;
  438. else b = c;
  439. rgbtest_put_pixel(picref->data[0], picref->linesize[0], x, y, r, g, b,
  440. ctx->outputs[0]->format, test->rgba_map);
  441. }
  442. }
  443. }
  444. static av_cold int rgbtest_init(AVFilterContext *ctx, const char *args)
  445. {
  446. TestSourceContext *test = ctx->priv;
  447. test->draw_once = 1;
  448. test->class = &rgbtestsrc_class;
  449. test->fill_picture_fn = rgbtest_fill_picture;
  450. return init(ctx, args);
  451. }
  452. static int rgbtest_query_formats(AVFilterContext *ctx)
  453. {
  454. static const enum PixelFormat pix_fmts[] = {
  455. PIX_FMT_RGBA, PIX_FMT_ARGB, PIX_FMT_BGRA, PIX_FMT_ABGR,
  456. PIX_FMT_BGR24, PIX_FMT_RGB24,
  457. PIX_FMT_RGB444, PIX_FMT_BGR444,
  458. PIX_FMT_RGB565, PIX_FMT_BGR565,
  459. PIX_FMT_RGB555, PIX_FMT_BGR555,
  460. PIX_FMT_NONE
  461. };
  462. ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
  463. return 0;
  464. }
  465. static int rgbtest_config_props(AVFilterLink *outlink)
  466. {
  467. TestSourceContext *test = outlink->src->priv;
  468. switch (outlink->format) {
  469. case PIX_FMT_ARGB: test->rgba_map[A] = 0; test->rgba_map[R] = 1; test->rgba_map[G] = 2; test->rgba_map[B] = 3; break;
  470. case PIX_FMT_ABGR: test->rgba_map[A] = 0; test->rgba_map[B] = 1; test->rgba_map[G] = 2; test->rgba_map[R] = 3; break;
  471. case PIX_FMT_RGBA:
  472. case PIX_FMT_RGB24: test->rgba_map[R] = 0; test->rgba_map[G] = 1; test->rgba_map[B] = 2; test->rgba_map[A] = 3; break;
  473. case PIX_FMT_BGRA:
  474. case PIX_FMT_BGR24: test->rgba_map[B] = 0; test->rgba_map[G] = 1; test->rgba_map[R] = 2; test->rgba_map[A] = 3; break;
  475. }
  476. return config_props(outlink);
  477. }
  478. AVFilter avfilter_vsrc_rgbtestsrc = {
  479. .name = "rgbtestsrc",
  480. .description = NULL_IF_CONFIG_SMALL("Generate RGB test pattern."),
  481. .priv_size = sizeof(TestSourceContext),
  482. .init = rgbtest_init,
  483. .uninit = uninit,
  484. .query_formats = rgbtest_query_formats,
  485. .inputs = (const AVFilterPad[]) {{ .name = NULL}},
  486. .outputs = (const AVFilterPad[]) {{ .name = "default",
  487. .type = AVMEDIA_TYPE_VIDEO,
  488. .request_frame = request_frame,
  489. .config_props = rgbtest_config_props, },
  490. { .name = NULL }},
  491. };
  492. #endif /* CONFIG_RGBTESTSRC_FILTER */