FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_convolve.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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/opt.h"
23 #include "libavutil/pixdesc.h"
24 #include "libavcodec/avfft.h"
25 
26 #include "avfilter.h"
27 #include "formats.h"
28 #include "framesync.h"
29 #include "internal.h"
30 #include "video.h"
31 
32 typedef struct ConvolveContext {
33  const AVClass *class;
35 
38 
39  int fft_bits[4];
40  int fft_len[4];
41  int planewidth[4];
42  int planeheight[4];
43 
48 
49  int depth;
50  int planes;
51  int impulse;
52  int nb_planes;
53  int got_impulse[4];
55 
56 #define OFFSET(x) offsetof(ConvolveContext, x)
57 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
58 
59 static const AVOption convolve_options[] = {
60  { "planes", "set planes to convolve", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=7}, 0, 15, FLAGS },
61  { "impulse", "when to process impulses", OFFSET(impulse), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "impulse" },
62  { "first", "process only first impulse, ignore rest", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "impulse" },
63  { "all", "process all impulses", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "impulse" },
64  { NULL },
65 };
66 
68 
70 {
71  static const enum AVPixelFormat pixel_fmts_fftfilt[] = {
90  };
91 
92  AVFilterFormats *fmts_list = ff_make_format_list(pixel_fmts_fftfilt);
93  if (!fmts_list)
94  return AVERROR(ENOMEM);
95  return ff_set_common_formats(ctx, fmts_list);
96 }
97 
98 static int config_input_main(AVFilterLink *inlink)
99 {
100  ConvolveContext *s = inlink->dst->priv;
102  int fft_bits, i;
103 
104  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
105  s->planewidth[0] = s->planewidth[3] = inlink->w;
106  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
107  s->planeheight[0] = s->planeheight[3] = inlink->h;
108 
109  s->nb_planes = desc->nb_components;
110  s->depth = desc->comp[0].depth;
111 
112  for (i = 0; i < s->nb_planes; i++) {
113  int w = s->planewidth[i];
114  int h = s->planeheight[i];
115  int n = FFMAX(w, h) * 10/9;
116 
117  for (fft_bits = 1; 1 << fft_bits < n; fft_bits++);
118 
119  s->fft_bits[i] = fft_bits;
120  s->fft_len[i] = 1 << s->fft_bits[i];
121 
122  if (!(s->fft_hdata[i] = av_calloc(s->fft_len[i], s->fft_len[i] * sizeof(FFTComplex))))
123  return AVERROR(ENOMEM);
124 
125  if (!(s->fft_vdata[i] = av_calloc(s->fft_len[i], s->fft_len[i] * sizeof(FFTComplex))))
126  return AVERROR(ENOMEM);
127 
128  if (!(s->fft_hdata_impulse[i] = av_calloc(s->fft_len[i], s->fft_len[i] * sizeof(FFTComplex))))
129  return AVERROR(ENOMEM);
130 
131  if (!(s->fft_vdata_impulse[i] = av_calloc(s->fft_len[i], s->fft_len[i] * sizeof(FFTComplex))))
132  return AVERROR(ENOMEM);
133  }
134 
135  return 0;
136 }
137 
139 {
140  AVFilterContext *ctx = inlink->dst;
141 
142  if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
143  ctx->inputs[0]->h != ctx->inputs[1]->h) {
144  av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n");
145  return AVERROR(EINVAL);
146  }
147  if (ctx->inputs[0]->format != ctx->inputs[1]->format) {
148  av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n");
149  return AVERROR(EINVAL);
150  }
151 
152  return 0;
153 }
154 
155 static void fft_horizontal(ConvolveContext *s, FFTComplex *fft_hdata,
156  AVFrame *in, int w, int h, int n, int plane, float scale)
157 {
158  int y, x;
159 
160  for (y = 0; y < h; y++) {
161  if (s->depth == 8) {
162  const uint8_t *src = in->data[plane] + in->linesize[plane] * y;
163 
164  for (x = 0; x < w; x++) {
165  fft_hdata[y * n + x].re = src[x] * scale;
166  fft_hdata[y * n + x].im = 0;
167  }
168  } else {
169  const uint16_t *src = (const uint16_t *)(in->data[plane] + in->linesize[plane] * y);
170 
171  for (x = 0; x < w; x++) {
172  fft_hdata[y * n + x].re = src[x] * scale;
173  fft_hdata[y * n + x].im = 0;
174  }
175  }
176  for (; x < n; x++) {
177  fft_hdata[y * n + x].re = 0;
178  fft_hdata[y * n + x].im = 0;
179  }
180  }
181 
182  for (; y < n; y++) {
183  for (x = 0; x < n; x++) {
184  fft_hdata[y * n + x].re = 0;
185  fft_hdata[y * n + x].im = 0;
186  }
187  }
188 
189  for (y = 0; y < n; y++) {
190  av_fft_permute(s->fft[plane], fft_hdata + y * n);
191  av_fft_calc(s->fft[plane], fft_hdata + y * n);
192  }
193 }
194 
195 static void fft_vertical(ConvolveContext *s, FFTComplex *fft_hdata, FFTComplex *fft_vdata,
196  int n, int plane)
197 {
198  int y, x;
199 
200  for (y = 0; y < n; y++) {
201  for (x = 0; x < n; x++) {
202  fft_vdata[y * n + x].re = fft_hdata[x * n + y].re;
203  fft_vdata[y * n + x].im = fft_hdata[x * n + y].im;
204  }
205  for (; x < n; x++) {
206  fft_vdata[y * n + x].re = 0;
207  fft_vdata[y * n + x].im = 0;
208  }
209  av_fft_permute(s->fft[plane], fft_vdata + y * n);
210  av_fft_calc(s->fft[plane], fft_vdata + y * n);
211  }
212 }
213 
214 static void ifft_vertical(ConvolveContext *s, int n, int plane)
215 {
216  int y, x;
217 
218  for (y = 0; y < n; y++) {
219  av_fft_permute(s->ifft[plane], s->fft_vdata[plane] + y * n);
220  av_fft_calc(s->ifft[plane], s->fft_vdata[plane] + y * n);
221  for (x = 0; x < n; x++) {
222  s->fft_hdata[plane][x * n + y].re = s->fft_vdata[plane][y * n + x].re;
223  s->fft_hdata[plane][x * n + y].im = s->fft_vdata[plane][y * n + x].im;
224  }
225  }
226 }
227 
229  int w, int h, int n, int plane)
230 {
231  const float scale = 1.f / (n * n);
232  const int max = (1 << s->depth) - 1;
233  const int oh = h / 2;
234  const int ow = w / 2;
235  int y, x;
236 
237  for (y = 0; y < n; y++) {
238  av_fft_permute(s->ifft[plane], s->fft_hdata[plane] + y * n);
239  av_fft_calc(s->ifft[plane], s->fft_hdata[plane] + y * n);
240  }
241 
242  if (s->depth == 8) {
243  for (y = 0; y < h; y++) {
244  uint8_t *dst = out->data[plane] + y * out->linesize[plane];
245  for (x = 0; x < w; x++)
246  dst[x] = av_clip_uint8(s->fft_hdata[plane][(y+oh) * n + x+ow].re * scale);
247  }
248  } else {
249  for (y = 0; y < h; y++) {
250  uint16_t *dst = (uint16_t *)(out->data[plane] + y * out->linesize[plane]);
251  for (x = 0; x < w; x++)
252  dst[x] = av_clip(s->fft_hdata[plane][(y+oh) * n + x+ow].re * scale, 0, max);
253  }
254  }
255 }
256 
257 static int do_convolve(FFFrameSync *fs)
258 {
259  AVFilterContext *ctx = fs->parent;
260  AVFilterLink *outlink = ctx->outputs[0];
261  ConvolveContext *s = ctx->priv;
262  AVFrame *mainpic = NULL, *impulsepic = NULL;
263  int ret, y, x, plane;
264 
265  ret = ff_framesync_dualinput_get(fs, &mainpic, &impulsepic);
266  if (ret < 0)
267  return ret;
268  if (!impulsepic)
269  return ff_filter_frame(outlink, mainpic);
270 
271  for (plane = 0; plane < s->nb_planes; plane++) {
272  const int n = s->fft_len[plane];
273  const int w = s->planewidth[plane];
274  const int h = s->planeheight[plane];
275  float total = 0;
276 
277  if (!(s->planes & (1 << plane))) {
278  continue;
279  }
280 
281  fft_horizontal(s, s->fft_hdata[plane], mainpic, w, h, n, plane, 1.f);
282  fft_vertical(s, s->fft_hdata[plane], s->fft_vdata[plane],
283  n, plane);
284 
285  if ((!s->impulse && !s->got_impulse[plane]) || s->impulse) {
286  if (s->depth == 8) {
287  for (y = 0; y < h; y++) {
288  const uint8_t *src = (const uint8_t *)(impulsepic->data[plane] + y * impulsepic->linesize[plane]) ;
289  for (x = 0; x < w; x++) {
290  total += src[x];
291  }
292  }
293  } else {
294  for (y = 0; y < h; y++) {
295  const uint16_t *src = (const uint16_t *)(impulsepic->data[plane] + y * impulsepic->linesize[plane]) ;
296  for (x = 0; x < w; x++) {
297  total += src[x];
298  }
299  }
300  }
301  total = FFMAX(1, total);
302 
303  fft_horizontal(s, s->fft_hdata_impulse[plane], impulsepic, w, h, n, plane, 1 / total);
304  fft_vertical(s, s->fft_hdata_impulse[plane], s->fft_vdata_impulse[plane],
305  n, plane);
306 
307  s->got_impulse[plane] = 1;
308  }
309 
310  for (y = 0; y < n; y++) {
311  for (x = 0; x < n; x++) {
312  FFTSample re, im, ire, iim;
313 
314  re = s->fft_vdata[plane][y*n + x].re;
315  im = s->fft_vdata[plane][y*n + x].im;
316  ire = s->fft_vdata_impulse[plane][y*n + x].re;
317  iim = s->fft_vdata_impulse[plane][y*n + x].im;
318 
319  s->fft_vdata[plane][y*n + x].re = ire * re - iim * im;
320  s->fft_vdata[plane][y*n + x].im = iim * re + ire * im;
321  }
322  }
323 
324  ifft_vertical(s, n, plane);
325  ifft_horizontal(s, mainpic, w, h, n, plane);
326  }
327 
328  return ff_filter_frame(outlink, mainpic);
329 }
330 
331 static int config_output(AVFilterLink *outlink)
332 {
333  AVFilterContext *ctx = outlink->src;
334  ConvolveContext *s = ctx->priv;
335  AVFilterLink *mainlink = ctx->inputs[0];
336  int ret, i;
337 
338  s->fs.on_event = do_convolve;
339  ret = ff_framesync_init_dualinput(&s->fs, ctx);
340  if (ret < 0)
341  return ret;
342  outlink->w = mainlink->w;
343  outlink->h = mainlink->h;
344  outlink->time_base = mainlink->time_base;
345  outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio;
346  outlink->frame_rate = mainlink->frame_rate;
347 
348  if ((ret = ff_framesync_configure(&s->fs)) < 0)
349  return ret;
350 
351  for (i = 0; i < s->nb_planes; i++) {
352  s->fft[i] = av_fft_init(s->fft_bits[i], 0);
353  s->ifft[i] = av_fft_init(s->fft_bits[i], 1);
354  if (!s->fft[i] || !s->ifft[i])
355  return AVERROR(ENOMEM);
356  }
357 
358  return 0;
359 }
360 
362 {
363  ConvolveContext *s = ctx->priv;
364  return ff_framesync_activate(&s->fs);
365 }
366 
368 {
369  ConvolveContext *s = ctx->priv;
370  int i;
371 
372  for (i = 0; i < 4; i++) {
373  av_freep(&s->fft_hdata[i]);
374  av_freep(&s->fft_vdata[i]);
375  av_freep(&s->fft_hdata_impulse[i]);
376  av_freep(&s->fft_vdata_impulse[i]);
377  av_fft_end(s->fft[i]);
378  av_fft_end(s->ifft[i]);
379  }
380 
381  ff_framesync_uninit(&s->fs);
382 }
383 
384 static const AVFilterPad convolve_inputs[] = {
385  {
386  .name = "main",
387  .type = AVMEDIA_TYPE_VIDEO,
388  .config_props = config_input_main,
389  },{
390  .name = "impulse",
391  .type = AVMEDIA_TYPE_VIDEO,
392  .config_props = config_input_impulse,
393  },
394  { NULL }
395 };
396 
397 static const AVFilterPad convolve_outputs[] = {
398  {
399  .name = "default",
400  .type = AVMEDIA_TYPE_VIDEO,
401  .config_props = config_output,
402  },
403  { NULL }
404 };
405 
407  .name = "convolve",
408  .description = NULL_IF_CONFIG_SMALL("Convolve first video stream with second video stream."),
409  .preinit = convolve_framesync_preinit,
410  .uninit = uninit,
411  .query_formats = query_formats,
412  .activate = activate,
413  .priv_size = sizeof(ConvolveContext),
414  .priv_class = &convolve_class,
415  .inputs = convolve_inputs,
416  .outputs = convolve_outputs,
418 };
int plane
Definition: avisynth_c.h:422
#define NULL
Definition: coverity.c:32
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:418
const char * s
Definition: avisynth_c.h:768
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:412
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2419
This structure describes decoded (raw) audio or video data.
Definition: frame.h:201
static const AVFilterPad convolve_outputs[]
Definition: vf_convolve.c:397
AVOption.
Definition: opt.h:246
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:414
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:389
av_cold void av_fft_end(FFTContext *s)
Definition: avfft.c:48
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:399
float re
Definition: fft.c:82
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:415
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
misc image utilities
Main libavfilter public API header.
const char * desc
Definition: nvenc.c:60
int got_impulse[4]
Definition: vf_convolve.c:53
int(* on_event)(struct FFFrameSync *fs)
Callback called when a frame event is ready.
Definition: framesync.h:172
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:180
static void fft_horizontal(ConvolveContext *s, FFTComplex *fft_hdata, AVFrame *in, int w, int h, int n, int plane, float scale)
Definition: vf_convolve.c:155
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:395
FFTContext * ifft[4]
Definition: vf_convolve.c:37
static void ifft_horizontal(ConvolveContext *s, AVFrame *out, int w, int h, int n, int plane)
Definition: vf_convolve.c:228
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:360
FFTSample re
Definition: avfft.h:38
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:383
static int activate(AVFilterContext *ctx)
Definition: vf_convolve.c:361
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:117
void av_fft_permute(FFTContext *s, FFTComplex *z)
Do the permutation needed BEFORE calling ff_fft_calc().
Definition: avfft.c:38
#define FLAGS
Definition: vf_convolve.c:57
static int config_input_main(AVFilterLink *inlink)
Definition: vf_convolve.c:98
#define src
Definition: vp8dsp.c:254
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_convolve.c:367
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:230
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:361
const char * name
Pad name.
Definition: internal.h:60
AVFilterContext * parent
Parent filter context.
Definition: framesync.h:152
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:362
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:346
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1151
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:102
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
uint8_t
#define av_cold
Definition: attributes.h:82
AVOptions.
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
Definition: framesync.c:361
int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
Definition: framesync.c:379
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:411
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:394
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:101
static int flags
Definition: log.c:57
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:75
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:392
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:384
static int do_convolve(FFFrameSync *fs)
Definition: vf_convolve.c:257
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:417
static int config_output(AVFilterLink *outlink)
Definition: vf_convolve.c:331
#define av_log(a,...)
A filter pad used for either input or output.
Definition: internal.h:54
FFTComplex * fft_hdata[4]
Definition: vf_convolve.c:44
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:188
static const AVOption convolve_options[]
Definition: vf_convolve.c:59
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:568
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:293
Frame sync structure.
Definition: framesync.h:146
#define AVERROR(e)
Definition: error.h:43
FFTComplex * fft_vdata_impulse[4]
Definition: vf_convolve.c:47
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
FRAMESYNC_DEFINE_CLASS(convolve, ConvolveContext, fs)
void * priv
private data for use by the filter
Definition: avfilter.h:353
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:419
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:400
FFTContext * av_fft_init(int nbits, int inverse)
Set up a complex FFT.
Definition: avfft.c:28
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition: framesync.c:344
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:382
static void convolve(float *tgt, const float *src, int len, int n)
Definition: ra288.c:92
#define FFMAX(a, b)
Definition: common.h:94
float FFTSample
Definition: avfft.h:35
int planeheight[4]
Definition: vf_convolve.c:42
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:401
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:377
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:83
FFTComplex * fft_vdata[4]
Definition: vf_convolve.c:45
Definition: fft.h:88
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:398
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:363
#define OFFSET(x)
Definition: vf_convolve.c:56
static void fft_vertical(ConvolveContext *s, FFTComplex *fft_hdata, FFTComplex *fft_vdata, int n, int plane)
Definition: vf_convolve.c:195
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:74
AVFormatContext * ctx
Definition: movenc.c:48
int n
Definition: avisynth_c.h:684
static void ifft_vertical(ConvolveContext *s, int n, int plane)
Definition: vf_convolve.c:214
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:416
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:389
FFFrameSync fs
Definition: vf_convolve.c:34
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:378
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:397
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:390
static int query_formats(AVFilterContext *ctx)
Definition: vf_convolve.c:69
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:379
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:387
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:232
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:189
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
FFT functions.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
AVFilter ff_vf_convolve
Definition: vf_convolve.c:406
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:379
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:68
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
float im
Definition: fft.c:82
const char * name
Filter name.
Definition: avfilter.h:148
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:385
FFTContext * fft[4]
Definition: vf_convolve.c:36
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:376
#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:133
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:388
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:396
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:380
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:386
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:215
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
Y , 8bpp.
Definition: pixfmt.h:70
FFTSample im
Definition: avfft.h:38
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:229
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:413
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:76
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:69
A list of supported formats for one end of a filter link.
Definition: formats.h:64
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:272
int planewidth[4]
Definition: vf_convolve.c:41
An instance of a filter.
Definition: avfilter.h:338
FILE * out
Definition: movenc.c:54
#define av_freep(p)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:100
static int config_input_impulse(AVFilterLink *inlink)
Definition: vf_convolve.c:138
static const AVFilterPad convolve_inputs[]
Definition: vf_convolve.c:384
internal API functions
FFTComplex * fft_hdata_impulse[4]
Definition: vf_convolve.c:46
int depth
Number of bits in the component.
Definition: pixdesc.h:58
void av_fft_calc(FFTContext *s, FFTComplex *z)
Do a complex FFT with the parameters defined in av_fft_init().
Definition: avfft.c:43
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:391
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58