FFmpeg
Loading...
Searching...
No Matches
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
29typedef struct TMidEqualizerContext {
30 const AVClass *class;
31
32 int planes;
33 int radius;
34 float sigma;
35
38 int depth;
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
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
68AVFILTER_DEFINE_CLASS(tmidequalizer);
69
93
94static 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
136static 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
149static 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
165static int filter_frame(AVFilterLink *inlink, AVFrame *in)
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
285static 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
303static 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
323static int config_input(AVFilterLink *inlink)
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
371static 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
385static 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 .p.name = "tmidequalizer",
427 .p.description = NULL_IF_CONFIG_SMALL("Apply Temporal Midway Equalization."),
428 .p.priv_class = &tmidequalizer_class,
430 .priv_size = sizeof(TMidEqualizerContext),
431 .uninit = uninit,
435};
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static int config_input(AVFilterLink *inlink)
static int request_frame(AVFilterLink *outlink)
Definition af_aecho.c:272
const FFFilter ff_vf_tmidequalizer
static FILE * out
static AVFormatContext * ctx
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition avfilter.c:483
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define f(width, name)
Definition cbs_vp8.c:236
#define s(width, name)
Definition cbs_vp9.c:198
#define FLAGS
Definition cmdutils.c:598
#define AV_CEIL_RSHIFT(a, b)
Definition common.h:60
#define NULL
Definition coverity.c:32
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270
#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:204
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition frame.c:599
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition frame.c:483
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
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
misc image utilities
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:244
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:478
#define av_cold
Definition attributes.h:117
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
#define expf(x)
Definition libm.h:285
#define lrintf(x)
Definition libm_mips.h:72
const char * desc
Definition libsvtav1.c:83
static const struct @257111027162314367033347246032313251342043035002 planes[]
uint8_t w
Definition llvidencdsp.c:39
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:264
Memory handling functions.
AVOptions.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3500
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3460
#define AV_PIX_FMT_GBRAP12
Definition pixfmt.h:569
#define AV_PIX_FMT_YUV420P16
Definition pixfmt.h:556
#define AV_PIX_FMT_YUV444P12
Definition pixfmt.h:552
#define AV_PIX_FMT_YUV444P9
Definition pixfmt.h:544
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:545
#define AV_PIX_FMT_GRAY9
Definition pixfmt.h:524
#define AV_PIX_FMT_GBRAP16
Definition pixfmt.h:571
#define AV_PIX_FMT_GBRP9
Definition pixfmt.h:563
#define AV_PIX_FMT_YUV422P9
Definition pixfmt.h:543
#define AV_PIX_FMT_YUVA444P10
Definition pixfmt.h:598
#define AV_PIX_FMT_YUVA420P16
Definition pixfmt.h:601
#define AV_PIX_FMT_YUV420P12
Definition pixfmt.h:549
#define AV_PIX_FMT_YUVA420P10
Definition pixfmt.h:596
#define AV_PIX_FMT_YUVA422P9
Definition pixfmt.h:594
#define AV_PIX_FMT_YUV422P12
Definition pixfmt.h:550
#define AV_PIX_FMT_GBRP10
Definition pixfmt.h:564
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:546
#define AV_PIX_FMT_GRAY12
Definition pixfmt.h:526
#define AV_PIX_FMT_GBRP12
Definition pixfmt.h:565
#define AV_PIX_FMT_YUV420P9
Definition pixfmt.h:542
#define AV_PIX_FMT_YUVA420P9
Definition pixfmt.h:593
#define AV_PIX_FMT_YUVA422P10
Definition pixfmt.h:597
#define AV_PIX_FMT_YUV420P14
Definition pixfmt.h:553
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ 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_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
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ 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_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_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition pixfmt.h:212
@ 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_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition pixfmt.h:173
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165
@ 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_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
#define AV_PIX_FMT_YUVA422P12
Definition pixfmt.h:599
#define AV_PIX_FMT_YUV422P14
Definition pixfmt.h:554
#define AV_PIX_FMT_GRAY10
Definition pixfmt.h:525
#define AV_PIX_FMT_GRAY14
Definition pixfmt.h:527
#define AV_PIX_FMT_YUV422P16
Definition pixfmt.h:557
#define AV_PIX_FMT_GRAY16
Definition pixfmt.h:528
#define AV_PIX_FMT_GBRAP10
Definition pixfmt.h:568
#define AV_PIX_FMT_YUVA444P16
Definition pixfmt.h:603
#define AV_PIX_FMT_YUVA422P16
Definition pixfmt.h:602
#define AV_PIX_FMT_GBRP16
Definition pixfmt.h:567
#define AV_PIX_FMT_YUV444P14
Definition pixfmt.h:555
#define AV_PIX_FMT_YUVA444P9
Definition pixfmt.h:595
#define AV_PIX_FMT_GBRP14
Definition pixfmt.h:566
#define AV_PIX_FMT_YUVA444P12
Definition pixfmt.h:600
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:558
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:548
const h264_weight_func weight
Describe the class of an AVClass context structure.
Definition log.h:76
An instance of a filter.
Definition avfilter.h:273
A filter pad used for either input or output.
Definition filters.h:40
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:493
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:517
AVOption.
Definition opt.h:428
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
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:248
static void hsub(htype *dst, const htype *src, int bins)
Definition vf_median.c:74
static void compute_histogram16(const uint16_t *src, ptrdiff_t linesize, int w, int h, float *histogram, size_t hsize)
static void compute_histogram8(const uint8_t *src, ptrdiff_t linesize, int w, int h, float *histogram, size_t hsize)
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 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)
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)
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:89