FFmpeg
vf_gblur.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Pascal Getreuer
3  * Copyright (c) 2016 Paul B Mahol
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following
12  * disclaimer in the documentation and/or other materials provided
13  * with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include <float.h>
29 
30 #include "libavutil/imgutils.h"
31 #include "libavutil/opt.h"
32 #include "libavutil/pixdesc.h"
33 #include "avfilter.h"
34 #include "formats.h"
35 #include "gblur.h"
36 #include "internal.h"
37 #include "video.h"
38 
39 #define OFFSET(x) offsetof(GBlurContext, x)
40 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
41 
42 static const AVOption gblur_options[] = {
43  { "sigma", "set sigma", OFFSET(sigma), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0.0, 1024, FLAGS },
44  { "steps", "set number of steps", OFFSET(steps), AV_OPT_TYPE_INT, {.i64=1}, 1, 6, FLAGS },
45  { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
46  { "sigmaV", "set vertical sigma", OFFSET(sigmaV), AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1, 1024, FLAGS },
47  { NULL }
48 };
49 
51 
52 typedef struct ThreadData {
53  int height;
54  int width;
55 } ThreadData;
56 
57 static void postscale_c(float *buffer, int length,
58  float postscale, float min, float max)
59 {
60  for (int i = 0; i < length; i++) {
61  buffer[i] *= postscale;
62  buffer[i] = av_clipf(buffer[i], min, max);
63  }
64 }
65 
66 static void horiz_slice_c(float *buffer, int width, int height, int steps,
67  float nu, float bscale)
68 {
69  int step, x, y;
70  float *ptr;
71  for (y = 0; y < height; y++) {
72  for (step = 0; step < steps; step++) {
73  ptr = buffer + width * y;
74  ptr[0] *= bscale;
75 
76  /* Filter rightwards */
77  for (x = 1; x < width; x++)
78  ptr[x] += nu * ptr[x - 1];
79  ptr[x = width - 1] *= bscale;
80 
81  /* Filter leftwards */
82  for (; x > 0; x--)
83  ptr[x - 1] += nu * ptr[x];
84  }
85  }
86 }
87 
88 static int filter_horizontally(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
89 {
90  GBlurContext *s = ctx->priv;
91  ThreadData *td = arg;
92  const int height = td->height;
93  const int width = td->width;
94  const int slice_start = (height * jobnr ) / nb_jobs;
95  const int slice_end = (height * (jobnr+1)) / nb_jobs;
96  const float boundaryscale = s->boundaryscale;
97  const int steps = s->steps;
98  const float nu = s->nu;
99  float *buffer = s->buffer;
100 
101  s->horiz_slice(buffer + width * slice_start, width, slice_end - slice_start,
102  steps, nu, boundaryscale);
103  emms_c();
104  return 0;
105 }
106 
107 static void do_vertical_columns(float *buffer, int width, int height,
108  int column_begin, int column_end, int steps,
109  float nu, float boundaryscale, int column_step)
110 {
111  const int numpixels = width * height;
112  int i, x, k, step;
113  float *ptr;
114  for (x = column_begin; x < column_end;) {
115  for (step = 0; step < steps; step++) {
116  ptr = buffer + x;
117  for (k = 0; k < column_step; k++) {
118  ptr[k] *= boundaryscale;
119  }
120  /* Filter downwards */
121  for (i = width; i < numpixels; i += width) {
122  for (k = 0; k < column_step; k++) {
123  ptr[i + k] += nu * ptr[i - width + k];
124  }
125  }
126  i = numpixels - width;
127 
128  for (k = 0; k < column_step; k++)
129  ptr[i + k] *= boundaryscale;
130 
131  /* Filter upwards */
132  for (; i > 0; i -= width) {
133  for (k = 0; k < column_step; k++)
134  ptr[i - width + k] += nu * ptr[i + k];
135  }
136  }
137  x += column_step;
138  }
139 }
140 
141 static int filter_vertically(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
142 {
143  GBlurContext *s = ctx->priv;
144  ThreadData *td = arg;
145  const int height = td->height;
146  const int width = td->width;
147  const int slice_start = (width * jobnr ) / nb_jobs;
148  const int slice_end = (width * (jobnr+1)) / nb_jobs;
149  const float boundaryscale = s->boundaryscaleV;
150  const int steps = s->steps;
151  const float nu = s->nuV;
152  float *buffer = s->buffer;
153  int aligned_end;
154 
155  aligned_end = slice_start + (((slice_end - slice_start) >> 3) << 3);
156  /* Filter vertically along columns (process 8 columns in each step) */
157  do_vertical_columns(buffer, width, height, slice_start, aligned_end,
158  steps, nu, boundaryscale, 8);
159 
160  /* Filter un-aligned columns one by one */
161  do_vertical_columns(buffer, width, height, aligned_end, slice_end,
162  steps, nu, boundaryscale, 1);
163  return 0;
164 }
165 
166 static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
167 {
168  GBlurContext *s = ctx->priv;
169  ThreadData *td = arg;
170  const float max = s->flt ? FLT_MAX : (1 << s->depth) - 1;
171  const float min = s->flt ? -FLT_MAX : 0.f;
172  const int height = td->height;
173  const int width = td->width;
174  const int awidth = FFALIGN(width, 64);
175  const int slice_start = (height * jobnr ) / nb_jobs;
176  const int slice_end = (height * (jobnr+1)) / nb_jobs;
177  const float postscale = s->postscale * s->postscaleV;
178  const int slice_size = slice_end - slice_start;
179 
180  s->postscale_slice(s->buffer + slice_start * awidth,
181  slice_size * awidth, postscale, min, max);
182 
183  return 0;
184 }
185 
187 {
188  GBlurContext *s = ctx->priv;
189  const int width = s->planewidth[plane];
190  const int height = s->planeheight[plane];
191  const int nb_threads = ff_filter_get_nb_threads(ctx);
192  ThreadData td;
193 
194  if (s->sigma <= 0 || s->steps < 0)
195  return;
196 
197  td.width = width;
198  td.height = height;
199  ctx->internal->execute(ctx, filter_horizontally, &td, NULL, FFMIN(height, nb_threads));
200  ctx->internal->execute(ctx, filter_vertically, &td, NULL, FFMIN(width, nb_threads));
201  ctx->internal->execute(ctx, filter_postscale, &td, NULL, FFMIN(width * height, nb_threads));
202 }
203 
205 {
206  static const enum AVPixelFormat pix_fmts[] = {
228  };
229 
230  return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
231 }
232 
234 {
237  if (ARCH_X86)
239 }
240 
242 {
244  GBlurContext *s = inlink->dst->priv;
245 
246  s->depth = desc->comp[0].depth;
247  s->flt = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
248  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
249  s->planewidth[0] = s->planewidth[3] = inlink->w;
250  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
251  s->planeheight[0] = s->planeheight[3] = inlink->h;
252 
254 
255  s->buffer = av_malloc_array(FFALIGN(inlink->w, 64), FFALIGN(inlink->h, 64) * sizeof(*s->buffer));
256  if (!s->buffer)
257  return AVERROR(ENOMEM);
258 
259  if (s->sigmaV < 0) {
260  s->sigmaV = s->sigma;
261  }
262  ff_gblur_init(s);
263 
264  return 0;
265 }
266 
267 static void set_params(float sigma, int steps, float *postscale, float *boundaryscale, float *nu)
268 {
269  double dnu, lambda;
270 
271  lambda = (sigma * sigma) / (2.0 * steps);
272  dnu = (1.0 + 2.0 * lambda - sqrt(1.0 + 4.0 * lambda)) / (2.0 * lambda);
273  *postscale = pow(dnu / lambda, steps);
274  *boundaryscale = 1.0 / (1.0 - dnu);
275  *nu = (float)dnu;
276 }
277 
279 {
280  AVFilterContext *ctx = inlink->dst;
281  GBlurContext *s = ctx->priv;
282  AVFilterLink *outlink = ctx->outputs[0];
283  AVFrame *out;
284  int plane;
285 
286  set_params(s->sigma, s->steps, &s->postscale, &s->boundaryscale, &s->nu);
287  set_params(s->sigmaV, s->steps, &s->postscaleV, &s->boundaryscaleV, &s->nuV);
288 
289  if (av_frame_is_writable(in)) {
290  out = in;
291  } else {
292  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
293  if (!out) {
294  av_frame_free(&in);
295  return AVERROR(ENOMEM);
296  }
297  av_frame_copy_props(out, in);
298  }
299 
300  for (plane = 0; plane < s->nb_planes; plane++) {
301  const int height = s->planeheight[plane];
302  const int width = s->planewidth[plane];
303  float *bptr = s->buffer;
304  const uint8_t *src = in->data[plane];
305  const uint16_t *src16 = (const uint16_t *)in->data[plane];
306  uint8_t *dst = out->data[plane];
307  uint16_t *dst16 = (uint16_t *)out->data[plane];
308  int y, x;
309 
310  if (!s->sigma || !(s->planes & (1 << plane))) {
311  if (out != in)
312  av_image_copy_plane(out->data[plane], out->linesize[plane],
313  in->data[plane], in->linesize[plane],
314  width * ((s->depth + 7) / 8), height);
315  continue;
316  }
317 
318  if (s->flt) {
319  av_image_copy_plane((uint8_t *)bptr, width * sizeof(float),
320  in->data[plane], in->linesize[plane],
321  width * sizeof(float), height);
322  } else if (s->depth == 8) {
323  for (y = 0; y < height; y++) {
324  for (x = 0; x < width; x++) {
325  bptr[x] = src[x];
326  }
327  bptr += width;
328  src += in->linesize[plane];
329  }
330  } else {
331  for (y = 0; y < height; y++) {
332  for (x = 0; x < width; x++) {
333  bptr[x] = src16[x];
334  }
335  bptr += width;
336  src16 += in->linesize[plane] / 2;
337  }
338  }
339 
340  gaussianiir2d(ctx, plane);
341 
342  bptr = s->buffer;
343  if (s->flt) {
344  av_image_copy_plane(out->data[plane], out->linesize[plane],
345  (uint8_t *)bptr, width * sizeof(float),
346  width * sizeof(float), height);
347  } else if (s->depth == 8) {
348  for (y = 0; y < height; y++) {
349  for (x = 0; x < width; x++) {
350  dst[x] = bptr[x];
351  }
352  bptr += width;
353  dst += out->linesize[plane];
354  }
355  } else {
356  for (y = 0; y < height; y++) {
357  for (x = 0; x < width; x++) {
358  dst16[x] = bptr[x];
359  }
360  bptr += width;
361  dst16 += out->linesize[plane] / 2;
362  }
363  }
364  }
365 
366  if (out != in)
367  av_frame_free(&in);
368  return ff_filter_frame(outlink, out);
369 }
370 
372 {
373  GBlurContext *s = ctx->priv;
374 
375  av_freep(&s->buffer);
376 }
377 
378 static const AVFilterPad gblur_inputs[] = {
379  {
380  .name = "default",
381  .type = AVMEDIA_TYPE_VIDEO,
382  .config_props = config_input,
383  .filter_frame = filter_frame,
384  },
385  { NULL }
386 };
387 
388 static const AVFilterPad gblur_outputs[] = {
389  {
390  .name = "default",
391  .type = AVMEDIA_TYPE_VIDEO,
392  },
393  { NULL }
394 };
395 
397  .name = "gblur",
398  .description = NULL_IF_CONFIG_SMALL("Apply Gaussian Blur filter."),
399  .priv_size = sizeof(GBlurContext),
400  .priv_class = &gblur_class,
401  .uninit = uninit,
403  .inputs = gblur_inputs,
404  .outputs = gblur_outputs,
407 };
float nu
Definition: gblur.h:49
float boundaryscale
Definition: gblur.h:45
#define NULL
Definition: coverity.c:32
static const AVFilterPad gblur_inputs[]
Definition: vf_gblur.c:378
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:442
AVFrame * out
Definition: af_adeclick.c:502
static int filter_horizontally(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_gblur.c:88
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:434
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
static int filter_vertically(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_gblur.c:141
This structure describes decoded (raw) audio or video data.
Definition: frame.h:314
int max
Definition: vf_ssim.c:233
AVOption.
Definition: opt.h:248
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:436
float nuV
Definition: gblur.h:50
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:409
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:419
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:437
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
misc image utilities
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2613
Main libavfilter public API header.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_gblur.c:278
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
static void postscale_c(float *buffer, int length, float postscale, float min, float max)
Definition: vf_gblur.c:57
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:415
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:379
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:403
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:99
static int config_input(AVFilterLink *inlink)
Definition: vf_gblur.c:241
static void do_vertical_columns(float *buffer, int width, int height, int column_begin, int column_end, int steps, float nu, float boundaryscale, int column_step)
Definition: vf_gblur.c:107
static const struct @322 planes[]
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
int planeheight[4]
Definition: gblur.h:43
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:287
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:380
int planewidth[4]
Definition: gblur.h:42
#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:126
const char * name
Pad name.
Definition: internal.h:60
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:381
float sigma
Definition: gblur.h:35
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1093
#define FLAGS
Definition: vf_gblur.c:40
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
uint8_t
#define av_cold
Definition: attributes.h:88
AVOptions.
void ff_gblur_init_x86(GBlurContext *s)
Definition: vf_gblur_init.c:33
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition: pixdesc.h:190
float boundaryscaleV
Definition: gblur.h:46
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_gblur.c:371
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:433
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:414
int height
Definition: vf_avgblur.c:61
static int query_formats(AVFilterContext *ctx)
Definition: vf_gblur.c:204
AVFrame * dst
Definition: vf_blend.c:56
int plane
Definition: vf_blend.c:58
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:100
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:412
AVFilter ff_vf_gblur
Definition: vf_gblur.c:396
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:404
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:441
void(* horiz_slice)(float *buffer, int width, int height, int steps, float nu, float bscale)
Definition: gblur.h:52
#define FFALIGN(x, a)
Definition: macros.h:48
A filter pad used for either input or output.
Definition: internal.h:54
#define av_clipf
Definition: common.h:170
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.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:588
#define td
Definition: regdef.h:70
int step
Definition: vf_remap.c:82
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
static const FLOAT postscale[64]
Definition: faandct.c:54
uint8_t * ptr
Definition: vf_avgblur.c:63
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:115
const uint8_t * src
Definition: vf_bm3d.c:56
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options...
Definition: avfilter.c:881
float sigmaV
Definition: gblur.h:36
void * priv
private data for use by the filter
Definition: avfilter.h:356
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:443
const char * arg
Definition: jacosubdec.c:66
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:420
GLsizei GLsizei * length
Definition: opengl_enc.c:114
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:402
AVFILTER_DEFINE_CLASS(gblur)
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:421
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:397
static void gaussianiir2d(AVFilterContext *ctx, int plane)
Definition: vf_gblur.c:186
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:418
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:801
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:383
#define FFMIN(a, b)
Definition: common.h:105
int flt
Definition: gblur.h:40
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_acrusher.c:336
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:440
AVFormatContext * ctx
Definition: movenc.c:48
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:438
float * buffer
Definition: gblur.h:44
float postscaleV
Definition: gblur.h:48
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:398
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:417
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:410
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:407
static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_gblur.c:166
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:431
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:594
Used for passing data between threads.
Definition: dsddec.c:67
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:345
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:177
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:382
int planes
Definition: gblur.h:38
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
void ff_gblur_init(GBlurContext *s)
Definition: vf_gblur.c:233
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:399
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
static const AVFilterPad gblur_outputs[]
Definition: vf_gblur.c:388
Filter definition.
Definition: avfilter.h:145
#define OFFSET(x)
Definition: vf_gblur.c:39
static void set_params(float sigma, int steps, float *postscale, float *boundaryscale, float *nu)
Definition: vf_gblur.c:267
int nb_planes
Definition: gblur.h:51
float postscale
Definition: gblur.h:47
const char * name
Filter name.
Definition: avfilter.h:149
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:405
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:396
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:353
AVFrame * min
Definition: vf_threshold.c:76
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:303
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:408
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:416
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:381
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:400
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:406
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:328
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:428
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
Y , 8bpp.
Definition: pixfmt.h:74
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:429
static const AVOption gblur_options[]
Definition: vf_gblur.c:42
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:435
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
avfilter_execute_func * execute
Definition: internal.h:136
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2033
const AVPixFmtDescriptor * desc
Definition: vf_tonemap.c:196
void(* postscale_slice)(float *buffer, int length, float postscale, float min, float max)
Definition: gblur.h:53
int depth
Definition: gblur.h:41
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:258
An instance of a filter.
Definition: avfilter.h:341
#define av_freep(p)
const void ** s
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
#define av_malloc_array(a, b)
AVFrame * in
Definition: af_adenorm.c:223
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:373
AVFilterLink * inlink
Definition: vf_blend.c:57
internal API functions
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
int depth
Number of bits in the component.
Definition: pixdesc.h:58
static void horiz_slice_c(float *buffer, int width, int height, int steps, float nu, float bscale)
Definition: vf_gblur.c:66
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:411
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:658
int i
Definition: input.c:407
GLuint buffer
Definition: opengl_enc.c:101
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:439
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
int steps
Definition: gblur.h:37