FFmpeg  4.4.9
vf_tmidequalizer.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 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/imgutils.h"
22 #include "libavutil/pixdesc.h"
23 #include "libavutil/opt.h"
24 #include "avfilter.h"
25 #include "formats.h"
26 #include "internal.h"
27 #include "video.h"
28 
29 typedef struct TMidEqualizerContext {
30  const AVClass *class;
31 
32  int planes;
33  int radius;
34  float sigma;
35 
37  int nb_frames;
38  int depth;
39  int f_frames;
40  int l_frames;
41  int del_frame;
42  int cur_frame;
43  int nb_planes;
45  float kernel[127];
46  float *histogram[4][256];
47  float *change[4];
48 
50 
51  void (*compute_histogram)(const uint8_t *ssrc, ptrdiff_t linesize,
52  int w, int h, float *histogram, size_t hsize);
53  void (*apply_contrast_change)(const uint8_t *src, ptrdiff_t src_linesize,
54  uint8_t *dst, ptrdiff_t dst_linesize,
55  int w, int h, float *change, float *orig,
56  size_t hsize);
58 
59 #define OFFSET(x) offsetof(TMidEqualizerContext, x)
60 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
61 
62 static const AVOption tmidequalizer_options[] = {
63  { "radius", "set radius", OFFSET(radius), AV_OPT_TYPE_INT, {.i64=5}, 1, 127, FLAGS },
64  { "sigma", "set sigma", OFFSET(sigma), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGS },
65  { "planes", "set planes", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
66  { NULL }
67 };
68 
69 AVFILTER_DEFINE_CLASS(tmidequalizer);
70 
72 {
73  static const enum AVPixelFormat pix_fmts[] = {
95  };
96 
98 }
99 
100 static void compute_contrast_function(const float *const histograms[256],
101  const float *const kernel,
102  int nb_frames, int radius, int hsize,
103  float *f, int idx)
104 {
105  const float *const h1 = histograms[idx];
106  int p2[256] = { 0 };
107 
108  for (int p1 = 0; p1 < hsize; p1++) {
109  float weight = 1.f;
110  float sum = p1 * weight;
111 
112  for (int j = 0; j < radius; j++) {
113  const int nidx = ((idx - radius + j) % nb_frames);
114  const float *const h2 = histograms[nidx < 0 ? nidx + nb_frames: nidx];
115  int k = j;
116 
117  for (; p2[k] < hsize && h2[p2[k]] < h1[p1]; p2[k]++);
118  if (p2[k] == hsize)
119  p2[k]--;
120 
121  weight += kernel[j];
122  sum += kernel[j] * p2[k];
123  }
124 
125  for (int j = radius + 1; j < nb_frames; j++) {
126  const int nidx = (idx - radius + j) % nb_frames;
127  const float *const h2 = histograms[nidx < 0 ? nidx + nb_frames: nidx];
128  int k = j;
129 
130  for (; p2[k] < hsize && h2[p2[k]] < h1[p1]; p2[k]++);
131  if (p2[k] == hsize)
132  p2[k]--;
133 
134  weight += kernel[j - radius - 1];
135  sum += kernel[j - radius - 1] * p2[k];
136  }
137 
138  f[p1] = sum / weight;
139  }
140 }
141 
142 static void apply_contrast_change8(const uint8_t *src, ptrdiff_t src_linesize,
143  uint8_t *dst, ptrdiff_t dst_linesize,
144  int w, int h, float *change, float *orig,
145  size_t hsize)
146 {
147  for (int y = 0; y < h; y++) {
148  for (int x = 0; x < w; x++)
149  dst[x] = lrintf(change[src[x]]);
150 
151  dst += dst_linesize;
152  src += src_linesize;
153  }
154 }
155 
156 static void apply_contrast_change16(const uint8_t *ssrc, ptrdiff_t src_linesize,
157  uint8_t *ddst, ptrdiff_t dst_linesize,
158  int w, int h, float *change, float *orig,
159  size_t hsize)
160 {
161  const uint16_t *src = (const uint16_t *)ssrc;
162  uint16_t *dst = (uint16_t *)ddst;
163 
164  for (int y = 0; y < h; y++) {
165  for (int x = 0; x < w; x++)
166  dst[x] = lrintf(change[FFMIN(src[x], hsize - 1)]);
167 
168  dst += dst_linesize / 2;
169  src += src_linesize / 2;
170  }
171 }
172 
173 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
174 {
175  AVFilterContext *ctx = inlink->dst;
176  TMidEqualizerContext *s = ctx->priv;
177  AVFilterLink *outlink = ctx->outputs[0];
178  AVFrame *out;
179  int eof = 0;
180 
181  if (!in) {
182  int idx = s->f_frames < s->nb_frames ? s->radius : s->del_frame ? s->del_frame - 1 : s->nb_frames - 1;
183 
184  if (s->f_frames < s->nb_frames) {
185  s->l_frames = s->nb_frames - s->f_frames;
186  } else {
187  s->l_frames++;
188  }
189  in = av_frame_clone(s->frames[idx]);
190  if (!in)
191  return AVERROR(ENOMEM);
192  eof = 1;
193  }
194 
195  if (s->f_frames < s->nb_frames) {
196  s->frames[s->f_frames] = in;
197 
198  for (int p = 0; p < s->nb_planes; p++) {
199  s->compute_histogram(in->data[p], in->linesize[p],
200  s->plane_width[p], s->plane_height[p],
201  s->histogram[p][s->f_frames],
202  s->histogram_size);
203  }
204 
205  s->f_frames++;
206 
207  while (s->f_frames <= s->radius) {
208  s->frames[s->f_frames] = av_frame_clone(in);
209  if (!s->frames[s->f_frames])
210  return AVERROR(ENOMEM);
211  for (int p = 0; p < s->nb_planes; p++) {
212  memcpy(s->histogram[p][s->f_frames],
213  s->histogram[p][s->f_frames - 1],
214  s->histogram_size * sizeof(float));
215  }
216  s->f_frames++;
217  }
218 
219  if (!eof && s->f_frames < s->nb_frames) {
220  return 0;
221  } else {
222  while (s->f_frames < s->nb_frames) {
223  s->frames[s->f_frames] = av_frame_clone(in);
224  if (!s->frames[s->f_frames])
225  return AVERROR(ENOMEM);
226  for (int p = 0; p < s->nb_planes; p++) {
227  memcpy(s->histogram[p][s->f_frames],
228  s->histogram[p][s->f_frames - 1],
229  s->histogram_size * sizeof(float));
230  }
231  s->f_frames++;
232  }
233  }
234  s->cur_frame = s->radius;
235  s->del_frame = 0;
236  } else {
237  av_frame_free(&s->frames[s->del_frame]);
238  s->frames[s->del_frame] = in;
239 
240  for (int p = 0; p < s->nb_planes; p++) {
241  s->compute_histogram(in->data[p], in->linesize[p],
242  s->plane_width[p], s->plane_height[p],
243  s->histogram[p][s->del_frame],
244  s->histogram_size);
245  }
246 
247  s->del_frame++;
248  if (s->del_frame >= s->nb_frames)
249  s->del_frame = 0;
250  }
251 
252  if (ctx->is_disabled) {
253  const int idx = s->cur_frame;
254 
255  out = av_frame_clone(s->frames[idx]);
256  if (!out)
257  return AVERROR(ENOMEM);
258  } else {
259  const int idx = s->cur_frame;
260 
261  in = s->frames[idx];
262  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
263  if (!out)
264  return AVERROR(ENOMEM);
266 
267  for (int p = 0; p < s->nb_planes; p++) {
268  if (!((1 << p) & s->planes)) {
269  av_image_copy_plane(out->data[p], out->linesize[p], in->data[p], in->linesize[p],
270  s->plane_width[p] * (1 + (s->depth > 8)), s->plane_height[p]);
271  continue;
272  }
273 
274  compute_contrast_function((const float *const *)s->histogram[p], s->kernel,
275  s->nb_frames, s->radius, s->histogram_size, s->change[p], idx);
276 
277  s->apply_contrast_change(in->data[p], in->linesize[p],
278  out->data[p], out->linesize[p],
279  s->plane_width[p], s->plane_height[p],
280  s->change[p], s->histogram[p][idx],
281  s->histogram_size);
282  }
283  }
284 
285  s->cur_frame++;
286  if (s->cur_frame >= s->nb_frames)
287  s->cur_frame = 0;
288 
289  return ff_filter_frame(outlink, out);
290 }
291 
292 static void compute_histogram8(const uint8_t *src, ptrdiff_t linesize,
293  int w, int h, float *histogram, size_t hsize)
294 {
295  memset(histogram, 0, hsize * sizeof(*histogram));
296 
297  for (int y = 0; y < h; y++) {
298  for (int x = 0; x < w; x++)
299  histogram[src[x]] += 1;
300  src += linesize;
301  }
302 
303  for (int x = 0; x < hsize; x++)
304  histogram[x] /= hsize;
305 
306  for (int x = 1; x < hsize; x++)
307  histogram[x] += histogram[x-1];
308 }
309 
310 static void compute_histogram16(const uint8_t *ssrc, ptrdiff_t linesize,
311  int w, int h, float *histogram, size_t hsize)
312 {
313  const uint16_t *src = (const uint16_t *)ssrc;
314 
315  memset(histogram, 0, hsize * sizeof(*histogram));
316 
317  for (int y = 0; y < h; y++) {
318  for (int x = 0; x < w; x++)
319  histogram[FFMIN(src[x], hsize - 1)] += 1;
320  src += linesize / 2;
321  }
322 
323  for (int x = 0; x < hsize; x++)
324  histogram[x] /= hsize;
325 
326  for (int x = 1; x < hsize; x++)
327  histogram[x] += histogram[x-1];
328 }
329 
330 static int config_input(AVFilterLink *inlink)
331 {
332  AVFilterContext *ctx = inlink->dst;
333  TMidEqualizerContext *s = ctx->priv;
335  float sigma = s->radius * s->sigma;
336  int vsub, hsub;
337 
338  s->depth = desc->comp[0].depth;
339  s->nb_frames = s->radius * 2 + 1;
340  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
341 
342  hsub = desc->log2_chroma_w;
343  vsub = desc->log2_chroma_h;
344 
345  s->plane_height[0] = s->plane_height[3] = inlink->h;
346  s->plane_width[0] = s->plane_width[3] = inlink->w;
347  s->plane_height[1] = s->plane_height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
348  s->plane_width[1] = s->plane_width[2] = AV_CEIL_RSHIFT(inlink->w, hsub);
349 
350  s->histogram_size = 1 << s->depth;
351 
352  for (int n = 0; n < s->radius; n++)
353  s->kernel[n] = expf(-0.5 * (n + 1) * (n + 1) / (sigma * sigma));
354 
355  for (int p = 0; p < s->nb_planes; p++) {
356  for (int n = 0; n < s->nb_frames; n++) {
357  s->histogram[p][n] = av_calloc(s->histogram_size, sizeof(float));
358  if (!s->histogram[p][n])
359  return AVERROR(ENOMEM);
360  }
361 
362  s->change[p] = av_calloc(s->histogram_size, sizeof(float));
363  if (!s->change[p])
364  return AVERROR(ENOMEM);
365  }
366 
367  if (!s->frames)
368  s->frames = av_calloc(s->nb_frames, sizeof(*s->frames));
369  if (!s->frames)
370  return AVERROR(ENOMEM);
371 
372  s->compute_histogram = s->depth <= 8 ? compute_histogram8 : compute_histogram16;
373  s->apply_contrast_change = s->depth <= 8 ? apply_contrast_change8 : apply_contrast_change16;
374 
375  return 0;
376 }
377 
378 static int request_frame(AVFilterLink *outlink)
379 {
380  AVFilterContext *ctx = outlink->src;
381  TMidEqualizerContext *s = ctx->priv;
382  int ret;
383 
384  ret = ff_request_frame(ctx->inputs[0]);
385  if (ret == AVERROR_EOF && s->l_frames < s->radius) {
386  ret = filter_frame(ctx->inputs[0], NULL);
387  }
388 
389  return ret;
390 }
391 
392 static void free_histograms(AVFilterContext *ctx, int x, int nb_frames)
393 {
394  TMidEqualizerContext *s = ctx->priv;
395 
396  for (int n = 0; n < nb_frames; n++)
397  av_freep(&s->histogram[x][n]);
398  av_freep(&s->change[x]);
399 }
400 
402 {
403  TMidEqualizerContext *s = ctx->priv;
404 
405  free_histograms(ctx, 0, s->nb_frames);
406  free_histograms(ctx, 1, s->nb_frames);
407  free_histograms(ctx, 2, s->nb_frames);
408  free_histograms(ctx, 3, s->nb_frames);
409 
410  for (int i = 0; i < s->nb_frames && s->frames; i++)
411  av_frame_free(&s->frames[i]);
412  av_freep(&s->frames);
413 }
414 
416  {
417  .name = "default",
418  .type = AVMEDIA_TYPE_VIDEO,
419  .config_props = config_input,
420  .filter_frame = filter_frame,
421  },
422  { NULL }
423 };
424 
426  {
427  .name = "default",
428  .type = AVMEDIA_TYPE_VIDEO,
429  .request_frame = request_frame,
430  },
431  { NULL }
432 };
433 
435  .name = "tmidequalizer",
436  .description = NULL_IF_CONFIG_SMALL("Apply Temporal Midway Equalization."),
437  .priv_size = sizeof(TMidEqualizerContext),
438  .uninit = uninit,
442  .priv_class = &tmidequalizer_class,
444 };
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
#define av_cold
Definition: attributes.h:88
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
uint8_t
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1099
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:411
Main libavfilter public API header.
#define flags(name, subs,...)
Definition: cbs_av1.c:572
#define s(width, name)
Definition: cbs_vp9.c:257
#define f(width, name)
Definition: cbs_vp9.c:255
#define FFMIN(a, b)
Definition: common.h:105
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
#define NULL
Definition: coverity.c:32
int 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:587
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:286
@ AV_OPT_TYPE_INT
Definition: opt.h:225
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:134
#define AVERROR_EOF
End of file.
Definition: error.h:55
#define AVERROR(e)
Definition: error.h:43
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:540
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:658
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:245
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:376
misc image utilities
int i
Definition: input.c:407
static int weight(int i, int blen, int offset)
Definition: diracdec.c:1563
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:309
#define expf(x)
Definition: libm.h:283
#define lrintf(x)
Definition: libm_mips.h:70
const char * desc
Definition: libsvtav1.c:83
uint8_t w
Definition: llviddspenc.c:39
static const struct @323 planes[]
AVOptions.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2613
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:420
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:410
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:406
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:398
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:399
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:379
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:421
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:414
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:397
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:438
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:441
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:403
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:436
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:434
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:404
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:415
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:400
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:381
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:416
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:396
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:433
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:437
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:407
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:100
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:177
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:258
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:176
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:439
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:408
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:380
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:382
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:411
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:383
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:419
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:443
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:442
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:418
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:409
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:435
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:417
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:440
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:412
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:402
typedef void(RENAME(mix_any_func_type))
Describe the class of an AVClass context structure.
Definition: log.h:67
An instance of a filter.
Definition: avfilter.h:341
A filter pad used for either input or output.
Definition: internal.h:54
const char * name
Pad name.
Definition: internal.h:60
Filter definition.
Definition: avfilter.h:145
const char * name
Filter name.
Definition: avfilter.h:149
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
AVOption.
Definition: opt.h:248
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
void(* compute_histogram)(const uint8_t *ssrc, ptrdiff_t linesize, int w, int h, float *histogram, size_t hsize)
float * histogram[4][256]
void(* apply_contrast_change)(const uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h, float *change, float *orig, size_t hsize)
#define av_freep(p)
#define src
Definition: vp8dsp.c:255
FILE * out
Definition: movenc.c:54
AVFormatContext * ctx
Definition: movenc.c:48
static void hsub(htype *dst, const htype *src, int bins)
Definition: vf_median.c:76
static void compute_contrast_function(const float *const histograms[256], const float *const kernel, int nb_frames, int radius, int hsize, float *f, int idx)
static const AVOption tmidequalizer_options[]
static void apply_contrast_change16(const uint8_t *ssrc, ptrdiff_t src_linesize, uint8_t *ddst, ptrdiff_t dst_linesize, int w, int h, float *change, float *orig, size_t hsize)
static const AVFilterPad tmidequalizer_inputs[]
static int query_formats(AVFilterContext *ctx)
static void compute_histogram16(const uint8_t *ssrc, ptrdiff_t linesize, int w, int h, float *histogram, size_t hsize)
static int config_input(AVFilterLink *inlink)
#define FLAGS
AVFILTER_DEFINE_CLASS(tmidequalizer)
static int request_frame(AVFilterLink *outlink)
static const AVFilterPad tmidequalizer_outputs[]
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static void compute_histogram8(const uint8_t *src, ptrdiff_t linesize, int w, int h, float *histogram, size_t hsize)
static av_cold void uninit(AVFilterContext *ctx)
#define OFFSET(x)
AVFilter ff_vf_tmidequalizer
static void free_histograms(AVFilterContext *ctx, int x, int nb_frames)
static void apply_contrast_change8(const uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h, float *change, float *orig, size_t hsize)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:104