FFmpeg  2.6.9
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
vf_histogram.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013 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 
21 #include "libavutil/avassert.h"
22 #include "libavutil/opt.h"
23 #include "libavutil/parseutils.h"
24 #include "libavutil/pixdesc.h"
25 #include "avfilter.h"
26 #include "formats.h"
27 #include "internal.h"
28 #include "video.h"
29 
36 };
37 
38 typedef struct HistogramContext {
39  const AVClass *class; ///< AVClass context for log and options purpose
41  unsigned histogram[256];
42  int ncomp;
43  const uint8_t *bg_color;
44  const uint8_t *fg_color;
47  int step;
54 
55 #define OFFSET(x) offsetof(HistogramContext, x)
56 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
57 
58 static const AVOption histogram_options[] = {
59  { "mode", "set histogram mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_LEVELS}, 0, MODE_NB-1, FLAGS, "mode"},
60  { "levels", "standard histogram", 0, AV_OPT_TYPE_CONST, {.i64=MODE_LEVELS}, 0, 0, FLAGS, "mode" },
61  { "waveform", "per row/column luminance graph", 0, AV_OPT_TYPE_CONST, {.i64=MODE_WAVEFORM}, 0, 0, FLAGS, "mode" },
62  { "color", "chroma values in vectorscope", 0, AV_OPT_TYPE_CONST, {.i64=MODE_COLOR}, 0, 0, FLAGS, "mode" },
63  { "color2", "chroma values in vectorscope", 0, AV_OPT_TYPE_CONST, {.i64=MODE_COLOR2}, 0, 0, FLAGS, "mode" },
64  { "level_height", "set level height", OFFSET(level_height), AV_OPT_TYPE_INT, {.i64=200}, 50, 2048, FLAGS},
65  { "scale_height", "set scale height", OFFSET(scale_height), AV_OPT_TYPE_INT, {.i64=12}, 0, 40, FLAGS},
66  { "step", "set waveform step value", OFFSET(step), AV_OPT_TYPE_INT, {.i64=10}, 1, 255, FLAGS},
67  { "waveform_mode", "set waveform mode", OFFSET(waveform_mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "waveform_mode"},
68  { "row", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "waveform_mode" },
69  { "column", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "waveform_mode" },
70  { "waveform_mirror", "set waveform mirroring", OFFSET(waveform_mirror), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "waveform_mirror"},
71  { "display_mode", "set display mode", OFFSET(display_mode), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "display_mode"},
72  { "parade", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "display_mode" },
73  { "overlay", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "display_mode" },
74  { "levels_mode", "set levels mode", OFFSET(levels_mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "levels_mode"},
75  { "linear", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "levels_mode" },
76  { "logarithmic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "levels_mode" },
77  { NULL }
78 };
79 
80 AVFILTER_DEFINE_CLASS(histogram);
81 
82 static const enum AVPixelFormat color_pix_fmts[] = {
85 };
86 
87 static const enum AVPixelFormat levels_pix_fmts[] = {
90 };
91 
92 static const enum AVPixelFormat waveform_pix_fmts[] = {
102 };
103 
105 {
106  HistogramContext *h = ctx->priv;
107  const enum AVPixelFormat *pix_fmts;
108 
109  switch (h->mode) {
110  case MODE_WAVEFORM:
111  pix_fmts = waveform_pix_fmts;
112  break;
113  case MODE_LEVELS:
114  pix_fmts = levels_pix_fmts;
115  break;
116  case MODE_COLOR:
117  case MODE_COLOR2:
118  pix_fmts = color_pix_fmts;
119  break;
120  default:
121  av_assert0(0);
122  }
123 
125 
126  return 0;
127 }
128 
129 static const uint8_t black_yuva_color[4] = { 0, 127, 127, 255 };
130 static const uint8_t black_gbrp_color[4] = { 0, 0, 0, 255 };
131 static const uint8_t white_yuva_color[4] = { 255, 127, 127, 255 };
132 static const uint8_t white_gbrp_color[4] = { 255, 255, 255, 255 };
133 
134 static int config_input(AVFilterLink *inlink)
135 {
136  HistogramContext *h = inlink->dst->priv;
137 
138  h->desc = av_pix_fmt_desc_get(inlink->format);
139  h->ncomp = h->desc->nb_components;
140 
141  switch (inlink->format) {
142  case AV_PIX_FMT_GBRAP:
143  case AV_PIX_FMT_GBRP:
146  break;
147  default:
150  }
151 
152  return 0;
153 }
154 
155 static int config_output(AVFilterLink *outlink)
156 {
157  AVFilterContext *ctx = outlink->src;
158  HistogramContext *h = ctx->priv;
159 
160  switch (h->mode) {
161  case MODE_LEVELS:
162  outlink->w = 256;
163  outlink->h = (h->level_height + h->scale_height) * FFMAX(h->ncomp * h->display_mode, 1);
164  break;
165  case MODE_WAVEFORM:
166  if (h->waveform_mode)
167  outlink->h = 256 * FFMAX(h->ncomp * h->display_mode, 1);
168  else
169  outlink->w = 256 * FFMAX(h->ncomp * h->display_mode, 1);
170  break;
171  case MODE_COLOR:
172  case MODE_COLOR2:
173  outlink->h = outlink->w = 256;
174  break;
175  default:
176  av_assert0(0);
177  }
178 
179  outlink->sample_aspect_ratio = (AVRational){1,1};
180 
181  return 0;
182 }
183 
184 static void gen_waveform(HistogramContext *h, AVFrame *inpicref, AVFrame *outpicref,
185  int component, int intensity, int offset, int col_mode)
186 {
187  const int plane = h->desc->comp[component].plane;
188  const int mirror = h->waveform_mirror;
189  const int is_chroma = (component == 1 || component == 2);
190  const int shift_w = (is_chroma ? h->desc->log2_chroma_w : 0);
191  const int shift_h = (is_chroma ? h->desc->log2_chroma_h : 0);
192  const int src_linesize = inpicref->linesize[plane];
193  const int dst_linesize = outpicref->linesize[plane];
194  const int dst_signed_linesize = dst_linesize * (mirror == 1 ? -1 : 1);
195  uint8_t *src_data = inpicref->data[plane];
196  uint8_t *dst_data = outpicref->data[plane] + (col_mode ? (offset >> shift_h) * dst_linesize : offset >> shift_w);
197  uint8_t * const dst_bottom_line = dst_data + dst_linesize * ((256 >> shift_h) - 1);
198  uint8_t * const dst_line = (mirror ? dst_bottom_line : dst_data);
199  const uint8_t max = 255 - intensity;
200  const int src_h = FF_CEIL_RSHIFT(inpicref->height, shift_h);
201  const int src_w = FF_CEIL_RSHIFT(inpicref->width, shift_w);
202  uint8_t *dst, *p;
203  int y;
204 
205  if (!col_mode && mirror)
206  dst_data += 256 >> shift_w;
207  for (y = 0; y < src_h; y++) {
208  const uint8_t *src_data_end = src_data + src_w;
209  dst = dst_line;
210  for (p = src_data; p < src_data_end; p++) {
211  uint8_t *target;
212  if (col_mode) {
213  target = dst++ + dst_signed_linesize * (*p >> shift_h);
214  } else {
215  if (mirror)
216  target = dst_data - (*p >> shift_w);
217  else
218  target = dst_data + (*p >> shift_w);
219  }
220  if (*target <= max)
221  *target += intensity;
222  else
223  *target = 255;
224  }
225  src_data += src_linesize;
226  dst_data += dst_linesize;
227  }
228 }
229 
230 
231 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
232 {
233  HistogramContext *h = inlink->dst->priv;
234  AVFilterContext *ctx = inlink->dst;
235  AVFilterLink *outlink = ctx->outputs[0];
236  AVFrame *out;
237  const uint8_t *src;
238  uint8_t *dst;
239  int i, j, k, l;
240 
241  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
242  if (!out) {
243  av_frame_free(&in);
244  return AVERROR(ENOMEM);
245  }
246 
247  out->pts = in->pts;
248 
249  for (k = 0; k < h->ncomp; k++) {
250  const int is_chroma = (k == 1 || k == 2);
251  const int dst_h = FF_CEIL_RSHIFT(outlink->h, (is_chroma ? h->desc->log2_chroma_h : 0));
252  const int dst_w = FF_CEIL_RSHIFT(outlink->w, (is_chroma ? h->desc->log2_chroma_w : 0));
253  for (i = 0; i < dst_h ; i++)
254  memset(out->data[h->desc->comp[k].plane] +
255  i * out->linesize[h->desc->comp[k].plane],
256  h->bg_color[k], dst_w);
257  }
258 
259  switch (h->mode) {
260  case MODE_LEVELS:
261  for (k = 0; k < h->ncomp; k++) {
262  const int p = h->desc->comp[k].plane;
263  const int start = k * (h->level_height + h->scale_height) * h->display_mode;
264  double max_hval_log;
265  unsigned max_hval = 0;
266 
267  for (i = 0; i < in->height; i++) {
268  src = in->data[p] + i * in->linesize[p];
269  for (j = 0; j < in->width; j++)
270  h->histogram[src[j]]++;
271  }
272 
273  for (i = 0; i < 256; i++)
274  max_hval = FFMAX(max_hval, h->histogram[i]);
275  max_hval_log = log2(max_hval + 1);
276 
277  for (i = 0; i < outlink->w; i++) {
278  int col_height;
279 
280  if (h->levels_mode)
281  col_height = round(h->level_height * (1. - (log2(h->histogram[i] + 1) / max_hval_log)));
282  else
283  col_height = h->level_height - (h->histogram[i] * (int64_t)h->level_height + max_hval - 1) / max_hval;
284 
285  for (j = h->level_height - 1; j >= col_height; j--) {
286  if (h->display_mode) {
287  for (l = 0; l < h->ncomp; l++)
288  out->data[l][(j + start) * out->linesize[l] + i] = h->fg_color[l];
289  } else {
290  out->data[p][(j + start) * out->linesize[p] + i] = 255;
291  }
292  }
293  for (j = h->level_height + h->scale_height - 1; j >= h->level_height; j--)
294  out->data[p][(j + start) * out->linesize[p] + i] = i;
295  }
296 
297  memset(h->histogram, 0, 256 * sizeof(unsigned));
298  }
299  break;
300  case MODE_WAVEFORM:
301  for (k = 0; k < h->ncomp; k++) {
302  const int offset = k * 256 * h->display_mode;
303  gen_waveform(h, in, out, k, h->step, offset, h->waveform_mode);
304  }
305  break;
306  case MODE_COLOR:
307  for (i = 0; i < inlink->h; i++) {
308  const int iw1 = i * in->linesize[1];
309  const int iw2 = i * in->linesize[2];
310  for (j = 0; j < inlink->w; j++) {
311  const int pos = in->data[1][iw1 + j] * out->linesize[0] + in->data[2][iw2 + j];
312  if (out->data[0][pos] < 255)
313  out->data[0][pos]++;
314  }
315  }
316  for (i = 0; i < 256; i++) {
317  dst = out->data[0] + i * out->linesize[0];
318  for (j = 0; j < 256; j++) {
319  if (!dst[j]) {
320  out->data[1][i * out->linesize[0] + j] = i;
321  out->data[2][i * out->linesize[0] + j] = j;
322  }
323  }
324  }
325  break;
326  case MODE_COLOR2:
327  for (i = 0; i < inlink->h; i++) {
328  const int iw1 = i * in->linesize[1];
329  const int iw2 = i * in->linesize[2];
330  for (j = 0; j < inlink->w; j++) {
331  const int u = in->data[1][iw1 + j];
332  const int v = in->data[2][iw2 + j];
333  const int pos = u * out->linesize[0] + v;
334  if (!out->data[0][pos])
335  out->data[0][pos] = FFABS(128 - u) + FFABS(128 - v);
336  out->data[1][pos] = u;
337  out->data[2][pos] = v;
338  }
339  }
340  break;
341  default:
342  av_assert0(0);
343  }
344 
345  av_frame_free(&in);
346  return ff_filter_frame(outlink, out);
347 }
348 
349 static const AVFilterPad inputs[] = {
350  {
351  .name = "default",
352  .type = AVMEDIA_TYPE_VIDEO,
353  .filter_frame = filter_frame,
354  .config_props = config_input,
355  },
356  { NULL }
357 };
358 
359 static const AVFilterPad outputs[] = {
360  {
361  .name = "default",
362  .type = AVMEDIA_TYPE_VIDEO,
363  .config_props = config_output,
364  },
365  { NULL }
366 };
367 
369  .name = "histogram",
370  .description = NULL_IF_CONFIG_SMALL("Compute and draw a histogram."),
371  .priv_size = sizeof(HistogramContext),
373  .inputs = inputs,
374  .outputs = outputs,
375  .priv_class = &histogram_class,
376 };
#define NULL
Definition: coverity.c:32
HistogramMode
Definition: vf_histogram.c:30
float v
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2029
This structure describes decoded (raw) audio or video data.
Definition: frame.h:163
AVOption.
Definition: opt.h:255
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:73
Main libavfilter public API header.
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:181
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
static enum AVPixelFormat waveform_pix_fmts[]
Definition: vf_histogram.c:92
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:109
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
#define log2(x)
Definition: libm.h:122
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:294
enum HistogramMode mode
Definition: vf_histogram.c:40
const char * name
Pad name.
Definition: internal.h:67
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
static const uint8_t black_gbrp_color[4]
Definition: vf_histogram.c:130
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1145
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:108
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:100
uint8_t
mode
Definition: f_perms.c:27
AVOptions.
const uint8_t * bg_color
Definition: vf_histogram.c:43
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:249
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
Definition: pixfmt.h:107
static const AVFilterPad inputs[]
Definition: vf_histogram.c:349
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
Definition: pixfmt.h:81
static int config_input(AVFilterLink *inlink)
Definition: vf_histogram.c:134
static void gen_waveform(HistogramContext *h, AVFrame *inpicref, AVFrame *outpicref, int component, int intensity, int offset, int col_mode)
Definition: vf_histogram.c:184
void ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:539
static const AVFilterPad outputs[]
Definition: vf_histogram.c:359
static enum AVPixelFormat color_pix_fmts[]
Definition: vf_histogram.c:82
A filter pad used for either input or output.
Definition: internal.h:61
static const uint8_t white_gbrp_color[4]
Definition: vf_histogram.c:132
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:267
int width
width and height of the video frame
Definition: frame.h:212
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:148
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:180
void * priv
private data for use by the filter
Definition: avfilter.h:654
simple assert() macros that are a bit more flexible than ISO C assert().
static av_always_inline av_const double round(double x)
Definition: libm.h:162
#define OFFSET(x)
Definition: vf_histogram.c:55
static const uint8_t offset[127][2]
Definition: vf_spp.c:92
#define FFMAX(a, b)
Definition: common.h:79
AVFilter ff_vf_histogram
Definition: vf_histogram.c:368
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:72
unsigned histogram[256]
Definition: vf_histogram.c:41
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
float y
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
Definition: pixfmt.h:80
#define FF_CEIL_RSHIFT(a, b)
Definition: common.h:57
const uint8_t * fg_color
Definition: vf_histogram.c:44
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:68
float u
static enum AVPixelFormat levels_pix_fmts[]
Definition: vf_histogram.c:87
static const AVOption histogram_options[]
Definition: vf_histogram.c:58
AVS_Value src
Definition: avisynth_c.h:524
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:191
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:266
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
const AVPixFmtDescriptor * desc
Definition: vf_histogram.c:52
static int config_output(AVFilterLink *outlink)
Definition: vf_histogram.c:155
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:74
Describe the class of an AVClass context structure.
Definition: log.h:66
Filter definition.
Definition: avfilter.h:470
rational number numerator/denominator
Definition: rational.h:43
static const uint8_t white_yuva_color[4]
Definition: vf_histogram.c:131
const char * name
Filter name.
Definition: avfilter.h:474
misc parsing utilities
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:648
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:174
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
uint16_t plane
Which of the 4 planes contains the component.
Definition: pixdesc.h:34
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:68
Y , 8bpp.
Definition: pixfmt.h:76
AVFILTER_DEFINE_CLASS(histogram)
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:285
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
Definition: pixfmt.h:82
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:75
#define FLAGS
Definition: vf_histogram.c:56
static int query_formats(AVFilterContext *ctx)
Definition: vf_histogram.c:104
static const uint8_t black_yuva_color[4]
Definition: vf_histogram.c:129
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_histogram.c:231
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:288
An instance of a filter.
Definition: avfilter.h:633
int height
Definition: frame.h:212
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
void INT64 start
Definition: avisynth_c.h:595
internal API functions
AVPixelFormat
Pixel format.
Definition: pixfmt.h:66
for(j=16;j >0;--j)