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/mem.h"
23 #include "libavutil/pixdesc.h"
24 #include "libavutil/opt.h"
25 #include "avfilter.h"
26 #include "filters.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  if (!s->frames[idx])
182  return AVERROR_EOF;
183  in = av_frame_clone(s->frames[idx]);
184  if (!in)
185  return AVERROR(ENOMEM);
186  eof = 1;
187  }
188 
189  if (s->f_frames < s->nb_frames) {
190  s->frames[s->f_frames] = in;
191 
192  for (int p = 0; p < s->nb_planes; p++) {
193  s->compute_histogram(in->data[p], in->linesize[p],
194  s->plane_width[p], s->plane_height[p],
195  s->histogram[p][s->f_frames],
196  s->histogram_size);
197  }
198 
199  s->f_frames++;
200 
201  while (s->f_frames <= s->radius) {
202  s->frames[s->f_frames] = av_frame_clone(in);
203  if (!s->frames[s->f_frames])
204  return AVERROR(ENOMEM);
205  for (int p = 0; p < s->nb_planes; p++) {
206  memcpy(s->histogram[p][s->f_frames],
207  s->histogram[p][s->f_frames - 1],
208  s->histogram_size * sizeof(float));
209  }
210  s->f_frames++;
211  }
212 
213  if (!eof && s->f_frames < s->nb_frames) {
214  return 0;
215  } else {
216  while (s->f_frames < s->nb_frames) {
217  s->frames[s->f_frames] = av_frame_clone(in);
218  if (!s->frames[s->f_frames])
219  return AVERROR(ENOMEM);
220  for (int p = 0; p < s->nb_planes; p++) {
221  memcpy(s->histogram[p][s->f_frames],
222  s->histogram[p][s->f_frames - 1],
223  s->histogram_size * sizeof(float));
224  }
225  s->f_frames++;
226  }
227  }
228  s->cur_frame = s->radius;
229  s->del_frame = 0;
230  } else {
231  av_frame_free(&s->frames[s->del_frame]);
232  s->frames[s->del_frame] = in;
233 
234  for (int p = 0; p < s->nb_planes; p++) {
235  s->compute_histogram(in->data[p], in->linesize[p],
236  s->plane_width[p], s->plane_height[p],
237  s->histogram[p][s->del_frame],
238  s->histogram_size);
239  }
240 
241  s->del_frame++;
242  if (s->del_frame >= s->nb_frames)
243  s->del_frame = 0;
244  }
245 
246  if (ctx->is_disabled) {
247  const int idx = s->cur_frame;
248 
249  out = av_frame_clone(s->frames[idx]);
250  if (!out)
251  return AVERROR(ENOMEM);
252  } else {
253  const int idx = s->cur_frame;
254 
255  in = s->frames[idx];
256  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
257  if (!out)
258  return AVERROR(ENOMEM);
260 
261  for (int p = 0; p < s->nb_planes; p++) {
262  if (!((1 << p) & s->planes)) {
263  av_image_copy_plane(out->data[p], out->linesize[p], in->data[p], in->linesize[p],
264  s->plane_width[p] * (1 + (s->depth > 8)), s->plane_height[p]);
265  continue;
266  }
267 
268  compute_contrast_function((const float *const *)s->histogram[p], s->kernel,
269  s->nb_frames, s->radius, s->histogram_size, s->change[p], idx);
270 
271  s->apply_contrast_change(in->data[p], in->linesize[p],
272  out->data[p], out->linesize[p],
273  s->plane_width[p], s->plane_height[p],
274  s->change[p], s->histogram[p][idx]);
275  }
276  }
277 
278  s->cur_frame++;
279  if (s->cur_frame >= s->nb_frames)
280  s->cur_frame = 0;
281 
282  return ff_filter_frame(outlink, out);
283 }
284 
285 static void compute_histogram8(const uint8_t *src, ptrdiff_t linesize,
286  int w, int h, float *histogram, size_t hsize)
287 {
288  memset(histogram, 0, hsize * sizeof(*histogram));
289 
290  for (int y = 0; y < h; y++) {
291  for (int x = 0; x < w; x++)
292  histogram[src[x]] += 1;
293  src += linesize;
294  }
295 
296  for (int x = 0; x < hsize; x++)
297  histogram[x] /= hsize;
298 
299  for (int x = 1; x < hsize; x++)
300  histogram[x] += histogram[x-1];
301 }
302 
303 static void compute_histogram16(const uint8_t *ssrc, ptrdiff_t linesize,
304  int w, int h, float *histogram, size_t hsize)
305 {
306  const uint16_t *src = (const uint16_t *)ssrc;
307 
308  memset(histogram, 0, hsize * sizeof(*histogram));
309 
310  for (int y = 0; y < h; y++) {
311  for (int x = 0; x < w; x++)
312  histogram[src[x]] += 1;
313  src += linesize / 2;
314  }
315 
316  for (int x = 0; x < hsize; x++)
317  histogram[x] /= hsize;
318 
319  for (int x = 1; x < hsize; x++)
320  histogram[x] += histogram[x-1];
321 }
322 
324 {
325  AVFilterContext *ctx = inlink->dst;
326  TMidEqualizerContext *s = ctx->priv;
328  float sigma = s->radius * s->sigma;
329  int vsub, hsub;
330 
331  s->depth = desc->comp[0].depth;
332  s->nb_frames = s->radius * 2 + 1;
333  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
334 
335  hsub = desc->log2_chroma_w;
336  vsub = desc->log2_chroma_h;
337 
338  s->plane_height[0] = s->plane_height[3] = inlink->h;
339  s->plane_width[0] = s->plane_width[3] = inlink->w;
340  s->plane_height[1] = s->plane_height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
341  s->plane_width[1] = s->plane_width[2] = AV_CEIL_RSHIFT(inlink->w, hsub);
342 
343  s->histogram_size = 1 << s->depth;
344 
345  for (int n = 0; n < s->radius; n++)
346  s->kernel[n] = expf(-0.5 * (n + 1) * (n + 1) / (sigma * sigma));
347 
348  for (int p = 0; p < s->nb_planes; p++) {
349  for (int n = 0; n < s->nb_frames; n++) {
350  s->histogram[p][n] = av_calloc(s->histogram_size, sizeof(float));
351  if (!s->histogram[p][n])
352  return AVERROR(ENOMEM);
353  }
354 
355  s->change[p] = av_calloc(s->histogram_size, sizeof(float));
356  if (!s->change[p])
357  return AVERROR(ENOMEM);
358  }
359 
360  if (!s->frames)
361  s->frames = av_calloc(s->nb_frames, sizeof(*s->frames));
362  if (!s->frames)
363  return AVERROR(ENOMEM);
364 
365  s->compute_histogram = s->depth <= 8 ? compute_histogram8 : compute_histogram16;
366  s->apply_contrast_change = s->depth <= 8 ? apply_contrast_change8 : apply_contrast_change16;
367 
368  return 0;
369 }
370 
371 static int request_frame(AVFilterLink *outlink)
372 {
373  AVFilterContext *ctx = outlink->src;
374  TMidEqualizerContext *s = ctx->priv;
375  int ret;
376 
377  ret = ff_request_frame(ctx->inputs[0]);
378  if (ret == AVERROR_EOF && s->l_frames < s->radius) {
379  ret = filter_frame(ctx->inputs[0], NULL);
380  }
381 
382  return ret;
383 }
384 
385 static void free_histograms(AVFilterContext *ctx, int x, int nb_frames)
386 {
387  TMidEqualizerContext *s = ctx->priv;
388 
389  for (int n = 0; n < nb_frames; n++)
390  av_freep(&s->histogram[x][n]);
391  av_freep(&s->change[x]);
392 }
393 
395 {
396  TMidEqualizerContext *s = ctx->priv;
397 
398  free_histograms(ctx, 0, s->nb_frames);
399  free_histograms(ctx, 1, s->nb_frames);
400  free_histograms(ctx, 2, s->nb_frames);
401  free_histograms(ctx, 3, s->nb_frames);
402 
403  for (int i = 0; i < s->nb_frames && s->frames; i++)
404  av_frame_free(&s->frames[i]);
405  av_freep(&s->frames);
406 }
407 
409  {
410  .name = "default",
411  .type = AVMEDIA_TYPE_VIDEO,
412  .config_props = config_input,
413  .filter_frame = filter_frame,
414  },
415 };
416 
418  {
419  .name = "default",
420  .type = AVMEDIA_TYPE_VIDEO,
421  .request_frame = request_frame,
422  },
423 };
424 
426  .name = "tmidequalizer",
427  .description = NULL_IF_CONFIG_SMALL("Apply Temporal Midway Equalization."),
428  .priv_size = sizeof(TMidEqualizerContext),
429  .uninit = uninit,
433  .priv_class = &tmidequalizer_class,
435 };
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:116
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:546
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:525
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
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
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
out
FILE * out
Definition: movenc.c:55
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:1061
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3170
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
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:285
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:162
TMidEqualizerContext
Definition: vf_tmidequalizer.c:29
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:538
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
pixdesc.h
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:545
w
uint8_t w
Definition: llviddspenc.c:38
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:540
AVOption
AVOption.
Definition: opt.h:429
expf
#define expf(x)
Definition: libm.h:283
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:502
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:475
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:106
TMidEqualizerContext::f_frames
int f_frames
Definition: vf_tmidequalizer.c:39
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
video.h
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:541
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:482
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:410
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
TMidEqualizerContext::frames
AVFrame ** frames
Definition: vf_tmidequalizer.c:49
ff_vf_tmidequalizer
const AVFilter ff_vf_tmidequalizer
Definition: vf_tmidequalizer.c:425
planes
static const struct @466 planes[]
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3210
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:537
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:520
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:212
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:518
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:547
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_tmidequalizer.c:323
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:500
weight
const h264_weight_func weight
Definition: h264dsp_init.c:33
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:486
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: filters.h:38
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:505
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:514
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:522
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:523
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:515
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:60
TMidEqualizerContext::depth
int depth
Definition: vf_tmidequalizer.c:38
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(tmidequalizer)
filters.h
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:544
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:499
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:513
ctx
AVFormatContext * ctx
Definition: movenc.c:49
tmidequalizer_inputs
static const AVFilterPad tmidequalizer_inputs[]
Definition: vf_tmidequalizer.c:408
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:485
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:609
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:45
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
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
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:483
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:521
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
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:725
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:85
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:503
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:517
f
f
Definition: af_crystalizer.c:122
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:94
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
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:303
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: vf_tmidequalizer.c:371
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:507
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:509
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:174
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:542
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
TMidEqualizerContext::change
float * change[4]
Definition: vf_tmidequalizer.c:47
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
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:256
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:519
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:165
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
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:264
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:501
AVFilter
Filter definition.
Definition: avfilter.h:201
ret
ret
Definition: filter_design.txt:187
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:539
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:506
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:511
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:543
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_tmidequalizer.c:394
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:457
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: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:77
mem.h
free_histograms
static void free_histograms(AVFilterContext *ctx, int x, int nb_frames)
Definition: vf_tmidequalizer.c:385
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
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
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: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:190
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:434
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:59
h
h
Definition: vp9dsp_template.c:2070
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:512
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:484
tmidequalizer_outputs
static const AVFilterPad tmidequalizer_outputs[]
Definition: vf_tmidequalizer.c:417
src
#define src
Definition: vp8dsp.c:248
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:510