FFmpeg
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 
70 static const enum AVPixelFormat pix_fmts[] = {
92 };
93 
94 static void compute_contrast_function(const float *const histograms[256],
95  const float *const kernel,
96  int nb_frames, int radius, int hsize,
97  float *f, int idx)
98 {
99  const float *const h1 = histograms[idx];
100  int p2[256] = { 0 };
101 
102  for (int p1 = 0; p1 < hsize; p1++) {
103  float weight = 1.f;
104  float sum = p1 * weight;
105 
106  for (int j = 0; j < radius; j++) {
107  const int nidx = ((idx - radius + j) % nb_frames);
108  const float *const h2 = histograms[nidx < 0 ? nidx + nb_frames: nidx];
109  int k = j;
110 
111  for (; p2[k] < hsize && h2[p2[k]] < h1[p1]; p2[k]++);
112  if (p2[k] == hsize)
113  p2[k]--;
114 
115  weight += kernel[j];
116  sum += kernel[j] * p2[k];
117  }
118 
119  for (int j = radius + 1; j < nb_frames; j++) {
120  const int nidx = (idx - radius + j) % nb_frames;
121  const float *const h2 = histograms[nidx < 0 ? nidx + nb_frames: nidx];
122  int k = j;
123 
124  for (; p2[k] < hsize && h2[p2[k]] < h1[p1]; p2[k]++);
125  if (p2[k] == hsize)
126  p2[k]--;
127 
128  weight += kernel[j - radius - 1];
129  sum += kernel[j - radius - 1] * p2[k];
130  }
131 
132  f[p1] = sum / weight;
133  }
134 }
135 
136 static void apply_contrast_change8(const uint8_t *src, ptrdiff_t src_linesize,
137  uint8_t *dst, ptrdiff_t dst_linesize,
138  int w, int h, float *change, float *orig)
139 {
140  for (int y = 0; y < h; y++) {
141  for (int x = 0; x < w; x++)
142  dst[x] = lrintf(change[src[x]]);
143 
144  dst += dst_linesize;
145  src += src_linesize;
146  }
147 }
148 
149 static void apply_contrast_change16(const uint8_t *ssrc, ptrdiff_t src_linesize,
150  uint8_t *ddst, ptrdiff_t dst_linesize,
151  int w, int h, float *change, float *orig)
152 {
153  const uint16_t *src = (const uint16_t *)ssrc;
154  uint16_t *dst = (uint16_t *)ddst;
155 
156  for (int y = 0; y < h; y++) {
157  for (int x = 0; x < w; x++)
158  dst[x] = lrintf(change[src[x]]);
159 
160  dst += dst_linesize / 2;
161  src += src_linesize / 2;
162  }
163 }
164 
166 {
167  AVFilterContext *ctx = inlink->dst;
168  TMidEqualizerContext *s = ctx->priv;
169  AVFilterLink *outlink = ctx->outputs[0];
170  AVFrame *out;
171  int eof = 0;
172 
173  if (!in) {
174  int idx = s->f_frames < s->nb_frames ? s->radius : s->del_frame ? s->del_frame - 1 : s->nb_frames - 1;
175 
176  if (s->f_frames < s->nb_frames) {
177  s->l_frames = s->nb_frames - s->f_frames;
178  } else {
179  s->l_frames++;
180  }
181  in = av_frame_clone(s->frames[idx]);
182  if (!in)
183  return AVERROR(ENOMEM);
184  eof = 1;
185  }
186 
187  if (s->f_frames < s->nb_frames) {
188  s->frames[s->f_frames] = in;
189 
190  for (int p = 0; p < s->nb_planes; p++) {
191  s->compute_histogram(in->data[p], in->linesize[p],
192  s->plane_width[p], s->plane_height[p],
193  s->histogram[p][s->f_frames],
194  s->histogram_size);
195  }
196 
197  s->f_frames++;
198 
199  while (s->f_frames <= s->radius) {
200  s->frames[s->f_frames] = av_frame_clone(in);
201  if (!s->frames[s->f_frames])
202  return AVERROR(ENOMEM);
203  for (int p = 0; p < s->nb_planes; p++) {
204  memcpy(s->histogram[p][s->f_frames],
205  s->histogram[p][s->f_frames - 1],
206  s->histogram_size * sizeof(float));
207  }
208  s->f_frames++;
209  }
210 
211  if (!eof && s->f_frames < s->nb_frames) {
212  return 0;
213  } else {
214  while (s->f_frames < s->nb_frames) {
215  s->frames[s->f_frames] = av_frame_clone(in);
216  if (!s->frames[s->f_frames])
217  return AVERROR(ENOMEM);
218  for (int p = 0; p < s->nb_planes; p++) {
219  memcpy(s->histogram[p][s->f_frames],
220  s->histogram[p][s->f_frames - 1],
221  s->histogram_size * sizeof(float));
222  }
223  s->f_frames++;
224  }
225  }
226  s->cur_frame = s->radius;
227  s->del_frame = 0;
228  } else {
229  av_frame_free(&s->frames[s->del_frame]);
230  s->frames[s->del_frame] = in;
231 
232  for (int p = 0; p < s->nb_planes; p++) {
233  s->compute_histogram(in->data[p], in->linesize[p],
234  s->plane_width[p], s->plane_height[p],
235  s->histogram[p][s->del_frame],
236  s->histogram_size);
237  }
238 
239  s->del_frame++;
240  if (s->del_frame >= s->nb_frames)
241  s->del_frame = 0;
242  }
243 
244  if (ctx->is_disabled) {
245  const int idx = s->cur_frame;
246 
247  out = av_frame_clone(s->frames[idx]);
248  if (!out)
249  return AVERROR(ENOMEM);
250  } else {
251  const int idx = s->cur_frame;
252 
253  in = s->frames[idx];
254  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
255  if (!out)
256  return AVERROR(ENOMEM);
258 
259  for (int p = 0; p < s->nb_planes; p++) {
260  if (!((1 << p) & s->planes)) {
261  av_image_copy_plane(out->data[p], out->linesize[p], in->data[p], in->linesize[p],
262  s->plane_width[p] * (1 + (s->depth > 8)), s->plane_height[p]);
263  continue;
264  }
265 
266  compute_contrast_function((const float *const *)s->histogram[p], s->kernel,
267  s->nb_frames, s->radius, s->histogram_size, s->change[p], idx);
268 
269  s->apply_contrast_change(in->data[p], in->linesize[p],
270  out->data[p], out->linesize[p],
271  s->plane_width[p], s->plane_height[p],
272  s->change[p], s->histogram[p][idx]);
273  }
274  }
275 
276  s->cur_frame++;
277  if (s->cur_frame >= s->nb_frames)
278  s->cur_frame = 0;
279 
280  return ff_filter_frame(outlink, out);
281 }
282 
283 static void compute_histogram8(const uint8_t *src, ptrdiff_t linesize,
284  int w, int h, float *histogram, size_t hsize)
285 {
286  memset(histogram, 0, hsize * sizeof(*histogram));
287 
288  for (int y = 0; y < h; y++) {
289  for (int x = 0; x < w; x++)
290  histogram[src[x]] += 1;
291  src += linesize;
292  }
293 
294  for (int x = 0; x < hsize; x++)
295  histogram[x] /= hsize;
296 
297  for (int x = 1; x < hsize; x++)
298  histogram[x] += histogram[x-1];
299 }
300 
301 static void compute_histogram16(const uint8_t *ssrc, ptrdiff_t linesize,
302  int w, int h, float *histogram, size_t hsize)
303 {
304  const uint16_t *src = (const uint16_t *)ssrc;
305 
306  memset(histogram, 0, hsize * sizeof(*histogram));
307 
308  for (int y = 0; y < h; y++) {
309  for (int x = 0; x < w; x++)
310  histogram[src[x]] += 1;
311  src += linesize / 2;
312  }
313 
314  for (int x = 0; x < hsize; x++)
315  histogram[x] /= hsize;
316 
317  for (int x = 1; x < hsize; x++)
318  histogram[x] += histogram[x-1];
319 }
320 
322 {
323  AVFilterContext *ctx = inlink->dst;
324  TMidEqualizerContext *s = ctx->priv;
326  float sigma = s->radius * s->sigma;
327  int vsub, hsub;
328 
329  s->depth = desc->comp[0].depth;
330  s->nb_frames = s->radius * 2 + 1;
331  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
332 
333  hsub = desc->log2_chroma_w;
334  vsub = desc->log2_chroma_h;
335 
336  s->plane_height[0] = s->plane_height[3] = inlink->h;
337  s->plane_width[0] = s->plane_width[3] = inlink->w;
338  s->plane_height[1] = s->plane_height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
339  s->plane_width[1] = s->plane_width[2] = AV_CEIL_RSHIFT(inlink->w, hsub);
340 
341  s->histogram_size = 1 << s->depth;
342 
343  for (int n = 0; n < s->radius; n++)
344  s->kernel[n] = expf(-0.5 * (n + 1) * (n + 1) / (sigma * sigma));
345 
346  for (int p = 0; p < s->nb_planes; p++) {
347  for (int n = 0; n < s->nb_frames; n++) {
348  s->histogram[p][n] = av_calloc(s->histogram_size, sizeof(float));
349  if (!s->histogram[p][n])
350  return AVERROR(ENOMEM);
351  }
352 
353  s->change[p] = av_calloc(s->histogram_size, sizeof(float));
354  if (!s->change[p])
355  return AVERROR(ENOMEM);
356  }
357 
358  if (!s->frames)
359  s->frames = av_calloc(s->nb_frames, sizeof(*s->frames));
360  if (!s->frames)
361  return AVERROR(ENOMEM);
362 
363  s->compute_histogram = s->depth <= 8 ? compute_histogram8 : compute_histogram16;
364  s->apply_contrast_change = s->depth <= 8 ? apply_contrast_change8 : apply_contrast_change16;
365 
366  return 0;
367 }
368 
369 static int request_frame(AVFilterLink *outlink)
370 {
371  AVFilterContext *ctx = outlink->src;
372  TMidEqualizerContext *s = ctx->priv;
373  int ret;
374 
375  ret = ff_request_frame(ctx->inputs[0]);
376  if (ret == AVERROR_EOF && s->l_frames < s->radius) {
377  ret = filter_frame(ctx->inputs[0], NULL);
378  }
379 
380  return ret;
381 }
382 
383 static void free_histograms(AVFilterContext *ctx, int x, int nb_frames)
384 {
385  TMidEqualizerContext *s = ctx->priv;
386 
387  for (int n = 0; n < nb_frames; n++)
388  av_freep(&s->histogram[x][n]);
389  av_freep(&s->change[x]);
390 }
391 
393 {
394  TMidEqualizerContext *s = ctx->priv;
395 
396  free_histograms(ctx, 0, s->nb_frames);
397  free_histograms(ctx, 1, s->nb_frames);
398  free_histograms(ctx, 2, s->nb_frames);
399  free_histograms(ctx, 3, s->nb_frames);
400 
401  for (int i = 0; i < s->nb_frames && s->frames; i++)
402  av_frame_free(&s->frames[i]);
403  av_freep(&s->frames);
404 }
405 
407  {
408  .name = "default",
409  .type = AVMEDIA_TYPE_VIDEO,
410  .config_props = config_input,
411  .filter_frame = filter_frame,
412  },
413 };
414 
416  {
417  .name = "default",
418  .type = AVMEDIA_TYPE_VIDEO,
419  .request_frame = request_frame,
420  },
421 };
422 
424  .name = "tmidequalizer",
425  .description = NULL_IF_CONFIG_SMALL("Apply Temporal Midway Equalization."),
426  .priv_size = sizeof(TMidEqualizerContext),
427  .uninit = uninit,
431  .priv_class = &tmidequalizer_class,
433 };
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:98
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:447
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:426
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
TMidEqualizerContext::l_frames
int l_frames
Definition: vf_tmidequalizer.c:40
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
out
FILE * out
Definition: movenc.c:54
TMidEqualizerContext::del_frame
int del_frame
Definition: vf_tmidequalizer.c:41
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2660
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:171
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_tmidequalizer.c:70
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
compute_histogram8
static void compute_histogram8(const uint8_t *src, ptrdiff_t linesize, int w, int h, float *histogram, size_t hsize)
Definition: vf_tmidequalizer.c:283
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
TMidEqualizerContext
Definition: vf_tmidequalizer.c:29
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:439
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
pixdesc.h
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:446
w
uint8_t w
Definition: llviddspenc.c:38
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:441
AVOption
AVOption.
Definition: opt.h:247
expf
#define expf(x)
Definition: libm.h:283
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:404
ff_request_frame
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:420
TMidEqualizerContext::nb_planes
int nb_planes
Definition: vf_tmidequalizer.c:43
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
TMidEqualizerContext::f_frames
int f_frames
Definition: vf_tmidequalizer.c:39
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
video.h
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:442
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:384
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:338
apply_contrast_change8
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)
Definition: vf_tmidequalizer.c:136
av_image_copy_plane
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:374
hsub
static void hsub(htype *dst, const htype *src, int bins)
Definition: vf_median.c:74
formats.h
TMidEqualizerContext::frames
AVFrame ** frames
Definition: vf_tmidequalizer.c:49
ff_vf_tmidequalizer
const AVFilter ff_vf_tmidequalizer
Definition: vf_tmidequalizer.c:423
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2700
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:438
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:422
TMidEqualizerContext::histogram_size
int histogram_size
Definition: vf_tmidequalizer.c:44
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:420
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:448
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_tmidequalizer.c:321
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:402
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:388
TMidEqualizerContext::histogram
float * histogram[4][256]
Definition: vf_tmidequalizer.c:46
TMidEqualizerContext::radius
int radius
Definition: vf_tmidequalizer.c:33
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:407
AV_PIX_FMT_YUVJ411P
@ 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:248
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:416
AV_PIX_FMT_YUVJ422P
@ 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_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:424
s
#define s(width, name)
Definition: cbs_vp9.c:257
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:425
AV_PIX_FMT_YUVA420P
@ 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_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:417
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:51
TMidEqualizerContext::depth
int depth
Definition: vf_tmidequalizer.c:38
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(tmidequalizer)
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:445
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:401
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:415
ctx
AVFormatContext * ctx
Definition: movenc.c:48
tmidequalizer_inputs
static const AVFilterPad tmidequalizer_inputs[]
Definition: vf_tmidequalizer.c:406
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:387
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:422
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
TMidEqualizerContext::kernel
float kernel[127]
Definition: vf_tmidequalizer.c:45
OFFSET
#define OFFSET(x)
Definition: vf_tmidequalizer.c:58
apply_contrast_change16
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)
Definition: vf_tmidequalizer.c:149
f
#define f(width, name)
Definition: cbs_vp9.c:255
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
AV_PIX_FMT_YUVJ444P
@ 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
planes
static const struct @321 planes[]
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:385
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:423
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
TMidEqualizerContext::apply_contrast_change
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)
Definition: vf_tmidequalizer.c:53
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:537
TMidEqualizerContext::nb_frames
int nb_frames
Definition: vf_tmidequalizer.c:37
AV_PIX_FMT_YUVJ420P
@ 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
src
#define src
Definition: vp8dsp.c:255
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:405
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:419
weight
static int weight(int i, int blen, int offset)
Definition: diracdec.c:1561
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
compute_histogram16
static void compute_histogram16(const uint8_t *ssrc, ptrdiff_t linesize, int w, int h, float *histogram, size_t hsize)
Definition: vf_tmidequalizer.c:301
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: vf_tmidequalizer.c:369
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:409
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:411
TMidEqualizerContext::plane_width
int plane_width[4]
Definition: vf_tmidequalizer.c:36
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:167
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:443
TMidEqualizerContext::sigma
float sigma
Definition: vf_tmidequalizer.c:34
compute_contrast_function
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)
Definition: vf_tmidequalizer.c:94
tmidequalizer_options
static const AVOption tmidequalizer_options[]
Definition: vf_tmidequalizer.c:61
internal.h
TMidEqualizerContext::change
float * change[4]
Definition: vf_tmidequalizer.c:47
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
TMidEqualizerContext::planes
int planes
Definition: vf_tmidequalizer.c:32
lrintf
#define lrintf(x)
Definition: libm_mips.h:72
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:421
AV_PIX_FMT_YUVJ440P
@ 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
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_tmidequalizer.c:165
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
TMidEqualizerContext::compute_histogram
void(* compute_histogram)(const uint8_t *ssrc, ptrdiff_t linesize, int w, int h, float *histogram, size_t hsize)
Definition: vf_tmidequalizer.c:51
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:271
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:403
AVFilter
Filter definition.
Definition: avfilter.h:165
ret
ret
Definition: filter_design.txt:187
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:440
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:408
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:413
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:444
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avfilter.h
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_tmidequalizer.c:392
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
free_histograms
static void free_histograms(AVFilterContext *ctx, int x, int nb_frames)
Definition: vf_tmidequalizer.c:383
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
TMidEqualizerContext::cur_frame
int cur_frame
Definition: vf_tmidequalizer.c:42
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
TMidEqualizerContext::plane_height
int plane_height[4]
Definition: vf_tmidequalizer.c:36
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#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:154
imgutils.h
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:362
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
FLAGS
#define FLAGS
Definition: vf_tmidequalizer.c:59
h
h
Definition: vp9dsp_template.c:2038
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:414
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:386
tmidequalizer_outputs
static const AVFilterPad tmidequalizer_outputs[]
Definition: vf_tmidequalizer.c:415
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:166
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:412