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.

1113 lines
37KB

  1. /*
  2. * Copyright (c) 2016 Paul B Mahol
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "libavutil/avassert.h"
  21. #include "libavutil/intreadwrite.h"
  22. #include "libavutil/opt.h"
  23. #include "libavutil/parseutils.h"
  24. #include "libavutil/pixdesc.h"
  25. #include "libavutil/xga_font_data.h"
  26. #include "avfilter.h"
  27. #include "drawutils.h"
  28. #include "formats.h"
  29. #include "internal.h"
  30. #include "video.h"
  31. typedef struct DatascopeContext {
  32. const AVClass *class;
  33. int ow, oh;
  34. int x, y;
  35. int mode;
  36. int dformat;
  37. int axis;
  38. float opacity;
  39. int nb_planes;
  40. int nb_comps;
  41. int chars;
  42. FFDrawContext draw;
  43. FFDrawColor yellow;
  44. FFDrawColor white;
  45. FFDrawColor black;
  46. FFDrawColor gray;
  47. void (*pick_color)(FFDrawContext *draw, FFDrawColor *color, AVFrame *in, int x, int y, int *value);
  48. void (*reverse_color)(FFDrawContext *draw, FFDrawColor *color, FFDrawColor *reverse);
  49. int (*filter)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
  50. } DatascopeContext;
  51. #define OFFSET(x) offsetof(DatascopeContext, x)
  52. #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
  53. #define FLAGSR AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
  54. static const AVOption datascope_options[] = {
  55. { "size", "set output size", OFFSET(ow), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
  56. { "s", "set output size", OFFSET(ow), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
  57. { "x", "set x offset", OFFSET(x), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
  58. { "y", "set y offset", OFFSET(y), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
  59. { "mode", "set scope mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "mode" },
  60. { "mono", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "mode" },
  61. { "color", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "mode" },
  62. { "color2", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "mode" },
  63. { "axis", "draw column/row numbers", OFFSET(axis), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
  64. { "opacity", "set background opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, FLAGS },
  65. { "format", "set display number format", OFFSET(dformat), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "format" },
  66. { "hex", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "format" },
  67. { "dec", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "format" },
  68. { NULL }
  69. };
  70. AVFILTER_DEFINE_CLASS(datascope);
  71. static int query_formats(AVFilterContext *ctx)
  72. {
  73. return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
  74. }
  75. static void draw_text(FFDrawContext *draw, AVFrame *frame, FFDrawColor *color,
  76. int x0, int y0, const uint8_t *text, int vertical)
  77. {
  78. int x = x0;
  79. for (; *text; text++) {
  80. if (*text == '\n') {
  81. x = x0;
  82. y0 += 8;
  83. continue;
  84. }
  85. ff_blend_mask(draw, color, frame->data, frame->linesize,
  86. frame->width, frame->height,
  87. avpriv_cga_font + *text * 8, 1, 8, 8, 0, 0, x, y0);
  88. if (vertical) {
  89. x = x0;
  90. y0 += 8;
  91. } else {
  92. x += 8;
  93. }
  94. }
  95. }
  96. static void pick_color8(FFDrawContext *draw, FFDrawColor *color, AVFrame *in, int x, int y, int *value)
  97. {
  98. int p, i;
  99. color->rgba[3] = 255;
  100. for (p = 0; p < draw->nb_planes; p++) {
  101. if (draw->nb_planes == 1) {
  102. for (i = 0; i < 4; i++) {
  103. value[i] = in->data[0][y * in->linesize[0] + x * draw->pixelstep[0] + i];
  104. color->comp[0].u8[i] = value[i];
  105. }
  106. } else {
  107. value[p] = in->data[p][(y >> draw->vsub[p]) * in->linesize[p] + (x >> draw->hsub[p])];
  108. color->comp[p].u8[0] = value[p];
  109. }
  110. }
  111. }
  112. static void pick_color16(FFDrawContext *draw, FFDrawColor *color, AVFrame *in, int x, int y, int *value)
  113. {
  114. int p, i;
  115. color->rgba[3] = 255;
  116. for (p = 0; p < draw->nb_planes; p++) {
  117. if (draw->nb_planes == 1) {
  118. for (i = 0; i < 4; i++) {
  119. value[i] = AV_RL16(in->data[0] + y * in->linesize[0] + x * draw->pixelstep[0] + i * 2);
  120. color->comp[0].u16[i] = value[i];
  121. }
  122. } else {
  123. value[p] = AV_RL16(in->data[p] + (y >> draw->vsub[p]) * in->linesize[p] + (x >> draw->hsub[p]) * 2);
  124. color->comp[p].u16[0] = value[p];
  125. }
  126. }
  127. }
  128. static void reverse_color8(FFDrawContext *draw, FFDrawColor *color, FFDrawColor *reverse)
  129. {
  130. int p;
  131. reverse->rgba[3] = 255;
  132. for (p = 0; p < draw->nb_planes; p++) {
  133. reverse->comp[p].u8[0] = color->comp[p].u8[0] > 127 ? 0 : 255;
  134. reverse->comp[p].u8[1] = color->comp[p].u8[1] > 127 ? 0 : 255;
  135. reverse->comp[p].u8[2] = color->comp[p].u8[2] > 127 ? 0 : 255;
  136. }
  137. }
  138. static void reverse_color16(FFDrawContext *draw, FFDrawColor *color, FFDrawColor *reverse)
  139. {
  140. int p;
  141. reverse->rgba[3] = 255;
  142. for (p = 0; p < draw->nb_planes; p++) {
  143. const unsigned max = (1 << draw->desc->comp[p].depth) - 1;
  144. const unsigned mid = (max + 1) / 2;
  145. reverse->comp[p].u16[0] = color->comp[p].u16[0] > mid ? 0 : max;
  146. reverse->comp[p].u16[1] = color->comp[p].u16[1] > mid ? 0 : max;
  147. reverse->comp[p].u16[2] = color->comp[p].u16[2] > mid ? 0 : max;
  148. }
  149. }
  150. typedef struct ThreadData {
  151. AVFrame *in, *out;
  152. int xoff, yoff;
  153. } ThreadData;
  154. static int filter_color2(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
  155. {
  156. DatascopeContext *s = ctx->priv;
  157. AVFilterLink *outlink = ctx->outputs[0];
  158. AVFilterLink *inlink = ctx->inputs[0];
  159. ThreadData *td = arg;
  160. AVFrame *in = td->in;
  161. AVFrame *out = td->out;
  162. const int xoff = td->xoff;
  163. const int yoff = td->yoff;
  164. const int P = FFMAX(s->nb_planes, s->nb_comps);
  165. const int C = s->chars;
  166. const int D = ((s->chars - s->dformat) >> 2) + s->dformat * 2;
  167. const int W = (outlink->w - xoff) / (C * 10);
  168. const int H = (outlink->h - yoff) / (P * 12);
  169. const char *format[4] = {"%02X\n", "%04X\n", "%03d\n", "%05d\n"};
  170. const int slice_start = (W * jobnr) / nb_jobs;
  171. const int slice_end = (W * (jobnr+1)) / nb_jobs;
  172. int x, y, p;
  173. for (y = 0; y < H && (y + s->y < inlink->h); y++) {
  174. for (x = slice_start; x < slice_end && (x + s->x < inlink->w); x++) {
  175. FFDrawColor color = { { 0 } };
  176. FFDrawColor reverse = { { 0 } };
  177. int value[4] = { 0 };
  178. s->pick_color(&s->draw, &color, in, x + s->x, y + s->y, value);
  179. s->reverse_color(&s->draw, &color, &reverse);
  180. ff_fill_rectangle(&s->draw, &color, out->data, out->linesize,
  181. xoff + x * C * 10, yoff + y * P * 12, C * 10, P * 12);
  182. for (p = 0; p < P; p++) {
  183. char text[256];
  184. snprintf(text, sizeof(text), format[D], value[p]);
  185. draw_text(&s->draw, out, &reverse, xoff + x * C * 10 + 2, yoff + y * P * 12 + p * 10 + 2, text, 0);
  186. }
  187. }
  188. }
  189. return 0;
  190. }
  191. static int filter_color(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
  192. {
  193. DatascopeContext *s = ctx->priv;
  194. AVFilterLink *outlink = ctx->outputs[0];
  195. AVFilterLink *inlink = ctx->inputs[0];
  196. ThreadData *td = arg;
  197. AVFrame *in = td->in;
  198. AVFrame *out = td->out;
  199. const int xoff = td->xoff;
  200. const int yoff = td->yoff;
  201. const int P = FFMAX(s->nb_planes, s->nb_comps);
  202. const int C = s->chars;
  203. const int D = ((s->chars - s->dformat) >> 2) + s->dformat * 2;
  204. const int W = (outlink->w - xoff) / (C * 10);
  205. const int H = (outlink->h - yoff) / (P * 12);
  206. const char *format[4] = {"%02X\n", "%04X\n", "%03d\n", "%05d\n"};
  207. const int slice_start = (W * jobnr) / nb_jobs;
  208. const int slice_end = (W * (jobnr+1)) / nb_jobs;
  209. int x, y, p;
  210. for (y = 0; y < H && (y + s->y < inlink->h); y++) {
  211. for (x = slice_start; x < slice_end && (x + s->x < inlink->w); x++) {
  212. FFDrawColor color = { { 0 } };
  213. int value[4] = { 0 };
  214. s->pick_color(&s->draw, &color, in, x + s->x, y + s->y, value);
  215. for (p = 0; p < P; p++) {
  216. char text[256];
  217. snprintf(text, sizeof(text), format[D], value[p]);
  218. draw_text(&s->draw, out, &color, xoff + x * C * 10 + 2, yoff + y * P * 12 + p * 10 + 2, text, 0);
  219. }
  220. }
  221. }
  222. return 0;
  223. }
  224. static int filter_mono(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
  225. {
  226. DatascopeContext *s = ctx->priv;
  227. AVFilterLink *outlink = ctx->outputs[0];
  228. AVFilterLink *inlink = ctx->inputs[0];
  229. ThreadData *td = arg;
  230. AVFrame *in = td->in;
  231. AVFrame *out = td->out;
  232. const int xoff = td->xoff;
  233. const int yoff = td->yoff;
  234. const int P = FFMAX(s->nb_planes, s->nb_comps);
  235. const int C = s->chars;
  236. const int D = ((s->chars - s->dformat) >> 2) + s->dformat * 2;
  237. const int W = (outlink->w - xoff) / (C * 10);
  238. const int H = (outlink->h - yoff) / (P * 12);
  239. const char *format[4] = {"%02X\n", "%04X\n", "%03d\n", "%05d\n"};
  240. const int slice_start = (W * jobnr) / nb_jobs;
  241. const int slice_end = (W * (jobnr+1)) / nb_jobs;
  242. int x, y, p;
  243. for (y = 0; y < H && (y + s->y < inlink->h); y++) {
  244. for (x = slice_start; x < slice_end && (x + s->x < inlink->w); x++) {
  245. FFDrawColor color = { { 0 } };
  246. int value[4] = { 0 };
  247. s->pick_color(&s->draw, &color, in, x + s->x, y + s->y, value);
  248. for (p = 0; p < P; p++) {
  249. char text[256];
  250. snprintf(text, sizeof(text), format[D], value[p]);
  251. draw_text(&s->draw, out, &s->white, xoff + x * C * 10 + 2, yoff + y * P * 12 + p * 10 + 2, text, 0);
  252. }
  253. }
  254. }
  255. return 0;
  256. }
  257. static int filter_frame(AVFilterLink *inlink, AVFrame *in)
  258. {
  259. AVFilterContext *ctx = inlink->dst;
  260. DatascopeContext *s = ctx->priv;
  261. AVFilterLink *outlink = ctx->outputs[0];
  262. ThreadData td = { 0 };
  263. int ymaxlen = 0;
  264. int xmaxlen = 0;
  265. AVFrame *out;
  266. out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
  267. if (!out) {
  268. av_frame_free(&in);
  269. return AVERROR(ENOMEM);
  270. }
  271. out->pts = in->pts;
  272. ff_fill_rectangle(&s->draw, &s->black, out->data, out->linesize,
  273. 0, 0, outlink->w, outlink->h);
  274. if (s->axis) {
  275. const int P = FFMAX(s->nb_planes, s->nb_comps);
  276. const int C = s->chars;
  277. int Y = outlink->h / (P * 12);
  278. int X = outlink->w / (C * 10);
  279. char text[256] = { 0 };
  280. int x, y;
  281. snprintf(text, sizeof(text), "%d", s->y + Y);
  282. ymaxlen = strlen(text);
  283. ymaxlen *= 10;
  284. snprintf(text, sizeof(text), "%d", s->x + X);
  285. xmaxlen = strlen(text);
  286. xmaxlen *= 10;
  287. Y = (outlink->h - xmaxlen) / (P * 12);
  288. X = (outlink->w - ymaxlen) / (C * 10);
  289. for (y = 0; y < Y; y++) {
  290. snprintf(text, sizeof(text), "%d", s->y + y);
  291. ff_fill_rectangle(&s->draw, &s->gray, out->data, out->linesize,
  292. 0, xmaxlen + y * P * 12 + (P + 1) * P - 2, ymaxlen, 10);
  293. draw_text(&s->draw, out, &s->yellow, 2, xmaxlen + y * P * 12 + (P + 1) * P, text, 0);
  294. }
  295. for (x = 0; x < X; x++) {
  296. snprintf(text, sizeof(text), "%d", s->x + x);
  297. ff_fill_rectangle(&s->draw, &s->gray, out->data, out->linesize,
  298. ymaxlen + x * C * 10 + 2 * C - 2, 0, 10, xmaxlen);
  299. draw_text(&s->draw, out, &s->yellow, ymaxlen + x * C * 10 + 2 * C, 2, text, 1);
  300. }
  301. }
  302. td.in = in; td.out = out, td.yoff = xmaxlen, td.xoff = ymaxlen;
  303. ctx->internal->execute(ctx, s->filter, &td, NULL, FFMIN(ff_filter_get_nb_threads(ctx), FFMAX(outlink->w / 20, 1)));
  304. av_frame_free(&in);
  305. return ff_filter_frame(outlink, out);
  306. }
  307. static int config_input(AVFilterLink *inlink)
  308. {
  309. DatascopeContext *s = inlink->dst->priv;
  310. uint8_t alpha = s->opacity * 255;
  311. s->nb_planes = av_pix_fmt_count_planes(inlink->format);
  312. ff_draw_init(&s->draw, inlink->format, 0);
  313. ff_draw_color(&s->draw, &s->white, (uint8_t[]){ 255, 255, 255, 255} );
  314. ff_draw_color(&s->draw, &s->black, (uint8_t[]){ 0, 0, 0, alpha} );
  315. ff_draw_color(&s->draw, &s->yellow, (uint8_t[]){ 255, 255, 0, 255} );
  316. ff_draw_color(&s->draw, &s->gray, (uint8_t[]){ 77, 77, 77, 255} );
  317. s->chars = (s->draw.desc->comp[0].depth + 7) / 8 * 2 + s->dformat;
  318. s->nb_comps = s->draw.desc->nb_components;
  319. switch (s->mode) {
  320. case 0: s->filter = filter_mono; break;
  321. case 1: s->filter = filter_color; break;
  322. case 2: s->filter = filter_color2; break;
  323. }
  324. if (s->draw.desc->comp[0].depth <= 8) {
  325. s->pick_color = pick_color8;
  326. s->reverse_color = reverse_color8;
  327. } else {
  328. s->pick_color = pick_color16;
  329. s->reverse_color = reverse_color16;
  330. }
  331. return 0;
  332. }
  333. static int config_output(AVFilterLink *outlink)
  334. {
  335. DatascopeContext *s = outlink->src->priv;
  336. outlink->h = s->oh;
  337. outlink->w = s->ow;
  338. outlink->sample_aspect_ratio = (AVRational){1,1};
  339. return 0;
  340. }
  341. static const AVFilterPad inputs[] = {
  342. {
  343. .name = "default",
  344. .type = AVMEDIA_TYPE_VIDEO,
  345. .filter_frame = filter_frame,
  346. .config_props = config_input,
  347. },
  348. { NULL }
  349. };
  350. static const AVFilterPad outputs[] = {
  351. {
  352. .name = "default",
  353. .type = AVMEDIA_TYPE_VIDEO,
  354. .config_props = config_output,
  355. },
  356. { NULL }
  357. };
  358. AVFilter ff_vf_datascope = {
  359. .name = "datascope",
  360. .description = NULL_IF_CONFIG_SMALL("Video data analysis."),
  361. .priv_size = sizeof(DatascopeContext),
  362. .priv_class = &datascope_class,
  363. .query_formats = query_formats,
  364. .inputs = inputs,
  365. .outputs = outputs,
  366. .flags = AVFILTER_FLAG_SLICE_THREADS,
  367. };
  368. typedef struct PixscopeContext {
  369. const AVClass *class;
  370. float xpos, ypos;
  371. float wx, wy;
  372. int w, h;
  373. float o;
  374. int x, y;
  375. int ww, wh;
  376. int nb_planes;
  377. int nb_comps;
  378. int is_rgb;
  379. uint8_t rgba_map[4];
  380. FFDrawContext draw;
  381. FFDrawColor dark;
  382. FFDrawColor black;
  383. FFDrawColor white;
  384. FFDrawColor green;
  385. FFDrawColor blue;
  386. FFDrawColor red;
  387. FFDrawColor *colors[4];
  388. uint16_t values[4][80][80];
  389. void (*pick_color)(FFDrawContext *draw, FFDrawColor *color, AVFrame *in, int x, int y, int *value);
  390. } PixscopeContext;
  391. #define POFFSET(x) offsetof(PixscopeContext, x)
  392. static const AVOption pixscope_options[] = {
  393. { "x", "set scope x offset", POFFSET(xpos), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGS },
  394. { "y", "set scope y offset", POFFSET(ypos), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGS },
  395. { "w", "set scope width", POFFSET(w), AV_OPT_TYPE_INT, {.i64=7}, 1, 80, FLAGS },
  396. { "h", "set scope height", POFFSET(h), AV_OPT_TYPE_INT, {.i64=7}, 1, 80, FLAGS },
  397. { "o", "set window opacity", POFFSET(o), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGS },
  398. { "wx", "set window x offset", POFFSET(wx), AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1, 1, FLAGS },
  399. { "wy", "set window y offset", POFFSET(wy), AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1, 1, FLAGS },
  400. { NULL }
  401. };
  402. AVFILTER_DEFINE_CLASS(pixscope);
  403. static int pixscope_config_input(AVFilterLink *inlink)
  404. {
  405. PixscopeContext *s = inlink->dst->priv;
  406. s->nb_planes = av_pix_fmt_count_planes(inlink->format);
  407. ff_draw_init(&s->draw, inlink->format, 0);
  408. ff_draw_color(&s->draw, &s->dark, (uint8_t[]){ 0, 0, 0, s->o * 255} );
  409. ff_draw_color(&s->draw, &s->black, (uint8_t[]){ 0, 0, 0, 255} );
  410. ff_draw_color(&s->draw, &s->white, (uint8_t[]){ 255, 255, 255, 255} );
  411. ff_draw_color(&s->draw, &s->green, (uint8_t[]){ 0, 255, 0, 255} );
  412. ff_draw_color(&s->draw, &s->blue, (uint8_t[]){ 0, 0, 255, 255} );
  413. ff_draw_color(&s->draw, &s->red, (uint8_t[]){ 255, 0, 0, 255} );
  414. s->nb_comps = s->draw.desc->nb_components;
  415. s->is_rgb = s->draw.desc->flags & AV_PIX_FMT_FLAG_RGB;
  416. if (s->is_rgb) {
  417. s->colors[0] = &s->red;
  418. s->colors[1] = &s->green;
  419. s->colors[2] = &s->blue;
  420. s->colors[3] = &s->white;
  421. ff_fill_rgba_map(s->rgba_map, inlink->format);
  422. } else {
  423. s->colors[0] = &s->white;
  424. s->colors[1] = &s->blue;
  425. s->colors[2] = &s->red;
  426. s->colors[3] = &s->white;
  427. s->rgba_map[0] = 0;
  428. s->rgba_map[1] = 1;
  429. s->rgba_map[2] = 2;
  430. s->rgba_map[3] = 3;
  431. }
  432. if (s->draw.desc->comp[0].depth <= 8) {
  433. s->pick_color = pick_color8;
  434. } else {
  435. s->pick_color = pick_color16;
  436. }
  437. if (inlink->w < 640 || inlink->h < 480) {
  438. av_log(inlink->dst, AV_LOG_ERROR, "min supported resolution is 640x480\n");
  439. return AVERROR(EINVAL);
  440. }
  441. s->ww = 300;
  442. s->wh = 300 * 1.6;
  443. s->x = s->xpos * (inlink->w - 1);
  444. s->y = s->ypos * (inlink->h - 1);
  445. if (s->x + s->w >= inlink->w || s->y + s->h >= inlink->h) {
  446. av_log(inlink->dst, AV_LOG_WARNING, "scope position is out of range, clipping\n");
  447. s->x = FFMIN(s->x, inlink->w - s->w);
  448. s->y = FFMIN(s->y, inlink->h - s->h);
  449. }
  450. return 0;
  451. }
  452. #define SQR(x) ((x)*(x))
  453. static int pixscope_filter_frame(AVFilterLink *inlink, AVFrame *in)
  454. {
  455. AVFilterContext *ctx = inlink->dst;
  456. PixscopeContext *s = ctx->priv;
  457. AVFilterLink *outlink = ctx->outputs[0];
  458. AVFrame *out = ff_get_video_buffer(outlink, in->width, in->height);
  459. int max[4] = { 0 }, min[4] = { INT_MAX, INT_MAX, INT_MAX, INT_MAX };
  460. float average[4] = { 0 };
  461. double std[4] = { 0 }, rms[4] = { 0 };
  462. const char rgba[4] = { 'R', 'G', 'B', 'A' };
  463. const char yuva[4] = { 'Y', 'U', 'V', 'A' };
  464. int x, y, X, Y, i, w, h;
  465. char text[128];
  466. if (!out) {
  467. av_frame_free(&in);
  468. return AVERROR(ENOMEM);
  469. }
  470. av_frame_copy_props(out, in);
  471. av_frame_copy(out, in);
  472. w = s->ww / s->w;
  473. h = s->ww / s->h;
  474. if (s->wx >= 0) {
  475. X = (in->width - s->ww) * s->wx;
  476. } else {
  477. X = (in->width - s->ww) * -s->wx;
  478. }
  479. if (s->wy >= 0) {
  480. Y = (in->height - s->wh) * s->wy;
  481. } else {
  482. Y = (in->height - s->wh) * -s->wy;
  483. }
  484. if (s->wx < 0) {
  485. if (s->x + s->w >= X && (s->x + s->w <= X + s->ww) &&
  486. s->y + s->h >= Y && (s->y + s->h <= Y + s->wh)) {
  487. X = (in->width - s->ww) * (1 + s->wx);
  488. }
  489. }
  490. if (s->wy < 0) {
  491. if (s->x + s->w >= X && (s->x + s->w <= X + s->ww) &&
  492. s->y + s->h >= Y && (s->y + s->h <= Y + s->wh)) {
  493. Y = (in->height - s->wh) * (1 + s->wy);
  494. }
  495. }
  496. ff_blend_rectangle(&s->draw, &s->dark, out->data, out->linesize,
  497. out->width, out->height,
  498. X,
  499. Y,
  500. s->ww,
  501. s->wh);
  502. for (y = 0; y < s->h; y++) {
  503. for (x = 0; x < s->w; x++) {
  504. FFDrawColor color = { { 0 } };
  505. int value[4] = { 0 };
  506. s->pick_color(&s->draw, &color, in, x + s->x, y + s->y, value);
  507. ff_fill_rectangle(&s->draw, &color, out->data, out->linesize,
  508. x * w + (s->ww - 4 - (s->w * w)) / 2 + X, y * h + 2 + Y, w, h);
  509. for (i = 0; i < 4; i++) {
  510. s->values[i][x][y] = value[i];
  511. rms[i] += (double)value[i] * (double)value[i];
  512. average[i] += value[i];
  513. min[i] = FFMIN(min[i], value[i]);
  514. max[i] = FFMAX(max[i], value[i]);
  515. }
  516. }
  517. }
  518. ff_blend_rectangle(&s->draw, &s->black, out->data, out->linesize,
  519. out->width, out->height,
  520. s->x - 2, s->y - 2, s->w + 4, 1);
  521. ff_blend_rectangle(&s->draw, &s->white, out->data, out->linesize,
  522. out->width, out->height,
  523. s->x - 1, s->y - 1, s->w + 2, 1);
  524. ff_blend_rectangle(&s->draw, &s->white, out->data, out->linesize,
  525. out->width, out->height,
  526. s->x - 1, s->y - 1, 1, s->h + 2);
  527. ff_blend_rectangle(&s->draw, &s->black, out->data, out->linesize,
  528. out->width, out->height,
  529. s->x - 2, s->y - 2, 1, s->h + 4);
  530. ff_blend_rectangle(&s->draw, &s->white, out->data, out->linesize,
  531. out->width, out->height,
  532. s->x - 1, s->y + 1 + s->h, s->w + 3, 1);
  533. ff_blend_rectangle(&s->draw, &s->black, out->data, out->linesize,
  534. out->width, out->height,
  535. s->x - 2, s->y + 2 + s->h, s->w + 4, 1);
  536. ff_blend_rectangle(&s->draw, &s->white, out->data, out->linesize,
  537. out->width, out->height,
  538. s->x + 1 + s->w, s->y - 1, 1, s->h + 2);
  539. ff_blend_rectangle(&s->draw, &s->black, out->data, out->linesize,
  540. out->width, out->height,
  541. s->x + 2 + s->w, s->y - 2, 1, s->h + 5);
  542. for (i = 0; i < 4; i++) {
  543. rms[i] /= s->w * s->h;
  544. rms[i] = sqrt(rms[i]);
  545. average[i] /= s->w * s->h;
  546. }
  547. for (y = 0; y < s->h; y++) {
  548. for (x = 0; x < s->w; x++) {
  549. for (i = 0; i < 4; i++)
  550. std[i] += SQR(s->values[i][x][y] - average[i]);
  551. }
  552. }
  553. for (i = 0; i < 4; i++) {
  554. std[i] /= s->w * s->h;
  555. std[i] = sqrt(std[i]);
  556. }
  557. snprintf(text, sizeof(text), "CH AVG MIN MAX RMS\n");
  558. draw_text(&s->draw, out, &s->white, X + 28, Y + s->ww + 5, text, 0);
  559. for (i = 0; i < s->nb_comps; i++) {
  560. int c = s->rgba_map[i];
  561. snprintf(text, sizeof(text), "%c %07.1f %05d %05d %07.1f\n", s->is_rgb ? rgba[i] : yuva[i], average[c], min[c], max[c], rms[c]);
  562. draw_text(&s->draw, out, s->colors[i], X + 28, Y + s->ww + 15 * (i + 1), text, 0);
  563. }
  564. snprintf(text, sizeof(text), "CH STD\n");
  565. draw_text(&s->draw, out, &s->white, X + 28, Y + s->ww + 15 * (0 + 5), text, 0);
  566. for (i = 0; i < s->nb_comps; i++) {
  567. int c = s->rgba_map[i];
  568. snprintf(text, sizeof(text), "%c %07.2f\n", s->is_rgb ? rgba[i] : yuva[i], std[c]);
  569. draw_text(&s->draw, out, s->colors[i], X + 28, Y + s->ww + 15 * (i + 6), text, 0);
  570. }
  571. av_frame_free(&in);
  572. return ff_filter_frame(outlink, out);
  573. }
  574. static const AVFilterPad pixscope_inputs[] = {
  575. {
  576. .name = "default",
  577. .type = AVMEDIA_TYPE_VIDEO,
  578. .filter_frame = pixscope_filter_frame,
  579. .config_props = pixscope_config_input,
  580. },
  581. { NULL }
  582. };
  583. static const AVFilterPad pixscope_outputs[] = {
  584. {
  585. .name = "default",
  586. .type = AVMEDIA_TYPE_VIDEO,
  587. },
  588. { NULL }
  589. };
  590. AVFilter ff_vf_pixscope = {
  591. .name = "pixscope",
  592. .description = NULL_IF_CONFIG_SMALL("Pixel data analysis."),
  593. .priv_size = sizeof(PixscopeContext),
  594. .priv_class = &pixscope_class,
  595. .query_formats = query_formats,
  596. .inputs = pixscope_inputs,
  597. .outputs = pixscope_outputs,
  598. .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
  599. };
  600. typedef struct PixelValues {
  601. uint16_t p[4];
  602. } PixelValues;
  603. typedef struct OscilloscopeContext {
  604. const AVClass *class;
  605. float xpos, ypos;
  606. float tx, ty;
  607. float size;
  608. float tilt;
  609. float theight, twidth;
  610. float o;
  611. int components;
  612. int grid;
  613. int statistics;
  614. int scope;
  615. int x1, y1, x2, y2;
  616. int ox, oy;
  617. int height, width;
  618. int max;
  619. int nb_planes;
  620. int nb_comps;
  621. int is_rgb;
  622. uint8_t rgba_map[4];
  623. FFDrawContext draw;
  624. FFDrawColor dark;
  625. FFDrawColor black;
  626. FFDrawColor white;
  627. FFDrawColor green;
  628. FFDrawColor blue;
  629. FFDrawColor red;
  630. FFDrawColor cyan;
  631. FFDrawColor magenta;
  632. FFDrawColor gray;
  633. FFDrawColor *colors[4];
  634. int nb_values;
  635. PixelValues *values;
  636. void (*pick_color)(FFDrawContext *draw, FFDrawColor *color, AVFrame *in, int x, int y, int *value);
  637. void (*draw_trace)(struct OscilloscopeContext *s, AVFrame *frame);
  638. } OscilloscopeContext;
  639. #define OOFFSET(x) offsetof(OscilloscopeContext, x)
  640. static const AVOption oscilloscope_options[] = {
  641. { "x", "set scope x position", OOFFSET(xpos), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGSR },
  642. { "y", "set scope y position", OOFFSET(ypos), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGSR },
  643. { "s", "set scope size", OOFFSET(size), AV_OPT_TYPE_FLOAT, {.dbl=0.8}, 0, 1, FLAGSR },
  644. { "t", "set scope tilt", OOFFSET(tilt), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGSR },
  645. { "o", "set trace opacity", OOFFSET(o), AV_OPT_TYPE_FLOAT, {.dbl=0.8}, 0, 1, FLAGSR },
  646. { "tx", "set trace x position", OOFFSET(tx), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGSR },
  647. { "ty", "set trace y position", OOFFSET(ty), AV_OPT_TYPE_FLOAT, {.dbl=0.9}, 0, 1, FLAGSR },
  648. { "tw", "set trace width", OOFFSET(twidth), AV_OPT_TYPE_FLOAT, {.dbl=0.8},.1, 1, FLAGSR },
  649. { "th", "set trace height", OOFFSET(theight), AV_OPT_TYPE_FLOAT, {.dbl=0.3},.1, 1, FLAGSR },
  650. { "c", "set components to trace", OOFFSET(components), AV_OPT_TYPE_INT, {.i64=7}, 0, 15, FLAGSR },
  651. { "g", "draw trace grid", OOFFSET(grid), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGSR },
  652. { "st", "draw statistics", OOFFSET(statistics), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGSR },
  653. { "sc", "draw scope", OOFFSET(scope), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGSR },
  654. { NULL }
  655. };
  656. AVFILTER_DEFINE_CLASS(oscilloscope);
  657. static void oscilloscope_uninit(AVFilterContext *ctx)
  658. {
  659. OscilloscopeContext *s = ctx->priv;
  660. av_freep(&s->values);
  661. }
  662. static void draw_line(FFDrawContext *draw, int x0, int y0, int x1, int y1,
  663. AVFrame *out, FFDrawColor *color)
  664. {
  665. int dx = FFABS(x1 - x0), sx = x0 < x1 ? 1 : -1;
  666. int dy = FFABS(y1 - y0), sy = y0 < y1 ? 1 : -1;
  667. int err = (dx > dy ? dx : -dy) / 2, e2;
  668. int p, i;
  669. for (;;) {
  670. if (x0 >= 0 && y0 >= 0 && x0 < out->width && y0 < out->height) {
  671. for (p = 0; p < draw->nb_planes; p++) {
  672. if (draw->desc->comp[p].depth == 8) {
  673. if (draw->nb_planes == 1) {
  674. for (i = 0; i < 4; i++) {
  675. out->data[0][y0 * out->linesize[0] + x0 * draw->pixelstep[0] + i] = color->comp[0].u8[i];
  676. }
  677. } else {
  678. out->data[p][out->linesize[p] * (y0 >> draw->vsub[p]) + (x0 >> draw->hsub[p])] = color->comp[p].u8[0];
  679. }
  680. } else {
  681. if (draw->nb_planes == 1) {
  682. for (i = 0; i < 4; i++) {
  683. AV_WN16(out->data[0] + y0 * out->linesize[0] + 2 * (x0 * draw->pixelstep[0] + i), color->comp[0].u16[i]);
  684. }
  685. } else {
  686. AV_WN16(out->data[p] + out->linesize[p] * (y0 >> draw->vsub[p]) + (x0 >> draw->hsub[p]) * 2, color->comp[p].u16[0]);
  687. }
  688. }
  689. }
  690. }
  691. if (x0 == x1 && y0 == y1)
  692. break;
  693. e2 = err;
  694. if (e2 >-dx) {
  695. err -= dy;
  696. x0 += sx;
  697. }
  698. if (e2 < dy) {
  699. err += dx;
  700. y0 += sy;
  701. }
  702. }
  703. }
  704. static void draw_trace8(OscilloscopeContext *s, AVFrame *frame)
  705. {
  706. int i, c;
  707. for (i = 1; i < s->nb_values; i++) {
  708. for (c = 0; c < s->nb_comps; c++) {
  709. if ((1 << c) & s->components) {
  710. int x = i * s->width / s->nb_values;
  711. int px = (i - 1) * s->width / s->nb_values;
  712. int py = s->height - s->values[i-1].p[s->rgba_map[c]] * s->height / 256;
  713. int y = s->height - s->values[i].p[s->rgba_map[c]] * s->height / 256;
  714. draw_line(&s->draw, s->ox + x, s->oy + y, s->ox + px, s->oy + py, frame, s->colors[c]);
  715. }
  716. }
  717. }
  718. }
  719. static void draw_trace16(OscilloscopeContext *s, AVFrame *frame)
  720. {
  721. int i, c;
  722. for (i = 1; i < s->nb_values; i++) {
  723. for (c = 0; c < s->nb_comps; c++) {
  724. if ((1 << c) & s->components) {
  725. int x = i * s->width / s->nb_values;
  726. int px = (i - 1) * s->width / s->nb_values;
  727. int py = s->height - s->values[i-1].p[s->rgba_map[c]] * s->height / s->max;
  728. int y = s->height - s->values[i].p[s->rgba_map[c]] * s->height / s->max;
  729. draw_line(&s->draw, s->ox + x, s->oy + y, s->ox + px, s->oy + py, frame, s->colors[c]);
  730. }
  731. }
  732. }
  733. }
  734. static void update_oscilloscope(AVFilterContext *ctx)
  735. {
  736. OscilloscopeContext *s = ctx->priv;
  737. AVFilterLink *inlink = ctx->inputs[0];
  738. int cx, cy, size;
  739. double tilt;
  740. ff_draw_color(&s->draw, &s->dark, (uint8_t[]){ 0, 0, 0, s->o * 255} );
  741. s->height = s->theight * inlink->h;
  742. s->width = s->twidth * inlink->w;
  743. size = hypot(inlink->w, inlink->h);
  744. size *= s->size;
  745. tilt = (s->tilt - 0.5) * M_PI;
  746. cx = s->xpos * (inlink->w - 1);
  747. cy = s->ypos * (inlink->h - 1);
  748. s->x1 = cx - size / 2.0 * cos(tilt);
  749. s->x2 = cx + size / 2.0 * cos(tilt);
  750. s->y1 = cy - size / 2.0 * sin(tilt);
  751. s->y2 = cy + size / 2.0 * sin(tilt);
  752. s->ox = (inlink->w - s->width) * s->tx;
  753. s->oy = (inlink->h - s->height) * s->ty;
  754. }
  755. static int oscilloscope_config_input(AVFilterLink *inlink)
  756. {
  757. OscilloscopeContext *s = inlink->dst->priv;
  758. int size;
  759. s->nb_planes = av_pix_fmt_count_planes(inlink->format);
  760. ff_draw_init(&s->draw, inlink->format, 0);
  761. ff_draw_color(&s->draw, &s->black, (uint8_t[]){ 0, 0, 0, 255} );
  762. ff_draw_color(&s->draw, &s->white, (uint8_t[]){ 255, 255, 255, 255} );
  763. ff_draw_color(&s->draw, &s->green, (uint8_t[]){ 0, 255, 0, 255} );
  764. ff_draw_color(&s->draw, &s->blue, (uint8_t[]){ 0, 0, 255, 255} );
  765. ff_draw_color(&s->draw, &s->red, (uint8_t[]){ 255, 0, 0, 255} );
  766. ff_draw_color(&s->draw, &s->cyan, (uint8_t[]){ 0, 255, 255, 255} );
  767. ff_draw_color(&s->draw, &s->magenta, (uint8_t[]){ 255, 0, 255, 255} );
  768. ff_draw_color(&s->draw, &s->gray, (uint8_t[]){ 128, 128, 128, 255} );
  769. s->nb_comps = s->draw.desc->nb_components;
  770. s->is_rgb = s->draw.desc->flags & AV_PIX_FMT_FLAG_RGB;
  771. if (s->is_rgb) {
  772. s->colors[0] = &s->red;
  773. s->colors[1] = &s->green;
  774. s->colors[2] = &s->blue;
  775. s->colors[3] = &s->white;
  776. ff_fill_rgba_map(s->rgba_map, inlink->format);
  777. } else {
  778. s->colors[0] = &s->white;
  779. s->colors[1] = &s->cyan;
  780. s->colors[2] = &s->magenta;
  781. s->colors[3] = &s->white;
  782. s->rgba_map[0] = 0;
  783. s->rgba_map[1] = 1;
  784. s->rgba_map[2] = 2;
  785. s->rgba_map[3] = 3;
  786. }
  787. if (s->draw.desc->comp[0].depth <= 8) {
  788. s->pick_color = pick_color8;
  789. s->draw_trace = draw_trace8;
  790. } else {
  791. s->pick_color = pick_color16;
  792. s->draw_trace = draw_trace16;
  793. }
  794. s->max = (1 << s->draw.desc->comp[0].depth);
  795. size = hypot(inlink->w, inlink->h);
  796. s->values = av_calloc(size, sizeof(*s->values));
  797. if (!s->values)
  798. return AVERROR(ENOMEM);
  799. update_oscilloscope(inlink->dst);
  800. return 0;
  801. }
  802. static void draw_scope(OscilloscopeContext *s, int x0, int y0, int x1, int y1,
  803. AVFrame *out, PixelValues *p, int state)
  804. {
  805. int dx = FFABS(x1 - x0), sx = x0 < x1 ? 1 : -1;
  806. int dy = FFABS(y1 - y0), sy = y0 < y1 ? 1 : -1;
  807. int err = (dx > dy ? dx : -dy) / 2, e2;
  808. for (;;) {
  809. if (x0 >= 0 && y0 >= 0 && x0 < out->width && y0 < out->height) {
  810. FFDrawColor color = { { 0 } };
  811. int value[4] = { 0 };
  812. s->pick_color(&s->draw, &color, out, x0, y0, value);
  813. s->values[s->nb_values].p[0] = value[0];
  814. s->values[s->nb_values].p[1] = value[1];
  815. s->values[s->nb_values].p[2] = value[2];
  816. s->values[s->nb_values].p[3] = value[3];
  817. s->nb_values++;
  818. if (s->scope) {
  819. if (s->draw.desc->comp[0].depth == 8) {
  820. if (s->draw.nb_planes == 1) {
  821. int i;
  822. for (i = 0; i < s->draw.pixelstep[0]; i++)
  823. out->data[0][out->linesize[0] * y0 + x0 * s->draw.pixelstep[0] + i] = 255 * ((s->nb_values + state) & 1);
  824. } else {
  825. out->data[0][out->linesize[0] * y0 + x0] = 255 * ((s->nb_values + state) & 1);
  826. }
  827. } else {
  828. if (s->draw.nb_planes == 1) {
  829. int i;
  830. for (i = 0; i < s->draw.pixelstep[0]; i++)
  831. AV_WN16(out->data[0] + out->linesize[0] * y0 + 2 * x0 * (s->draw.pixelstep[0] + i), (s->max - 1) * ((s->nb_values + state) & 1));
  832. } else {
  833. AV_WN16(out->data[0] + out->linesize[0] * y0 + 2 * x0, (s->max - 1) * ((s->nb_values + state) & 1));
  834. }
  835. }
  836. }
  837. }
  838. if (x0 == x1 && y0 == y1)
  839. break;
  840. e2 = err;
  841. if (e2 >-dx) {
  842. err -= dy;
  843. x0 += sx;
  844. }
  845. if (e2 < dy) {
  846. err += dx;
  847. y0 += sy;
  848. }
  849. }
  850. }
  851. static int oscilloscope_filter_frame(AVFilterLink *inlink, AVFrame *frame)
  852. {
  853. AVFilterContext *ctx = inlink->dst;
  854. OscilloscopeContext *s = ctx->priv;
  855. AVFilterLink *outlink = ctx->outputs[0];
  856. float average[4] = { 0 };
  857. int max[4] = { 0 };
  858. int min[4] = { INT_MAX, INT_MAX, INT_MAX, INT_MAX };
  859. int i, c;
  860. s->nb_values = 0;
  861. draw_scope(s, s->x1, s->y1, s->x2, s->y2, frame, s->values, inlink->frame_count_in & 1);
  862. ff_blend_rectangle(&s->draw, &s->dark, frame->data, frame->linesize,
  863. frame->width, frame->height,
  864. s->ox, s->oy, s->width, s->height + 20 * s->statistics);
  865. if (s->grid && outlink->h >= 10) {
  866. ff_fill_rectangle(&s->draw, &s->gray, frame->data, frame->linesize,
  867. s->ox, s->oy, s->width - 1, 1);
  868. for (i = 1; i < 5; i++) {
  869. ff_fill_rectangle(&s->draw, &s->gray, frame->data, frame->linesize,
  870. s->ox, s->oy + i * (s->height - 1) / 4, s->width, 1);
  871. }
  872. for (i = 0; i < 10; i++) {
  873. ff_fill_rectangle(&s->draw, &s->gray, frame->data, frame->linesize,
  874. s->ox + i * (s->width - 1) / 10, s->oy, 1, s->height);
  875. }
  876. ff_fill_rectangle(&s->draw, &s->gray, frame->data, frame->linesize,
  877. s->ox + s->width - 1, s->oy, 1, s->height);
  878. }
  879. s->draw_trace(s, frame);
  880. for (i = 0; i < s->nb_values; i++) {
  881. for (c = 0; c < s->nb_comps; c++) {
  882. if ((1 << c) & s->components) {
  883. max[c] = FFMAX(max[c], s->values[i].p[s->rgba_map[c]]);
  884. min[c] = FFMIN(min[c], s->values[i].p[s->rgba_map[c]]);
  885. average[c] += s->values[i].p[s->rgba_map[c]];
  886. }
  887. }
  888. }
  889. for (c = 0; c < s->nb_comps; c++) {
  890. average[c] /= s->nb_values;
  891. }
  892. if (s->statistics && s->height > 10 && s->width > 280 * av_popcount(s->components)) {
  893. for (c = 0, i = 0; c < s->nb_comps; c++) {
  894. if ((1 << c) & s->components) {
  895. const char rgba[4] = { 'R', 'G', 'B', 'A' };
  896. const char yuva[4] = { 'Y', 'U', 'V', 'A' };
  897. char text[128];
  898. snprintf(text, sizeof(text), "%c avg:%.1f min:%d max:%d\n", s->is_rgb ? rgba[c] : yuva[c], average[c], min[c], max[c]);
  899. draw_text(&s->draw, frame, &s->white, s->ox + 2 + 280 * i++, s->oy + s->height + 4, text, 0);
  900. }
  901. }
  902. }
  903. return ff_filter_frame(outlink, frame);
  904. }
  905. static int oscilloscope_process_command(AVFilterContext *ctx, const char *cmd, const char *args,
  906. char *res, int res_len, int flags)
  907. {
  908. int ret;
  909. ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
  910. if (ret < 0)
  911. return ret;
  912. update_oscilloscope(ctx);
  913. return 0;
  914. }
  915. static const AVFilterPad oscilloscope_inputs[] = {
  916. {
  917. .name = "default",
  918. .type = AVMEDIA_TYPE_VIDEO,
  919. .filter_frame = oscilloscope_filter_frame,
  920. .config_props = oscilloscope_config_input,
  921. .needs_writable = 1,
  922. },
  923. { NULL }
  924. };
  925. static const AVFilterPad oscilloscope_outputs[] = {
  926. {
  927. .name = "default",
  928. .type = AVMEDIA_TYPE_VIDEO,
  929. },
  930. { NULL }
  931. };
  932. AVFilter ff_vf_oscilloscope = {
  933. .name = "oscilloscope",
  934. .description = NULL_IF_CONFIG_SMALL("2D Video Oscilloscope."),
  935. .priv_size = sizeof(OscilloscopeContext),
  936. .priv_class = &oscilloscope_class,
  937. .query_formats = query_formats,
  938. .uninit = oscilloscope_uninit,
  939. .inputs = oscilloscope_inputs,
  940. .outputs = oscilloscope_outputs,
  941. .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
  942. .process_command = oscilloscope_process_command,
  943. };