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 "libavutil/imgutils.h"
29 #include "libavutil/opt.h"
30 #include "libavutil/pixdesc.h"
31 #include "avfilter.h"
32 #include "formats.h"
33 #include "gblur.h"
34 #include "internal.h"
35 #include "video.h"
36 
37 #define OFFSET(x) offsetof(GBlurContext, x)
38 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
39 
40 static const AVOption gblur_options[] = {
41  { "sigma", "set sigma", OFFSET(sigma), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0.0, 1024, FLAGS },
42  { "steps", "set number of steps", OFFSET(steps), AV_OPT_TYPE_INT, {.i64=1}, 1, 6, FLAGS },
43  { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
44  { "sigmaV", "set vertical sigma", OFFSET(sigmaV), AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1, 1024, FLAGS },
45  { NULL }
46 };
47 
49 
50 typedef struct ThreadData {
51  int height;
52  int width;
53 } ThreadData;
54 
55 static void horiz_slice_c(float *buffer, int width, int height, int steps,
56  float nu, float bscale)
57 {
58  int step, x, y;
59  float *ptr;
60  for (y = 0; y < height; y++) {
61  for (step = 0; step < steps; step++) {
62  ptr = buffer + width * y;
63  ptr[0] *= bscale;
64 
65  /* Filter rightwards */
66  for (x = 1; x < width; x++)
67  ptr[x] += nu * ptr[x - 1];
68  ptr[x = width - 1] *= bscale;
69 
70  /* Filter leftwards */
71  for (; x > 0; x--)
72  ptr[x - 1] += nu * ptr[x];
73  }
74  }
75 }
76 
77 static int filter_horizontally(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
78 {
79  GBlurContext *s = ctx->priv;
80  ThreadData *td = arg;
81  const int height = td->height;
82  const int width = td->width;
83  const int slice_start = (height * jobnr ) / nb_jobs;
84  const int slice_end = (height * (jobnr+1)) / nb_jobs;
85  const float boundaryscale = s->boundaryscale;
86  const int steps = s->steps;
87  const float nu = s->nu;
88  float *buffer = s->buffer;
89 
90  s->horiz_slice(buffer + width * slice_start, width, slice_end - slice_start,
91  steps, nu, boundaryscale);
92  emms_c();
93  return 0;
94 }
95 
96 static void do_vertical_columns(float *buffer, int width, int height,
97  int column_begin, int column_end, int steps,
98  float nu, float boundaryscale, int column_step)
99 {
100  const int numpixels = width * height;
101  int i, x, k, step;
102  float *ptr;
103  for (x = column_begin; x < column_end;) {
104  for (step = 0; step < steps; step++) {
105  ptr = buffer + x;
106  for (k = 0; k < column_step; k++) {
107  ptr[k] *= boundaryscale;
108  }
109  /* Filter downwards */
110  for (i = width; i < numpixels; i += width) {
111  for (k = 0; k < column_step; k++) {
112  ptr[i + k] += nu * ptr[i - width + k];
113  }
114  }
115  i = numpixels - width;
116 
117  for (k = 0; k < column_step; k++)
118  ptr[i + k] *= boundaryscale;
119 
120  /* Filter upwards */
121  for (; i > 0; i -= width) {
122  for (k = 0; k < column_step; k++)
123  ptr[i - width + k] += nu * ptr[i + k];
124  }
125  }
126  x += column_step;
127  }
128 }
129 
130 static int filter_vertically(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
131 {
132  GBlurContext *s = ctx->priv;
133  ThreadData *td = arg;
134  const int height = td->height;
135  const int width = td->width;
136  const int slice_start = (width * jobnr ) / nb_jobs;
137  const int slice_end = (width * (jobnr+1)) / nb_jobs;
138  const float boundaryscale = s->boundaryscaleV;
139  const int steps = s->steps;
140  const float nu = s->nuV;
141  float *buffer = s->buffer;
142  int aligned_end;
143 
144  aligned_end = slice_start + (((slice_end - slice_start) >> 3) << 3);
145  /* Filter vertically along columns (process 8 columns in each step) */
146  do_vertical_columns(buffer, width, height, slice_start, aligned_end,
147  steps, nu, boundaryscale, 8);
148 
149  /* Filter un-aligned columns one by one */
151  steps, nu, boundaryscale, 1);
152  return 0;
153 }
154 
155 
156 static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
157 {
158  GBlurContext *s = ctx->priv;
159  ThreadData *td = arg;
160  const int height = td->height;
161  const int width = td->width;
162  const int64_t numpixels = width * (int64_t)height;
163  const unsigned slice_start = (numpixels * jobnr ) / nb_jobs;
164  const unsigned slice_end = (numpixels * (jobnr+1)) / nb_jobs;
165  const float postscale = s->postscale * s->postscaleV;
166  float *buffer = s->buffer;
167  unsigned i;
168 
169  for (i = slice_start; i < slice_end; i++)
170  buffer[i] *= postscale;
171 
172  return 0;
173 }
174 
176 {
177  GBlurContext *s = ctx->priv;
178  const int width = s->planewidth[plane];
179  const int height = s->planeheight[plane];
180  const int nb_threads = ff_filter_get_nb_threads(ctx);
181  ThreadData td;
182 
183  if (s->sigma <= 0 || s->steps < 0)
184  return;
185 
186  td.width = width;
187  td.height = height;
188  ctx->internal->execute(ctx, filter_horizontally, &td, NULL, FFMIN(height, nb_threads));
189  ctx->internal->execute(ctx, filter_vertically, &td, NULL, FFMIN(width, nb_threads));
190  ctx->internal->execute(ctx, filter_postscale, &td, NULL, FFMIN(width * height, nb_threads));
191 }
192 
194 {
195  static const enum AVPixelFormat pix_fmts[] = {
214  };
215 
217 }
218 
220 {
221  s->horiz_slice = horiz_slice_c;
222  if (ARCH_X86_64)
224 }
225 
227 {
229  GBlurContext *s = inlink->dst->priv;
230 
231  s->depth = desc->comp[0].depth;
232  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
233  s->planewidth[0] = s->planewidth[3] = inlink->w;
234  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
235  s->planeheight[0] = s->planeheight[3] = inlink->h;
236 
237  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
238 
239  s->buffer = av_malloc_array(FFALIGN(inlink->w, 16), FFALIGN(inlink->h, 16) * sizeof(*s->buffer));
240  if (!s->buffer)
241  return AVERROR(ENOMEM);
242 
243  if (s->sigmaV < 0) {
244  s->sigmaV = s->sigma;
245  }
246  ff_gblur_init(s);
247 
248  return 0;
249 }
250 
251 static void set_params(float sigma, int steps, float *postscale, float *boundaryscale, float *nu)
252 {
253  double dnu, lambda;
254 
255  lambda = (sigma * sigma) / (2.0 * steps);
256  dnu = (1.0 + 2.0 * lambda - sqrt(1.0 + 4.0 * lambda)) / (2.0 * lambda);
257  *postscale = pow(dnu / lambda, steps);
258  *boundaryscale = 1.0 / (1.0 - dnu);
259  *nu = (float)dnu;
260 }
261 
263 {
264  AVFilterContext *ctx = inlink->dst;
265  GBlurContext *s = ctx->priv;
266  AVFilterLink *outlink = ctx->outputs[0];
267  AVFrame *out;
268  int plane;
269 
270  set_params(s->sigma, s->steps, &s->postscale, &s->boundaryscale, &s->nu);
271  set_params(s->sigmaV, s->steps, &s->postscaleV, &s->boundaryscaleV, &s->nuV);
272 
273  if (av_frame_is_writable(in)) {
274  out = in;
275  } else {
276  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
277  if (!out) {
278  av_frame_free(&in);
279  return AVERROR(ENOMEM);
280  }
282  }
283 
284  for (plane = 0; plane < s->nb_planes; plane++) {
285  const int height = s->planeheight[plane];
286  const int width = s->planewidth[plane];
287  float *bptr = s->buffer;
288  const uint8_t *src = in->data[plane];
289  const uint16_t *src16 = (const uint16_t *)in->data[plane];
290  uint8_t *dst = out->data[plane];
291  uint16_t *dst16 = (uint16_t *)out->data[plane];
292  int y, x;
293 
294  if (!s->sigma || !(s->planes & (1 << plane))) {
295  if (out != in)
296  av_image_copy_plane(out->data[plane], out->linesize[plane],
297  in->data[plane], in->linesize[plane],
298  width * ((s->depth + 7) / 8), height);
299  continue;
300  }
301 
302  if (s->depth == 8) {
303  for (y = 0; y < height; y++) {
304  for (x = 0; x < width; x++) {
305  bptr[x] = src[x];
306  }
307  bptr += width;
308  src += in->linesize[plane];
309  }
310  } else {
311  for (y = 0; y < height; y++) {
312  for (x = 0; x < width; x++) {
313  bptr[x] = src16[x];
314  }
315  bptr += width;
316  src16 += in->linesize[plane] / 2;
317  }
318  }
319 
321 
322  bptr = s->buffer;
323  if (s->depth == 8) {
324  for (y = 0; y < height; y++) {
325  for (x = 0; x < width; x++) {
326  dst[x] = bptr[x];
327  }
328  bptr += width;
329  dst += out->linesize[plane];
330  }
331  } else {
332  for (y = 0; y < height; y++) {
333  for (x = 0; x < width; x++) {
334  dst16[x] = bptr[x];
335  }
336  bptr += width;
337  dst16 += out->linesize[plane] / 2;
338  }
339  }
340  }
341 
342  if (out != in)
343  av_frame_free(&in);
344  return ff_filter_frame(outlink, out);
345 }
346 
348 {
349  GBlurContext *s = ctx->priv;
350 
351  av_freep(&s->buffer);
352 }
353 
354 static const AVFilterPad gblur_inputs[] = {
355  {
356  .name = "default",
357  .type = AVMEDIA_TYPE_VIDEO,
358  .config_props = config_input,
359  .filter_frame = filter_frame,
360  },
361  { NULL }
362 };
363 
364 static const AVFilterPad gblur_outputs[] = {
365  {
366  .name = "default",
367  .type = AVMEDIA_TYPE_VIDEO,
368  },
369  { NULL }
370 };
371 
373  .name = "gblur",
374  .description = NULL_IF_CONFIG_SMALL("Apply Gaussian Blur filter."),
375  .priv_size = sizeof(GBlurContext),
376  .priv_class = &gblur_class,
377  .uninit = uninit,
379  .inputs = gblur_inputs,
382 };
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:99
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:430
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:409
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
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
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:1080
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2522
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:202
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:422
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
pixdesc.h
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:429
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:424
AVOption
AVOption.
Definition: opt.h:246
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:387
filter_horizontally
static int filter_horizontally(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_gblur.c:77
filter_vertically
static int filter_vertically(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_gblur.c:130
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:148
video.h
AVFormatContext::internal
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1795
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:425
ThreadData::width
int width
Definition: vf_avgblur.c:62
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:367
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:338
formats.h
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2562
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:421
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:405
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
ff_vf_gblur
AVFilter ff_vf_gblur
Definition: vf_gblur.c:372
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:403
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:431
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_gblur.c:347
plane
int plane
Definition: avisynth_c.h:384
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:385
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:371
OFFSET
#define OFFSET(x)
Definition: vf_gblur.c:37
src
#define src
Definition: vp8dsp.c:254
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:390
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:258
gblur_inputs
static const AVFilterPad gblur_inputs[]
Definition: vf_gblur.c:354
av_cold
#define av_cold
Definition: attributes.h:84
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:399
ff_set_common_formats
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
gblur.h
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:407
width
#define width
filter_postscale
static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_gblur.c:156
s
#define s(width, name)
Definition: cbs_vp9.c:257
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:408
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:400
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
ThreadData::height
int height
Definition: vf_avgblur.c:61
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2026
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:275
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:384
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:398
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:370
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
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:66
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:368
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:406
NULL
#define NULL
Definition: coverity.c:32
FLAGS
#define FLAGS
Definition: vf_gblur.c:38
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:654
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_gblur.c:226
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
gblur_outputs
static const AVFilterPad gblur_outputs[]
Definition: vf_gblur.c:364
ff_gblur_init_x86
void ff_gblur_init_x86(GBlurContext *s)
Definition: vf_gblur_init.c:30
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:388
inputs
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
Definition: filter_design.txt:243
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:402
postscale
static const FLOAT postscale[64]
Definition: faandct.c:54
desc
const char * desc
Definition: nvenc.c:68
planes
static const struct @314 planes[]
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:188
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:392
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:394
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:594
gblur_options
static const AVOption gblur_options[]
Definition: vf_gblur.c:40
height
#define height
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
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:177
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:426
internal.h
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#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:125
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:226
in
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Definition: audio_convert.c:326
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_gblur.c:262
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:404
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:802
ThreadData
Used for passing data between threads.
Definition: af_adeclick.c:487
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
uint8_t
uint8_t
Definition: audio_convert.c:194
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:386
AVFilter
Filter definition.
Definition: avfilter.h:144
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(gblur)
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:423
horiz_slice_c
static void horiz_slice_c(float *buffer, int width, int height, int steps, float nu, float bscale)
Definition: vf_gblur.c:55
set_params
static void set_params(float sigma, int steps, float *postscale, float *boundaryscale, float *nu)
Definition: vf_gblur.c:251
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:391
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:396
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
avfilter.h
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:338
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_gblur.c:193
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
ff_gblur_init
void ff_gblur_init(GBlurContext *s)
Definition: vf_gblur.c:219
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:116
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:81
gaussianiir2d
static void gaussianiir2d(AVFilterContext *ctx, int plane)
Definition: vf_gblur.c:175
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:48
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
GBlurContext
Definition: gblur.h:32
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
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
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_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:393
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:397
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:369
do_vertical_columns
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:96
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:176
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:395