FFmpeg
Loading...
Searching...
No Matches
vf_fftfilt.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Arwa Arif <arwaarif1994@gmail.com>
3 * Copyright (c) 2017 Paul B Mahol
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; either version 2.1 of the License,
10 * or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22/**
23 * @file
24 * FFT domain filtering.
25 */
26
27#include "filters.h"
28#include "video.h"
29#include "libavutil/common.h"
30#include "libavutil/cpu.h"
31#include "libavutil/mem.h"
32#include "libavutil/opt.h"
33#include "libavutil/pixdesc.h"
34#include "libavutil/tx.h"
35#include "libavutil/eval.h"
36
37#define MAX_THREADS 32
38#define MAX_PLANES 4
39
45
83
84static const char *const var_names[] = { "X", "Y", "W", "H", "N", "WS", "HS", NULL };
86
87enum { Y = 0, U, V };
88
89#define OFFSET(x) offsetof(FFTFILTContext, x)
90#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
91
92static const AVOption fftfilt_options[] = {
93 { "dc_Y", "adjust gain in Y plane", OFFSET(dc[Y]), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1000, FLAGS },
94 { "dc_U", "adjust gain in U plane", OFFSET(dc[U]), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1000, FLAGS },
95 { "dc_V", "adjust gain in V plane", OFFSET(dc[V]), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1000, FLAGS },
96 { "weight_Y", "set luminance expression in Y plane", OFFSET(weight_str[Y]), AV_OPT_TYPE_STRING, {.str = "1"}, 0, 0, FLAGS },
97 { "weight_U", "set chrominance expression in U plane", OFFSET(weight_str[U]), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
98 { "weight_V", "set chrominance expression in V plane", OFFSET(weight_str[V]), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
99 { "eval", "specify when to evaluate expressions", OFFSET(eval_mode), AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_INIT}, 0, EVAL_MODE_NB-1, FLAGS, .unit = "eval" },
100 { "init", "eval expressions once during initialization", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT}, .flags = FLAGS, .unit = "eval" },
101 { "frame", "eval expressions per-frame", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = FLAGS, .unit = "eval" },
102 {NULL},
103};
104
106
107static inline double lum(void *priv, double x, double y, int plane)
108{
109 FFTFILTContext *s = priv;
110 if (!s->rdft_vdata_out[plane])
111 return 0;
112 return s->rdft_vdata_out[plane][((int)x & (s->rdft_hlen[plane] - 1)) * s->rdft_vstride[plane] +
113 ((int)y & (s->rdft_vlen[plane] - 1))];
114}
115
116static double weight_Y(void *priv, double x, double y) { return lum(priv, x, y, Y); }
117static double weight_U(void *priv, double x, double y) { return lum(priv, x, y, U); }
118static double weight_V(void *priv, double x, double y) { return lum(priv, x, y, V); }
119
120static void copy_rev(float *dest, int w, int w2)
121{
122 int i;
123
124 for (i = w; i < w + (w2-w)/2; i++)
125 dest[i] = dest[2*w - i - 1];
126
127 for (; i < w2; i++)
128 dest[i] = dest[w2 - i];
129}
130
131static int rdft_horizontal8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
132{
133 FFTFILTContext *s = ctx->priv;
134 AVFrame *in = arg;
135
136 for (int plane = 0; plane < s->nb_planes; plane++) {
137 const int w = s->planewidth[plane];
138 const int h = s->planeheight[plane];
139 const int slice_start = ff_slice_pos(h, jobnr, nb_jobs);
140 const int slice_end = ff_slice_pos(h, jobnr + 1, nb_jobs);
141
142 for (int i = slice_start; i < slice_end; i++) {
143 const uint8_t *src = in->data[plane] + i * in->linesize[plane];
144 float *hdata_in = s->rdft_hdata_in[plane] + i * s->rdft_hstride[plane];
145
146 for (int j = 0; j < w; j++)
147 hdata_in[j] = src[j];
148
149 copy_rev(s->rdft_hdata_in[plane] + i * s->rdft_hstride[plane], w, s->rdft_hlen[plane]);
150 }
151
152 for (int i = slice_start; i < slice_end; i++)
153 s->htx_fn(s->hrdft[jobnr][plane],
154 s->rdft_hdata_out[plane] + i * s->rdft_hstride[plane],
155 s->rdft_hdata_in[plane] + i * s->rdft_hstride[plane],
156 sizeof(float));
157 }
158
159 return 0;
160}
161
162static int rdft_horizontal16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
163{
164 FFTFILTContext *s = ctx->priv;
165 AVFrame *in = arg;
166
167 for (int plane = 0; plane < s->nb_planes; plane++) {
168 const int w = s->planewidth[plane];
169 const int h = s->planeheight[plane];
170 const int slice_start = ff_slice_pos(h, jobnr, nb_jobs);
171 const int slice_end = ff_slice_pos(h, jobnr + 1, nb_jobs);
172
173 for (int i = slice_start; i < slice_end; i++) {
174 const uint16_t *src = (const uint16_t *)(in->data[plane] + i * in->linesize[plane]);
175 float *hdata_in = s->rdft_hdata_in[plane] + i * s->rdft_hstride[plane];
176
177 for (int j = 0; j < w; j++)
178 hdata_in[j] = src[j];
179
180 copy_rev(s->rdft_hdata_in[plane] + i * s->rdft_hstride[plane], w, s->rdft_hlen[plane]);
181 }
182
183 for (int i = slice_start; i < slice_end; i++)
184 s->htx_fn(s->hrdft[jobnr][plane],
185 s->rdft_hdata_out[plane] + i * s->rdft_hstride[plane],
186 s->rdft_hdata_in[plane] + i * s->rdft_hstride[plane],
187 sizeof(float));
188 }
189
190 return 0;
191}
192
193static int irdft_horizontal8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
194{
195 FFTFILTContext *s = ctx->priv;
196 AVFrame *out = arg;
197
198 for (int plane = 0; plane < s->nb_planes; plane++) {
199 const int w = s->planewidth[plane];
200 const int h = s->planeheight[plane];
201 const int slice_start = ff_slice_pos(h, jobnr, nb_jobs);
202 const int slice_end = ff_slice_pos(h, jobnr + 1, nb_jobs);
203
204 for (int i = slice_start; i < slice_end; i++)
205 s->ihtx_fn(s->ihrdft[jobnr][plane],
206 s->rdft_hdata_out[plane] + i * s->rdft_hstride[plane],
207 s->rdft_hdata_in[plane] + i * s->rdft_hstride[plane],
208 sizeof(AVComplexFloat));
209
210 for (int i = slice_start; i < slice_end; i++) {
211 const float scale = 1.f / (s->rdft_hlen[plane] * s->rdft_vlen[plane]);
212 const float *src = s->rdft_hdata_out[plane] + i * s->rdft_hstride[plane];
213 uint8_t *dst = out->data[plane] + i * out->linesize[plane];
214
215 for (int j = 0; j < w; j++)
216 dst[j] = av_clip_uint8(lrintf(src[j] * scale));
217 }
218 }
219
220 return 0;
221}
222
223static int irdft_horizontal16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
224{
225 FFTFILTContext *s = ctx->priv;
226 AVFrame *out = arg;
227
228 for (int plane = 0; plane < s->nb_planes; plane++) {
229 int max = (1 << s->depth) - 1;
230 const int w = s->planewidth[plane];
231 const int h = s->planeheight[plane];
232 const int slice_start = ff_slice_pos(h, jobnr, nb_jobs);
233 const int slice_end = ff_slice_pos(h, jobnr + 1, nb_jobs);
234
235 for (int i = slice_start; i < slice_end; i++)
236 s->ihtx_fn(s->ihrdft[jobnr][plane],
237 s->rdft_hdata_out[plane] + i * s->rdft_hstride[plane],
238 s->rdft_hdata_in[plane] + i * s->rdft_hstride[plane],
239 sizeof(AVComplexFloat));
240
241 for (int i = slice_start; i < slice_end; i++) {
242 const float scale = 1.f / (s->rdft_hlen[plane] * s->rdft_vlen[plane]);
243 const float *src = s->rdft_hdata_out[plane] + i * s->rdft_hstride[plane];
244 uint16_t *dst = (uint16_t *)(out->data[plane] + i * out->linesize[plane]);
245
246 for (int j = 0; j < w; j++)
247 dst[j] = av_clip(lrintf(src[j] * scale), 0, max);
248 }
249 }
250
251 return 0;
252}
253
255{
256 FFTFILTContext *s = ctx->priv;
257 int ret = 0, plane;
258
259 if (!s->dc[U] && !s->dc[V]) {
260 s->dc[U] = s->dc[Y];
261 s->dc[V] = s->dc[Y];
262 } else {
263 if (!s->dc[U]) s->dc[U] = s->dc[V];
264 if (!s->dc[V]) s->dc[V] = s->dc[U];
265 }
266
267 if (!s->weight_str[U] && !s->weight_str[V]) {
268 s->weight_str[U] = av_strdup(s->weight_str[Y]);
269 s->weight_str[V] = av_strdup(s->weight_str[Y]);
270 } else {
271 if (!s->weight_str[U]) s->weight_str[U] = av_strdup(s->weight_str[V]);
272 if (!s->weight_str[V]) s->weight_str[V] = av_strdup(s->weight_str[U]);
273 }
274
275 for (plane = 0; plane < 3; plane++) {
276 static double (*p[])(void *, double, double) = { weight_Y, weight_U, weight_V };
277 const char *const func2_names[] = {"weight_Y", "weight_U", "weight_V", NULL };
278 double (*func2[])(void *, double, double) = { weight_Y, weight_U, weight_V, p[plane], NULL };
279
280 ret = av_expr_parse(&s->weight_expr[plane], s->weight_str[plane], var_names,
281 NULL, NULL, func2_names, func2, 0, ctx);
282 if (ret < 0)
283 break;
284 }
285 return ret;
286}
287
288static void do_eval(FFTFILTContext *s, AVFilterLink *inlink, int plane)
289{
290 FilterLink *l = ff_filter_link(inlink);
291 double values[VAR_VARS_NB];
292 int i, j;
293
294 values[VAR_N] = l->frame_count_out;
295 values[VAR_W] = s->planewidth[plane];
296 values[VAR_H] = s->planeheight[plane];
297 values[VAR_WS] = s->rdft_hlen[plane];
298 values[VAR_HS] = s->rdft_vlen[plane];
299
300 for (i = 0; i < s->rdft_hlen[plane]; i++) {
301 values[VAR_X] = i;
302 for (j = 0; j < s->rdft_vlen[plane]; j++) {
303 values[VAR_Y] = j;
304 s->weight[plane][i * s->rdft_vlen[plane] + j] =
305 av_expr_eval(s->weight_expr[plane], values, s);
306 }
307 }
308}
309
310static int config_props(AVFilterLink *inlink)
311{
312 FFTFILTContext *s = inlink->dst->priv;
314 int ret, i, plane;
315
317 s->depth = desc->comp[0].depth;
318 s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
319 s->planewidth[0] = s->planewidth[3] = inlink->w;
320 s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
321 s->planeheight[0] = s->planeheight[3] = inlink->h;
322
323 s->nb_planes = av_pix_fmt_count_planes(inlink->format);
324 s->nb_threads = FFMIN(32, ff_filter_get_nb_threads(inlink->dst));
325
326 for (i = 0; i < desc->nb_components; i++) {
327 int w = s->planewidth[i];
328 int h = s->planeheight[i];
329
330 /* RDFT - Array initialization for Horizontal pass*/
331 s->rdft_hlen[i] = 1 << (32 - ff_clz(w));
332 s->rdft_hstride[i] = FFALIGN(s->rdft_hlen[i] + 2, av_cpu_max_align());
333 s->rdft_hbits[i] = av_log2(s->rdft_hlen[i]);
334 if (!(s->rdft_hdata_in[i] = av_calloc(h, s->rdft_hstride[i] * sizeof(float))))
335 return AVERROR(ENOMEM);
336
337 if (!(s->rdft_hdata_out[i] = av_calloc(h, s->rdft_hstride[i] * sizeof(float))))
338 return AVERROR(ENOMEM);
339
340 for (int j = 0; j < s->nb_threads; j++) {
341 float scale = 1.f, iscale = 1.f;
342
343 ret = av_tx_init(&s->hrdft[j][i], &s->htx_fn, AV_TX_FLOAT_RDFT,
344 0, 1 << s->rdft_hbits[i], &scale, 0);
345 if (ret < 0)
346 return ret;
347 ret = av_tx_init(&s->ihrdft[j][i], &s->ihtx_fn, AV_TX_FLOAT_RDFT,
348 1, 1 << s->rdft_hbits[i], &iscale, 0);
349 if (ret < 0)
350 return ret;
351 }
352
353 /* RDFT - Array initialization for Vertical pass*/
354 s->rdft_vlen[i] = 1 << (32 - ff_clz(h));
355 s->rdft_vstride[i] = FFALIGN(s->rdft_vlen[i] + 2, av_cpu_max_align());
356 s->rdft_vbits[i] = av_log2(s->rdft_vlen[i]);
357 if (!(s->rdft_vdata_in[i] = av_calloc(s->rdft_hstride[i], s->rdft_vstride[i] * sizeof(float))))
358 return AVERROR(ENOMEM);
359
360 if (!(s->rdft_vdata_out[i] = av_calloc(s->rdft_hstride[i], s->rdft_vstride[i] * sizeof(float))))
361 return AVERROR(ENOMEM);
362
363 for (int j = 0; j < s->nb_threads; j++) {
364 float scale = 1.f, iscale = 1.f;
365
366 ret = av_tx_init(&s->vrdft[j][i], &s->vtx_fn, AV_TX_FLOAT_RDFT,
367 0, 1 << s->rdft_vbits[i], &scale, 0);
368 if (ret < 0)
369 return ret;
370 ret = av_tx_init(&s->ivrdft[j][i], &s->ivtx_fn, AV_TX_FLOAT_RDFT,
371 1, 1 << s->rdft_vbits[i], &iscale, 0);
372 if (ret < 0)
373 return ret;
374 }
375 }
376
377 /*Luminance value - Array initialization*/
378 for (plane = 0; plane < 3; plane++) {
379 if(!(s->weight[plane] = av_calloc(s->rdft_hlen[plane], s->rdft_vlen[plane] * sizeof(double))))
380 return AVERROR(ENOMEM);
381
382 if (s->eval_mode == EVAL_MODE_INIT)
383 do_eval(s, inlink, plane);
384 }
385
386 if (s->depth <= 8) {
387 s->rdft_horizontal = rdft_horizontal8;
388 s->irdft_horizontal = irdft_horizontal8;
389 } else {
390 s->rdft_horizontal = rdft_horizontal16;
391 s->irdft_horizontal = irdft_horizontal16;
392 }
393 return 0;
394}
395
396static int multiply_data(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
397{
398 FFTFILTContext *s = ctx->priv;
399
400 for (int plane = 0; plane < s->nb_planes; plane++) {
401 const int height = s->rdft_hlen[plane];
402 const int slice_start = ff_slice_pos(height, jobnr, nb_jobs);
403 const int slice_end = ff_slice_pos(height, jobnr + 1, nb_jobs);
404 /*Change user defined parameters*/
405 for (int i = slice_start; i < slice_end; i++) {
406 const double *weight = s->weight[plane] + i * s->rdft_vlen[plane];
407 float *vdata = s->rdft_vdata_out[plane] + i * s->rdft_vstride[plane];
408
409 for (int j = 0; j < s->rdft_vlen[plane]; j++)
410 vdata[j] *= weight[j];
411 }
412 }
413
414 return 0;
415}
416
417static int copy_vertical(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
418{
419 FFTFILTContext *s = ctx->priv;
420
421 for (int plane = 0; plane < s->nb_planes; plane++) {
422 const int hlen = s->rdft_hlen[plane];
423 const int vlen = s->rdft_vlen[plane];
424 const int hstride = s->rdft_hstride[plane];
425 const int vstride = s->rdft_vstride[plane];
426 const int slice_start = ff_slice_pos(hlen, jobnr, nb_jobs);
427 const int slice_end = ff_slice_pos(hlen, jobnr + 1, nb_jobs);
428 const int h = s->planeheight[plane];
429 float *hdata = s->rdft_hdata_out[plane];
430 float *vdata = s->rdft_vdata_in[plane];
431
432 for (int i = slice_start; i < slice_end; i++) {
433 for (int j = 0; j < h; j++)
434 vdata[i * vstride + j] = hdata[j * hstride + i];
435 copy_rev(vdata + i * vstride, h, vlen);
436 }
437 }
438
439 return 0;
440}
441
442static int rdft_vertical(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
443{
444 FFTFILTContext *s = ctx->priv;
445
446 for (int plane = 0; plane < s->nb_planes; plane++) {
447 const int height = s->rdft_hlen[plane];
448 const int slice_start = ff_slice_pos(height, jobnr, nb_jobs);
449 const int slice_end = ff_slice_pos(height, jobnr + 1, nb_jobs);
450
451 for (int i = slice_start; i < slice_end; i++)
452 s->vtx_fn(s->vrdft[jobnr][plane],
453 s->rdft_vdata_out[plane] + i * s->rdft_vstride[plane],
454 s->rdft_vdata_in[plane] + i * s->rdft_vstride[plane],
455 sizeof(float));
456 }
457
458 return 0;
459}
460
461static int irdft_vertical(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
462{
463 FFTFILTContext *s = ctx->priv;
464
465 for (int plane = 0; plane < s->nb_planes; plane++) {
466 const int height = s->rdft_hlen[plane];
467 const int slice_start = ff_slice_pos(height, jobnr, nb_jobs);
468 const int slice_end = ff_slice_pos(height, jobnr + 1, nb_jobs);
469
470 for (int i = slice_start; i < slice_end; i++)
471 s->ivtx_fn(s->ivrdft[jobnr][plane],
472 s->rdft_vdata_in[plane] + i * s->rdft_vstride[plane],
473 s->rdft_vdata_out[plane] + i * s->rdft_vstride[plane],
474 sizeof(AVComplexFloat));
475 }
476
477 return 0;
478}
479
480static int copy_horizontal(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
481{
482 FFTFILTContext *s = ctx->priv;
483
484 for (int plane = 0; plane < s->nb_planes; plane++) {
485 const int hlen = s->rdft_hlen[plane];
486 const int hstride = s->rdft_hstride[plane];
487 const int vstride = s->rdft_vstride[plane];
488 const int slice_start = ff_slice_pos(hlen, jobnr, nb_jobs);
489 const int slice_end = ff_slice_pos(hlen, jobnr + 1, nb_jobs);
490 const int h = s->planeheight[plane];
491 float *hdata = s->rdft_hdata_in[plane];
492 float *vdata = s->rdft_vdata_in[plane];
493
494 for (int i = slice_start; i < slice_end; i++)
495 for (int j = 0; j < h; j++)
496 hdata[j * hstride + i] = vdata[i * vstride + j];
497 }
498
499 return 0;
500}
501
502static int filter_frame(AVFilterLink *inlink, AVFrame *in)
503{
504 AVFilterContext *ctx = inlink->dst;
505 AVFilterLink *outlink = inlink->dst->outputs[0];
506 FFTFILTContext *s = ctx->priv;
507 AVFrame *out;
508
509 out = ff_get_video_buffer(outlink, inlink->w, inlink->h);
510 if (!out) {
511 av_frame_free(&in);
512 return AVERROR(ENOMEM);
513 }
514
516
517 ff_filter_execute(ctx, s->rdft_horizontal, in, NULL,
518 FFMIN(s->planeheight[1], s->nb_threads));
519
521 FFMIN(s->planeheight[1], s->nb_threads));
522
524 FFMIN(s->planeheight[1], s->nb_threads));
525
526 for (int plane = 0; plane < s->nb_planes; plane++) {
527 if (s->eval_mode == EVAL_MODE_FRAME)
528 do_eval(s, inlink, plane);
529 }
530
532 FFMIN(s->planeheight[1], s->nb_threads));
533
534 for (int plane = 0; plane < s->nb_planes; plane++)
535 s->rdft_vdata_out[plane][0] += s->rdft_hlen[plane] * s->rdft_vlen[plane] * s->dc[plane] * (1 << (s->depth - 8));
536
538 FFMIN(s->planeheight[1], s->nb_threads));
539
541 FFMIN(s->planeheight[1], s->nb_threads));
542
543 ff_filter_execute(ctx, s->irdft_horizontal, out, NULL,
544 FFMIN(s->planeheight[1], s->nb_threads));
545
546 av_frame_free(&in);
547 return ff_filter_frame(outlink, out);
548}
549
551{
552 FFTFILTContext *s = ctx->priv;
553
554 for (int i = 0; i < MAX_PLANES; i++) {
555 av_freep(&s->rdft_hdata_in[i]);
556 av_freep(&s->rdft_vdata_in[i]);
557 av_freep(&s->rdft_hdata_out[i]);
558 av_freep(&s->rdft_vdata_out[i]);
559 av_expr_free(s->weight_expr[i]);
560 av_freep(&s->weight[i]);
561 for (int j = 0; j < s->nb_threads; j++) {
562 av_tx_uninit(&s->hrdft[j][i]);
563 av_tx_uninit(&s->ihrdft[j][i]);
564 av_tx_uninit(&s->vrdft[j][i]);
565 av_tx_uninit(&s->ivrdft[j][i]);
566 }
567 }
568}
569
588
589static const AVFilterPad fftfilt_inputs[] = {
590 {
591 .name = "default",
592 .type = AVMEDIA_TYPE_VIDEO,
593 .config_props = config_props,
594 .filter_frame = filter_frame,
595 },
596};
597
599 .p.name = "fftfilt",
600 .p.description = NULL_IF_CONFIG_SMALL("Apply arbitrary expressions to pixels in frequency domain."),
601 .p.priv_class = &fftfilt_class,
603 .priv_size = sizeof(FFTFILTContext),
607 .init = initialize,
608 .uninit = uninit,
609};
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:97
static double(*const func2[])(void *, double, double)
Definition af_afftfilt.c:99
static const char *const func2_names[]
Definition af_afftfilt.c:98
EvalMode
Definition af_volume.h:39
@ EVAL_MODE_NB
Definition af_volume.h:42
@ EVAL_MODE_FRAME
Definition af_volume.h:41
const FFFilter ff_vf_fftfilt
Definition vf_fftfilt.c:598
static FILE * out
static AVFormatContext * ctx
#define U(x)
Definition vpx_arith.h:37
#define V
Definition avdct.c:32
@ VAR_H
Definition avfilter.c:607
@ VAR_W
Definition avfilter.c:606
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1112
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition avfilter.c:1754
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition avfilter.c:890
#define Y
Definition boxblur.h:37
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define FLAGS
Definition cmdutils.c:596
common internal and external API header
#define AV_CEIL_RSHIFT(a, b)
Definition common.h:60
#define av_clip
Definition common.h:100
#define av_clip_uint8
Definition common.h:106
#define NULL
Definition coverity.c:32
#define max(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition eval.c:368
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition eval.c:824
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
Definition eval.c:735
simple arithmetic expression evaluator
int ret
Definition ffplay.c:391
#define MAX_PLANES
Definition ffv1.h:44
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition avfilter.h:202
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:172
#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:65
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition frame.c:604
#define ff_clz
Definition intmath.h:141
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static av_always_inline void scale(vec_s32 res[4], vec_s16 res_packed[2], const int shift)
#define av_log2
Definition intmath.h:84
static av_cold void uninit(AVBitStreamFilterContext *ctx)
const char * arg
Definition jacosubdec.c:66
#define FILTER_INPUTS(array)
Definition filters.h:279
#define FILTER_OUTPUTS(array)
Definition filters.h:280
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
Definition filters.h:813
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:259
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition filters.h:199
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:493
@ VAR_X
Definition vf_blend.c:55
@ VAR_Y
Definition vf_blend.c:55
static int initialize(AVFilterContext *ctx)
Definition vf_eq.c:159
#define av_cold
Definition attributes.h:117
size_t av_cpu_max_align(void)
Get the maximum data alignment that may be required by FFmpeg.
Definition cpu.c:289
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:98
#define lrintf(x)
Definition libm_mips.h:74
const char * desc
Definition libsvtav1.c:110
uint8_t w
Definition llvidencdsp.c:39
#define FFMIN(a, b)
Definition macros.h:49
#define FFALIGN(x, a)
Definition macros.h:78
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:370
Memory handling functions.
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
Definition mpeg12dec.c:1711
@ VAR_N
Definition noise.c:47
@ VAR_VARS_NB
Definition noise.c:59
static const char *const var_names[]
Definition noise.c:30
#define av_strdup(s)
Definition ops_static.c:55
AVOptions.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3524
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3484
#define AV_PIX_FMT_YUV420P16
Definition pixfmt.h:559
#define AV_PIX_FMT_YUV444P12
Definition pixfmt.h:555
#define AV_PIX_FMT_YUV444P9
Definition pixfmt.h:547
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:548
#define AV_PIX_FMT_GRAY9
Definition pixfmt.h:527
#define AV_PIX_FMT_YUV422P9
Definition pixfmt.h:546
#define AV_PIX_FMT_YUV420P12
Definition pixfmt.h:552
#define AV_PIX_FMT_YUV422P12
Definition pixfmt.h:553
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:549
#define AV_PIX_FMT_GRAY12
Definition pixfmt.h:529
#define AV_PIX_FMT_YUV420P9
Definition pixfmt.h:545
#define AV_PIX_FMT_YUV420P14
Definition pixfmt.h:556
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_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_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ 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_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_YUV422P14
Definition pixfmt.h:557
#define AV_PIX_FMT_GRAY10
Definition pixfmt.h:528
#define AV_PIX_FMT_GRAY14
Definition pixfmt.h:530
#define AV_PIX_FMT_YUV422P16
Definition pixfmt.h:560
#define AV_PIX_FMT_GRAY16
Definition pixfmt.h:531
#define AV_PIX_FMT_YUV444P14
Definition pixfmt.h:558
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:561
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:551
const h264_weight_func weight
static int config_props(AVBitStreamFilterLink *link)
Definition source.c:181
Describe the class of an AVClass context structure.
Definition log.h:76
Definition eval.c:171
An instance of a filter.
Definition avfilter.h:279
void * priv
private data for use by the filter
Definition avfilter.h:294
AVFilterLink ** outputs
array of pointers to output links
Definition avfilter.h:291
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:479
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:500
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:524
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
int(* irdft_horizontal)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_fftfilt.c:81
int planewidth[MAX_PLANES]
Definition vf_fftfilt.c:53
int planeheight[MAX_PLANES]
Definition vf_fftfilt.c:54
int rdft_vbits[MAX_PLANES]
Definition vf_fftfilt.c:65
int dc[MAX_PLANES]
Definition vf_fftfilt.c:75
av_tx_fn ihtx_fn
Definition vf_fftfilt.c:61
char * weight_str[MAX_PLANES]
Definition vf_fftfilt.c:76
float * rdft_hdata_in[MAX_PLANES]
Definition vf_fftfilt.c:70
float * rdft_vdata_out[MAX_PLANES]
Definition vf_fftfilt.c:73
AVTXContext * ivrdft[MAX_THREADS][MAX_PLANES]
Definition vf_fftfilt.c:59
size_t rdft_hstride[MAX_PLANES]
Definition vf_fftfilt.c:66
size_t rdft_vstride[MAX_PLANES]
Definition vf_fftfilt.c:67
size_t rdft_hlen[MAX_PLANES]
Definition vf_fftfilt.c:68
AVTXContext * hrdft[MAX_THREADS][MAX_PLANES]
Definition vf_fftfilt.c:56
float * rdft_hdata_out[MAX_PLANES]
Definition vf_fftfilt.c:72
size_t rdft_vlen[MAX_PLANES]
Definition vf_fftfilt.c:69
float * rdft_vdata_in[MAX_PLANES]
Definition vf_fftfilt.c:71
av_tx_fn ivtx_fn
Definition vf_fftfilt.c:62
double * weight[MAX_PLANES]
Definition vf_fftfilt.c:78
AVTXContext * vrdft[MAX_THREADS][MAX_PLANES]
Definition vf_fftfilt.c:57
AVExpr * weight_expr[MAX_PLANES]
Definition vf_fftfilt.c:77
AVTXContext * ihrdft[MAX_THREADS][MAX_PLANES]
Definition vf_fftfilt.c:58
av_tx_fn vtx_fn
Definition vf_fftfilt.c:62
av_tx_fn htx_fn
Definition vf_fftfilt.c:61
int rdft_hbits[MAX_PLANES]
Definition vf_fftfilt.c:64
int(* rdft_horizontal)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_fftfilt.c:80
#define av_freep(p)
#define src
Definition vp8dsp.c:248
#define height
Definition dsp.h:99
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
Definition tx.c:295
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
Definition tx.c:903
@ AV_TX_FLOAT_RDFT
Real to complex and complex to real DFTs.
Definition tx.h:90
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
Definition tx.h:151
static enum AVPixelFormat pixel_fmts_fftfilt[]
Definition vf_convolve.c:94
@ VAR_HS
Definition vf_fftfilt.c:85
@ VAR_WS
Definition vf_fftfilt.c:85
static int irdft_vertical(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_fftfilt.c:461
static void copy_rev(float *dest, int w, int w2)
Definition vf_fftfilt.c:120
static int rdft_horizontal8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_fftfilt.c:131
static int irdft_horizontal8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_fftfilt.c:193
static int irdft_horizontal16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_fftfilt.c:223
static void do_eval(FFTFILTContext *s, AVFilterLink *inlink, int plane)
Definition vf_fftfilt.c:288
static av_cold int initialize(AVFilterContext *ctx)
Definition vf_fftfilt.c:254
static double weight_Y(void *priv, double x, double y)
Definition vf_fftfilt.c:116
static int copy_horizontal(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_fftfilt.c:480
#define MAX_PLANES
Definition vf_fftfilt.c:38
static int rdft_horizontal16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_fftfilt.c:162
static const AVFilterPad fftfilt_inputs[]
Definition vf_fftfilt.c:589
static int multiply_data(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_fftfilt.c:396
static int copy_vertical(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_fftfilt.c:417
static double weight_U(void *priv, double x, double y)
Definition vf_fftfilt.c:117
static int rdft_vertical(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_fftfilt.c:442
static double weight_V(void *priv, double x, double y)
Definition vf_fftfilt.c:118
#define MAX_THREADS
Definition vf_fftfilt.c:37
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition vf_fftfilt.c:502
@ EVAL_MODE_INIT
Definition vf_fftfilt.c:41
static int config_props(AVFilterLink *inlink)
Definition vf_fftfilt.c:310
static const AVOption fftfilt_options[]
Definition vf_fftfilt.c:92
static av_cold void uninit(AVFilterContext *ctx)
Definition vf_fftfilt.c:550
#define OFFSET(x)
Definition vf_fftfilt.c:89
static double lum(void *priv, double x, double y, int plane)
Definition vf_fftfilt.c:107
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition video.c:37
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition video.c:120
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
Definition dec.c:851