FFmpeg
vf_bilateral.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Ming Yang
3  * Copyright (c) 2019 Paul B Mahol
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to deal
7  * in the Software without restriction, including without limitation the rights
8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9  * copies of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  */
23 
24 #include "libavutil/imgutils.h"
25 #include "libavutil/opt.h"
26 #include "libavutil/pixdesc.h"
27 #include "avfilter.h"
28 #include "internal.h"
29 #include "video.h"
30 
31 typedef struct BilateralContext {
32  const AVClass *class;
33 
34  float sigmaS;
35  float sigmaR;
36  int planes;
37 
39  int nb_planes;
40  int depth;
41  int planewidth[4];
42  int planeheight[4];
43 
44  float alpha;
45  float range_table[65536];
46 
47  float *img_out_f[4];
48  float *img_temp[4];
49  float *map_factor_a[4];
50  float *map_factor_b[4];
51  float *slice_factor_a[4];
52  float *slice_factor_b[4];
53  float *line_factor_a[4];
54  float *line_factor_b[4];
56 
57 #define OFFSET(x) offsetof(BilateralContext, x)
58 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
59 
60 static const AVOption bilateral_options[] = {
61  { "sigmaS", "set spatial sigma", OFFSET(sigmaS), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.0, 512, FLAGS },
62  { "sigmaR", "set range sigma", OFFSET(sigmaR), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.0, 1, FLAGS },
63  { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=1}, 0, 0xF, FLAGS },
64  { NULL }
65 };
66 
67 AVFILTER_DEFINE_CLASS(bilateral);
68 
69 static const enum AVPixelFormat pix_fmts[] = {
88 };
89 
91 {
92  BilateralContext *s = ctx->priv;
93  float inv_sigma_range;
94 
95  inv_sigma_range = 1.0f / (s->sigmaR * ((1 << s->depth) - 1));
96  s->alpha = expf(-sqrtf(2.f) / s->sigmaS);
97 
98  //compute a lookup table
99  for (int i = 0; i < (1 << s->depth); i++)
100  s->range_table[i] = s->alpha * expf(-i * inv_sigma_range);
101 
102  return 0;
103 }
104 
105 typedef struct ThreadData {
106  AVFrame *in, *out;
107 } ThreadData;
108 
110 {
111  AVFilterContext *ctx = inlink->dst;
112  BilateralContext *s = ctx->priv;
114 
115  s->depth = desc->comp[0].depth;
117 
118  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
119  s->planewidth[0] = s->planewidth[3] = inlink->w;
120  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
121  s->planeheight[0] = s->planeheight[3] = inlink->h;
122 
123  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
124  s->nb_threads = ff_filter_get_nb_threads(ctx);
125 
126  for (int p = 0; p < s->nb_planes; p++) {
127  const int w = s->planewidth[p];
128  const int h = s->planeheight[p];
129 
130  s->img_out_f[p] = av_calloc(w * h, sizeof(float));
131  s->img_temp[p] = av_calloc(w * h, sizeof(float));
132  s->map_factor_a[p] = av_calloc(w * h, sizeof(float));
133  s->map_factor_b[p] = av_calloc(w * h, sizeof(float));
134  s->slice_factor_a[p] = av_calloc(w, sizeof(float));
135  s->slice_factor_b[p] = av_calloc(w, sizeof(float));
136  s->line_factor_a[p] = av_calloc(w, sizeof(float));
137  s->line_factor_b[p] = av_calloc(w, sizeof(float));
138 
139  if (!s->img_out_f[p] ||
140  !s->img_temp[p] ||
141  !s->map_factor_a[p] ||
142  !s->map_factor_b[p] ||
143  !s->slice_factor_a[p] ||
144  !s->slice_factor_a[p] ||
145  !s->line_factor_a[p] ||
146  !s->line_factor_a[p])
147  return AVERROR(ENOMEM);
148  }
149 
150  return 0;
151 }
152 
153 #define BILATERAL_H(type, name) \
154 static void bilateralh_##name(BilateralContext *s, AVFrame *out, AVFrame *in, \
155  int jobnr, int nb_jobs, int plane) \
156 { \
157  const int width = s->planewidth[plane]; \
158  const int height = s->planeheight[plane]; \
159  const int slice_start = (height * jobnr) / nb_jobs; \
160  const int slice_end = (height * (jobnr+1)) / nb_jobs; \
161  const int src_linesize = in->linesize[plane] / sizeof(type); \
162  const type *src = (const type *)in->data[plane]; \
163  float *img_temp = s->img_temp[plane]; \
164  float *map_factor_a = s->map_factor_a[plane]; \
165  const float *const range_table = s->range_table; \
166  const float alpha = s->alpha; \
167  float ypr, ycr, fp, fc; \
168  const float inv_alpha_ = 1.f - alpha; \
169  \
170  for (int y = slice_start; y < slice_end; y++) { \
171  float *temp_factor_x, *temp_x = &img_temp[y * width]; \
172  const type *in_x = &src[y * src_linesize]; \
173  const type *texture_x = &src[y * src_linesize]; \
174  type tpr; \
175  \
176  *temp_x++ = ypr = *in_x++; \
177  tpr = *texture_x++; \
178  \
179  temp_factor_x = &map_factor_a[y * width]; \
180  *temp_factor_x++ = fp = 1; \
181  \
182  for (int x = 1; x < width; x++) { \
183  float alpha_; \
184  int range_dist; \
185  type tcr = *texture_x++; \
186  type dr = abs(tcr - tpr); \
187  \
188  range_dist = dr; \
189  alpha_ = range_table[range_dist]; \
190  *temp_x++ = ycr = inv_alpha_*(*in_x++) + alpha_*ypr; \
191  tpr = tcr; \
192  ypr = ycr; \
193  *temp_factor_x++ = fc = inv_alpha_ + alpha_ * fp; \
194  fp = fc; \
195  } \
196  --temp_x; *temp_x = ((*temp_x) + (*--in_x)); \
197  tpr = *--texture_x; \
198  ypr = *in_x; \
199  \
200  --temp_factor_x; *temp_factor_x = ((*temp_factor_x) + 1); \
201  fp = 1; \
202  \
203  for (int x = width - 2; x >= 0; x--) { \
204  type tcr = *--texture_x; \
205  type dr = abs(tcr - tpr); \
206  int range_dist = dr; \
207  float alpha_ = range_table[range_dist]; \
208  \
209  ycr = inv_alpha_ * (*--in_x) + alpha_ * ypr; \
210  --temp_x; *temp_x = ((*temp_x) + ycr); \
211  tpr = tcr; \
212  ypr = ycr; \
213  \
214  fc = inv_alpha_ + alpha_*fp; \
215  --temp_factor_x; \
216  *temp_factor_x = ((*temp_factor_x) + fc); \
217  fp = fc; \
218  } \
219  } \
220 }
221 
222 BILATERAL_H(uint8_t, byte)
223 BILATERAL_H(uint16_t, word)
224 
225 #define BILATERAL_V(type, name) \
226 static void bilateralv_##name(BilateralContext *s, AVFrame *out, AVFrame *in, \
227  int jobnr, int nb_jobs, int plane) \
228 { \
229  const int width = s->planewidth[plane]; \
230  const int height = s->planeheight[plane]; \
231  const int slice_start = (width * jobnr) / nb_jobs; \
232  const int slice_end = (width * (jobnr+1)) / nb_jobs; \
233  const int src_linesize = in->linesize[plane] / sizeof(type); \
234  const type *src = (const type *)in->data[plane] + slice_start; \
235  float *img_out_f = s->img_out_f[plane] + slice_start; \
236  float *img_temp = s->img_temp[plane] + slice_start; \
237  float *map_factor_a = s->map_factor_a[plane] + slice_start; \
238  float *map_factor_b = s->map_factor_b[plane] + slice_start; \
239  float *slice_factor_a = s->slice_factor_a[plane] + slice_start; \
240  float *slice_factor_b = s->slice_factor_b[plane] + slice_start; \
241  float *line_factor_a = s->line_factor_a[plane] + slice_start; \
242  float *line_factor_b = s->line_factor_b[plane] + slice_start; \
243  const float *const range_table = s->range_table; \
244  const float alpha = s->alpha; \
245  float *ycy, *ypy, *xcy; \
246  const float inv_alpha_ = 1.f - alpha; \
247  float *ycf, *ypf, *xcf, *in_factor; \
248  const type *tcy, *tpy; \
249  int h1; \
250  \
251  memcpy(img_out_f, img_temp, sizeof(float) * (slice_end - slice_start)); \
252  \
253  in_factor = map_factor_a; \
254  memcpy(map_factor_b, in_factor, sizeof(float) * (slice_end - slice_start)); \
255  for (int y = 1; y < height; y++) { \
256  tpy = &src[(y - 1) * src_linesize]; \
257  tcy = &src[y * src_linesize]; \
258  xcy = &img_temp[y * width]; \
259  ypy = &img_out_f[(y - 1) * width]; \
260  ycy = &img_out_f[y * width]; \
261  \
262  xcf = &in_factor[y * width]; \
263  ypf = &map_factor_b[(y - 1) * width]; \
264  ycf = &map_factor_b[y * width]; \
265  for (int x = 0; x < slice_end - slice_start; x++) { \
266  type dr = abs((*tcy++) - (*tpy++)); \
267  int range_dist = dr; \
268  float alpha_ = range_table[range_dist]; \
269  \
270  *ycy++ = inv_alpha_*(*xcy++) + alpha_*(*ypy++); \
271  *ycf++ = inv_alpha_*(*xcf++) + alpha_*(*ypf++); \
272  } \
273  } \
274  h1 = height - 1; \
275  ycf = line_factor_a; \
276  ypf = line_factor_b; \
277  memcpy(ypf, &in_factor[h1 * width], sizeof(float) * (slice_end - slice_start)); \
278  for (int x = 0, k = 0; x < slice_end - slice_start; x++) \
279  map_factor_b[h1 * width + x] = (map_factor_b[h1 * width + x] + ypf[k++]); \
280  \
281  ycy = slice_factor_a; \
282  ypy = slice_factor_b; \
283  memcpy(ypy, &img_temp[h1 * width], sizeof(float) * (slice_end - slice_start)); \
284  for (int x = 0, k = 0; x < slice_end - slice_start; x++) { \
285  int idx = h1 * width + x; \
286  img_out_f[idx] = (img_out_f[idx] + ypy[k++]) / map_factor_b[h1 * width + x]; \
287  } \
288  \
289  for (int y = h1 - 1; y >= 0; y--) { \
290  float *ycf_, *ypf_, *factor_; \
291  float *ycy_, *ypy_, *out_; \
292  \
293  tpy = &src[(y + 1) * src_linesize]; \
294  tcy = &src[y * src_linesize]; \
295  xcy = &img_temp[y * width]; \
296  ycy_ = ycy; \
297  ypy_ = ypy; \
298  out_ = &img_out_f[y * width]; \
299  \
300  xcf = &in_factor[y * width]; \
301  ycf_ = ycf; \
302  ypf_ = ypf; \
303  factor_ = &map_factor_b[y * width]; \
304  for (int x = 0; x < slice_end - slice_start; x++) { \
305  type dr = abs((*tcy++) - (*tpy++)); \
306  int range_dist = dr; \
307  float alpha_ = range_table[range_dist]; \
308  float ycc, fcc = inv_alpha_*(*xcf++) + alpha_*(*ypf_++); \
309  \
310  *ycf_++ = fcc; \
311  *factor_ = (*factor_ + fcc); \
312  \
313  ycc = inv_alpha_*(*xcy++) + alpha_*(*ypy_++); \
314  *ycy_++ = ycc; \
315  *out_ = (*out_ + ycc) / (*factor_); \
316  out_++; \
317  factor_++; \
318  } \
319  \
320  ypy = ycy; \
321  ypf = ycf; \
322  } \
323 }
324 
325 BILATERAL_V(uint8_t, byte)
326 BILATERAL_V(uint16_t, word)
327 
328 #define BILATERAL_O(type, name) \
329 static void bilateralo_##name(BilateralContext *s, AVFrame *out, AVFrame *in, \
330  int jobnr, int nb_jobs, int plane) \
331 { \
332  const int width = s->planewidth[plane]; \
333  const int height = s->planeheight[plane]; \
334  const int slice_start = (height * jobnr) / nb_jobs; \
335  const int slice_end = (height * (jobnr+1)) / nb_jobs; \
336  const int dst_linesize = out->linesize[plane] / sizeof(type); \
337  \
338  for (int i = slice_start; i < slice_end; i++) { \
339  type *dst = (type *)out->data[plane] + i * dst_linesize; \
340  const float *const img_out_f = s->img_out_f[plane] + i * width; \
341  for (int j = 0; j < width; j++) \
342  dst[j] = lrintf(img_out_f[j]); \
343  } \
344 }
345 
346 BILATERAL_O(uint8_t, byte)
347 BILATERAL_O(uint16_t, word)
348 
350  int jobnr, int nb_jobs)
351 {
352  BilateralContext *s = ctx->priv;
353  ThreadData *td = arg;
354  AVFrame *out = td->out;
355  AVFrame *in = td->in;
356 
357  for (int plane = 0; plane < s->nb_planes; plane++) {
358  if (!(s->planes & (1 << plane)))
359  continue;
360 
361  if (s->depth <= 8)
362  bilateralh_byte(s, out, in, jobnr, nb_jobs, plane);
363  else
364  bilateralh_word(s, out, in, jobnr, nb_jobs, plane);
365  }
366 
367  return 0;
368 }
369 
371  int jobnr, int nb_jobs)
372 {
373  BilateralContext *s = ctx->priv;
374  ThreadData *td = arg;
375  AVFrame *out = td->out;
376  AVFrame *in = td->in;
377 
378  for (int plane = 0; plane < s->nb_planes; plane++) {
379  if (!(s->planes & (1 << plane)))
380  continue;
381 
382  if (s->depth <= 8)
383  bilateralv_byte(s, out, in, jobnr, nb_jobs, plane);
384  else
385  bilateralv_word(s, out, in, jobnr, nb_jobs, plane);
386  }
387 
388  return 0;
389 }
390 
392  int jobnr, int nb_jobs)
393 {
394  BilateralContext *s = ctx->priv;
395  ThreadData *td = arg;
396  AVFrame *out = td->out;
397  AVFrame *in = td->in;
398 
399  for (int plane = 0; plane < s->nb_planes; plane++) {
400  if (!(s->planes & (1 << plane))) {
401  if (out != in) {
402  const int height = s->planeheight[plane];
403  const int slice_start = (height * jobnr) / nb_jobs;
404  const int slice_end = (height * (jobnr+1)) / nb_jobs;
405  const int width = s->planewidth[plane];
406  const int linesize = in->linesize[plane];
407  const int dst_linesize = out->linesize[plane];
408  const uint8_t *src = in->data[plane];
409  uint8_t *dst = out->data[plane];
410 
411  av_image_copy_plane(dst + slice_start * dst_linesize,
412  dst_linesize,
413  src + slice_start * linesize,
414  linesize,
415  width * ((s->depth + 7) / 8),
416  slice_end - slice_start);
417  }
418  continue;
419  }
420 
421  if (s->depth <= 8)
422  bilateralo_byte(s, out, in, jobnr, nb_jobs, plane);
423  else
424  bilateralo_word(s, out, in, jobnr, nb_jobs, plane);
425  }
426 
427  return 0;
428 }
429 
431 {
432  AVFilterContext *ctx = inlink->dst;
433  BilateralContext *s = ctx->priv;
434  AVFilterLink *outlink = ctx->outputs[0];
435  ThreadData td;
436  AVFrame *out;
437 
438  if (av_frame_is_writable(in)) {
439  out = in;
440  } else {
441  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
442  if (!out) {
443  av_frame_free(&in);
444  return AVERROR(ENOMEM);
445  }
447  }
448 
449  td.in = in;
450  td.out = out;
451  ff_filter_execute(ctx, bilateralh_planes, &td, NULL, s->nb_threads);
452  ff_filter_execute(ctx, bilateralv_planes, &td, NULL, s->nb_threads);
453  ff_filter_execute(ctx, bilateralo_planes, &td, NULL, s->nb_threads);
454 
455  if (out != in)
456  av_frame_free(&in);
457  return ff_filter_frame(outlink, out);
458 }
459 
461 {
462  BilateralContext *s = ctx->priv;
463 
464  for (int p = 0; p < s->nb_planes; p++) {
465  av_freep(&s->img_out_f[p]);
466  av_freep(&s->img_temp[p]);
467  av_freep(&s->map_factor_a[p]);
468  av_freep(&s->map_factor_b[p]);
469  av_freep(&s->slice_factor_a[p]);
470  av_freep(&s->slice_factor_b[p]);
471  av_freep(&s->line_factor_a[p]);
472  av_freep(&s->line_factor_b[p]);
473  }
474 }
475 
477  const char *cmd,
478  const char *arg,
479  char *res,
480  int res_len,
481  int flags)
482 {
483  int ret = ff_filter_process_command(ctx, cmd, arg, res, res_len, flags);
484 
485  if (ret < 0)
486  return ret;
487 
488  return config_params(ctx);
489 }
490 
491 static const AVFilterPad bilateral_inputs[] = {
492  {
493  .name = "default",
494  .type = AVMEDIA_TYPE_VIDEO,
495  .config_props = config_input,
496  .filter_frame = filter_frame,
497  },
498 };
499 
501  .name = "bilateral",
502  .description = NULL_IF_CONFIG_SMALL("Apply Bilateral filter."),
503  .priv_size = sizeof(BilateralContext),
504  .priv_class = &bilateral_class,
505  .uninit = uninit,
511  .process_command = process_command,
512 };
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:108
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:512
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:491
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
config_params
static int config_params(AVFilterContext *ctx)
Definition: vf_bilateral.c:90
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:978
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2964
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:172
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
bilateralv_planes
static int bilateralv_planes(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_bilateral.c:370
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:100
BilateralContext::sigmaR
float sigmaR
Definition: vf_bilateral.c:35
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:504
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
pixdesc.h
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:511
w
uint8_t w
Definition: llviddspenc.c:38
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:506
AVOption
AVOption.
Definition: opt.h:251
BilateralContext::planewidth
int planewidth[4]
Definition: vf_bilateral.c:41
expf
#define expf(x)
Definition: libm.h:283
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:468
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:170
FLAGS
#define FLAGS
Definition: vf_bilateral.c:58
ThreadData::out
AVFrame * out
Definition: af_adeclick.c:526
video.h
ThreadData::in
AVFrame * in
Definition: af_adecorrelate.c:153
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:507
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:448
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:361
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
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3004
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:503
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:486
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:484
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:513
BilateralContext::slice_factor_a
float * slice_factor_a[4]
Definition: vf_bilateral.c:51
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:466
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_bilateral.c:460
BilateralContext::range_table
float range_table[65536]
Definition: vf_bilateral.c:45
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_bilateral.c:69
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:452
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:47
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:471
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:276
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:480
ff_video_default_filterpad
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition: video.c:36
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:488
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_bilateral.c:430
width
#define width
s
#define s(width, name)
Definition: cbs_vp9.c:198
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_bilateral.c:109
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:489
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:481
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:51
BilateralContext::nb_planes
int nb_planes
Definition: vf_bilateral.c:39
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:1979
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:465
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:479
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:451
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
BilateralContext::img_out_f
float * img_out_f[4]
Definition: vf_bilateral.c:47
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(bilateral)
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:192
bilateral_options
static const AVOption bilateral_options[]
Definition: vf_bilateral.c:60
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
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:449
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:487
OFFSET
#define OFFSET(x)
Definition: vf_bilateral.c:57
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
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:736
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
BilateralContext::map_factor_b
float * map_factor_b[4]
Definition: vf_bilateral.c:50
sqrtf
static __device__ float sqrtf(float a)
Definition: cuda_runtime.h:184
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:469
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:483
BilateralContext::sigmaS
float sigmaS
Definition: vf_bilateral.c:34
bilateral_inputs
static const AVFilterPad bilateral_inputs[]
Definition: vf_bilateral.c:491
BILATERAL_H
#define BILATERAL_H(type, name)
Definition: vf_bilateral.c:153
f
f
Definition: af_crystalizer.c:121
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:106
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:473
BilateralContext::planes
int planes
Definition: vf_bilateral.c:36
BilateralContext::slice_factor_b
float * slice_factor_b[4]
Definition: vf_bilateral.c:52
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:475
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:666
BilateralContext::img_temp
float * img_temp[4]
Definition: vf_bilateral.c:48
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:851
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:508
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:147
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
BILATERAL_V
#define BILATERAL_V(type, name)
Definition: vf_bilateral.c:225
bilateralh_planes
static int bilateralh_planes(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_bilateral.c:349
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
BilateralContext::planeheight
int planeheight[4]
Definition: vf_bilateral.c:42
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:485
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:786
ThreadData
Used for passing data between threads.
Definition: dsddec.c:69
planes
static const struct @363 planes[]
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:53
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:467
AVFilter
Filter definition.
Definition: avfilter.h:166
ret
ret
Definition: filter_design.txt:187
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:505
BilateralContext::nb_threads
int nb_threads
Definition: vf_bilateral.c:38
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:472
bilateralo_planes
static int bilateralo_planes(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_bilateral.c:391
BilateralContext::depth
int depth
Definition: vf_bilateral.c:40
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:477
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Definition: vf_bilateral.c:476
BilateralContext::alpha
float alpha
Definition: vf_bilateral.c:44
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
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
BilateralContext
Definition: vf_bilateral.c:31
AVFilterContext
An instance of a filter.
Definition: avfilter.h:397
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:117
desc
const char * desc
Definition: libsvtav1.c:83
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
BilateralContext::line_factor_b
float * line_factor_b[4]
Definition: vf_bilateral.c:54
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
ff_vf_bilateral
const AVFilter ff_vf_bilateral
Definition: vf_bilateral.c:500
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:193
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
BilateralContext::line_factor_a
float * line_factor_a[4]
Definition: vf_bilateral.c:53
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:474
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:385
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:474
h
h
Definition: vp9dsp_template.c:2038
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:478
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:450
BILATERAL_O
#define BILATERAL_O(type, name)
Definition: vf_bilateral.c:328
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:144
BilateralContext::map_factor_a
float * map_factor_a[4]
Definition: vf_bilateral.c:49
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:476