Libav
vf_boxblur.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002 Michael Niedermayer <michaelni@gmx.at>
3  * Copyright (c) 2011 Stefano Sabatini
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * Libav 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
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with Libav; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
28 #include "libavutil/avstring.h"
29 #include "libavutil/common.h"
30 #include "libavutil/eval.h"
31 #include "libavutil/opt.h"
32 #include "libavutil/pixdesc.h"
33 #include "avfilter.h"
34 #include "formats.h"
35 #include "internal.h"
36 #include "video.h"
37 
38 static const char *const var_names[] = {
39  "w",
40  "h",
41  "cw",
42  "ch",
43  "hsub",
44  "vsub",
45  NULL
46 };
47 
48 enum var_name {
56 };
57 
58 typedef struct FilterParam {
59  int radius;
60  int power;
61 } FilterParam;
62 
63 typedef struct BoxBlurContext {
64  const AVClass *class;
71 
72  int hsub, vsub;
73  int radius[4];
74  int power[4];
75  uint8_t *temp[2];
77 
78 #define Y 0
79 #define U 1
80 #define V 2
81 #define A 3
82 
83 static av_cold int init(AVFilterContext *ctx)
84 {
85  BoxBlurContext *s = ctx->priv;
86 
87  if (!s->luma_radius_expr) {
88  av_log(ctx, AV_LOG_ERROR, "Luma radius expression is not set.\n");
89  return AVERROR(EINVAL);
90  }
91 
92  if (!s->chroma_radius_expr) {
94  if (!s->chroma_radius_expr)
95  return AVERROR(ENOMEM);
97  }
98  if (!s->alpha_radius_expr) {
100  if (!s->alpha_radius_expr)
101  return AVERROR(ENOMEM);
103  }
104 
105  return 0;
106 }
107 
108 static av_cold void uninit(AVFilterContext *ctx)
109 {
110  BoxBlurContext *s = ctx->priv;
111 
112  av_freep(&s->temp[0]);
113  av_freep(&s->temp[1]);
114 }
115 
117 {
118  enum AVPixelFormat pix_fmts[] = {
125  };
126 
128  return 0;
129 }
130 
131 static int config_input(AVFilterLink *inlink)
132 {
133  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
134  AVFilterContext *ctx = inlink->dst;
135  BoxBlurContext *s = ctx->priv;
136  int w = inlink->w, h = inlink->h;
137  int cw, ch;
138  double var_values[VARS_NB], res;
139  char *expr;
140  int ret;
141 
142  av_freep(&s->temp[0]);
143  av_freep(&s->temp[1]);
144  if (!(s->temp[0] = av_malloc(FFMAX(w, h))))
145  return AVERROR(ENOMEM);
146  if (!(s->temp[1] = av_malloc(FFMAX(w, h)))) {
147  av_freep(&s->temp[0]);
148  return AVERROR(ENOMEM);
149  }
150 
151  s->hsub = desc->log2_chroma_w;
152  s->vsub = desc->log2_chroma_h;
153 
154  var_values[VAR_W] = inlink->w;
155  var_values[VAR_H] = inlink->h;
156  var_values[VAR_CW] = cw = w>>s->hsub;
157  var_values[VAR_CH] = ch = h>>s->vsub;
158  var_values[VAR_HSUB] = 1<<s->hsub;
159  var_values[VAR_VSUB] = 1<<s->vsub;
160 
161 #define EVAL_RADIUS_EXPR(comp) \
162  expr = s->comp##_radius_expr; \
163  ret = av_expr_parse_and_eval(&res, expr, var_names, var_values, \
164  NULL, NULL, NULL, NULL, NULL, 0, ctx); \
165  s->comp##_param.radius = res; \
166  if (ret < 0) { \
167  av_log(NULL, AV_LOG_ERROR, \
168  "Error when evaluating " #comp " radius expression '%s'\n", expr); \
169  return ret; \
170  }
171  EVAL_RADIUS_EXPR(luma);
172  EVAL_RADIUS_EXPR(chroma);
173  EVAL_RADIUS_EXPR(alpha);
174 
175  av_log(ctx, AV_LOG_DEBUG,
176  "luma_radius:%d luma_power:%d "
177  "chroma_radius:%d chroma_power:%d "
178  "alpha_radius:%d alpha_power:%d "
179  "w:%d chroma_w:%d h:%d chroma_h:%d\n",
183  w, cw, h, ch);
184 
185 #define CHECK_RADIUS_VAL(w_, h_, comp) \
186  if (s->comp##_param.radius < 0 || \
187  2*s->comp##_param.radius > FFMIN(w_, h_)) { \
188  av_log(ctx, AV_LOG_ERROR, \
189  "Invalid " #comp " radius value %d, must be >= 0 and <= %d\n", \
190  s->comp##_param.radius, FFMIN(w_, h_)/2); \
191  return AVERROR(EINVAL); \
192  }
193  CHECK_RADIUS_VAL(w, h, luma);
194  CHECK_RADIUS_VAL(cw, ch, chroma);
195  CHECK_RADIUS_VAL(w, h, alpha);
196 
197  s->radius[Y] = s->luma_param.radius;
198  s->radius[U] = s->radius[V] = s->chroma_param.radius;
199  s->radius[A] = s->alpha_param.radius;
200 
201  s->power[Y] = s->luma_param.power;
202  s->power[U] = s->power[V] = s->chroma_param.power;
203  s->power[A] = s->alpha_param.power;
204 
205  return 0;
206 }
207 
208 static inline void blur(uint8_t *dst, int dst_step, const uint8_t *src, int src_step,
209  int len, int radius)
210 {
211  /* Naive boxblur would sum source pixels from x-radius .. x+radius
212  * for destination pixel x. That would be O(radius*width).
213  * If you now look at what source pixels represent 2 consecutive
214  * output pixels, then you see they are almost identical and only
215  * differ by 2 pixels, like:
216  * src0 111111111
217  * dst0 1
218  * src1 111111111
219  * dst1 1
220  * src0-src1 1 -1
221  * so when you know one output pixel you can find the next by just adding
222  * and subtracting 1 input pixel.
223  * The following code adopts this faster variant.
224  */
225  const int length = radius*2 + 1;
226  const int inv = ((1<<16) + length/2)/length;
227  int x, sum = 0;
228 
229  for (x = 0; x < radius; x++)
230  sum += src[x*src_step]<<1;
231  sum += src[radius*src_step];
232 
233  for (x = 0; x <= radius; x++) {
234  sum += src[(radius+x)*src_step] - src[(radius-x)*src_step];
235  dst[x*dst_step] = (sum*inv + (1<<15))>>16;
236  }
237 
238  for (; x < len-radius; x++) {
239  sum += src[(radius+x)*src_step] - src[(x-radius-1)*src_step];
240  dst[x*dst_step] = (sum*inv + (1<<15))>>16;
241  }
242 
243  for (; x < len; x++) {
244  sum += src[(2*len-radius-x-1)*src_step] - src[(x-radius-1)*src_step];
245  dst[x*dst_step] = (sum*inv + (1<<15))>>16;
246  }
247 }
248 
249 static inline void blur_power(uint8_t *dst, int dst_step, const uint8_t *src, int src_step,
250  int len, int radius, int power, uint8_t *temp[2])
251 {
252  uint8_t *a = temp[0], *b = temp[1];
253 
254  if (radius && power) {
255  blur(a, 1, src, src_step, len, radius);
256  for (; power > 2; power--) {
257  uint8_t *c;
258  blur(b, 1, a, 1, len, radius);
259  c = a; a = b; b = c;
260  }
261  if (power > 1) {
262  blur(dst, dst_step, a, 1, len, radius);
263  } else {
264  int i;
265  for (i = 0; i < len; i++)
266  dst[i*dst_step] = a[i];
267  }
268  } else {
269  int i;
270  for (i = 0; i < len; i++)
271  dst[i*dst_step] = src[i*src_step];
272  }
273 }
274 
275 static void hblur(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize,
276  int w, int h, int radius, int power, uint8_t *temp[2])
277 {
278  int y;
279 
280  if (radius == 0 && dst == src)
281  return;
282 
283  for (y = 0; y < h; y++)
284  blur_power(dst + y*dst_linesize, 1, src + y*src_linesize, 1,
285  w, radius, power, temp);
286 }
287 
288 static void vblur(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize,
289  int w, int h, int radius, int power, uint8_t *temp[2])
290 {
291  int x;
292 
293  if (radius == 0 && dst == src)
294  return;
295 
296  for (x = 0; x < w; x++)
297  blur_power(dst + x, dst_linesize, src + x, src_linesize,
298  h, radius, power, temp);
299 }
300 
301 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
302 {
303  AVFilterContext *ctx = inlink->dst;
304  BoxBlurContext *s = ctx->priv;
305  AVFilterLink *outlink = inlink->dst->outputs[0];
306  AVFrame *out;
307  int plane;
308  int cw = inlink->w >> s->hsub, ch = in->height >> s->vsub;
309  int w[4] = { inlink->w, cw, cw, inlink->w };
310  int h[4] = { in->height, ch, ch, in->height };
311 
312  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
313  if (!out) {
314  av_frame_free(&in);
315  return AVERROR(ENOMEM);
316  }
317  av_frame_copy_props(out, in);
318 
319  for (plane = 0; in->data[plane] && plane < 4; plane++)
320  hblur(out->data[plane], out->linesize[plane],
321  in ->data[plane], in ->linesize[plane],
322  w[plane], h[plane], s->radius[plane], s->power[plane],
323  s->temp);
324 
325  for (plane = 0; in->data[plane] && plane < 4; plane++)
326  vblur(out->data[plane], out->linesize[plane],
327  out->data[plane], out->linesize[plane],
328  w[plane], h[plane], s->radius[plane], s->power[plane],
329  s->temp);
330 
331  av_frame_free(&in);
332 
333  return ff_filter_frame(outlink, out);
334 }
335 
336 #define OFFSET(x) offsetof(BoxBlurContext, x)
337 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM
338 static const AVOption options[] = {
339  { "luma_radius", "Radius of the luma blurring box", OFFSET(luma_radius_expr), AV_OPT_TYPE_STRING, .flags = FLAGS },
340  { "luma_power", "How many times should the boxblur be applied to luma",
341  OFFSET(luma_param.power), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, FLAGS },
342  { "chroma_radius", "Radius of the chroma blurring box", OFFSET(chroma_radius_expr), AV_OPT_TYPE_STRING, .flags = FLAGS },
343  { "chroma_power", "How many times should the boxblur be applied to chroma",
344  OFFSET(chroma_param.power), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, FLAGS },
345  { "alpha_radius", "Radius of the alpha blurring box", OFFSET(alpha_radius_expr), AV_OPT_TYPE_STRING, .flags = FLAGS },
346  { "alpha_power", "How many times should the boxblur be applied to alpha",
347  OFFSET(alpha_param.power), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, FLAGS },
348  { NULL },
349 };
350 
351 static const AVClass boxblur_class = {
352  .class_name = "boxblur",
353  .item_name = av_default_item_name,
354  .option = options,
355  .version = LIBAVUTIL_VERSION_INT,
356 };
357 
359  {
360  .name = "default",
361  .type = AVMEDIA_TYPE_VIDEO,
362  .config_props = config_input,
363  .filter_frame = filter_frame,
364  },
365  { NULL }
366 };
367 
369  {
370  .name = "default",
371  .type = AVMEDIA_TYPE_VIDEO,
372  },
373  { NULL }
374 };
375 
377  .name = "boxblur",
378  .description = NULL_IF_CONFIG_SMALL("Blur the input."),
379  .priv_size = sizeof(BoxBlurContext),
380  .priv_class = &boxblur_class,
381  .init = init,
382  .uninit = uninit,
384 
385  .inputs = avfilter_vf_boxblur_inputs,
386  .outputs = avfilter_vf_boxblur_outputs,
387 };
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:62
#define U
Definition: vf_boxblur.c:79
char * luma_radius_expr
Definition: vf_boxblur.c:68
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:1599
This structure describes decoded (raw) audio or video data.
Definition: frame.h:135
AVOption.
Definition: opt.h:234
static void hblur(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int w, int h, int radius, int power, uint8_t *temp[2])
Definition: vf_boxblur.c:275
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:70
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:232
Main libavfilter public API header.
static int config_input(AVFilterLink *inlink)
Definition: vf_boxblur.c:131
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_dlog(ac->avr,"%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
static av_cold int init(AVFilterContext *ctx)
Definition: vf_boxblur.c:83
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:104
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:198
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:165
const char * name
Pad name.
Definition: internal.h:42
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:38
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:733
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:104
uint8_t
#define av_cold
Definition: attributes.h:66
uint8_t * temp[2]
temporary buffer used in blur_power()
Definition: vf_boxblur.c:75
AVOptions.
#define Y
Definition: vf_boxblur.c:78
char * chroma_radius_expr
Definition: vf_boxblur.c:69
#define b
Definition: input.c:52
#define A
Definition: vf_boxblur.c:81
static const AVFilterPad avfilter_vf_boxblur_outputs[]
Definition: vf_boxblur.c:368
static void vblur(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int w, int h, int radius, int power, uint8_t *temp[2])
Definition: vf_boxblur.c:288
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
Definition: pixfmt.h:103
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
Definition: pixfmt.h:78
FilterParam alpha_param
Definition: vf_boxblur.c:67
#define OFFSET(x)
Definition: vf_boxblur.c:336
void 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:379
A filter pad used for either input or output.
Definition: internal.h:36
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:123
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:69
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:150
void * priv
private data for use by the filter
Definition: avfilter.h:584
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:144
static int query_formats(AVFilterContext *ctx)
Definition: vf_boxblur.c:116
int radius[4]
Definition: vf_boxblur.c:73
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:169
static const AVFilterPad avfilter_vf_boxblur_inputs[]
Definition: vf_boxblur.c:358
#define FFMAX(a, b)
Definition: common.h:55
#define V
Definition: vf_boxblur.c:80
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:69
#define FLAGS
Definition: vf_boxblur.c:337
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
Definition: pixfmt.h:77
FilterParam luma_param
Definition: vf_boxblur.c:65
static const char *const var_names[]
Definition: vf_boxblur.c:38
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
int power[4]
Definition: vf_boxblur.c:74
#define EVAL_RADIUS_EXPR(comp)
NULL
Definition: eval.c:55
static void blur(uint8_t *dst, int dst_step, const uint8_t *src, int src_step, int len, int radius)
Definition: vf_boxblur.c:208
char * av_strdup(const char *s)
Duplicate the string s.
Definition: mem.c:213
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:153
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_boxblur.c:301
static void blur_power(uint8_t *dst, int dst_step, const uint8_t *src, int src_step, int len, int radius, int power, uint8_t *temp[2])
Definition: vf_boxblur.c:249
av_default_item_name
Definition: dnxhdenc.c:52
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
char * alpha_radius_expr
Definition: vf_boxblur.c:70
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:71
Describe the class of an AVClass context structure.
Definition: log.h:33
Filter definition.
Definition: avfilter.h:421
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:221
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_boxblur.c:108
const char * name
Filter name.
Definition: avfilter.h:425
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:578
AVFilter ff_vf_boxblur
Definition: vf_boxblur.c:376
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:141
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_dlog(ac->avr,"%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-> out
static const AVClass boxblur_class
Definition: vf_boxblur.c:351
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:65
Y , 8bpp.
Definition: pixfmt.h:73
common internal and external API header
#define CHECK_RADIUS_VAL(w_, h_, comp)
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
Definition: pixfmt.h:79
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:72
FilterParam chroma_param
Definition: vf_boxblur.c:66
int len
An instance of a filter.
Definition: avfilter.h:563
int height
Definition: frame.h:174
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:102
internal API functions
AVPixelFormat
Pixel format.
Definition: pixfmt.h:63
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:367
var_name
Definition: setpts.c:60
static const AVOption options[]
Definition: vf_boxblur.c:338
simple arithmetic expression evaluator