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.

520 lines
21KB

  1. /*
  2. * Copyright (c) 2012-2019 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/colorspace.h"
  22. #include "libavutil/opt.h"
  23. #include "libavutil/parseutils.h"
  24. #include "libavutil/pixdesc.h"
  25. #include "libavutil/imgutils.h"
  26. #include "libavutil/intreadwrite.h"
  27. #include "avfilter.h"
  28. #include "formats.h"
  29. #include "internal.h"
  30. #include "video.h"
  31. typedef struct HistogramContext {
  32. const AVClass *class; ///< AVClass context for log and options purpose
  33. int thistogram;
  34. int envelope;
  35. unsigned histogram[256*256];
  36. int histogram_size;
  37. int width;
  38. int x_pos;
  39. int mult;
  40. int ncomp;
  41. int dncomp;
  42. uint8_t bg_color[4];
  43. uint8_t fg_color[4];
  44. uint8_t envelope_rgba[4];
  45. uint8_t envelope_color[4];
  46. int level_height;
  47. int scale_height;
  48. int display_mode;
  49. int levels_mode;
  50. const AVPixFmtDescriptor *desc, *odesc;
  51. int components;
  52. float fgopacity;
  53. float bgopacity;
  54. int planewidth[4];
  55. int planeheight[4];
  56. int start[4];
  57. AVFrame *out;
  58. } HistogramContext;
  59. #define OFFSET(x) offsetof(HistogramContext, x)
  60. #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
  61. #define COMMON_OPTIONS \
  62. { "display_mode", "set display mode", OFFSET(display_mode), AV_OPT_TYPE_INT, {.i64=2}, 0, 2, FLAGS, "display_mode"}, \
  63. { "d", "set display mode", OFFSET(display_mode), AV_OPT_TYPE_INT, {.i64=2}, 0, 2, FLAGS, "display_mode"}, \
  64. { "overlay", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "display_mode" }, \
  65. { "parade", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "display_mode" }, \
  66. { "stack", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "display_mode" }, \
  67. { "levels_mode", "set levels mode", OFFSET(levels_mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "levels_mode"}, \
  68. { "m", "set levels mode", OFFSET(levels_mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "levels_mode"}, \
  69. { "linear", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "levels_mode" }, \
  70. { "logarithmic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "levels_mode" }, \
  71. { "components", "set color components to display", OFFSET(components), AV_OPT_TYPE_INT, {.i64=7}, 1, 15, FLAGS}, \
  72. { "c", "set color components to display", OFFSET(components), AV_OPT_TYPE_INT, {.i64=7}, 1, 15, FLAGS},
  73. static const AVOption histogram_options[] = {
  74. { "level_height", "set level height", OFFSET(level_height), AV_OPT_TYPE_INT, {.i64=200}, 50, 2048, FLAGS},
  75. { "scale_height", "set scale height", OFFSET(scale_height), AV_OPT_TYPE_INT, {.i64=12}, 0, 40, FLAGS},
  76. COMMON_OPTIONS
  77. { "fgopacity", "set foreground opacity", OFFSET(fgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.7}, 0, 1, FLAGS},
  78. { "f", "set foreground opacity", OFFSET(fgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.7}, 0, 1, FLAGS},
  79. { "bgopacity", "set background opacity", OFFSET(bgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGS},
  80. { "b", "set background opacity", OFFSET(bgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGS},
  81. { NULL }
  82. };
  83. AVFILTER_DEFINE_CLASS(histogram);
  84. static const enum AVPixelFormat levels_in_pix_fmts[] = {
  85. AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P,
  86. AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVJ422P,
  87. AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUVJ411P,
  88. AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV410P,
  89. AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P,
  90. AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
  91. AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA444P9,
  92. AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
  93. AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10,
  94. AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV440P12,
  95. AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA444P12,
  96. AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRP,
  97. AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10,
  98. AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12,
  99. AV_PIX_FMT_GRAY8,
  100. AV_PIX_FMT_NONE
  101. };
  102. static const enum AVPixelFormat levels_out_yuv8_pix_fmts[] = {
  103. AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUV444P,
  104. AV_PIX_FMT_NONE
  105. };
  106. static const enum AVPixelFormat levels_out_yuv9_pix_fmts[] = {
  107. AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUV444P9,
  108. AV_PIX_FMT_NONE
  109. };
  110. static const enum AVPixelFormat levels_out_yuv10_pix_fmts[] = {
  111. AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUV444P10,
  112. AV_PIX_FMT_NONE
  113. };
  114. static const enum AVPixelFormat levels_out_yuv12_pix_fmts[] = {
  115. AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUV444P12,
  116. AV_PIX_FMT_NONE
  117. };
  118. static const enum AVPixelFormat levels_out_rgb8_pix_fmts[] = {
  119. AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRP,
  120. AV_PIX_FMT_NONE
  121. };
  122. static const enum AVPixelFormat levels_out_rgb9_pix_fmts[] = {
  123. AV_PIX_FMT_GBRP9,
  124. AV_PIX_FMT_NONE
  125. };
  126. static const enum AVPixelFormat levels_out_rgb10_pix_fmts[] = {
  127. AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10,
  128. AV_PIX_FMT_NONE
  129. };
  130. static const enum AVPixelFormat levels_out_rgb12_pix_fmts[] = {
  131. AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12,
  132. AV_PIX_FMT_NONE
  133. };
  134. static int query_formats(AVFilterContext *ctx)
  135. {
  136. AVFilterFormats *avff;
  137. const AVPixFmtDescriptor *desc;
  138. const enum AVPixelFormat *out_pix_fmts;
  139. int rgb, i, bits;
  140. int ret;
  141. if (!ctx->inputs[0]->in_formats ||
  142. !ctx->inputs[0]->in_formats->nb_formats) {
  143. return AVERROR(EAGAIN);
  144. }
  145. if (!ctx->inputs[0]->out_formats)
  146. if ((ret = ff_formats_ref(ff_make_format_list(levels_in_pix_fmts), &ctx->inputs[0]->out_formats)) < 0)
  147. return ret;
  148. avff = ctx->inputs[0]->in_formats;
  149. desc = av_pix_fmt_desc_get(avff->formats[0]);
  150. rgb = desc->flags & AV_PIX_FMT_FLAG_RGB;
  151. bits = desc->comp[0].depth;
  152. for (i = 1; i < avff->nb_formats; i++) {
  153. desc = av_pix_fmt_desc_get(avff->formats[i]);
  154. if ((rgb != (desc->flags & AV_PIX_FMT_FLAG_RGB)) ||
  155. (bits != desc->comp[0].depth))
  156. return AVERROR(EAGAIN);
  157. }
  158. if (rgb && bits == 8)
  159. out_pix_fmts = levels_out_rgb8_pix_fmts;
  160. else if (rgb && bits == 9)
  161. out_pix_fmts = levels_out_rgb9_pix_fmts;
  162. else if (rgb && bits == 10)
  163. out_pix_fmts = levels_out_rgb10_pix_fmts;
  164. else if (rgb && bits == 12)
  165. out_pix_fmts = levels_out_rgb12_pix_fmts;
  166. else if (bits == 8)
  167. out_pix_fmts = levels_out_yuv8_pix_fmts;
  168. else if (bits == 9)
  169. out_pix_fmts = levels_out_yuv9_pix_fmts;
  170. else if (bits == 10)
  171. out_pix_fmts = levels_out_yuv10_pix_fmts;
  172. else if (bits == 12)
  173. out_pix_fmts = levels_out_yuv12_pix_fmts;
  174. else
  175. return AVERROR(EAGAIN);
  176. if ((ret = ff_formats_ref(ff_make_format_list(out_pix_fmts), &ctx->outputs[0]->in_formats)) < 0)
  177. return ret;
  178. return 0;
  179. }
  180. static const uint8_t black_yuva_color[4] = { 0, 127, 127, 255 };
  181. static const uint8_t black_gbrp_color[4] = { 0, 0, 0, 255 };
  182. static const uint8_t white_yuva_color[4] = { 255, 127, 127, 255 };
  183. static const uint8_t white_gbrp_color[4] = { 255, 255, 255, 255 };
  184. static int config_input(AVFilterLink *inlink)
  185. {
  186. HistogramContext *s = inlink->dst->priv;
  187. s->desc = av_pix_fmt_desc_get(inlink->format);
  188. s->ncomp = s->desc->nb_components;
  189. s->histogram_size = 1 << s->desc->comp[0].depth;
  190. s->mult = s->histogram_size / 256;
  191. switch (inlink->format) {
  192. case AV_PIX_FMT_GBRAP12:
  193. case AV_PIX_FMT_GBRP12:
  194. case AV_PIX_FMT_GBRAP10:
  195. case AV_PIX_FMT_GBRP10:
  196. case AV_PIX_FMT_GBRP9:
  197. case AV_PIX_FMT_GBRAP:
  198. case AV_PIX_FMT_GBRP:
  199. memcpy(s->bg_color, black_gbrp_color, 4);
  200. memcpy(s->fg_color, white_gbrp_color, 4);
  201. s->start[0] = s->start[1] = s->start[2] = s->start[3] = 0;
  202. memcpy(s->envelope_color, s->envelope_rgba, 4);
  203. break;
  204. default:
  205. memcpy(s->bg_color, black_yuva_color, 4);
  206. memcpy(s->fg_color, white_yuva_color, 4);
  207. s->start[0] = s->start[3] = 0;
  208. s->start[1] = s->start[2] = s->histogram_size / 2;
  209. s->envelope_color[0] = RGB_TO_Y_BT709(s->envelope_rgba[0], s->envelope_rgba[1], s->envelope_rgba[2]);
  210. s->envelope_color[1] = RGB_TO_U_BT709(s->envelope_rgba[0], s->envelope_rgba[1], s->envelope_rgba[2], 0);
  211. s->envelope_color[2] = RGB_TO_V_BT709(s->envelope_rgba[0], s->envelope_rgba[1], s->envelope_rgba[2], 0);
  212. s->envelope_color[3] = s->envelope_rgba[3];
  213. }
  214. s->fg_color[3] = s->fgopacity * 255;
  215. s->bg_color[3] = s->bgopacity * 255;
  216. s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, s->desc->log2_chroma_h);
  217. s->planeheight[0] = s->planeheight[3] = inlink->h;
  218. s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, s->desc->log2_chroma_w);
  219. s->planewidth[0] = s->planewidth[3] = inlink->w;
  220. return 0;
  221. }
  222. static int config_output(AVFilterLink *outlink)
  223. {
  224. AVFilterContext *ctx = outlink->src;
  225. HistogramContext *s = ctx->priv;
  226. int ncomp = 0, i;
  227. if (!strcmp(ctx->filter->name, "thistogram"))
  228. s->thistogram = 1;
  229. for (i = 0; i < s->ncomp; i++) {
  230. if ((1 << i) & s->components)
  231. ncomp++;
  232. }
  233. if (s->thistogram) {
  234. if (!s->width)
  235. s->width = ctx->inputs[0]->w;
  236. outlink->w = s->width * FFMAX(ncomp * (s->display_mode == 1), 1);
  237. outlink->h = s->histogram_size * FFMAX(ncomp * (s->display_mode == 2), 1);
  238. } else {
  239. outlink->w = s->histogram_size * FFMAX(ncomp * (s->display_mode == 1), 1);
  240. outlink->h = (s->level_height + s->scale_height) * FFMAX(ncomp * (s->display_mode == 2), 1);
  241. }
  242. s->odesc = av_pix_fmt_desc_get(outlink->format);
  243. s->dncomp = s->odesc->nb_components;
  244. outlink->sample_aspect_ratio = (AVRational){1,1};
  245. return 0;
  246. }
  247. static int filter_frame(AVFilterLink *inlink, AVFrame *in)
  248. {
  249. HistogramContext *s = inlink->dst->priv;
  250. AVFilterContext *ctx = inlink->dst;
  251. AVFilterLink *outlink = ctx->outputs[0];
  252. AVFrame *out = s->out;
  253. int i, j, k, l, m;
  254. if (!s->thistogram || !out) {
  255. out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
  256. if (!out) {
  257. av_frame_free(&in);
  258. return AVERROR(ENOMEM);
  259. }
  260. s->out = out;
  261. for (k = 0; k < 4 && out->data[k]; k++) {
  262. const int is_chroma = (k == 1 || k == 2);
  263. const int dst_h = AV_CEIL_RSHIFT(outlink->h, (is_chroma ? s->odesc->log2_chroma_h : 0));
  264. const int dst_w = AV_CEIL_RSHIFT(outlink->w, (is_chroma ? s->odesc->log2_chroma_w : 0));
  265. if (s->histogram_size <= 256) {
  266. for (i = 0; i < dst_h ; i++)
  267. memset(out->data[s->odesc->comp[k].plane] +
  268. i * out->linesize[s->odesc->comp[k].plane],
  269. s->bg_color[k], dst_w);
  270. } else {
  271. const int mult = s->mult;
  272. for (i = 0; i < dst_h ; i++)
  273. for (j = 0; j < dst_w; j++)
  274. AV_WN16(out->data[s->odesc->comp[k].plane] +
  275. i * out->linesize[s->odesc->comp[k].plane] + j * 2,
  276. s->bg_color[k] * mult);
  277. }
  278. }
  279. }
  280. for (m = 0, k = 0; k < s->ncomp; k++) {
  281. const int p = s->desc->comp[k].plane;
  282. const int max_value = s->histogram_size - 1 - s->start[p];
  283. const int height = s->planeheight[p];
  284. const int width = s->planewidth[p];
  285. double max_hval_log;
  286. unsigned max_hval = 0;
  287. int starty, startx;
  288. if (!((1 << k) & s->components))
  289. continue;
  290. if (s->thistogram) {
  291. starty = m * s->histogram_size * (s->display_mode == 2);
  292. startx = m++ * s->width * (s->display_mode == 1);
  293. } else {
  294. startx = m * s->histogram_size * (s->display_mode == 1);
  295. starty = m++ * (s->level_height + s->scale_height) * (s->display_mode == 2);
  296. }
  297. if (s->histogram_size <= 256) {
  298. for (i = 0; i < height; i++) {
  299. const uint8_t *src = in->data[p] + i * in->linesize[p];
  300. for (j = 0; j < width; j++)
  301. s->histogram[src[j]]++;
  302. }
  303. } else {
  304. for (i = 0; i < height; i++) {
  305. const uint16_t *src = (const uint16_t *)(in->data[p] + i * in->linesize[p]);
  306. for (j = 0; j < width; j++)
  307. s->histogram[src[j]]++;
  308. }
  309. }
  310. for (i = 0; i < s->histogram_size; i++)
  311. max_hval = FFMAX(max_hval, s->histogram[i]);
  312. max_hval_log = log2(max_hval + 1);
  313. if (s->thistogram) {
  314. int minh = s->histogram_size - 1, maxh = 0;
  315. for (int i = 0; i < s->histogram_size; i++) {
  316. int idx = s->histogram_size - i - 1;
  317. int value = s->start[p];
  318. if (s->envelope && s->histogram[idx]) {
  319. minh = FFMIN(minh, i);
  320. maxh = FFMAX(maxh, i);
  321. }
  322. if (s->levels_mode)
  323. value += lrint(max_value * (log2(s->histogram[idx] + 1) / max_hval_log));
  324. else
  325. value += lrint(max_value * s->histogram[idx] / (float)max_hval);
  326. if (s->histogram_size <= 256) {
  327. s->out->data[p][(i + starty) * s->out->linesize[p] + startx + s->x_pos] = value;
  328. } else {
  329. AV_WN16(s->out->data[p] + (i + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, value);
  330. }
  331. }
  332. if (s->envelope) {
  333. if (s->histogram_size <= 256) {
  334. s->out->data[0][(minh + starty) * s->out->linesize[p] + startx + s->x_pos] = s->envelope_color[0];
  335. s->out->data[0][(maxh + starty) * s->out->linesize[p] + startx + s->x_pos] = s->envelope_color[0];
  336. if (s->dncomp >= 3) {
  337. s->out->data[1][(minh + starty) * s->out->linesize[p] + startx + s->x_pos] = s->envelope_color[1];
  338. s->out->data[2][(minh + starty) * s->out->linesize[p] + startx + s->x_pos] = s->envelope_color[2];
  339. s->out->data[1][(maxh + starty) * s->out->linesize[p] + startx + s->x_pos] = s->envelope_color[1];
  340. s->out->data[2][(maxh + starty) * s->out->linesize[p] + startx + s->x_pos] = s->envelope_color[2];
  341. }
  342. } else {
  343. const int mult = s->mult;
  344. AV_WN16(s->out->data[0] + (minh + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, s->envelope_color[0] * mult);
  345. AV_WN16(s->out->data[0] + (maxh + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, s->envelope_color[0] * mult);
  346. if (s->dncomp >= 3) {
  347. AV_WN16(s->out->data[1] + (minh + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, s->envelope_color[1] * mult);
  348. AV_WN16(s->out->data[2] + (minh + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, s->envelope_color[2] * mult);
  349. AV_WN16(s->out->data[1] + (maxh + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, s->envelope_color[1] * mult);
  350. AV_WN16(s->out->data[2] + (maxh + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, s->envelope_color[2] * mult);
  351. }
  352. }
  353. }
  354. } else {
  355. for (i = 0; i < s->histogram_size; i++) {
  356. int col_height;
  357. if (s->levels_mode)
  358. col_height = lrint(s->level_height * (1. - (log2(s->histogram[i] + 1) / max_hval_log)));
  359. else
  360. col_height = s->level_height - (s->histogram[i] * (int64_t)s->level_height + max_hval - 1) / max_hval;
  361. if (s->histogram_size <= 256) {
  362. for (j = s->level_height - 1; j >= col_height; j--) {
  363. if (s->display_mode) {
  364. for (l = 0; l < s->dncomp; l++)
  365. out->data[l][(j + starty) * out->linesize[l] + startx + i] = s->fg_color[l];
  366. } else {
  367. out->data[p][(j + starty) * out->linesize[p] + startx + i] = 255;
  368. }
  369. }
  370. for (j = s->level_height + s->scale_height - 1; j >= s->level_height; j--)
  371. out->data[p][(j + starty) * out->linesize[p] + startx + i] = i;
  372. } else {
  373. const int mult = s->mult;
  374. for (j = s->level_height - 1; j >= col_height; j--) {
  375. if (s->display_mode) {
  376. for (l = 0; l < s->dncomp; l++)
  377. AV_WN16(out->data[l] + (j + starty) * out->linesize[l] + startx * 2 + i * 2, s->fg_color[l] * mult);
  378. } else {
  379. AV_WN16(out->data[p] + (j + starty) * out->linesize[p] + startx * 2 + i * 2, 255 * mult);
  380. }
  381. }
  382. for (j = s->level_height + s->scale_height - 1; j >= s->level_height; j--)
  383. AV_WN16(out->data[p] + (j + starty) * out->linesize[p] + startx * 2 + i * 2, i);
  384. }
  385. }
  386. }
  387. memset(s->histogram, 0, s->histogram_size * sizeof(unsigned));
  388. }
  389. out->pts = in->pts;
  390. av_frame_free(&in);
  391. s->x_pos++;
  392. if (s->x_pos >= s->width)
  393. s->x_pos = 0;
  394. if (s->thistogram) {
  395. AVFrame *clone = av_frame_clone(out);
  396. if (!clone)
  397. return AVERROR(ENOMEM);
  398. return ff_filter_frame(outlink, clone);
  399. }
  400. return ff_filter_frame(outlink, out);
  401. }
  402. static const AVFilterPad inputs[] = {
  403. {
  404. .name = "default",
  405. .type = AVMEDIA_TYPE_VIDEO,
  406. .filter_frame = filter_frame,
  407. .config_props = config_input,
  408. },
  409. { NULL }
  410. };
  411. static const AVFilterPad outputs[] = {
  412. {
  413. .name = "default",
  414. .type = AVMEDIA_TYPE_VIDEO,
  415. .config_props = config_output,
  416. },
  417. { NULL }
  418. };
  419. #if CONFIG_HISTOGRAM_FILTER
  420. AVFilter ff_vf_histogram = {
  421. .name = "histogram",
  422. .description = NULL_IF_CONFIG_SMALL("Compute and draw a histogram."),
  423. .priv_size = sizeof(HistogramContext),
  424. .query_formats = query_formats,
  425. .inputs = inputs,
  426. .outputs = outputs,
  427. .priv_class = &histogram_class,
  428. };
  429. #endif /* CONFIG_HISTOGRAM_FILTER */
  430. #if CONFIG_THISTOGRAM_FILTER
  431. static const AVOption thistogram_options[] = {
  432. { "width", "set width", OFFSET(width), AV_OPT_TYPE_INT, {.i64=0}, 0, 8192, FLAGS},
  433. { "w", "set width", OFFSET(width), AV_OPT_TYPE_INT, {.i64=0}, 0, 8192, FLAGS},
  434. COMMON_OPTIONS
  435. { "bgopacity", "set background opacity", OFFSET(bgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.9}, 0, 1, FLAGS},
  436. { "b", "set background opacity", OFFSET(bgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.9}, 0, 1, FLAGS},
  437. { "envelope", "display envelope", OFFSET(envelope), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
  438. { "e", "display envelope", OFFSET(envelope), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
  439. { "ecolor", "set envelope color", OFFSET(envelope_rgba), AV_OPT_TYPE_COLOR, {.str="gold"}, 0, 0, FLAGS },
  440. { "ec", "set envelope color", OFFSET(envelope_rgba), AV_OPT_TYPE_COLOR, {.str="gold"}, 0, 0, FLAGS },
  441. { NULL }
  442. };
  443. AVFILTER_DEFINE_CLASS(thistogram);
  444. AVFilter ff_vf_thistogram = {
  445. .name = "thistogram",
  446. .description = NULL_IF_CONFIG_SMALL("Compute and draw a temporal histogram."),
  447. .priv_size = sizeof(HistogramContext),
  448. .query_formats = query_formats,
  449. .inputs = inputs,
  450. .outputs = outputs,
  451. .priv_class = &thistogram_class,
  452. };
  453. #endif /* CONFIG_THISTOGRAM_FILTER */