vsrc_testsrc.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071
  1. /*
  2. * Copyright (c) 2007 Nicolas George <nicolas.george@normalesup.org>
  3. * Copyright (c) 2011 Stefano Sabatini
  4. * Copyright (c) 2012 Paul B Mahol
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. /**
  23. * @file
  24. * Misc test sources.
  25. *
  26. * testsrc is based on the test pattern generator demuxer by Nicolas George:
  27. * http://lists.ffmpeg.org/pipermail/ffmpeg-devel/2007-October/037845.html
  28. *
  29. * rgbtestsrc is ported from MPlayer libmpcodecs/vf_rgbtest.c by
  30. * Michael Niedermayer.
  31. *
  32. * smptebars and smptehdbars are by Paul B Mahol.
  33. */
  34. #include <float.h>
  35. #include "libavutil/avassert.h"
  36. #include "libavutil/common.h"
  37. #include "libavutil/opt.h"
  38. #include "libavutil/imgutils.h"
  39. #include "libavutil/intreadwrite.h"
  40. #include "libavutil/parseutils.h"
  41. #include "avfilter.h"
  42. #include "drawutils.h"
  43. #include "formats.h"
  44. #include "internal.h"
  45. #include "video.h"
  46. typedef struct TestSourceContext {
  47. const AVClass *class;
  48. int w, h;
  49. unsigned int nb_frame;
  50. AVRational time_base, frame_rate;
  51. int64_t pts;
  52. int64_t duration; ///< duration expressed in microseconds
  53. AVRational sar; ///< sample aspect ratio
  54. int draw_once; ///< draw only the first frame, always put out the same picture
  55. int draw_once_reset; ///< draw only the first frame or in case of reset
  56. AVFrame *picref; ///< cached reference containing the painted picture
  57. void (* fill_picture_fn)(AVFilterContext *ctx, AVFrame *frame);
  58. /* only used by testsrc */
  59. int nb_decimals;
  60. /* only used by color */
  61. FFDrawContext draw;
  62. FFDrawColor color;
  63. uint8_t color_rgba[4];
  64. /* only used by rgbtest */
  65. uint8_t rgba_map[4];
  66. /* only used by haldclut */
  67. int level;
  68. } TestSourceContext;
  69. #define OFFSET(x) offsetof(TestSourceContext, x)
  70. #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
  71. #define SIZE_OPTIONS \
  72. { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\
  73. { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\
  74. #define COMMON_OPTIONS_NOSIZE \
  75. { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },\
  76. { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },\
  77. { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },\
  78. { "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },\
  79. { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX, FLAGS },
  80. #define COMMON_OPTIONS SIZE_OPTIONS COMMON_OPTIONS_NOSIZE
  81. static const AVOption options[] = {
  82. COMMON_OPTIONS
  83. { NULL }
  84. };
  85. static av_cold int init(AVFilterContext *ctx)
  86. {
  87. TestSourceContext *test = ctx->priv;
  88. test->time_base = av_inv_q(test->frame_rate);
  89. test->nb_frame = 0;
  90. test->pts = 0;
  91. av_log(ctx, AV_LOG_VERBOSE, "size:%dx%d rate:%d/%d duration:%f sar:%d/%d\n",
  92. test->w, test->h, test->frame_rate.num, test->frame_rate.den,
  93. test->duration < 0 ? -1 : (double)test->duration/1000000,
  94. test->sar.num, test->sar.den);
  95. return 0;
  96. }
  97. static av_cold void uninit(AVFilterContext *ctx)
  98. {
  99. TestSourceContext *test = ctx->priv;
  100. av_frame_free(&test->picref);
  101. }
  102. static int config_props(AVFilterLink *outlink)
  103. {
  104. TestSourceContext *test = outlink->src->priv;
  105. outlink->w = test->w;
  106. outlink->h = test->h;
  107. outlink->sample_aspect_ratio = test->sar;
  108. outlink->frame_rate = test->frame_rate;
  109. outlink->time_base = test->time_base;
  110. return 0;
  111. }
  112. static int request_frame(AVFilterLink *outlink)
  113. {
  114. TestSourceContext *test = outlink->src->priv;
  115. AVFrame *frame;
  116. if (test->duration >= 0 &&
  117. av_rescale_q(test->pts, test->time_base, AV_TIME_BASE_Q) >= test->duration)
  118. return AVERROR_EOF;
  119. if (test->draw_once) {
  120. if (test->draw_once_reset) {
  121. av_frame_free(&test->picref);
  122. test->draw_once_reset = 0;
  123. }
  124. if (!test->picref) {
  125. test->picref =
  126. ff_get_video_buffer(outlink, test->w, test->h);
  127. if (!test->picref)
  128. return AVERROR(ENOMEM);
  129. test->fill_picture_fn(outlink->src, test->picref);
  130. }
  131. frame = av_frame_clone(test->picref);
  132. } else
  133. frame = ff_get_video_buffer(outlink, test->w, test->h);
  134. if (!frame)
  135. return AVERROR(ENOMEM);
  136. frame->pts = test->pts;
  137. frame->key_frame = 1;
  138. frame->interlaced_frame = 0;
  139. frame->pict_type = AV_PICTURE_TYPE_I;
  140. frame->sample_aspect_ratio = test->sar;
  141. if (!test->draw_once)
  142. test->fill_picture_fn(outlink->src, frame);
  143. test->pts++;
  144. test->nb_frame++;
  145. return ff_filter_frame(outlink, frame);
  146. }
  147. #if CONFIG_COLOR_FILTER
  148. static const AVOption color_options[] = {
  149. { "color", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
  150. { "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
  151. COMMON_OPTIONS
  152. { NULL }
  153. };
  154. AVFILTER_DEFINE_CLASS(color);
  155. static void color_fill_picture(AVFilterContext *ctx, AVFrame *picref)
  156. {
  157. TestSourceContext *test = ctx->priv;
  158. ff_fill_rectangle(&test->draw, &test->color,
  159. picref->data, picref->linesize,
  160. 0, 0, test->w, test->h);
  161. }
  162. static av_cold int color_init(AVFilterContext *ctx)
  163. {
  164. TestSourceContext *test = ctx->priv;
  165. test->fill_picture_fn = color_fill_picture;
  166. test->draw_once = 1;
  167. return init(ctx);
  168. }
  169. static int color_query_formats(AVFilterContext *ctx)
  170. {
  171. ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
  172. return 0;
  173. }
  174. static int color_config_props(AVFilterLink *inlink)
  175. {
  176. AVFilterContext *ctx = inlink->src;
  177. TestSourceContext *test = ctx->priv;
  178. int ret;
  179. ff_draw_init(&test->draw, inlink->format, 0);
  180. ff_draw_color(&test->draw, &test->color, test->color_rgba);
  181. test->w = ff_draw_round_to_sub(&test->draw, 0, -1, test->w);
  182. test->h = ff_draw_round_to_sub(&test->draw, 1, -1, test->h);
  183. if (av_image_check_size(test->w, test->h, 0, ctx) < 0)
  184. return AVERROR(EINVAL);
  185. if ((ret = config_props(inlink)) < 0)
  186. return ret;
  187. return 0;
  188. }
  189. static int color_process_command(AVFilterContext *ctx, const char *cmd, const char *args,
  190. char *res, int res_len, int flags)
  191. {
  192. TestSourceContext *test = ctx->priv;
  193. int ret;
  194. if (!strcmp(cmd, "color") || !strcmp(cmd, "c")) {
  195. uint8_t color_rgba[4];
  196. ret = av_parse_color(color_rgba, args, -1, ctx);
  197. if (ret < 0)
  198. return ret;
  199. memcpy(test->color_rgba, color_rgba, sizeof(color_rgba));
  200. ff_draw_color(&test->draw, &test->color, test->color_rgba);
  201. test->draw_once_reset = 1;
  202. return 0;
  203. }
  204. return AVERROR(ENOSYS);
  205. }
  206. static const AVFilterPad color_outputs[] = {
  207. {
  208. .name = "default",
  209. .type = AVMEDIA_TYPE_VIDEO,
  210. .request_frame = request_frame,
  211. .config_props = color_config_props,
  212. },
  213. { NULL }
  214. };
  215. AVFilter ff_vsrc_color = {
  216. .name = "color",
  217. .description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."),
  218. .priv_class = &color_class,
  219. .priv_size = sizeof(TestSourceContext),
  220. .init = color_init,
  221. .uninit = uninit,
  222. .query_formats = color_query_formats,
  223. .inputs = NULL,
  224. .outputs = color_outputs,
  225. .process_command = color_process_command,
  226. };
  227. #endif /* CONFIG_COLOR_FILTER */
  228. #if CONFIG_HALDCLUTSRC_FILTER
  229. static const AVOption haldclutsrc_options[] = {
  230. { "level", "set level", OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 6}, 2, 8, FLAGS },
  231. COMMON_OPTIONS_NOSIZE
  232. { NULL }
  233. };
  234. AVFILTER_DEFINE_CLASS(haldclutsrc);
  235. static void haldclutsrc_fill_picture(AVFilterContext *ctx, AVFrame *frame)
  236. {
  237. int i, j, k, x = 0, y = 0, is16bit = 0, step;
  238. uint32_t alpha = 0;
  239. const TestSourceContext *hc = ctx->priv;
  240. int level = hc->level;
  241. float scale;
  242. const int w = frame->width;
  243. const int h = frame->height;
  244. const uint8_t *data = frame->data[0];
  245. const int linesize = frame->linesize[0];
  246. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
  247. uint8_t rgba_map[4];
  248. av_assert0(w == h && w == level*level*level);
  249. ff_fill_rgba_map(rgba_map, frame->format);
  250. switch (frame->format) {
  251. case AV_PIX_FMT_RGB48:
  252. case AV_PIX_FMT_BGR48:
  253. case AV_PIX_FMT_RGBA64:
  254. case AV_PIX_FMT_BGRA64:
  255. is16bit = 1;
  256. alpha = 0xffff;
  257. break;
  258. case AV_PIX_FMT_RGBA:
  259. case AV_PIX_FMT_BGRA:
  260. case AV_PIX_FMT_ARGB:
  261. case AV_PIX_FMT_ABGR:
  262. alpha = 0xff;
  263. break;
  264. }
  265. step = av_get_padded_bits_per_pixel(desc) >> (3 + is16bit);
  266. scale = ((float)(1 << (8*(is16bit+1))) - 1) / (level*level - 1);
  267. #define LOAD_CLUT(nbits) do { \
  268. uint##nbits##_t *dst = ((uint##nbits##_t *)(data + y*linesize)) + x*step; \
  269. dst[rgba_map[0]] = av_clip_uint##nbits(i * scale); \
  270. dst[rgba_map[1]] = av_clip_uint##nbits(j * scale); \
  271. dst[rgba_map[2]] = av_clip_uint##nbits(k * scale); \
  272. if (step == 4) \
  273. dst[rgba_map[3]] = alpha; \
  274. } while (0)
  275. level *= level;
  276. for (k = 0; k < level; k++) {
  277. for (j = 0; j < level; j++) {
  278. for (i = 0; i < level; i++) {
  279. if (!is16bit)
  280. LOAD_CLUT(8);
  281. else
  282. LOAD_CLUT(16);
  283. if (++x == w) {
  284. x = 0;
  285. y++;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. static av_cold int haldclutsrc_init(AVFilterContext *ctx)
  292. {
  293. TestSourceContext *hc = ctx->priv;
  294. hc->fill_picture_fn = haldclutsrc_fill_picture;
  295. hc->draw_once = 1;
  296. return init(ctx);
  297. }
  298. static int haldclutsrc_query_formats(AVFilterContext *ctx)
  299. {
  300. static const enum AVPixelFormat pix_fmts[] = {
  301. AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,
  302. AV_PIX_FMT_RGBA, AV_PIX_FMT_BGRA,
  303. AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR,
  304. AV_PIX_FMT_0RGB, AV_PIX_FMT_0BGR,
  305. AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0,
  306. AV_PIX_FMT_RGB48, AV_PIX_FMT_BGR48,
  307. AV_PIX_FMT_RGBA64, AV_PIX_FMT_BGRA64,
  308. AV_PIX_FMT_NONE,
  309. };
  310. ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
  311. return 0;
  312. }
  313. static int haldclutsrc_config_props(AVFilterLink *outlink)
  314. {
  315. AVFilterContext *ctx = outlink->src;
  316. TestSourceContext *hc = ctx->priv;
  317. hc->w = hc->h = hc->level * hc->level * hc->level;
  318. return config_props(outlink);
  319. }
  320. static const AVFilterPad haldclutsrc_outputs[] = {
  321. {
  322. .name = "default",
  323. .type = AVMEDIA_TYPE_VIDEO,
  324. .request_frame = request_frame,
  325. .config_props = haldclutsrc_config_props,
  326. },
  327. { NULL }
  328. };
  329. AVFilter ff_vsrc_haldclutsrc = {
  330. .name = "haldclutsrc",
  331. .description = NULL_IF_CONFIG_SMALL("Provide an identity Hald CLUT."),
  332. .priv_class = &haldclutsrc_class,
  333. .priv_size = sizeof(TestSourceContext),
  334. .init = haldclutsrc_init,
  335. .uninit = uninit,
  336. .query_formats = haldclutsrc_query_formats,
  337. .inputs = NULL,
  338. .outputs = haldclutsrc_outputs,
  339. };
  340. #endif /* CONFIG_HALDCLUTSRC_FILTER */
  341. #if CONFIG_NULLSRC_FILTER
  342. #define nullsrc_options options
  343. AVFILTER_DEFINE_CLASS(nullsrc);
  344. static void nullsrc_fill_picture(AVFilterContext *ctx, AVFrame *picref) { }
  345. static av_cold int nullsrc_init(AVFilterContext *ctx)
  346. {
  347. TestSourceContext *test = ctx->priv;
  348. test->fill_picture_fn = nullsrc_fill_picture;
  349. return init(ctx);
  350. }
  351. static const AVFilterPad nullsrc_outputs[] = {
  352. {
  353. .name = "default",
  354. .type = AVMEDIA_TYPE_VIDEO,
  355. .request_frame = request_frame,
  356. .config_props = config_props,
  357. },
  358. { NULL },
  359. };
  360. AVFilter ff_vsrc_nullsrc = {
  361. .name = "nullsrc",
  362. .description = NULL_IF_CONFIG_SMALL("Null video source, return unprocessed video frames."),
  363. .init = nullsrc_init,
  364. .uninit = uninit,
  365. .priv_size = sizeof(TestSourceContext),
  366. .priv_class = &nullsrc_class,
  367. .inputs = NULL,
  368. .outputs = nullsrc_outputs,
  369. };
  370. #endif /* CONFIG_NULLSRC_FILTER */
  371. #if CONFIG_TESTSRC_FILTER
  372. static const AVOption testsrc_options[] = {
  373. COMMON_OPTIONS
  374. { "decimals", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS },
  375. { "n", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS },
  376. { NULL }
  377. };
  378. AVFILTER_DEFINE_CLASS(testsrc);
  379. /**
  380. * Fill a rectangle with value val.
  381. *
  382. * @param val the RGB value to set
  383. * @param dst pointer to the destination buffer to fill
  384. * @param dst_linesize linesize of destination
  385. * @param segment_width width of the segment
  386. * @param x horizontal coordinate where to draw the rectangle in the destination buffer
  387. * @param y horizontal coordinate where to draw the rectangle in the destination buffer
  388. * @param w width of the rectangle to draw, expressed as a number of segment_width units
  389. * @param h height of the rectangle to draw, expressed as a number of segment_width units
  390. */
  391. static void draw_rectangle(unsigned val, uint8_t *dst, int dst_linesize, int segment_width,
  392. int x, int y, int w, int h)
  393. {
  394. int i;
  395. int step = 3;
  396. dst += segment_width * (step * x + y * dst_linesize);
  397. w *= segment_width * step;
  398. h *= segment_width;
  399. for (i = 0; i < h; i++) {
  400. memset(dst, val, w);
  401. dst += dst_linesize;
  402. }
  403. }
  404. static void draw_digit(int digit, uint8_t *dst, int dst_linesize,
  405. int segment_width)
  406. {
  407. #define TOP_HBAR 1
  408. #define MID_HBAR 2
  409. #define BOT_HBAR 4
  410. #define LEFT_TOP_VBAR 8
  411. #define LEFT_BOT_VBAR 16
  412. #define RIGHT_TOP_VBAR 32
  413. #define RIGHT_BOT_VBAR 64
  414. struct segments {
  415. int x, y, w, h;
  416. } segments[] = {
  417. { 1, 0, 5, 1 }, /* TOP_HBAR */
  418. { 1, 6, 5, 1 }, /* MID_HBAR */
  419. { 1, 12, 5, 1 }, /* BOT_HBAR */
  420. { 0, 1, 1, 5 }, /* LEFT_TOP_VBAR */
  421. { 0, 7, 1, 5 }, /* LEFT_BOT_VBAR */
  422. { 6, 1, 1, 5 }, /* RIGHT_TOP_VBAR */
  423. { 6, 7, 1, 5 } /* RIGHT_BOT_VBAR */
  424. };
  425. static const unsigned char masks[10] = {
  426. /* 0 */ TOP_HBAR |BOT_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  427. /* 1 */ RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  428. /* 2 */ TOP_HBAR|MID_HBAR|BOT_HBAR|LEFT_BOT_VBAR |RIGHT_TOP_VBAR,
  429. /* 3 */ TOP_HBAR|MID_HBAR|BOT_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  430. /* 4 */ MID_HBAR |LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  431. /* 5 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_BOT_VBAR,
  432. /* 6 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR |RIGHT_BOT_VBAR,
  433. /* 7 */ TOP_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  434. /* 8 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  435. /* 9 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
  436. };
  437. unsigned mask = masks[digit];
  438. int i;
  439. draw_rectangle(0, dst, dst_linesize, segment_width, 0, 0, 8, 13);
  440. for (i = 0; i < FF_ARRAY_ELEMS(segments); i++)
  441. if (mask & (1<<i))
  442. draw_rectangle(255, dst, dst_linesize, segment_width,
  443. segments[i].x, segments[i].y, segments[i].w, segments[i].h);
  444. }
  445. #define GRADIENT_SIZE (6 * 256)
  446. static void test_fill_picture(AVFilterContext *ctx, AVFrame *frame)
  447. {
  448. TestSourceContext *test = ctx->priv;
  449. uint8_t *p, *p0;
  450. int x, y;
  451. int color, color_rest;
  452. int icolor;
  453. int radius;
  454. int quad0, quad;
  455. int dquad_x, dquad_y;
  456. int grad, dgrad, rgrad, drgrad;
  457. int seg_size;
  458. int second;
  459. int i;
  460. uint8_t *data = frame->data[0];
  461. int width = frame->width;
  462. int height = frame->height;
  463. /* draw colored bars and circle */
  464. radius = (width + height) / 4;
  465. quad0 = width * width / 4 + height * height / 4 - radius * radius;
  466. dquad_y = 1 - height;
  467. p0 = data;
  468. for (y = 0; y < height; y++) {
  469. p = p0;
  470. color = 0;
  471. color_rest = 0;
  472. quad = quad0;
  473. dquad_x = 1 - width;
  474. for (x = 0; x < width; x++) {
  475. icolor = color;
  476. if (quad < 0)
  477. icolor ^= 7;
  478. quad += dquad_x;
  479. dquad_x += 2;
  480. *(p++) = icolor & 1 ? 255 : 0;
  481. *(p++) = icolor & 2 ? 255 : 0;
  482. *(p++) = icolor & 4 ? 255 : 0;
  483. color_rest += 8;
  484. if (color_rest >= width) {
  485. color_rest -= width;
  486. color++;
  487. }
  488. }
  489. quad0 += dquad_y;
  490. dquad_y += 2;
  491. p0 += frame->linesize[0];
  492. }
  493. /* draw sliding color line */
  494. p0 = p = data + frame->linesize[0] * (height * 3/4);
  495. grad = (256 * test->nb_frame * test->time_base.num / test->time_base.den) %
  496. GRADIENT_SIZE;
  497. rgrad = 0;
  498. dgrad = GRADIENT_SIZE / width;
  499. drgrad = GRADIENT_SIZE % width;
  500. for (x = 0; x < width; x++) {
  501. *(p++) =
  502. grad < 256 || grad >= 5 * 256 ? 255 :
  503. grad >= 2 * 256 && grad < 4 * 256 ? 0 :
  504. grad < 2 * 256 ? 2 * 256 - 1 - grad : grad - 4 * 256;
  505. *(p++) =
  506. grad >= 4 * 256 ? 0 :
  507. grad >= 1 * 256 && grad < 3 * 256 ? 255 :
  508. grad < 1 * 256 ? grad : 4 * 256 - 1 - grad;
  509. *(p++) =
  510. grad < 2 * 256 ? 0 :
  511. grad >= 3 * 256 && grad < 5 * 256 ? 255 :
  512. grad < 3 * 256 ? grad - 2 * 256 : 6 * 256 - 1 - grad;
  513. grad += dgrad;
  514. rgrad += drgrad;
  515. if (rgrad >= GRADIENT_SIZE) {
  516. grad++;
  517. rgrad -= GRADIENT_SIZE;
  518. }
  519. if (grad >= GRADIENT_SIZE)
  520. grad -= GRADIENT_SIZE;
  521. }
  522. p = p0;
  523. for (y = height / 8; y > 0; y--) {
  524. memcpy(p+frame->linesize[0], p, 3 * width);
  525. p += frame->linesize[0];
  526. }
  527. /* draw digits */
  528. seg_size = width / 80;
  529. if (seg_size >= 1 && height >= 13 * seg_size) {
  530. int64_t p10decimals = 1;
  531. double time = av_q2d(test->time_base) * test->nb_frame *
  532. pow(10, test->nb_decimals);
  533. if (time >= INT_MAX)
  534. return;
  535. for (x = 0; x < test->nb_decimals; x++)
  536. p10decimals *= 10;
  537. second = av_rescale_rnd(test->nb_frame * test->time_base.num, p10decimals, test->time_base.den, AV_ROUND_ZERO);
  538. x = width - (width - seg_size * 64) / 2;
  539. y = (height - seg_size * 13) / 2;
  540. p = data + (x*3 + y * frame->linesize[0]);
  541. for (i = 0; i < 8; i++) {
  542. p -= 3 * 8 * seg_size;
  543. draw_digit(second % 10, p, frame->linesize[0], seg_size);
  544. second /= 10;
  545. if (second == 0)
  546. break;
  547. }
  548. }
  549. }
  550. static av_cold int test_init(AVFilterContext *ctx)
  551. {
  552. TestSourceContext *test = ctx->priv;
  553. test->fill_picture_fn = test_fill_picture;
  554. return init(ctx);
  555. }
  556. static int test_query_formats(AVFilterContext *ctx)
  557. {
  558. static const enum AVPixelFormat pix_fmts[] = {
  559. AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE
  560. };
  561. ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
  562. return 0;
  563. }
  564. static const AVFilterPad avfilter_vsrc_testsrc_outputs[] = {
  565. {
  566. .name = "default",
  567. .type = AVMEDIA_TYPE_VIDEO,
  568. .request_frame = request_frame,
  569. .config_props = config_props,
  570. },
  571. { NULL }
  572. };
  573. AVFilter ff_vsrc_testsrc = {
  574. .name = "testsrc",
  575. .description = NULL_IF_CONFIG_SMALL("Generate test pattern."),
  576. .priv_size = sizeof(TestSourceContext),
  577. .priv_class = &testsrc_class,
  578. .init = test_init,
  579. .uninit = uninit,
  580. .query_formats = test_query_formats,
  581. .inputs = NULL,
  582. .outputs = avfilter_vsrc_testsrc_outputs,
  583. };
  584. #endif /* CONFIG_TESTSRC_FILTER */
  585. #if CONFIG_RGBTESTSRC_FILTER
  586. #define rgbtestsrc_options options
  587. AVFILTER_DEFINE_CLASS(rgbtestsrc);
  588. #define R 0
  589. #define G 1
  590. #define B 2
  591. #define A 3
  592. static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize,
  593. int x, int y, int r, int g, int b, enum AVPixelFormat fmt,
  594. uint8_t rgba_map[4])
  595. {
  596. int32_t v;
  597. uint8_t *p;
  598. switch (fmt) {
  599. case AV_PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4); break;
  600. case AV_PIX_FMT_RGB444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b >> 4) << 8) | ((g >> 4) << 4) | (r >> 4); break;
  601. case AV_PIX_FMT_BGR555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<10) | ((g>>3)<<5) | (b>>3); break;
  602. case AV_PIX_FMT_RGB555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<10) | ((g>>3)<<5) | (r>>3); break;
  603. case AV_PIX_FMT_BGR565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<11) | ((g>>2)<<5) | (b>>3); break;
  604. case AV_PIX_FMT_RGB565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<11) | ((g>>2)<<5) | (r>>3); break;
  605. case AV_PIX_FMT_RGB24:
  606. case AV_PIX_FMT_BGR24:
  607. v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8));
  608. p = dst + 3*x + y*dst_linesize;
  609. AV_WL24(p, v);
  610. break;
  611. case AV_PIX_FMT_RGBA:
  612. case AV_PIX_FMT_BGRA:
  613. case AV_PIX_FMT_ARGB:
  614. case AV_PIX_FMT_ABGR:
  615. v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)) + (255 << (rgba_map[A]*8));
  616. p = dst + 4*x + y*dst_linesize;
  617. AV_WL32(p, v);
  618. break;
  619. }
  620. }
  621. static void rgbtest_fill_picture(AVFilterContext *ctx, AVFrame *frame)
  622. {
  623. TestSourceContext *test = ctx->priv;
  624. int x, y, w = frame->width, h = frame->height;
  625. for (y = 0; y < h; y++) {
  626. for (x = 0; x < w; x++) {
  627. int c = 256*x/w;
  628. int r = 0, g = 0, b = 0;
  629. if (3*y < h ) r = c;
  630. else if (3*y < 2*h) g = c;
  631. else b = c;
  632. rgbtest_put_pixel(frame->data[0], frame->linesize[0], x, y, r, g, b,
  633. ctx->outputs[0]->format, test->rgba_map);
  634. }
  635. }
  636. }
  637. static av_cold int rgbtest_init(AVFilterContext *ctx)
  638. {
  639. TestSourceContext *test = ctx->priv;
  640. test->draw_once = 1;
  641. test->fill_picture_fn = rgbtest_fill_picture;
  642. return init(ctx);
  643. }
  644. static int rgbtest_query_formats(AVFilterContext *ctx)
  645. {
  646. static const enum AVPixelFormat pix_fmts[] = {
  647. AV_PIX_FMT_RGBA, AV_PIX_FMT_ARGB, AV_PIX_FMT_BGRA, AV_PIX_FMT_ABGR,
  648. AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24,
  649. AV_PIX_FMT_RGB444, AV_PIX_FMT_BGR444,
  650. AV_PIX_FMT_RGB565, AV_PIX_FMT_BGR565,
  651. AV_PIX_FMT_RGB555, AV_PIX_FMT_BGR555,
  652. AV_PIX_FMT_NONE
  653. };
  654. ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
  655. return 0;
  656. }
  657. static int rgbtest_config_props(AVFilterLink *outlink)
  658. {
  659. TestSourceContext *test = outlink->src->priv;
  660. ff_fill_rgba_map(test->rgba_map, outlink->format);
  661. return config_props(outlink);
  662. }
  663. static const AVFilterPad avfilter_vsrc_rgbtestsrc_outputs[] = {
  664. {
  665. .name = "default",
  666. .type = AVMEDIA_TYPE_VIDEO,
  667. .request_frame = request_frame,
  668. .config_props = rgbtest_config_props,
  669. },
  670. { NULL }
  671. };
  672. AVFilter ff_vsrc_rgbtestsrc = {
  673. .name = "rgbtestsrc",
  674. .description = NULL_IF_CONFIG_SMALL("Generate RGB test pattern."),
  675. .priv_size = sizeof(TestSourceContext),
  676. .priv_class = &rgbtestsrc_class,
  677. .init = rgbtest_init,
  678. .uninit = uninit,
  679. .query_formats = rgbtest_query_formats,
  680. .inputs = NULL,
  681. .outputs = avfilter_vsrc_rgbtestsrc_outputs,
  682. };
  683. #endif /* CONFIG_RGBTESTSRC_FILTER */
  684. #if CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER
  685. static const uint8_t rainbow[7][4] = {
  686. { 180, 128, 128, 255 }, /* gray */
  687. { 168, 44, 136, 255 }, /* yellow */
  688. { 145, 147, 44, 255 }, /* cyan */
  689. { 133, 63, 52, 255 }, /* green */
  690. { 63, 193, 204, 255 }, /* magenta */
  691. { 51, 109, 212, 255 }, /* red */
  692. { 28, 212, 120, 255 }, /* blue */
  693. };
  694. static const uint8_t wobnair[7][4] = {
  695. { 32, 240, 118, 255 }, /* blue */
  696. { 19, 128, 128, 255 }, /* 7.5% intensity black */
  697. { 54, 184, 198, 255 }, /* magenta */
  698. { 19, 128, 128, 255 }, /* 7.5% intensity black */
  699. { 188, 154, 16, 255 }, /* cyan */
  700. { 19, 128, 128, 255 }, /* 7.5% intensity black */
  701. { 191, 128, 128, 255 }, /* gray */
  702. };
  703. static const uint8_t white[4] = { 235, 128, 128, 255 };
  704. static const uint8_t black[4] = { 19, 128, 128, 255 }; /* 7.5% intensity black */
  705. /* pluge pulses */
  706. static const uint8_t neg4ire[4] = { 9, 128, 128, 255 }; /* 3.5% intensity black */
  707. static const uint8_t pos4ire[4] = { 29, 128, 128, 255 }; /* 11.5% intensity black */
  708. /* fudged Q/-I */
  709. static const uint8_t i_pixel[4] = { 61, 153, 99, 255 };
  710. static const uint8_t q_pixel[4] = { 35, 174, 152, 255 };
  711. static const uint8_t gray40[4] = { 104, 128, 128, 255 };
  712. static const uint8_t gray15[4] = { 49, 128, 128, 255 };
  713. static const uint8_t cyan[4] = { 188, 154, 16, 255 };
  714. static const uint8_t yellow[4] = { 219, 16, 138, 255 };
  715. static const uint8_t blue[4] = { 32, 240, 118, 255 };
  716. static const uint8_t red[4] = { 63, 102, 240, 255 };
  717. static const uint8_t black0[4] = { 16, 128, 128, 255 };
  718. static const uint8_t black2[4] = { 20, 128, 128, 255 };
  719. static const uint8_t black4[4] = { 25, 128, 128, 255 };
  720. static const uint8_t neg2[4] = { 12, 128, 128, 255 };
  721. static void draw_bar(TestSourceContext *test, const uint8_t color[4],
  722. unsigned x, unsigned y, unsigned w, unsigned h,
  723. AVFrame *frame)
  724. {
  725. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
  726. uint8_t *p, *p0;
  727. int plane;
  728. x = FFMIN(x, test->w - 1);
  729. y = FFMIN(y, test->h - 1);
  730. w = FFMIN(w, test->w - x);
  731. h = FFMIN(h, test->h - y);
  732. av_assert0(x + w <= test->w);
  733. av_assert0(y + h <= test->h);
  734. for (plane = 0; frame->data[plane]; plane++) {
  735. const int c = color[plane];
  736. const int linesize = frame->linesize[plane];
  737. int i, px, py, pw, ph;
  738. if (plane == 1 || plane == 2) {
  739. px = x >> desc->log2_chroma_w;
  740. pw = w >> desc->log2_chroma_w;
  741. py = y >> desc->log2_chroma_h;
  742. ph = h >> desc->log2_chroma_h;
  743. } else {
  744. px = x;
  745. pw = w;
  746. py = y;
  747. ph = h;
  748. }
  749. p0 = p = frame->data[plane] + py * linesize + px;
  750. memset(p, c, pw);
  751. p += linesize;
  752. for (i = 1; i < ph; i++, p += linesize)
  753. memcpy(p, p0, pw);
  754. }
  755. }
  756. static int smptebars_query_formats(AVFilterContext *ctx)
  757. {
  758. static const enum AVPixelFormat pix_fmts[] = {
  759. AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
  760. AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
  761. AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
  762. AV_PIX_FMT_NONE,
  763. };
  764. ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
  765. return 0;
  766. }
  767. static const AVFilterPad smptebars_outputs[] = {
  768. {
  769. .name = "default",
  770. .type = AVMEDIA_TYPE_VIDEO,
  771. .request_frame = request_frame,
  772. .config_props = config_props,
  773. },
  774. { NULL }
  775. };
  776. #if CONFIG_SMPTEBARS_FILTER
  777. #define smptebars_options options
  778. AVFILTER_DEFINE_CLASS(smptebars);
  779. static void smptebars_fill_picture(AVFilterContext *ctx, AVFrame *picref)
  780. {
  781. TestSourceContext *test = ctx->priv;
  782. int r_w, r_h, w_h, p_w, p_h, i, tmp, x = 0;
  783. const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format);
  784. av_frame_set_colorspace(picref, AVCOL_SPC_BT470BG);
  785. r_w = FFALIGN((test->w + 6) / 7, 1 << pixdesc->log2_chroma_w);
  786. r_h = FFALIGN(test->h * 2 / 3, 1 << pixdesc->log2_chroma_h);
  787. w_h = FFALIGN(test->h * 3 / 4 - r_h, 1 << pixdesc->log2_chroma_h);
  788. p_w = FFALIGN(r_w * 5 / 4, 1 << pixdesc->log2_chroma_w);
  789. p_h = test->h - w_h - r_h;
  790. for (i = 0; i < 7; i++) {
  791. draw_bar(test, rainbow[i], x, 0, r_w, r_h, picref);
  792. draw_bar(test, wobnair[i], x, r_h, r_w, w_h, picref);
  793. x += r_w;
  794. }
  795. x = 0;
  796. draw_bar(test, i_pixel, x, r_h + w_h, p_w, p_h, picref);
  797. x += p_w;
  798. draw_bar(test, white, x, r_h + w_h, p_w, p_h, picref);
  799. x += p_w;
  800. draw_bar(test, q_pixel, x, r_h + w_h, p_w, p_h, picref);
  801. x += p_w;
  802. tmp = FFALIGN(5 * r_w - x, 1 << pixdesc->log2_chroma_w);
  803. draw_bar(test, black, x, r_h + w_h, tmp, p_h, picref);
  804. x += tmp;
  805. tmp = FFALIGN(r_w / 3, 1 << pixdesc->log2_chroma_w);
  806. draw_bar(test, neg4ire, x, r_h + w_h, tmp, p_h, picref);
  807. x += tmp;
  808. draw_bar(test, black, x, r_h + w_h, tmp, p_h, picref);
  809. x += tmp;
  810. draw_bar(test, pos4ire, x, r_h + w_h, tmp, p_h, picref);
  811. x += tmp;
  812. draw_bar(test, black, x, r_h + w_h, test->w - x, p_h, picref);
  813. }
  814. static av_cold int smptebars_init(AVFilterContext *ctx)
  815. {
  816. TestSourceContext *test = ctx->priv;
  817. test->fill_picture_fn = smptebars_fill_picture;
  818. test->draw_once = 1;
  819. return init(ctx);
  820. }
  821. AVFilter ff_vsrc_smptebars = {
  822. .name = "smptebars",
  823. .description = NULL_IF_CONFIG_SMALL("Generate SMPTE color bars."),
  824. .priv_size = sizeof(TestSourceContext),
  825. .priv_class = &smptebars_class,
  826. .init = smptebars_init,
  827. .uninit = uninit,
  828. .query_formats = smptebars_query_formats,
  829. .inputs = NULL,
  830. .outputs = smptebars_outputs,
  831. };
  832. #endif /* CONFIG_SMPTEBARS_FILTER */
  833. #if CONFIG_SMPTEHDBARS_FILTER
  834. #define smptehdbars_options options
  835. AVFILTER_DEFINE_CLASS(smptehdbars);
  836. static void smptehdbars_fill_picture(AVFilterContext *ctx, AVFrame *picref)
  837. {
  838. TestSourceContext *test = ctx->priv;
  839. int d_w, r_w, r_h, l_w, i, tmp, x = 0, y = 0;
  840. const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format);
  841. av_frame_set_colorspace(picref, AVCOL_SPC_BT709);
  842. d_w = FFALIGN(test->w / 8, 1 << pixdesc->log2_chroma_w);
  843. r_h = FFALIGN(test->h * 7 / 12, 1 << pixdesc->log2_chroma_h);
  844. draw_bar(test, gray40, x, 0, d_w, r_h, picref);
  845. x += d_w;
  846. r_w = FFALIGN((((test->w + 3) / 4) * 3) / 7, 1 << pixdesc->log2_chroma_w);
  847. for (i = 0; i < 7; i++) {
  848. draw_bar(test, rainbow[i], x, 0, r_w, r_h, picref);
  849. x += r_w;
  850. }
  851. draw_bar(test, gray40, x, 0, test->w - x, r_h, picref);
  852. y = r_h;
  853. r_h = FFALIGN(test->h / 12, 1 << pixdesc->log2_chroma_h);
  854. draw_bar(test, cyan, 0, y, d_w, r_h, picref);
  855. x = d_w;
  856. draw_bar(test, i_pixel, x, y, r_w, r_h, picref);
  857. x += r_w;
  858. tmp = r_w * 6;
  859. draw_bar(test, rainbow[0], x, y, tmp, r_h, picref);
  860. x += tmp;
  861. l_w = x;
  862. draw_bar(test, blue, x, y, test->w - x, r_h, picref);
  863. y += r_h;
  864. draw_bar(test, yellow, 0, y, d_w, r_h, picref);
  865. x = d_w;
  866. draw_bar(test, q_pixel, x, y, r_w, r_h, picref);
  867. x += r_w;
  868. for (i = 0; i < tmp; i += 1 << pixdesc->log2_chroma_w) {
  869. uint8_t yramp[4] = {0};
  870. yramp[0] = i * 255 / tmp;
  871. yramp[1] = 128;
  872. yramp[2] = 128;
  873. yramp[3] = 255;
  874. draw_bar(test, yramp, x, y, 1 << pixdesc->log2_chroma_w, r_h, picref);
  875. x += 1 << pixdesc->log2_chroma_w;
  876. }
  877. draw_bar(test, red, x, y, test->w - x, r_h, picref);
  878. y += r_h;
  879. draw_bar(test, gray15, 0, y, d_w, test->h - y, picref);
  880. x = d_w;
  881. tmp = FFALIGN(r_w * 3 / 2, 1 << pixdesc->log2_chroma_w);
  882. draw_bar(test, black0, x, y, tmp, test->h - y, picref);
  883. x += tmp;
  884. tmp = FFALIGN(r_w * 2, 1 << pixdesc->log2_chroma_w);
  885. draw_bar(test, white, x, y, tmp, test->h - y, picref);
  886. x += tmp;
  887. tmp = FFALIGN(r_w * 5 / 6, 1 << pixdesc->log2_chroma_w);
  888. draw_bar(test, black0, x, y, tmp, test->h - y, picref);
  889. x += tmp;
  890. tmp = FFALIGN(r_w / 3, 1 << pixdesc->log2_chroma_w);
  891. draw_bar(test, neg2, x, y, tmp, test->h - y, picref);
  892. x += tmp;
  893. draw_bar(test, black0, x, y, tmp, test->h - y, picref);
  894. x += tmp;
  895. draw_bar(test, black2, x, y, tmp, test->h - y, picref);
  896. x += tmp;
  897. draw_bar(test, black0, x, y, tmp, test->h - y, picref);
  898. x += tmp;
  899. draw_bar(test, black4, x, y, tmp, test->h - y, picref);
  900. x += tmp;
  901. r_w = l_w - x;
  902. draw_bar(test, black0, x, y, r_w, test->h - y, picref);
  903. x += r_w;
  904. draw_bar(test, gray15, x, y, test->w - x, test->h - y, picref);
  905. }
  906. static av_cold int smptehdbars_init(AVFilterContext *ctx)
  907. {
  908. TestSourceContext *test = ctx->priv;
  909. test->fill_picture_fn = smptehdbars_fill_picture;
  910. test->draw_once = 1;
  911. return init(ctx);
  912. }
  913. AVFilter ff_vsrc_smptehdbars = {
  914. .name = "smptehdbars",
  915. .description = NULL_IF_CONFIG_SMALL("Generate SMPTE HD color bars."),
  916. .priv_size = sizeof(TestSourceContext),
  917. .priv_class = &smptehdbars_class,
  918. .init = smptehdbars_init,
  919. .uninit = uninit,
  920. .query_formats = smptebars_query_formats,
  921. .inputs = NULL,
  922. .outputs = smptebars_outputs,
  923. };
  924. #endif /* CONFIG_SMPTEHDBARS_FILTER */
  925. #endif /* CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER */