FFmpeg
vf_hqdn3d.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003 Daniel Moreno <comac AT comac DOT darktech DOT org>
3  * Copyright (c) 2010 Baptiste Coudurier
4  * Copyright (c) 2012 Loren Merritt
5  *
6  * This file is part of FFmpeg, ported from MPlayer.
7  *
8  * FFmpeg is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 /**
24  * @file
25  * high quality 3d video denoiser, ported from MPlayer
26  * libmpcodecs/vf_hqdn3d.c.
27  */
28 
29 #include <float.h>
30 
31 #include "config.h"
32 #include "libavutil/attributes.h"
33 #include "libavutil/common.h"
34 #include "libavutil/pixdesc.h"
35 #include "libavutil/intreadwrite.h"
36 #include "libavutil/opt.h"
37 
38 #include "avfilter.h"
39 #include "formats.h"
40 #include "internal.h"
41 #include "video.h"
42 #include "vf_hqdn3d.h"
43 
44 #define LUT_BITS (depth==16 ? 8 : 4)
45 #define LOAD(x) (((depth == 8 ? src[x] : AV_RN16A(src + (x) * 2)) << (16 - depth))\
46  + (((1 << (16 - depth)) - 1) >> 1))
47 #define STORE(x,val) (depth == 8 ? dst[x] = (val) >> (16 - depth) : \
48  AV_WN16A(dst + (x) * 2, (val) >> (16 - depth)))
49 
51 static uint32_t lowpass(int prev, int cur, int16_t *coef, int depth)
52 {
53  int d = (prev - cur) >> (8 - LUT_BITS);
54  return cur + coef[d];
55 }
56 
58 static void denoise_temporal(uint8_t *src, uint8_t *dst,
59  uint16_t *frame_ant,
60  int w, int h, int sstride, int dstride,
61  int16_t *temporal, int depth)
62 {
63  long x, y;
64  uint32_t tmp;
65 
66  temporal += 256 << LUT_BITS;
67 
68  for (y = 0; y < h; y++) {
69  for (x = 0; x < w; x++) {
70  frame_ant[x] = tmp = lowpass(frame_ant[x], LOAD(x), temporal, depth);
71  STORE(x, tmp);
72  }
73  src += sstride;
74  dst += dstride;
75  frame_ant += w;
76  }
77 }
78 
81  uint8_t *src, uint8_t *dst,
82  uint16_t *line_ant, uint16_t *frame_ant,
83  int w, int h, int sstride, int dstride,
84  int16_t *spatial, int16_t *temporal, int depth)
85 {
86  long x, y;
87  uint32_t pixel_ant;
88  uint32_t tmp;
89 
90  spatial += 256 << LUT_BITS;
91  temporal += 256 << LUT_BITS;
92 
93  /* First line has no top neighbor. Only left one for each tmp and
94  * last frame */
95  pixel_ant = LOAD(0);
96  for (x = 0; x < w; x++) {
97  line_ant[x] = tmp = pixel_ant = lowpass(pixel_ant, LOAD(x), spatial, depth);
98  frame_ant[x] = tmp = lowpass(frame_ant[x], tmp, temporal, depth);
99  STORE(x, tmp);
100  }
101 
102  for (y = 1; y < h; y++) {
103  src += sstride;
104  dst += dstride;
105  frame_ant += w;
106  if (s->denoise_row[depth]) {
107  s->denoise_row[depth](src, dst, line_ant, frame_ant, w, spatial, temporal);
108  continue;
109  }
110  pixel_ant = LOAD(0);
111  for (x = 0; x < w-1; x++) {
112  line_ant[x] = tmp = lowpass(line_ant[x], pixel_ant, spatial, depth);
113  pixel_ant = lowpass(pixel_ant, LOAD(x+1), spatial, depth);
114  frame_ant[x] = tmp = lowpass(frame_ant[x], tmp, temporal, depth);
115  STORE(x, tmp);
116  }
117  line_ant[x] = tmp = lowpass(line_ant[x], pixel_ant, spatial, depth);
118  frame_ant[x] = tmp = lowpass(frame_ant[x], tmp, temporal, depth);
119  STORE(x, tmp);
120  }
121 }
122 
125  uint8_t *src, uint8_t *dst,
126  uint16_t *line_ant, uint16_t **frame_ant_ptr,
127  int w, int h, int sstride, int dstride,
128  int16_t *spatial, int16_t *temporal, int depth)
129 {
130  // FIXME: For 16-bit depth, frame_ant could be a pointer to the previous
131  // filtered frame rather than a separate buffer.
132  long x, y;
133  uint16_t *frame_ant = *frame_ant_ptr;
134  if (!frame_ant) {
135  uint8_t *frame_src = src;
136  *frame_ant_ptr = frame_ant = av_malloc_array(w, h*sizeof(uint16_t));
137  if (!frame_ant)
138  return AVERROR(ENOMEM);
139  for (y = 0; y < h; y++, src += sstride, frame_ant += w)
140  for (x = 0; x < w; x++)
141  frame_ant[x] = LOAD(x);
142  src = frame_src;
143  frame_ant = *frame_ant_ptr;
144  }
145 
146  if (spatial[0])
147  denoise_spatial(s, src, dst, line_ant, frame_ant,
148  w, h, sstride, dstride, spatial, temporal, depth);
149  else
150  denoise_temporal(src, dst, frame_ant,
151  w, h, sstride, dstride, temporal, depth);
152  emms_c();
153  return 0;
154 }
155 
156 #define denoise(...) \
157  do { \
158  int ret = AVERROR_BUG; \
159  switch (s->depth) { \
160  case 8: ret = denoise_depth(__VA_ARGS__, 8); break; \
161  case 9: ret = denoise_depth(__VA_ARGS__, 9); break; \
162  case 10: ret = denoise_depth(__VA_ARGS__, 10); break; \
163  case 12: ret = denoise_depth(__VA_ARGS__, 12); break; \
164  case 14: ret = denoise_depth(__VA_ARGS__, 14); break; \
165  case 16: ret = denoise_depth(__VA_ARGS__, 16); break; \
166  } \
167  if (ret < 0) { \
168  av_frame_free(&out); \
169  if (!direct) \
170  av_frame_free(&in); \
171  return ret; \
172  } \
173  } while (0)
174 
175 static void precalc_coefs(double dist25, int depth, int16_t *ct)
176 {
177  int i;
178  double gamma, simil, C;
179 
180  gamma = log(0.25) / log(1.0 - FFMIN(dist25,252.0)/255.0 - 0.00001);
181 
182  for (i = -(256<<LUT_BITS); i < 256<<LUT_BITS; i++) {
183  double f = ((i<<(9-LUT_BITS)) + (1<<(8-LUT_BITS)) - 1) / 512.0; // midpoint of the bin
184  simil = FFMAX(0, 1.0 - fabs(f) / 255.0);
185  C = pow(simil, gamma) * 256.0 * f;
186  ct[(256<<LUT_BITS)+i] = lrint(C);
187  }
188 
189  ct[0] = !!dist25;
190 }
191 
192 #define PARAM1_DEFAULT 4.0
193 #define PARAM2_DEFAULT 3.0
194 #define PARAM3_DEFAULT 6.0
195 
197 {
198  HQDN3DContext *s = ctx->priv;
199 
200  if (!s->strength[LUMA_SPATIAL])
201  s->strength[LUMA_SPATIAL] = PARAM1_DEFAULT;
202  if (!s->strength[CHROMA_SPATIAL])
203  s->strength[CHROMA_SPATIAL] = PARAM2_DEFAULT * s->strength[LUMA_SPATIAL] / PARAM1_DEFAULT;
204  if (!s->strength[LUMA_TMP])
205  s->strength[LUMA_TMP] = PARAM3_DEFAULT * s->strength[LUMA_SPATIAL] / PARAM1_DEFAULT;
206  if (!s->strength[CHROMA_TMP])
207  s->strength[CHROMA_TMP] = s->strength[LUMA_TMP] * s->strength[CHROMA_SPATIAL] / s->strength[LUMA_SPATIAL];
208 
209  av_log(ctx, AV_LOG_VERBOSE, "ls:%f cs:%f lt:%f ct:%f\n",
210  s->strength[LUMA_SPATIAL], s->strength[CHROMA_SPATIAL],
211  s->strength[LUMA_TMP], s->strength[CHROMA_TMP]);
212 
213  return 0;
214 }
215 
217 {
218  HQDN3DContext *s = ctx->priv;
219 
220  av_freep(&s->coefs[0]);
221  av_freep(&s->coefs[1]);
222  av_freep(&s->coefs[2]);
223  av_freep(&s->coefs[3]);
224  av_freep(&s->line[0]);
225  av_freep(&s->line[1]);
226  av_freep(&s->line[2]);
227  av_freep(&s->frame_prev[0]);
228  av_freep(&s->frame_prev[1]);
229  av_freep(&s->frame_prev[2]);
230 }
231 
233 {
234  static const enum AVPixelFormat pix_fmts[] = {
246  };
248 }
249 
251 {
252  HQDN3DContext *s = ctx->priv;
253 
254  for (int i = 0; i < 4; i++)
255  precalc_coefs(s->strength[i], s->depth, s->coefs[i]);
256 }
257 
259 {
260  AVFilterContext *ctx = inlink->dst;
261  HQDN3DContext *s = inlink->dst->priv;
263  int i, depth;
264 
265  uninit(inlink->dst);
266 
267  s->hsub = desc->log2_chroma_w;
268  s->vsub = desc->log2_chroma_h;
269  s->depth = depth = desc->comp[0].depth;
270 
271  for (i = 0; i < 3; i++) {
272  s->line[i] = av_malloc_array(inlink->w, sizeof(*s->line[i]));
273  if (!s->line[i])
274  return AVERROR(ENOMEM);
275  }
276 
277  for (i = 0; i < 4; i++) {
278  s->coefs[i] = av_malloc((512<<LUT_BITS) * sizeof(int16_t));
279  if (!s->coefs[i])
280  return AVERROR(ENOMEM);
281  }
282 
283  calc_coefs(ctx);
284 
285  if (ARCH_X86)
287 
288  return 0;
289 }
290 
291 typedef struct ThreadData {
292  AVFrame *in, *out;
293  int direct;
294 } ThreadData;
295 
296 static int do_denoise(AVFilterContext *ctx, void *data, int job_nr, int n_jobs)
297 {
298  HQDN3DContext *s = ctx->priv;
299  const ThreadData *td = data;
300  AVFrame *out = td->out;
301  AVFrame *in = td->in;
302  int direct = td->direct;
303 
304  denoise(s, in->data[job_nr], out->data[job_nr],
305  s->line[job_nr], &s->frame_prev[job_nr],
306  AV_CEIL_RSHIFT(in->width, (!!job_nr * s->hsub)),
307  AV_CEIL_RSHIFT(in->height, (!!job_nr * s->vsub)),
308  in->linesize[job_nr], out->linesize[job_nr],
309  s->coefs[job_nr ? CHROMA_SPATIAL : LUMA_SPATIAL],
310  s->coefs[job_nr ? CHROMA_TMP : LUMA_TMP]);
311 
312  return 0;
313 }
314 
316 {
317  AVFilterContext *ctx = inlink->dst;
318  AVFilterLink *outlink = ctx->outputs[0];
319 
320  AVFrame *out;
321  int direct = av_frame_is_writable(in) && !ctx->is_disabled;
322  ThreadData td;
323 
324  if (direct) {
325  out = in;
326  } else {
327  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
328  if (!out) {
329  av_frame_free(&in);
330  return AVERROR(ENOMEM);
331  }
332 
334  }
335 
336  td.in = in;
337  td.out = out;
338  td.direct = direct;
339  /* one thread per plane */
341 
342  if (ctx->is_disabled) {
343  av_frame_free(&out);
344  return ff_filter_frame(outlink, in);
345  }
346 
347  if (!direct)
348  av_frame_free(&in);
349 
350  return ff_filter_frame(outlink, out);
351 }
352 
353 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
354  char *res, int res_len, int flags)
355 {
356  int ret;
357 
358  ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
359  if (ret < 0)
360  return ret;
361 
362  calc_coefs(ctx);
363 
364  return 0;
365 }
366 
367 #define OFFSET(x) offsetof(HQDN3DContext, x)
368 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
369 static const AVOption hqdn3d_options[] = {
370  { "luma_spatial", "spatial luma strength", OFFSET(strength[LUMA_SPATIAL]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
371  { "chroma_spatial", "spatial chroma strength", OFFSET(strength[CHROMA_SPATIAL]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
372  { "luma_tmp", "temporal luma strength", OFFSET(strength[LUMA_TMP]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
373  { "chroma_tmp", "temporal chroma strength", OFFSET(strength[CHROMA_TMP]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
374  { NULL }
375 };
376 
377 AVFILTER_DEFINE_CLASS(hqdn3d);
378 
380  {
381  .name = "default",
382  .type = AVMEDIA_TYPE_VIDEO,
383  .config_props = config_input,
384  .filter_frame = filter_frame,
385  },
386 };
387 
388 
390  {
391  .name = "default",
392  .type = AVMEDIA_TYPE_VIDEO
393  },
394 };
395 
397  .name = "hqdn3d",
398  .description = NULL_IF_CONFIG_SMALL("Apply a High Quality 3D Denoiser."),
399  .priv_size = sizeof(HQDN3DContext),
400  .priv_class = &hqdn3d_class,
401  .init = init,
402  .uninit = uninit,
407  .process_command = process_command,
408 };
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_hqdn3d.c:196
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:98
vf_hqdn3d.h
direct
static void direct(const float *in, const FFTComplex *ir, int len, float *out)
Definition: af_afir.c:61
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
LOAD
#define LOAD(x)
Definition: vf_hqdn3d.c:45
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:1017
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2540
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
LUT_BITS
#define LUT_BITS
Definition: vf_hqdn3d.c:44
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:112
PARAM2_DEFAULT
#define PARAM2_DEFAULT
Definition: vf_hqdn3d.c:193
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:26
pixdesc.h
AVFrame::width
int width
Definition: frame.h:361
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:247
data
const char data[16]
Definition: mxf.c:143
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:389
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
float.h
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
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:153
ThreadData::out
AVFrame * out
Definition: af_adeclick.c:492
video.h
lowpass
static av_always_inline uint32_t lowpass(int prev, int cur, int16_t *coef, int depth)
Definition: vf_hqdn3d.c:51
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:317
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_hqdn3d.c:258
formats.h
STORE
#define STORE(x, val)
Definition: vf_hqdn3d.c:47
ff_hqdn3d_init_x86
void ff_hqdn3d_init_x86(HQDN3DContext *hqdn3d)
Definition: vf_hqdn3d_init.c:41
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:387
FLAGS
#define FLAGS
Definition: vf_hqdn3d.c:368
OFFSET
#define OFFSET(x)
Definition: vf_hqdn3d.c:367
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
PARAM3_DEFAULT
#define PARAM3_DEFAULT
Definition: vf_hqdn3d.c:194
CHROMA_TMP
#define CHROMA_TMP
Definition: vf_hqdn3d.h:45
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:392
C
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going which in turn will define variables for the build system and the C
Definition: writing_filters.txt:58
lrint
#define lrint
Definition: tablegen.h:53
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:401
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
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_hqdn3d.c:232
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:402
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:51
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_hqdn3d.c:216
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:226
ThreadData::direct
int direct
Definition: vf_hqdn3d.c:293
ff_set_common_formats_from_list
int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts)
Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))
Definition: formats.c:703
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:290
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:386
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:400
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
f
#define f(width, name)
Definition: cbs_vp9.c:255
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:152
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
fabs
static __device__ float fabs(float a)
Definition: cuda_runtime.h:182
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:537
avfilter_vf_hqdn3d_inputs
static const AVFilterPad avfilter_vf_hqdn3d_inputs[]
Definition: vf_hqdn3d.c:379
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
src
#define src
Definition: vp8dsp.c:255
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:391
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:390
PARAM1_DEFAULT
#define PARAM1_DEFAULT
Definition: vf_hqdn3d.c:192
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
LUMA_SPATIAL
#define LUMA_SPATIAL
Definition: vf_hqdn3d.h:42
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:394
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(hqdn3d)
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:396
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:473
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:883
denoise_temporal
static av_always_inline void denoise_temporal(uint8_t *src, uint8_t *dst, uint16_t *frame_ant, int w, int h, int sstride, int dstride, int16_t *temporal, int depth)
Definition: vf_hqdn3d.c:58
hqdn3d_options
static const AVOption hqdn3d_options[]
Definition: vf_hqdn3d.c:369
do_denoise
static int do_denoise(AVFilterContext *ctx, void *data, int job_nr, int n_jobs)
Definition: vf_hqdn3d.c:296
attributes.h
precalc_coefs
static void precalc_coefs(double dist25, int depth, int16_t *ct)
Definition: vf_hqdn3d.c:175
internal.h
denoise
#define denoise(...)
Definition: vf_hqdn3d.c:156
i
int i
Definition: input.c:406
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
common.h
ThreadData
Used for passing data between threads.
Definition: dsddec.c:67
av_always_inline
#define av_always_inline
Definition: attributes.h:49
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:100
denoise_spatial
static av_always_inline void denoise_spatial(HQDN3DContext *s, uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, int w, int h, int sstride, int dstride, int16_t *spatial, int16_t *temporal, int depth)
Definition: vf_hqdn3d.c:80
LUMA_TMP
#define LUMA_TMP
Definition: vf_hqdn3d.h:43
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:388
CHROMA_SPATIAL
#define CHROMA_SPATIAL
Definition: vf_hqdn3d.h:44
AVFilter
Filter definition.
Definition: avfilter.h:149
ret
ret
Definition: filter_design.txt:187
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:393
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:398
ff_vf_hqdn3d
const AVFilter ff_vf_hqdn3d
Definition: vf_hqdn3d.c:396
AVFrame::height
int height
Definition: frame.h:361
avfilter_vf_hqdn3d_outputs
static const AVFilterPad avfilter_vf_hqdn3d_outputs[]
Definition: vf_hqdn3d.c:389
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
avfilter.h
HQDN3DContext
Definition: vf_hqdn3d.h:31
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:346
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:121
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
ThreadData::in
AVFrame * in
Definition: af_adecorrelate.c:171
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_hqdn3d.c:315
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:153
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
denoise_depth
static av_always_inline int denoise_depth(HQDN3DContext *s, uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t **frame_ant_ptr, int w, int h, int sstride, int dstride, int16_t *spatial, int16_t *temporal, int depth)
Definition: vf_hqdn3d.c:124
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
d
d
Definition: ffmpeg_filter.c:156
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:138
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:334
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:395
h
h
Definition: vp9dsp_template.c:2038
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:399
calc_coefs
static void calc_coefs(AVFilterContext *ctx)
Definition: vf_hqdn3d.c:250
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:143
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_hqdn3d.c:353
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:397