FFmpeg  4.4
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);
57 
58 #define OFFSET(x) offsetof(TMidEqualizerContext, x)
59 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
60 
61 static const AVOption tmidequalizer_options[] = {
62  { "radius", "set radius", OFFSET(radius), AV_OPT_TYPE_INT, {.i64=5}, 1, 127, FLAGS },
63  { "sigma", "set sigma", OFFSET(sigma), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGS },
64  { "planes", "set planes", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
65  { NULL }
66 };
67 
68 AVFILTER_DEFINE_CLASS(tmidequalizer);
69 
71 {
72  static const enum AVPixelFormat pix_fmts[] = {
94  };
95 
97 }
98 
99 static void compute_contrast_function(const float *const histograms[256],
100  const float *const kernel,
101  int nb_frames, int radius, int hsize,
102  float *f, int idx)
103 {
104  const float *const h1 = histograms[idx];
105  int p2[256] = { 0 };
106 
107  for (int p1 = 0; p1 < hsize; p1++) {
108  float weight = 1.f;
109  float sum = p1 * weight;
110 
111  for (int j = 0; j < radius; j++) {
112  const int nidx = ((idx - radius + j) % nb_frames);
113  const float *const h2 = histograms[nidx < 0 ? nidx + nb_frames: nidx];
114  int k = j;
115 
116  for (; p2[k] < hsize && h2[p2[k]] < h1[p1]; p2[k]++);
117  if (p2[k] == hsize)
118  p2[k]--;
119 
120  weight += kernel[j];
121  sum += kernel[j] * p2[k];
122  }
123 
124  for (int j = radius + 1; j < nb_frames; j++) {
125  const int nidx = (idx - radius + j) % nb_frames;
126  const float *const h2 = histograms[nidx < 0 ? nidx + nb_frames: nidx];
127  int k = j;
128 
129  for (; p2[k] < hsize && h2[p2[k]] < h1[p1]; p2[k]++);
130  if (p2[k] == hsize)
131  p2[k]--;
132 
133  weight += kernel[j - radius - 1];
134  sum += kernel[j - radius - 1] * p2[k];
135  }
136 
137  f[p1] = sum / weight;
138  }
139 }
140 
141 static void apply_contrast_change8(const uint8_t *src, ptrdiff_t src_linesize,
142  uint8_t *dst, ptrdiff_t dst_linesize,
143  int w, int h, float *change, float *orig)
144 {
145  for (int y = 0; y < h; y++) {
146  for (int x = 0; x < w; x++)
147  dst[x] = lrintf(change[src[x]]);
148 
149  dst += dst_linesize;
150  src += src_linesize;
151  }
152 }
153 
154 static void apply_contrast_change16(const uint8_t *ssrc, ptrdiff_t src_linesize,
155  uint8_t *ddst, ptrdiff_t dst_linesize,
156  int w, int h, float *change, float *orig)
157 {
158  const uint16_t *src = (const uint16_t *)ssrc;
159  uint16_t *dst = (uint16_t *)ddst;
160 
161  for (int y = 0; y < h; y++) {
162  for (int x = 0; x < w; x++)
163  dst[x] = lrintf(change[src[x]]);
164 
165  dst += dst_linesize / 2;
166  src += src_linesize / 2;
167  }
168 }
169 
170 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
171 {
172  AVFilterContext *ctx = inlink->dst;
173  TMidEqualizerContext *s = ctx->priv;
174  AVFilterLink *outlink = ctx->outputs[0];
175  AVFrame *out;
176  int eof = 0;
177 
178  if (!in) {
179  int idx = s->f_frames < s->nb_frames ? s->radius : s->del_frame ? s->del_frame - 1 : s->nb_frames - 1;
180 
181  if (s->f_frames < s->nb_frames) {
182  s->l_frames = s->nb_frames - s->f_frames;
183  } else {
184  s->l_frames++;
185  }
186  in = av_frame_clone(s->frames[idx]);
187  if (!in)
188  return AVERROR(ENOMEM);
189  eof = 1;
190  }
191 
192  if (s->f_frames < s->nb_frames) {
193  s->frames[s->f_frames] = in;
194 
195  for (int p = 0; p < s->nb_planes; p++) {
196  s->compute_histogram(in->data[p], in->linesize[p],
197  s->plane_width[p], s->plane_height[p],
198  s->histogram[p][s->f_frames],
199  s->histogram_size);
200  }
201 
202  s->f_frames++;
203 
204  while (s->f_frames <= s->radius) {
205  s->frames[s->f_frames] = av_frame_clone(in);
206  if (!s->frames[s->f_frames])
207  return AVERROR(ENOMEM);
208  for (int p = 0; p < s->nb_planes; p++) {
209  memcpy(s->histogram[p][s->f_frames],
210  s->histogram[p][s->f_frames - 1],
211  s->histogram_size * sizeof(float));
212  }
213  s->f_frames++;
214  }
215 
216  if (!eof && s->f_frames < s->nb_frames) {
217  return 0;
218  } else {
219  while (s->f_frames < s->nb_frames) {
220  s->frames[s->f_frames] = av_frame_clone(in);
221  if (!s->frames[s->f_frames])
222  return AVERROR(ENOMEM);
223  for (int p = 0; p < s->nb_planes; p++) {
224  memcpy(s->histogram[p][s->f_frames],
225  s->histogram[p][s->f_frames - 1],
226  s->histogram_size * sizeof(float));
227  }
228  s->f_frames++;
229  }
230  }
231  s->cur_frame = s->radius;
232  s->del_frame = 0;
233  } else {
234  av_frame_free(&s->frames[s->del_frame]);
235  s->frames[s->del_frame] = in;
236 
237  for (int p = 0; p < s->nb_planes; p++) {
238  s->compute_histogram(in->data[p], in->linesize[p],
239  s->plane_width[p], s->plane_height[p],
240  s->histogram[p][s->del_frame],
241  s->histogram_size);
242  }
243 
244  s->del_frame++;
245  if (s->del_frame >= s->nb_frames)
246  s->del_frame = 0;
247  }
248 
249  if (ctx->is_disabled) {
250  const int idx = s->cur_frame;
251 
252  out = av_frame_clone(s->frames[idx]);
253  if (!out)
254  return AVERROR(ENOMEM);
255  } else {
256  const int idx = s->cur_frame;
257 
258  in = s->frames[idx];
259  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
260  if (!out)
261  return AVERROR(ENOMEM);
263 
264  for (int p = 0; p < s->nb_planes; p++) {
265  if (!((1 << p) & s->planes)) {
266  av_image_copy_plane(out->data[p], out->linesize[p], in->data[p], in->linesize[p],
267  s->plane_width[p] * (1 + (s->depth > 8)), s->plane_height[p]);
268  continue;
269  }
270 
271  compute_contrast_function((const float *const *)s->histogram[p], s->kernel,
272  s->nb_frames, s->radius, s->histogram_size, s->change[p], idx);
273 
274  s->apply_contrast_change(in->data[p], in->linesize[p],
275  out->data[p], out->linesize[p],
276  s->plane_width[p], s->plane_height[p],
277  s->change[p], s->histogram[p][idx]);
278  }
279  }
280 
281  s->cur_frame++;
282  if (s->cur_frame >= s->nb_frames)
283  s->cur_frame = 0;
284 
285  return ff_filter_frame(outlink, out);
286 }
287 
288 static void compute_histogram8(const uint8_t *src, ptrdiff_t linesize,
289  int w, int h, float *histogram, size_t hsize)
290 {
291  memset(histogram, 0, hsize * sizeof(*histogram));
292 
293  for (int y = 0; y < h; y++) {
294  for (int x = 0; x < w; x++)
295  histogram[src[x]] += 1;
296  src += linesize;
297  }
298 
299  for (int x = 0; x < hsize; x++)
300  histogram[x] /= hsize;
301 
302  for (int x = 1; x < hsize; x++)
303  histogram[x] += histogram[x-1];
304 }
305 
306 static void compute_histogram16(const uint8_t *ssrc, ptrdiff_t linesize,
307  int w, int h, float *histogram, size_t hsize)
308 {
309  const uint16_t *src = (const uint16_t *)ssrc;
310 
311  memset(histogram, 0, hsize * sizeof(*histogram));
312 
313  for (int y = 0; y < h; y++) {
314  for (int x = 0; x < w; x++)
315  histogram[src[x]] += 1;
316  src += linesize / 2;
317  }
318 
319  for (int x = 0; x < hsize; x++)
320  histogram[x] /= hsize;
321 
322  for (int x = 1; x < hsize; x++)
323  histogram[x] += histogram[x-1];
324 }
325 
326 static int config_input(AVFilterLink *inlink)
327 {
328  AVFilterContext *ctx = inlink->dst;
329  TMidEqualizerContext *s = ctx->priv;
331  float sigma = s->radius * s->sigma;
332  int vsub, hsub;
333 
334  s->depth = desc->comp[0].depth;
335  s->nb_frames = s->radius * 2 + 1;
336  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
337 
338  hsub = desc->log2_chroma_w;
339  vsub = desc->log2_chroma_h;
340 
341  s->plane_height[0] = s->plane_height[3] = inlink->h;
342  s->plane_width[0] = s->plane_width[3] = inlink->w;
343  s->plane_height[1] = s->plane_height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
344  s->plane_width[1] = s->plane_width[2] = AV_CEIL_RSHIFT(inlink->w, hsub);
345 
346  s->histogram_size = 1 << s->depth;
347 
348  for (int n = 0; n < s->radius; n++)
349  s->kernel[n] = expf(-0.5 * (n + 1) * (n + 1) / (sigma * sigma));
350 
351  for (int p = 0; p < s->nb_planes; p++) {
352  for (int n = 0; n < s->nb_frames; n++) {
353  s->histogram[p][n] = av_calloc(s->histogram_size, sizeof(float));
354  if (!s->histogram[p][n])
355  return AVERROR(ENOMEM);
356  }
357 
358  s->change[p] = av_calloc(s->histogram_size, sizeof(float));
359  if (!s->change[p])
360  return AVERROR(ENOMEM);
361  }
362 
363  if (!s->frames)
364  s->frames = av_calloc(s->nb_frames, sizeof(*s->frames));
365  if (!s->frames)
366  return AVERROR(ENOMEM);
367 
368  s->compute_histogram = s->depth <= 8 ? compute_histogram8 : compute_histogram16;
369  s->apply_contrast_change = s->depth <= 8 ? apply_contrast_change8 : apply_contrast_change16;
370 
371  return 0;
372 }
373 
374 static int request_frame(AVFilterLink *outlink)
375 {
376  AVFilterContext *ctx = outlink->src;
377  TMidEqualizerContext *s = ctx->priv;
378  int ret;
379 
380  ret = ff_request_frame(ctx->inputs[0]);
381  if (ret == AVERROR_EOF && s->l_frames < s->radius) {
382  ret = filter_frame(ctx->inputs[0], NULL);
383  }
384 
385  return ret;
386 }
387 
388 static void free_histograms(AVFilterContext *ctx, int x, int nb_frames)
389 {
390  TMidEqualizerContext *s = ctx->priv;
391 
392  for (int n = 0; n < nb_frames; n++)
393  av_freep(&s->histogram[x][n]);
394  av_freep(&s->change[x]);
395 }
396 
398 {
399  TMidEqualizerContext *s = ctx->priv;
400 
401  free_histograms(ctx, 0, s->nb_frames);
402  free_histograms(ctx, 1, s->nb_frames);
403  free_histograms(ctx, 2, s->nb_frames);
404  free_histograms(ctx, 3, s->nb_frames);
405 
406  for (int i = 0; i < s->nb_frames && s->frames; i++)
407  av_frame_free(&s->frames[i]);
408  av_freep(&s->frames);
409 }
410 
412  {
413  .name = "default",
414  .type = AVMEDIA_TYPE_VIDEO,
415  .config_props = config_input,
416  .filter_frame = filter_frame,
417  },
418  { NULL }
419 };
420 
422  {
423  .name = "default",
424  .type = AVMEDIA_TYPE_VIDEO,
425  .request_frame = request_frame,
426  },
427  { NULL }
428 };
429 
431  .name = "tmidequalizer",
432  .description = NULL_IF_CONFIG_SMALL("Apply Temporal Midway Equalization."),
433  .priv_size = sizeof(TMidEqualizerContext),
434  .uninit = uninit,
438  .priv_class = &tmidequalizer_class,
440 };
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:1094
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:408
Main libavfilter public API header.
#define flags(name, subs,...)
Definition: cbs_av1.c:561
#define s(width, name)
Definition: cbs_vp9.c:257
#define f(width, name)
Definition: cbs_vp9.c:255
#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:373
misc image utilities
int i
Definition: input.c:407
static int weight(int i, int blen, int offset)
Definition: diracdec.c:1561
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:303
#define expf(x)
Definition: libm.h:283
#define lrintf(x)
Definition: libm_mips.h:70
const char * desc
Definition: libsvtav1.c:79
uint8_t w
Definition: llviddspenc.c:39
static const struct @322 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(* 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)
void(* compute_histogram)(const uint8_t *ssrc, ptrdiff_t linesize, int w, int h, float *histogram, size_t hsize)
float * histogram[4][256]
#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:75
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)
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 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 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)
static void free_histograms(AVFilterContext *ctx, int x, int nb_frames)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:99