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 "internal.h"
26 #include "video.h"
27 
28 typedef struct TMidEqualizerContext {
29  const AVClass *class;
30 
31  int planes;
32  int radius;
33  float sigma;
34 
36  int nb_frames;
37  int depth;
38  int f_frames;
39  int l_frames;
40  int del_frame;
41  int cur_frame;
42  int nb_planes;
44  float kernel[127];
45  float *histogram[4][256];
46  float *change[4];
47 
49 
50  void (*compute_histogram)(const uint8_t *ssrc, ptrdiff_t linesize,
51  int w, int h, float *histogram, size_t hsize);
52  void (*apply_contrast_change)(const uint8_t *src, ptrdiff_t src_linesize,
53  uint8_t *dst, ptrdiff_t dst_linesize,
54  int w, int h, float *change, float *orig);
56 
57 #define OFFSET(x) offsetof(TMidEqualizerContext, x)
58 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
59 
60 static const AVOption tmidequalizer_options[] = {
61  { "radius", "set radius", OFFSET(radius), AV_OPT_TYPE_INT, {.i64=5}, 1, 127, FLAGS },
62  { "sigma", "set sigma", OFFSET(sigma), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGS },
63  { "planes", "set planes", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
64  { NULL }
65 };
66 
67 AVFILTER_DEFINE_CLASS(tmidequalizer);
68 
69 static const enum AVPixelFormat pix_fmts[] = {
91 };
92 
93 static void compute_contrast_function(const float *const histograms[256],
94  const float *const kernel,
95  int nb_frames, int radius, int hsize,
96  float *f, int idx)
97 {
98  const float *const h1 = histograms[idx];
99  int p2[256] = { 0 };
100 
101  for (int p1 = 0; p1 < hsize; p1++) {
102  float weight = 1.f;
103  float sum = p1 * weight;
104 
105  for (int j = 0; j < radius; j++) {
106  const int nidx = ((idx - radius + j) % nb_frames);
107  const float *const h2 = histograms[nidx < 0 ? nidx + nb_frames: nidx];
108  int k = j;
109 
110  for (; p2[k] < hsize && h2[p2[k]] < h1[p1]; p2[k]++);
111  if (p2[k] == hsize)
112  p2[k]--;
113 
114  weight += kernel[j];
115  sum += kernel[j] * p2[k];
116  }
117 
118  for (int j = radius + 1; j < nb_frames; j++) {
119  const int nidx = (idx - radius + j) % nb_frames;
120  const float *const h2 = histograms[nidx < 0 ? nidx + nb_frames: nidx];
121  int k = j;
122 
123  for (; p2[k] < hsize && h2[p2[k]] < h1[p1]; p2[k]++);
124  if (p2[k] == hsize)
125  p2[k]--;
126 
127  weight += kernel[j - radius - 1];
128  sum += kernel[j - radius - 1] * p2[k];
129  }
130 
131  f[p1] = sum / weight;
132  }
133 }
134 
135 static void apply_contrast_change8(const uint8_t *src, ptrdiff_t src_linesize,
136  uint8_t *dst, ptrdiff_t dst_linesize,
137  int w, int h, float *change, float *orig)
138 {
139  for (int y = 0; y < h; y++) {
140  for (int x = 0; x < w; x++)
141  dst[x] = lrintf(change[src[x]]);
142 
143  dst += dst_linesize;
144  src += src_linesize;
145  }
146 }
147 
148 static void apply_contrast_change16(const uint8_t *ssrc, ptrdiff_t src_linesize,
149  uint8_t *ddst, ptrdiff_t dst_linesize,
150  int w, int h, float *change, float *orig)
151 {
152  const uint16_t *src = (const uint16_t *)ssrc;
153  uint16_t *dst = (uint16_t *)ddst;
154 
155  for (int y = 0; y < h; y++) {
156  for (int x = 0; x < w; x++)
157  dst[x] = lrintf(change[src[x]]);
158 
159  dst += dst_linesize / 2;
160  src += src_linesize / 2;
161  }
162 }
163 
165 {
166  AVFilterContext *ctx = inlink->dst;
167  TMidEqualizerContext *s = ctx->priv;
168  AVFilterLink *outlink = ctx->outputs[0];
169  AVFrame *out;
170  int eof = 0;
171 
172  if (!in) {
173  int idx = s->f_frames < s->nb_frames ? s->radius : s->del_frame ? s->del_frame - 1 : s->nb_frames - 1;
174 
175  if (s->f_frames < s->nb_frames) {
176  s->l_frames = s->nb_frames - s->f_frames;
177  } else {
178  s->l_frames++;
179  }
180  if (!s->frames[idx])
181  return AVERROR_EOF;
182  in = av_frame_clone(s->frames[idx]);
183  if (!in)
184  return AVERROR(ENOMEM);
185  eof = 1;
186  }
187 
188  if (s->f_frames < s->nb_frames) {
189  s->frames[s->f_frames] = in;
190 
191  for (int p = 0; p < s->nb_planes; p++) {
192  s->compute_histogram(in->data[p], in->linesize[p],
193  s->plane_width[p], s->plane_height[p],
194  s->histogram[p][s->f_frames],
195  s->histogram_size);
196  }
197 
198  s->f_frames++;
199 
200  while (s->f_frames <= s->radius) {
201  s->frames[s->f_frames] = av_frame_clone(in);
202  if (!s->frames[s->f_frames])
203  return AVERROR(ENOMEM);
204  for (int p = 0; p < s->nb_planes; p++) {
205  memcpy(s->histogram[p][s->f_frames],
206  s->histogram[p][s->f_frames - 1],
207  s->histogram_size * sizeof(float));
208  }
209  s->f_frames++;
210  }
211 
212  if (!eof && s->f_frames < s->nb_frames) {
213  return 0;
214  } else {
215  while (s->f_frames < s->nb_frames) {
216  s->frames[s->f_frames] = av_frame_clone(in);
217  if (!s->frames[s->f_frames])
218  return AVERROR(ENOMEM);
219  for (int p = 0; p < s->nb_planes; p++) {
220  memcpy(s->histogram[p][s->f_frames],
221  s->histogram[p][s->f_frames - 1],
222  s->histogram_size * sizeof(float));
223  }
224  s->f_frames++;
225  }
226  }
227  s->cur_frame = s->radius;
228  s->del_frame = 0;
229  } else {
230  av_frame_free(&s->frames[s->del_frame]);
231  s->frames[s->del_frame] = in;
232 
233  for (int p = 0; p < s->nb_planes; p++) {
234  s->compute_histogram(in->data[p], in->linesize[p],
235  s->plane_width[p], s->plane_height[p],
236  s->histogram[p][s->del_frame],
237  s->histogram_size);
238  }
239 
240  s->del_frame++;
241  if (s->del_frame >= s->nb_frames)
242  s->del_frame = 0;
243  }
244 
245  if (ctx->is_disabled) {
246  const int idx = s->cur_frame;
247 
248  out = av_frame_clone(s->frames[idx]);
249  if (!out)
250  return AVERROR(ENOMEM);
251  } else {
252  const int idx = s->cur_frame;
253 
254  in = s->frames[idx];
255  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
256  if (!out)
257  return AVERROR(ENOMEM);
259 
260  for (int p = 0; p < s->nb_planes; p++) {
261  if (!((1 << p) & s->planes)) {
262  av_image_copy_plane(out->data[p], out->linesize[p], in->data[p], in->linesize[p],
263  s->plane_width[p] * (1 + (s->depth > 8)), s->plane_height[p]);
264  continue;
265  }
266 
267  compute_contrast_function((const float *const *)s->histogram[p], s->kernel,
268  s->nb_frames, s->radius, s->histogram_size, s->change[p], idx);
269 
270  s->apply_contrast_change(in->data[p], in->linesize[p],
271  out->data[p], out->linesize[p],
272  s->plane_width[p], s->plane_height[p],
273  s->change[p], s->histogram[p][idx]);
274  }
275  }
276 
277  s->cur_frame++;
278  if (s->cur_frame >= s->nb_frames)
279  s->cur_frame = 0;
280 
281  return ff_filter_frame(outlink, out);
282 }
283 
284 static void compute_histogram8(const uint8_t *src, ptrdiff_t linesize,
285  int w, int h, float *histogram, size_t hsize)
286 {
287  memset(histogram, 0, hsize * sizeof(*histogram));
288 
289  for (int y = 0; y < h; y++) {
290  for (int x = 0; x < w; x++)
291  histogram[src[x]] += 1;
292  src += linesize;
293  }
294 
295  for (int x = 0; x < hsize; x++)
296  histogram[x] /= hsize;
297 
298  for (int x = 1; x < hsize; x++)
299  histogram[x] += histogram[x-1];
300 }
301 
302 static void compute_histogram16(const uint8_t *ssrc, ptrdiff_t linesize,
303  int w, int h, float *histogram, size_t hsize)
304 {
305  const uint16_t *src = (const uint16_t *)ssrc;
306 
307  memset(histogram, 0, hsize * sizeof(*histogram));
308 
309  for (int y = 0; y < h; y++) {
310  for (int x = 0; x < w; x++)
311  histogram[src[x]] += 1;
312  src += linesize / 2;
313  }
314 
315  for (int x = 0; x < hsize; x++)
316  histogram[x] /= hsize;
317 
318  for (int x = 1; x < hsize; x++)
319  histogram[x] += histogram[x-1];
320 }
321 
323 {
324  AVFilterContext *ctx = inlink->dst;
325  TMidEqualizerContext *s = ctx->priv;
327  float sigma = s->radius * s->sigma;
328  int vsub, hsub;
329 
330  s->depth = desc->comp[0].depth;
331  s->nb_frames = s->radius * 2 + 1;
332  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
333 
334  hsub = desc->log2_chroma_w;
335  vsub = desc->log2_chroma_h;
336 
337  s->plane_height[0] = s->plane_height[3] = inlink->h;
338  s->plane_width[0] = s->plane_width[3] = inlink->w;
339  s->plane_height[1] = s->plane_height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
340  s->plane_width[1] = s->plane_width[2] = AV_CEIL_RSHIFT(inlink->w, hsub);
341 
342  s->histogram_size = 1 << s->depth;
343 
344  for (int n = 0; n < s->radius; n++)
345  s->kernel[n] = expf(-0.5 * (n + 1) * (n + 1) / (sigma * sigma));
346 
347  for (int p = 0; p < s->nb_planes; p++) {
348  for (int n = 0; n < s->nb_frames; n++) {
349  s->histogram[p][n] = av_calloc(s->histogram_size, sizeof(float));
350  if (!s->histogram[p][n])
351  return AVERROR(ENOMEM);
352  }
353 
354  s->change[p] = av_calloc(s->histogram_size, sizeof(float));
355  if (!s->change[p])
356  return AVERROR(ENOMEM);
357  }
358 
359  if (!s->frames)
360  s->frames = av_calloc(s->nb_frames, sizeof(*s->frames));
361  if (!s->frames)
362  return AVERROR(ENOMEM);
363 
364  s->compute_histogram = s->depth <= 8 ? compute_histogram8 : compute_histogram16;
365  s->apply_contrast_change = s->depth <= 8 ? apply_contrast_change8 : apply_contrast_change16;
366 
367  return 0;
368 }
369 
370 static int request_frame(AVFilterLink *outlink)
371 {
372  AVFilterContext *ctx = outlink->src;
373  TMidEqualizerContext *s = ctx->priv;
374  int ret;
375 
376  ret = ff_request_frame(ctx->inputs[0]);
377  if (ret == AVERROR_EOF && s->l_frames < s->radius) {
378  ret = filter_frame(ctx->inputs[0], NULL);
379  }
380 
381  return ret;
382 }
383 
384 static void free_histograms(AVFilterContext *ctx, int x, int nb_frames)
385 {
386  TMidEqualizerContext *s = ctx->priv;
387 
388  for (int n = 0; n < nb_frames; n++)
389  av_freep(&s->histogram[x][n]);
390  av_freep(&s->change[x]);
391 }
392 
394 {
395  TMidEqualizerContext *s = ctx->priv;
396 
397  free_histograms(ctx, 0, s->nb_frames);
398  free_histograms(ctx, 1, s->nb_frames);
399  free_histograms(ctx, 2, s->nb_frames);
400  free_histograms(ctx, 3, s->nb_frames);
401 
402  for (int i = 0; i < s->nb_frames && s->frames; i++)
403  av_frame_free(&s->frames[i]);
404  av_freep(&s->frames);
405 }
406 
408  {
409  .name = "default",
410  .type = AVMEDIA_TYPE_VIDEO,
411  .config_props = config_input,
412  .filter_frame = filter_frame,
413  },
414 };
415 
417  {
418  .name = "default",
419  .type = AVMEDIA_TYPE_VIDEO,
420  .request_frame = request_frame,
421  },
422 };
423 
425  .name = "tmidequalizer",
426  .description = NULL_IF_CONFIG_SMALL("Apply Temporal Midway Equalization."),
427  .priv_size = sizeof(TMidEqualizerContext),
428  .uninit = uninit,
432  .priv_class = &tmidequalizer_class,
434 };
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:112
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:522
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:501
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
TMidEqualizerContext::l_frames
int l_frames
Definition: vf_tmidequalizer.c:39
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:40
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:2962
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:162
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_tmidequalizer.c:69
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:284
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:88
TMidEqualizerContext
Definition: vf_tmidequalizer.c:28
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:514
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
pixdesc.h
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:521
w
uint8_t w
Definition: llviddspenc.c:38
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:516
AVOption
AVOption.
Definition: opt.h:346
expf
#define expf(x)
Definition: libm.h:283
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:478
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:462
TMidEqualizerContext::nb_planes
int nb_planes
Definition: vf_tmidequalizer.c:42
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
TMidEqualizerContext::f_frames
int f_frames
Definition: vf_tmidequalizer.c:38
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
video.h
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:517
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:458
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:361
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:135
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:73
TMidEqualizerContext::frames
AVFrame ** frames
Definition: vf_tmidequalizer.c:48
ff_vf_tmidequalizer
const AVFilter ff_vf_tmidequalizer
Definition: vf_tmidequalizer.c:424
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3002
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:513
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:496
TMidEqualizerContext::histogram_size
int histogram_size
Definition: vf_tmidequalizer.c:43
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:494
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:523
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_tmidequalizer.c:322
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:476
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:462
TMidEqualizerContext::histogram
float * histogram[4][256]
Definition: vf_tmidequalizer.c:45
TMidEqualizerContext::radius
int radius
Definition: vf_tmidequalizer.c:32
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:481
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:283
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:490
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:86
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:498
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:499
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:108
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:491
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
TMidEqualizerContext::depth
int depth
Definition: vf_tmidequalizer.c:37
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(tmidequalizer)
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:520
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:475
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:489
ctx
AVFormatContext * ctx
Definition: movenc.c:48
tmidequalizer_inputs
static const AVFilterPad tmidequalizer_inputs[]
Definition: vf_tmidequalizer.c:407
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:461
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:521
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:73
TMidEqualizerContext::kernel
float kernel[127]
Definition: vf_tmidequalizer.c:44
OFFSET
#define OFFSET(x)
Definition: vf_tmidequalizer.c:57
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:148
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
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:87
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:459
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:497
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:52
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:637
TMidEqualizerContext::nb_frames
int nb_frames
Definition: vf_tmidequalizer.c:36
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:85
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:479
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:493
weight
static int weight(int i, int blen, int offset)
Definition: diracdec.c:1562
f
f
Definition: af_crystalizer.c:121
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:106
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:302
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: vf_tmidequalizer.c:370
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:483
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:485
TMidEqualizerContext::plane_width
int plane_width[4]
Definition: vf_tmidequalizer.c:35
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:174
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:518
TMidEqualizerContext::sigma
float sigma
Definition: vf_tmidequalizer.c:33
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:93
tmidequalizer_options
static const AVOption tmidequalizer_options[]
Definition: vf_tmidequalizer.c:60
internal.h
TMidEqualizerContext::change
float * change[4]
Definition: vf_tmidequalizer.c:46
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:238
TMidEqualizerContext::planes
int planes
Definition: vf_tmidequalizer.c:31
lrintf
#define lrintf(x)
Definition: libm_mips.h:72
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:495
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:107
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_tmidequalizer.c:164
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
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:50
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:477
AVFilter
Filter definition.
Definition: avfilter.h:166
ret
ret
Definition: filter_design.txt:187
planes
static const struct @383 planes[]
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:515
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:482
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:487
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:519
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
avfilter.h
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_tmidequalizer.c:393
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:78
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
desc
const char * desc
Definition: libsvtav1.c:73
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:77
free_histograms
static void free_histograms(AVFilterContext *ctx, int x, int nb_frames)
Definition: vf_tmidequalizer.c:384
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:41
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
TMidEqualizerContext::plane_height
int plane_height[4]
Definition: vf_tmidequalizer.c:35
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:80
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:155
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:385
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:79
FLAGS
#define FLAGS
Definition: vf_tmidequalizer.c:58
h
h
Definition: vp9dsp_template.c:2038
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:488
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:460
tmidequalizer_outputs
static const AVFilterPad tmidequalizer_outputs[]
Definition: vf_tmidequalizer.c:416
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:173
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:486