FFmpeg
vf_varblur.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 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 "avfilter.h"
25 #include "formats.h"
26 #include "framesync.h"
27 #include "internal.h"
28 #include "video.h"
29 
30 typedef struct VarBlurContext {
31  const AVClass *class;
33 
36  int planes;
37 
38  int depth;
39  int planewidth[4];
40  int planeheight[4];
41 
43  int nb_planes;
44 
45  void (*compute_sat)(const uint8_t *ssrc,
46  int linesize,
47  int w, int h,
48  const uint8_t *dstp,
49  int dst_linesize);
50 
52  uint8_t *ddst,
53  int ddst_linesize,
54  const uint8_t *rrptr,
55  int rrptr_linesize,
56  int w, int h,
57  const uint8_t *pptr,
58  int pptr_linesize,
59  int slice_start, int slice_end);
61 
62 #define OFFSET(x) offsetof(VarBlurContext, x)
63 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
64 
65 static const AVOption varblur_options[] = {
66  { "min_r", "set min blur radius", OFFSET(min_radius), AV_OPT_TYPE_INT, {.i64=0}, 0, 254, FLAGS },
67  { "max_r", "set max blur radius", OFFSET(max_radius), AV_OPT_TYPE_INT, {.i64=8}, 1, 255, FLAGS },
68  { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
69  { NULL }
70 };
71 
73 
74 static const enum AVPixelFormat pix_fmts[] = {
94 };
95 
96 #define COMPUTE_SAT(type, stype, depth) \
97 static void compute_sat##depth(const uint8_t *ssrc, \
98  int linesize, \
99  int w, int h, \
100  const uint8_t *dstp, \
101  int dst_linesize) \
102 { \
103  const type *src = (const type *)ssrc; \
104  stype *dst = (stype *)dstp; \
105  \
106  linesize /= (depth / 8); \
107  dst_linesize /= (depth / 2); \
108  dst += dst_linesize; \
109  \
110  for (int y = 0; y < h; y++) { \
111  stype sum = 0; \
112  \
113  for (int x = 1; x < w; x++) { \
114  sum += src[x - 1]; \
115  dst[x] = sum + dst[x - dst_linesize]; \
116  } \
117  \
118  src += linesize; \
119  dst += dst_linesize; \
120  } \
121 }
122 
123 COMPUTE_SAT(uint8_t, uint32_t, 8)
124 COMPUTE_SAT(uint16_t, uint64_t, 16)
125 
126 typedef struct ThreadData {
127  AVFrame *in, *out, *radius;
128 } ThreadData;
129 
130 static float lerpf(float v0, float v1, float f)
131 {
132  return v0 + (v1 - v0) * f;
133 }
134 
135 #define BLUR_PLANE(type, stype, bits) \
136 static int blur_plane##bits(AVFilterContext *ctx, \
137  uint8_t *ddst, \
138  int ddst_linesize, \
139  const uint8_t *rrptr, \
140  int rrptr_linesize, \
141  int w, int h, \
142  const uint8_t *pptr, \
143  int pptr_linesize, \
144  int slice_start, int slice_end) \
145 { \
146  VarBlurContext *s = ctx->priv; \
147  const int ddepth = s->depth; \
148  const int dst_linesize = ddst_linesize / (bits / 8); \
149  const int ptr_linesize = pptr_linesize / (bits / 2); \
150  const int rptr_linesize = rrptr_linesize / (bits / 8); \
151  const type *rptr = (const type *)rrptr + slice_start * rptr_linesize; \
152  type *dst = (type *)ddst + slice_start * dst_linesize; \
153  const stype *ptr = (stype *)pptr; \
154  const float minr = 2.f * s->min_radius + 1.f; \
155  const float maxr = 2.f * s->max_radius + 1.f; \
156  const float scaler = (maxr - minr) / ((1 << ddepth) - 1); \
157  \
158  for (int y = slice_start; y < slice_end; y++) { \
159  for (int x = 0; x < w; x++) { \
160  const float radiusf = minr + (FFMAX(0.f, 2 * rptr[x] + 1 - minr)) * scaler; \
161  const int radius = floorf(radiusf); \
162  const float factor = radiusf - radius; \
163  const int nradius = radius + 1; \
164  const int l = FFMIN(radius, x); \
165  const int r = FFMIN(radius, w - x - 1); \
166  const int t = FFMIN(radius, y); \
167  const int b = FFMIN(radius, h - y - 1); \
168  const int nl = FFMIN(nradius, x); \
169  const int nr = FFMIN(nradius, w - x - 1); \
170  const int nt = FFMIN(nradius, y); \
171  const int nb = FFMIN(nradius, h - y - 1); \
172  stype tl = ptr[(y - t) * ptr_linesize + x - l]; \
173  stype tr = ptr[(y - t) * ptr_linesize + x + r]; \
174  stype bl = ptr[(y + b) * ptr_linesize + x - l]; \
175  stype br = ptr[(y + b) * ptr_linesize + x + r]; \
176  stype ntl = ptr[(y - nt) * ptr_linesize + x - nl]; \
177  stype ntr = ptr[(y - nt) * ptr_linesize + x + nr]; \
178  stype nbl = ptr[(y + nb) * ptr_linesize + x - nl]; \
179  stype nbr = ptr[(y + nb) * ptr_linesize + x + nr]; \
180  stype div = (l + r) * (t + b); \
181  stype ndiv = (nl + nr) * (nt + nb); \
182  stype p0 = (br + tl - bl - tr) / div; \
183  stype n0 = (nbr + ntl - nbl - ntr) / ndiv; \
184  \
185  dst[x] = av_clip_uintp2_c(lrintf( \
186  lerpf(p0, n0, factor)), \
187  ddepth); \
188  } \
189  \
190  rptr += rptr_linesize; \
191  dst += dst_linesize; \
192  } \
193  \
194  return 0; \
195 }
196 
197 BLUR_PLANE(uint8_t, uint32_t, 8)
198 BLUR_PLANE(uint16_t, uint64_t, 16)
199 
200 static int blur_planes(AVFilterContext *ctx, void *arg,
201  int jobnr, int nb_jobs)
202 {
203  VarBlurContext *s = ctx->priv;
204  ThreadData *td = arg;
205  AVFrame *radius = td->radius;
206  AVFrame *out = td->out;
207  AVFrame *in = td->in;
208 
209  for (int plane = 0; plane < s->nb_planes; plane++) {
210  const int height = s->planeheight[plane];
211  const int slice_start = (height * jobnr) / nb_jobs;
212  const int slice_end = (height * (jobnr+1)) / nb_jobs;
213  const int width = s->planewidth[plane];
214  const int linesize = in->linesize[plane];
215  const int dst_linesize = out->linesize[plane];
216  const uint8_t *rptr = radius->data[plane];
217  const int rptr_linesize = radius->linesize[plane];
218  uint8_t *ptr = s->sat->data[plane];
219  const int ptr_linesize = s->sat->linesize[plane];
220  const uint8_t *src = in->data[plane];
221  uint8_t *dst = out->data[plane];
222 
223  if (!(s->planes & (1 << plane))) {
224  if (out != in)
225  av_image_copy_plane(dst + slice_start * dst_linesize,
226  dst_linesize,
227  src + slice_start * linesize,
228  linesize,
229  width * ((s->depth + 7) / 8),
230  slice_end - slice_start);
231  continue;
232  }
233 
234  s->blur_plane(ctx, dst, dst_linesize,
235  rptr, rptr_linesize,
236  width, height,
237  ptr, ptr_linesize,
238  slice_start, slice_end);
239  }
240 
241  return 0;
242 }
243 
244 static int blur_frame(AVFilterContext *ctx, AVFrame *in, AVFrame *radius)
245 {
246  VarBlurContext *s = ctx->priv;
247  AVFilterLink *outlink = ctx->outputs[0];
248  ThreadData td;
249  AVFrame *out;
250 
251  if (av_frame_is_writable(in)) {
252  out = in;
253  } else {
254  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
255  if (!out) {
256  av_frame_free(&in);
257  return AVERROR(ENOMEM);
258  }
260  }
261 
262  for (int plane = 0; plane < s->nb_planes; plane++) {
263  const int height = s->planeheight[plane];
264  const int width = s->planewidth[plane];
265  const int linesize = in->linesize[plane];
266  uint8_t *ptr = s->sat->data[plane];
267  const int ptr_linesize = s->sat->linesize[plane];
268  const uint8_t *src = in->data[plane];
269 
270  if (!(s->planes & (1 << plane)))
271  continue;
272 
273  s->compute_sat(src, linesize, width, height, ptr, ptr_linesize);
274  }
275 
276  td.in = in;
277  td.out = out;
278  td.radius = radius;
280  FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
281 
282  if (out != in)
283  av_frame_free(&in);
284  return ff_filter_frame(outlink, out);
285 }
286 
288 {
289  VarBlurContext *s = ctx->priv;
290  return ff_framesync_activate(&s->fs);
291 }
292 
294 {
295  AVFilterContext *ctx = fs->parent;
296  VarBlurContext *s = ctx->priv;
297  AVFrame *in, *radius;
298  int ret;
299 
300  if (s->max_radius <= s->min_radius)
301  s->max_radius = s->min_radius + 1;
302 
303  ret = ff_framesync_dualinput_get(fs, &in, &radius);
304  if (ret < 0)
305  return ret;
306  if (!radius)
307  return ff_filter_frame(ctx->outputs[0], in);
308  return blur_frame(ctx, in, radius);
309 }
310 
311 static int config_output(AVFilterLink *outlink)
312 {
313  AVFilterContext *ctx = outlink->src;
314  AVFilterLink *inlink = ctx->inputs[0];
315  AVFilterLink *radiuslink = ctx->inputs[1];
316  VarBlurContext *s = ctx->priv;
318  int ret;
319 
320  if (inlink->w != radiuslink->w || inlink->h != radiuslink->h) {
321  av_log(ctx, AV_LOG_ERROR, "First input link %s parameters "
322  "(size %dx%d) do not match the corresponding "
323  "second input link %s parameters (size %dx%d)\n",
324  ctx->input_pads[0].name, inlink->w, inlink->h,
325  ctx->input_pads[1].name, radiuslink->w, radiuslink->h);
326  return AVERROR(EINVAL);
327  }
328 
329  outlink->w = inlink->w;
330  outlink->h = inlink->h;
331  outlink->time_base = inlink->time_base;
332  outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
333  outlink->frame_rate = inlink->frame_rate;
334 
335  s->depth = desc->comp[0].depth;
336  s->blur_plane = s->depth <= 8 ? blur_plane8 : blur_plane16;
337  s->compute_sat = s->depth <= 8 ? compute_sat8 : compute_sat16;
338 
339  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(outlink->w, desc->log2_chroma_w);
340  s->planewidth[0] = s->planewidth[3] = outlink->w;
341  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(outlink->h, desc->log2_chroma_h);
342  s->planeheight[0] = s->planeheight[3] = outlink->h;
343 
344  s->nb_planes = av_pix_fmt_count_planes(outlink->format);
345 
346  s->sat = ff_get_video_buffer(outlink, (outlink->w + 1) * 4 * ((s->depth + 7) / 8), outlink->h + 1);
347  if (!s->sat)
348  return AVERROR(ENOMEM);
349 
350  s->fs.on_event = varblur_frame;
351  if ((ret = ff_framesync_init_dualinput(&s->fs, ctx)) < 0)
352  return ret;
353 
354  ret = ff_framesync_configure(&s->fs);
355  outlink->time_base = s->fs.time_base;
356 
357  return ret;
358 }
359 
361 {
362  VarBlurContext *s = ctx->priv;
363 
364  ff_framesync_uninit(&s->fs);
365  av_frame_free(&s->sat);
366 }
367 
368 static const AVFilterPad varblur_inputs[] = {
369  {
370  .name = "default",
371  .type = AVMEDIA_TYPE_VIDEO,
372  },
373  {
374  .name = "radius",
375  .type = AVMEDIA_TYPE_VIDEO,
376  },
377 };
378 
379 static const AVFilterPad varblur_outputs[] = {
380  {
381  .name = "default",
382  .type = AVMEDIA_TYPE_VIDEO,
383  .config_props = config_output,
384  },
385 };
386 
388  .name = "varblur",
389  .description = NULL_IF_CONFIG_SMALL("Apply Variable Blur filter."),
390  .priv_size = sizeof(VarBlurContext),
391  .priv_class = &varblur_class,
392  .activate = activate,
393  .preinit = varblur_framesync_preinit,
394  .uninit = uninit,
400  .process_command = ff_filter_process_command,
401 };
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:98
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:447
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:426
blur_planes
static int blur_planes(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_varblur.c:200
ff_framesync_configure
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:119
td
#define td
Definition: regdef.h:70
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
ThreadData::radius
AVFrame * radius
Definition: vf_varblur.c:127
ff_framesync_uninit
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:285
out
FILE * out
Definition: movenc.c:54
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2660
VarBlurContext::compute_sat
void(* compute_sat)(const uint8_t *ssrc, int linesize, int w, int h, const uint8_t *dstp, int dst_linesize)
Definition: vf_varblur.c:45
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:171
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_varblur.c:311
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:439
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
pixdesc.h
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:446
w
uint8_t w
Definition: llviddspenc.c:38
VarBlurContext::nb_planes
int nb_planes
Definition: vf_varblur.c:43
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:441
AVOption
AVOption.
Definition: opt.h:247
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:404
preinit
static av_cold int preinit(AVFilterContext *ctx)
Definition: af_aresample.c:46
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
FFFrameSync
Frame sync structure.
Definition: framesync.h:146
video.h
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:442
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:384
BLUR_PLANE
#define BLUR_PLANE(type, stype, bits)
Definition: vf_varblur.c:135
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:338
av_image_copy_plane
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:374
formats.h
varblur_inputs
static const AVFilterPad varblur_inputs[]
Definition: vf_varblur.c:368
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2700
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:438
VarBlurContext::planewidth
int planewidth[4]
Definition: vf_varblur.c:39
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:422
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
v0
#define v0
Definition: regdef.h:26
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:420
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:448
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:402
lerpf
static float lerpf(float v0, float v1, float f)
Definition: vf_varblur.c:130
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:388
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
varblur_frame
static int varblur_frame(FFFrameSync *fs)
Definition: vf_varblur.c:293
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:407
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:248
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:416
VarBlurContext::fs
FFFrameSync fs
Definition: vf_varblur.c:32
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:424
width
#define width
s
#define s(width, name)
Definition: cbs_vp9.c:257
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:425
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:417
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:51
VarBlurContext::depth
int depth
Definition: vf_varblur.c:38
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2042
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:445
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:401
ff_vf_varblur
const AVFilter ff_vf_varblur
Definition: vf_varblur.c:387
FLAGS
#define FLAGS
Definition: vf_varblur.c:63
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:415
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:387
VarBlurContext::planeheight
int planeheight[4]
Definition: vf_varblur.c:40
VarBlurContext
Definition: vf_varblur.c:30
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
f
#define f(width, name)
Definition: cbs_vp9.c:255
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
arg
const char * arg
Definition: jacosubdec.c:67
planes
static const struct @321 planes[]
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:385
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:423
VarBlurContext::planes
int planes
Definition: vf_varblur.c:36
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
COMPUTE_SAT
#define COMPUTE_SAT(type, stype, depth)
Definition: vf_varblur.c:96
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:537
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:259
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_varblur.c:360
src
#define src
Definition: vp8dsp.c:255
varblur_options
static const AVOption varblur_options[]
Definition: vf_varblur.c:65
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:405
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:419
VarBlurContext::max_radius
int max_radius
Definition: vf_varblur.c:35
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
ff_framesync_init_dualinput
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
Definition: framesync.c:353
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:409
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:411
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:473
ff_filter_process_command
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:882
VarBlurContext::min_radius
int min_radius
Definition: vf_varblur.c:34
height
#define height
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:167
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:443
blur_frame
static int blur_frame(AVFilterContext *ctx, AVFrame *in, AVFrame *radius)
Definition: vf_varblur.c:244
internal.h
FRAMESYNC_DEFINE_CLASS
FRAMESYNC_DEFINE_CLASS(varblur, VarBlurContext, fs)
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:421
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:803
ThreadData
Used for passing data between threads.
Definition: dsddec.c:67
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:100
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
activate
static int activate(AVFilterContext *ctx)
Definition: vf_varblur.c:287
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:403
VarBlurContext::sat
AVFrame * sat
Definition: vf_varblur.c:42
AVFilter
Filter definition.
Definition: avfilter.h:165
ret
ret
Definition: filter_design.txt:187
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:440
VarBlurContext::blur_plane
int(* blur_plane)(AVFilterContext *ctx, uint8_t *ddst, int ddst_linesize, const uint8_t *rrptr, int rrptr_linesize, int w, int h, const uint8_t *pptr, int pptr_linesize, int slice_start, int slice_end)
Definition: vf_varblur.c:51
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:408
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:413
framesync.h
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:444
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avfilter.h
varblur_outputs
static const AVFilterPad varblur_outputs[]
Definition: vf_varblur.c:379
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:121
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:154
imgutils.h
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:362
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:410
h
h
Definition: vp9dsp_template.c:2038
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_varblur.c:74
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:414
ff_framesync_activate
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition: framesync.c:336
ff_framesync_dualinput_get
int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
Definition: framesync.c:371
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:386
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:143
int
int
Definition: ffmpeg_filter.c:153
OFFSET
#define OFFSET(x)
Definition: vf_varblur.c:62
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:166
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:412