FFmpeg
Loading...
Searching...
No Matches
vf_nlmeans.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Clément Bœsch <u pkh me>
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/**
22 * @todo
23 * - better automatic defaults? see "Parameters" @ http://www.ipol.im/pub/art/2011/bcm_nlm/
24 * - temporal support (probably doesn't need any displacement according to
25 * "Denoising image sequences does not require motion estimation")
26 * - Bayer pixel format support for at least raw photos? (DNG support would be
27 * handy here)
28 * - FATE test (probably needs visual threshold test mechanism due to the use
29 * of floats)
30 */
31
32#include "libavutil/avassert.h"
33#include "libavutil/mem.h"
34#include "libavutil/opt.h"
35#include "libavutil/pixdesc.h"
36#include "avfilter.h"
37#include "filters.h"
38#include "vf_nlmeans.h"
39#include "vf_nlmeans_init.h"
40#include "video.h"
41
42typedef struct NLMeansContext {
43 const AVClass *class;
46 double pdiff_scale; // invert of the filtering parameter (sigma*10) squared
47 double sigma; // denoising strength
48 int patch_size, patch_hsize; // patch size and half size
49 int patch_size_uv, patch_hsize_uv; // patch size and half size for chroma planes
50 int research_size, research_hsize; // research size and half size
51 int research_size_uv, research_hsize_uv; // research size and half size for chroma planes
52 uint32_t *ii_orig; // integral image
53 uint32_t *ii; // integral image starting after the 0-line and 0-column
54 int ii_w, ii_h; // width and height of the integral image
55 ptrdiff_t ii_lz_32; // linesize in 32-bit units of the integral image
56 float *total_weight; // total weight for every pixel
57 float *sum; // weighted sum for every pixel
58 int linesize; // sum and total_weight linesize
59 float *weight_lut; // lookup table mapping (scaled) patch differences to their associated weights
60 uint32_t max_meaningful_diff; // maximum difference considered (if the patch difference is too high we ignore the pixel)
63
64#define OFFSET(x) offsetof(NLMeansContext, x)
65#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
66static const AVOption nlmeans_options[] = {
67 { "s", "denoising strength", OFFSET(sigma), AV_OPT_TYPE_DOUBLE, { .dbl = 1.0 }, 1.0, 30.0, FLAGS },
68 { "p", "patch size", OFFSET(patch_size), AV_OPT_TYPE_INT, { .i64 = 3*2+1 }, 0, 99, FLAGS },
69 { "pc", "patch size for chroma planes", OFFSET(patch_size_uv), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 99, FLAGS },
70 { "r", "research window", OFFSET(research_size), AV_OPT_TYPE_INT, { .i64 = 7*2+1 }, 0, 99, FLAGS },
71 { "rc", "research window for chroma planes", OFFSET(research_size_uv), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 99, FLAGS },
72 { NULL }
73};
74
76
87
88/**
89 * Compute squared difference of an unsafe area (the zone nor s1 nor s2 could
90 * be readable).
91 *
92 * On the other hand, the line above dst and the column to its left are always
93 * readable.
94 *
95 * There is little point in having this function SIMDified as it is likely too
96 * complex and only handle small portions of the image.
97 *
98 * @param dst integral image
99 * @param dst_linesize_32 integral image linesize (in 32-bit integers unit)
100 * @param startx integral starting x position
101 * @param starty integral starting y position
102 * @param src source plane buffer
103 * @param linesize source plane linesize
104 * @param offx source offsetting in x
105 * @param offy source offsetting in y
106 * @paran r absolute maximum source offsetting
107 * @param sw source width
108 * @param sh source height
109 * @param w width to compute
110 * @param h height to compute
111 */
112static inline void compute_unsafe_ssd_integral_image(uint32_t *dst, ptrdiff_t dst_linesize_32,
113 int startx, int starty,
114 const uint8_t *src, ptrdiff_t linesize,
115 int offx, int offy, int r, int sw, int sh,
116 int w, int h)
117{
118 for (int y = starty; y < starty + h; y++) {
119 uint32_t acc = dst[y*dst_linesize_32 + startx - 1] - dst[(y-1)*dst_linesize_32 + startx - 1];
120 const int s1y = av_clip(y - r, 0, sh - 1);
121 const int s2y = av_clip(y - (r + offy), 0, sh - 1);
122
123 for (int x = startx; x < startx + w; x++) {
124 const int s1x = av_clip(x - r, 0, sw - 1);
125 const int s2x = av_clip(x - (r + offx), 0, sw - 1);
126 const uint8_t v1 = src[s1y*linesize + s1x];
127 const uint8_t v2 = src[s2y*linesize + s2x];
128 const int d = v1 - v2;
129 acc += d * d;
130 dst[y*dst_linesize_32 + x] = dst[(y-1)*dst_linesize_32 + x] + acc;
131 }
132 }
133}
134
135/*
136 * Compute the sum of squared difference integral image
137 * http://www.ipol.im/pub/art/2014/57/
138 * Integral Images for Block Matching - Gabriele Facciolo, Nicolas Limare, Enric Meinhardt-Llopis
139 *
140 * @param ii integral image of dimension (w+e*2) x (h+e*2) with
141 * an additional zeroed top line and column already
142 * "applied" to the pointer value
143 * @param ii_linesize_32 integral image linesize (in 32-bit integers unit)
144 * @param src source plane buffer
145 * @param linesize source plane linesize
146 * @param offx x-offsetting ranging in [-e;e]
147 * @param offy y-offsetting ranging in [-e;e]
148 * @param w source width
149 * @param h source height
150 * @param e research padding edge
151 */
153 uint32_t *ii, ptrdiff_t ii_linesize_32,
154 const uint8_t *src, ptrdiff_t linesize, int offx, int offy,
155 int e, int w, int h)
156{
157 // ii has a surrounding padding of thickness "e"
158 const int ii_w = w + e*2;
159 const int ii_h = h + e*2;
160
161 // we center the first source
162 const int s1x = e;
163 const int s1y = e;
164
165 // 2nd source is the frame with offsetting
166 const int s2x = e + offx;
167 const int s2y = e + offy;
168
169 // get the dimension of the overlapping rectangle where it is always safe
170 // to compare the 2 sources pixels
171 const int startx_safe = FFMAX(s1x, s2x);
172 const int starty_safe = FFMAX(s1y, s2y);
173 const int u_endx_safe = FFMIN(s1x + w, s2x + w); // unaligned
174 const int endy_safe = FFMIN(s1y + h, s2y + h);
175
176 // deduce the safe area width and height
177 const int safe_pw = (u_endx_safe - startx_safe) & ~0xf;
178 const int safe_ph = endy_safe - starty_safe;
179
180 // adjusted end x position of the safe area after width of the safe area gets aligned
181 const int endx_safe = startx_safe + safe_pw;
182
183 // top part where only one of s1 and s2 is still readable, or none at all
184 compute_unsafe_ssd_integral_image(ii, ii_linesize_32,
185 0, 0,
186 src, linesize,
187 offx, offy, e, w, h,
188 ii_w, starty_safe);
189
190 // fill the left column integral required to compute the central
191 // overlapping one
192 compute_unsafe_ssd_integral_image(ii, ii_linesize_32,
193 0, starty_safe,
194 src, linesize,
195 offx, offy, e, w, h,
196 startx_safe, safe_ph);
197
198 // main and safe part of the integral
199 av_assert1(startx_safe - s1x >= 0); av_assert1(startx_safe - s1x < w);
200 av_assert1(starty_safe - s1y >= 0); av_assert1(starty_safe - s1y < h);
201 av_assert1(startx_safe - s2x >= 0); av_assert1(startx_safe - s2x < w);
202 av_assert1(starty_safe - s2y >= 0); av_assert1(starty_safe - s2y < h);
203 if (safe_pw && safe_ph)
204 dsp->compute_safe_ssd_integral_image(ii + starty_safe*ii_linesize_32 + startx_safe, ii_linesize_32,
205 src + (starty_safe - s1y) * linesize + (startx_safe - s1x), linesize,
206 src + (starty_safe - s2y) * linesize + (startx_safe - s2x), linesize,
207 safe_pw, safe_ph);
208
209 // right part of the integral
210 compute_unsafe_ssd_integral_image(ii, ii_linesize_32,
211 endx_safe, starty_safe,
212 src, linesize,
213 offx, offy, e, w, h,
214 ii_w - endx_safe, safe_ph);
215
216 // bottom part where only one of s1 and s2 is still readable, or none at all
217 compute_unsafe_ssd_integral_image(ii, ii_linesize_32,
218 0, endy_safe,
219 src, linesize,
220 offx, offy, e, w, h,
221 ii_w, ii_h - endy_safe);
222}
223
224static int config_input(AVFilterLink *inlink)
225{
226 AVFilterContext *ctx = inlink->dst;
227 NLMeansContext *s = ctx->priv;
229 const int e = FFMAX(s->research_hsize, s->research_hsize_uv)
230 + FFMAX(s->patch_hsize, s->patch_hsize_uv);
231
232 s->chroma_w = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
233 s->chroma_h = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
234 s->nb_planes = av_pix_fmt_count_planes(inlink->format);
235
236 /* Allocate the integral image with extra edges of thickness "e"
237 *
238 * +_+-------------------------------+
239 * |0|0000000000000000000000000000000|
240 * +-x-------------------------------+
241 * |0|\ ^ |
242 * |0| ii | e |
243 * |0| v |
244 * |0| +-----------------------+ |
245 * |0| | | |
246 * |0|<->| | |
247 * |0| e | | |
248 * |0| | | |
249 * |0| +-----------------------+ |
250 * |0| |
251 * |0| |
252 * |0| |
253 * +-+-------------------------------+
254 */
255 s->ii_w = inlink->w + e*2;
256 s->ii_h = inlink->h + e*2;
257
258 // align to 4 the linesize, "+1" is for the space of the left 0-column
259 s->ii_lz_32 = FFALIGN(s->ii_w + 1, 4);
260
261 // "+1" is for the space of the top 0-line
262 s->ii_orig = av_calloc(s->ii_h + 1, s->ii_lz_32 * sizeof(*s->ii_orig));
263 if (!s->ii_orig)
264 return AVERROR(ENOMEM);
265
266 // skip top 0-line and left 0-column
267 s->ii = s->ii_orig + s->ii_lz_32 + 1;
268
269 // allocate weighted average for every pixel
270 s->linesize = inlink->w + 100;
271 s->total_weight = av_malloc_array(s->linesize, inlink->h * sizeof(*s->total_weight));
272 s->sum = av_malloc_array(s->linesize, inlink->h * sizeof(*s->sum));
273 if (!s->total_weight || !s->sum)
274 return AVERROR(ENOMEM);
275
276 return 0;
277}
278
279struct thread_data {
280 const uint8_t *src;
281 ptrdiff_t src_linesize;
283 int endx, endy;
284 const uint32_t *ii_start;
285 int p;
286};
287
288static int nlmeans_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
289{
290 NLMeansContext *s = ctx->priv;
291 const uint32_t max_meaningful_diff = s->max_meaningful_diff;
292 const struct thread_data *td = arg;
293 const ptrdiff_t src_linesize = td->src_linesize;
294 const int process_h = td->endy - td->starty;
295 const int slice_start = ff_slice_pos(process_h, jobnr, nb_jobs);
296 const int slice_end = ff_slice_pos(process_h, jobnr + 1, nb_jobs);
297 const int starty = td->starty + slice_start;
298 const int endy = td->starty + slice_end;
299 const int p = td->p;
300 const uint32_t *ii = td->ii_start + (starty - p - 1) * s->ii_lz_32 - p - 1;
301 const int dist_b = 2*p + 1;
302 const int dist_d = dist_b * s->ii_lz_32;
303 const int dist_e = dist_d + dist_b;
304 const float *const weight_lut = s->weight_lut;
305 NLMeansDSPContext *dsp = &s->dsp;
306
307 for (int y = starty; y < endy; y++) {
308 const uint8_t *const src = td->src + y*src_linesize;
309 float *total_weight = s->total_weight + y*s->linesize;
310 float *sum = s->sum + y*s->linesize;
311 const uint32_t *const iia = ii;
312 const uint32_t *const iib = ii + dist_b;
313 const uint32_t *const iid = ii + dist_d;
314 const uint32_t *const iie = ii + dist_e;
315
316 dsp->compute_weights_line(iia, iib, iid, iie, src, total_weight, sum,
317 weight_lut, max_meaningful_diff,
318 td->startx, td->endx);
319 ii += s->ii_lz_32;
320 }
321 return 0;
322}
323
324static void weight_averages(uint8_t *dst, ptrdiff_t dst_linesize,
325 const uint8_t *src, ptrdiff_t src_linesize,
326 float *total_weight, float *sum, ptrdiff_t linesize,
327 int w, int h)
328{
329 for (int y = 0; y < h; y++) {
330 for (int x = 0; x < w; x++) {
331 // Also weight the centered pixel
332 total_weight[x] += 1.f;
333 sum[x] += 1.f * src[x];
334 dst[x] = av_clip_uint8(sum[x] / total_weight[x] + 0.5f);
335 }
336 dst += dst_linesize;
337 src += src_linesize;
338 total_weight += linesize;
339 sum += linesize;
340 }
341}
342
343static int nlmeans_plane(AVFilterContext *ctx, int w, int h, int p, int r,
344 uint8_t *dst, ptrdiff_t dst_linesize,
345 const uint8_t *src, ptrdiff_t src_linesize)
346{
347 NLMeansContext *s = ctx->priv;
348 /* patches center points cover the whole research window so the patches
349 * themselves overflow the research window */
350 const int e = r + p;
351 /* focus an integral pointer on the centered image (s1) */
352 const uint32_t *centered_ii = s->ii + e*s->ii_lz_32 + e;
353
354 memset(s->total_weight, 0, s->linesize * h * sizeof(*s->total_weight));
355 memset(s->sum, 0, s->linesize * h * sizeof(*s->sum));
356
357 for (int offy = -r; offy <= r; offy++) {
358 for (int offx = -r; offx <= r; offx++) {
359 if (offx || offy) {
360 struct thread_data td = {
361 .src = src + offy*src_linesize + offx,
362 .src_linesize = src_linesize,
363 .startx = FFMAX(0, -offx),
364 .starty = FFMAX(0, -offy),
365 .endx = FFMIN(w, w - offx),
366 .endy = FFMIN(h, h - offy),
367 .ii_start = centered_ii + offy*s->ii_lz_32 + offx,
368 .p = p,
369 };
370
371 compute_ssd_integral_image(&s->dsp, s->ii, s->ii_lz_32,
373 offx, offy, e, w, h);
376 }
377 }
378 }
379
380 weight_averages(dst, dst_linesize, src, src_linesize,
381 s->total_weight, s->sum, s->linesize, w, h);
382
383 return 0;
384}
385
386static int filter_frame(AVFilterLink *inlink, AVFrame *in)
387{
388 AVFilterContext *ctx = inlink->dst;
389 NLMeansContext *s = ctx->priv;
390 AVFilterLink *outlink = ctx->outputs[0];
391
392 AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
393 if (!out) {
395 return AVERROR(ENOMEM);
396 }
398
399 for (int i = 0; i < s->nb_planes; i++) {
400 const int w = i ? s->chroma_w : inlink->w;
401 const int h = i ? s->chroma_h : inlink->h;
402 const int p = i ? s->patch_hsize_uv : s->patch_hsize;
403 const int r = i ? s->research_hsize_uv : s->research_hsize;
404 nlmeans_plane(ctx, w, h, p, r,
405 out->data[i], out->linesize[i],
406 in->data[i], in->linesize[i]);
407 }
408
410 return ff_filter_frame(outlink, out);
411}
412
413#define CHECK_ODD_FIELD(field, name) do { \
414 if (!(s->field & 1)) { \
415 s->field |= 1; \
416 av_log(ctx, AV_LOG_WARNING, name " size must be odd, " \
417 "setting it to %d\n", s->field); \
418 } \
419} while (0)
420
422{
423 NLMeansContext *s = ctx->priv;
424 const double h = s->sigma * 10.;
425
426 s->pdiff_scale = 1. / (h * h);
427 s->max_meaningful_diff = log(255.) / s->pdiff_scale;
428 s->weight_lut = av_calloc(s->max_meaningful_diff + 1, sizeof(*s->weight_lut));
429 if (!s->weight_lut)
430 return AVERROR(ENOMEM);
431 for (int i = 0; i < s->max_meaningful_diff; i++)
432 s->weight_lut[i] = exp(-i * s->pdiff_scale);
433
434 CHECK_ODD_FIELD(research_size, "Luma research window");
435 CHECK_ODD_FIELD(patch_size, "Luma patch");
436
437 if (!s->research_size_uv) s->research_size_uv = s->research_size;
438 if (!s->patch_size_uv) s->patch_size_uv = s->patch_size;
439
440 CHECK_ODD_FIELD(research_size_uv, "Chroma research window");
441 CHECK_ODD_FIELD(patch_size_uv, "Chroma patch");
442
443 s->research_hsize = s->research_size / 2;
444 s->research_hsize_uv = s->research_size_uv / 2;
445 s->patch_hsize = s->patch_size / 2;
446 s->patch_hsize_uv = s->patch_size_uv / 2;
447
448 av_log(ctx, AV_LOG_DEBUG, "Research window: %dx%d / %dx%d, patch size: %dx%d / %dx%d\n",
449 s->research_size, s->research_size, s->research_size_uv, s->research_size_uv,
450 s->patch_size, s->patch_size, s->patch_size_uv, s->patch_size_uv);
451
452 ff_nlmeans_init(&s->dsp);
453
454 return 0;
455}
456
458{
459 NLMeansContext *s = ctx->priv;
460 av_freep(&s->weight_lut);
461 av_freep(&s->ii_orig);
462 av_freep(&s->total_weight);
463 av_freep(&s->sum);
464}
465
466static const AVFilterPad nlmeans_inputs[] = {
467 {
468 .name = "default",
469 .type = AVMEDIA_TYPE_VIDEO,
470 .config_props = config_input,
471 .filter_frame = filter_frame,
472 },
473};
474
476 .p.name = "nlmeans",
477 .p.description = NULL_IF_CONFIG_SMALL("Non-local means denoiser."),
478 .p.priv_class = &nlmeans_class,
480 .priv_size = sizeof(NLMeansContext),
481 .init = init,
482 .uninit = uninit,
486};
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_nlmeans
Definition vf_nlmeans.c:475
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition avassert.h:58
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition avfilter.c:1696
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition avfilter.c:846
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define FLAGS
Definition cmdutils.c:598
#define AV_CEIL_RSHIFT(a, b)
Definition common.h:60
#define av_clip
Definition common.h:100
#define av_clip_uint8
Definition common.h:106
#define NULL
Definition coverity.c:32
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
int8_t exp
Definition eval.c:76
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition opt.h:266
#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:196
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
#define AVERROR(e)
Definition error.h:45
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition frame.c:599
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define r
Definition input.c:42
static av_cold void uninit(AVBitStreamFilterContext *ctx)
const char * arg
Definition jacosubdec.c:65
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
Definition filters.h:763
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:244
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:478
static void compute_ssd_integral_image(const NLMeansDSPContext *dsp, uint32_t *ii, ptrdiff_t ii_linesize_32, const uint8_t *src, ptrdiff_t linesize, int offx, int offy, int e, int w, int h)
Definition vf_nlmeans.c:152
static int nlmeans_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_nlmeans.c:288
static const AVFilterPad nlmeans_inputs[]
Definition vf_nlmeans.c:466
static int config_input(AVFilterLink *inlink)
Definition vf_nlmeans.c:224
static void weight_averages(uint8_t *dst, ptrdiff_t dst_linesize, const uint8_t *src, ptrdiff_t src_linesize, float *total_weight, float *sum, ptrdiff_t linesize, int w, int h)
Definition vf_nlmeans.c:324
static void compute_unsafe_ssd_integral_image(uint32_t *dst, ptrdiff_t dst_linesize_32, int startx, int starty, const uint8_t *src, ptrdiff_t linesize, int offx, int offy, int r, int sw, int sh, int w, int h)
Compute squared difference of an unsafe area (the zone nor s1 nor s2 could be readable).
Definition vf_nlmeans.c:112
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition vf_nlmeans.c:386
#define CHECK_ODD_FIELD(field, name)
Definition vf_nlmeans.c:413
static av_cold void uninit(AVFilterContext *ctx)
Definition vf_nlmeans.c:457
static const AVOption nlmeans_options[]
Definition vf_nlmeans.c:66
#define OFFSET(x)
Definition vf_nlmeans.c:64
static int nlmeans_plane(AVFilterContext *ctx, int w, int h, int p, int r, uint8_t *dst, ptrdiff_t dst_linesize, const uint8_t *src, ptrdiff_t src_linesize)
Definition vf_nlmeans.c:343
#define av_cold
Definition attributes.h:117
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
const char * desc
Definition libsvtav1.c:83
uint8_t w
Definition llvidencdsp.c:39
#define FFMIN(a, b)
Definition macros.h:49
#define FFMAX(a, b)
Definition macros.h:47
#define FFALIGN(x, a)
Definition macros.h:78
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:264
Memory handling functions.
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
Definition mpeg12dec.c:1697
AVOptions.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3500
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3460
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ 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:107
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ 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:283
@ 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:86
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165
@ 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:87
@ 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:85
Describe the class of an AVClass context structure.
Definition log.h:76
An instance of a filter.
Definition avfilter.h:273
A filter pad used for either input or output.
Definition filters.h:40
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:493
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:517
AVOption.
Definition opt.h:428
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
ptrdiff_t ii_lz_32
Definition vf_nlmeans.c:55
NLMeansDSPContext dsp
Definition vf_nlmeans.c:61
uint32_t * ii_orig
Definition vf_nlmeans.c:52
uint32_t * ii
Definition vf_nlmeans.c:53
double pdiff_scale
Definition vf_nlmeans.c:46
float * weight_lut
Definition vf_nlmeans.c:59
uint32_t max_meaningful_diff
Definition vf_nlmeans.c:60
int research_hsize_uv
Definition vf_nlmeans.c:51
float * total_weight
Definition vf_nlmeans.c:56
void(* compute_safe_ssd_integral_image)(uint32_t *dst, ptrdiff_t dst_linesize_32, const uint8_t *s1, ptrdiff_t linesize1, const uint8_t *s2, ptrdiff_t linesize2, int w, int h)
Definition vf_nlmeans.h:26
void(* compute_weights_line)(const uint32_t *const iia, const uint32_t *const iib, const uint32_t *const iid, const uint32_t *const iie, const uint8_t *const src, float *total_weight, float *sum, const float *const weight_lut, ptrdiff_t max_meaningful_diff, ptrdiff_t startx, ptrdiff_t endx)
Definition vf_nlmeans.h:30
const uint32_t * ii_start
Definition vf_nlmeans.c:284
const uint8_t * src
Definition vf_nlmeans.c:280
ptrdiff_t src_linesize
Definition vf_nlmeans.c:281
AVFrame * in
Definition vf_lut.c:342
#define av_malloc_array(a, b)
#define av_freep(p)
#define av_log(a,...)
#define src
Definition vp8dsp.c:248
static FILE * out
Definition movenc.c:55
static AVFormatContext * ctx
Definition movenc.c:49
static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp)
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:37
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition video.c:89
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
Definition dec.c:844