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/emms.h"
35 #include "libavutil/mem.h"
36 #include "libavutil/pixdesc.h"
37 #include "libavutil/intreadwrite.h"
38 #include "libavutil/opt.h"
39 
40 #include "avfilter.h"
41 #include "filters.h"
42 #include "video.h"
43 #include "vf_hqdn3d.h"
44 
45 #define LUT_BITS (depth==16 ? 8 : 4)
46 #define LOAD(x) (((depth == 8 ? src[x] : AV_RN16A(src + (x) * 2)) << (16 - depth))\
47  + (((1 << (16 - depth)) - 1) >> 1))
48 #define STORE(x,val) (depth == 8 ? dst[x] = (val) >> (16 - depth) : \
49  AV_WN16A(dst + (x) * 2, (val) >> (16 - depth)))
50 
52 static uint32_t lowpass(int prev, int cur, int16_t *coef, int depth)
53 {
54  int d = (prev - cur) >> (8 - LUT_BITS);
55  return cur + coef[d];
56 }
57 
59 static void denoise_temporal(uint8_t *src, uint8_t *dst,
60  uint16_t *frame_ant,
61  int w, int h, int sstride, int dstride,
62  int16_t *temporal, int depth)
63 {
64  long x, y;
65  uint32_t tmp;
66 
67  temporal += 256 << LUT_BITS;
68 
69  for (y = 0; y < h; y++) {
70  for (x = 0; x < w; x++) {
71  frame_ant[x] = tmp = lowpass(frame_ant[x], LOAD(x), temporal, depth);
72  STORE(x, tmp);
73  }
74  src += sstride;
75  dst += dstride;
76  frame_ant += w;
77  }
78 }
79 
82  uint8_t *src, uint8_t *dst,
83  uint16_t *line_ant, uint16_t *frame_ant,
84  int w, int h, int sstride, int dstride,
85  int16_t *spatial, int16_t *temporal, int depth)
86 {
87  long x, y;
88  uint32_t pixel_ant;
89  uint32_t tmp;
90 
91  spatial += 256 << LUT_BITS;
92  temporal += 256 << LUT_BITS;
93 
94  /* First line has no top neighbor. Only left one for each tmp and
95  * last frame */
96  pixel_ant = LOAD(0);
97  for (x = 0; x < w; x++) {
98  line_ant[x] = tmp = pixel_ant = lowpass(pixel_ant, LOAD(x), spatial, depth);
99  frame_ant[x] = tmp = lowpass(frame_ant[x], tmp, temporal, depth);
100  STORE(x, tmp);
101  }
102 
103  for (y = 1; y < h; y++) {
104  src += sstride;
105  dst += dstride;
106  frame_ant += w;
107  if (s->denoise_row[depth]) {
108  s->denoise_row[depth](src, dst, line_ant, frame_ant, w, spatial, temporal);
109  continue;
110  }
111  pixel_ant = LOAD(0);
112  for (x = 0; x < w-1; x++) {
113  line_ant[x] = tmp = lowpass(line_ant[x], pixel_ant, spatial, depth);
114  pixel_ant = lowpass(pixel_ant, LOAD(x+1), spatial, depth);
115  frame_ant[x] = tmp = lowpass(frame_ant[x], tmp, temporal, depth);
116  STORE(x, tmp);
117  }
118  line_ant[x] = tmp = lowpass(line_ant[x], pixel_ant, spatial, depth);
119  frame_ant[x] = tmp = lowpass(frame_ant[x], tmp, temporal, depth);
120  STORE(x, tmp);
121  }
122 }
123 
126  uint8_t *src, uint8_t *dst,
127  uint16_t *line_ant, uint16_t **frame_ant_ptr,
128  int w, int h, int sstride, int dstride,
129  int16_t *spatial, int16_t *temporal, int depth)
130 {
131  // FIXME: For 16-bit depth, frame_ant could be a pointer to the previous
132  // filtered frame rather than a separate buffer.
133  long x, y;
134  uint16_t *frame_ant = *frame_ant_ptr;
135  if (!frame_ant) {
136  uint8_t *frame_src = src;
137  *frame_ant_ptr = frame_ant = av_malloc_array(w, h*sizeof(uint16_t));
138  if (!frame_ant)
139  return AVERROR(ENOMEM);
140  for (y = 0; y < h; y++, src += sstride, frame_ant += w)
141  for (x = 0; x < w; x++)
142  frame_ant[x] = LOAD(x);
143  src = frame_src;
144  frame_ant = *frame_ant_ptr;
145  }
146 
147  if (spatial[0])
148  denoise_spatial(s, src, dst, line_ant, frame_ant,
149  w, h, sstride, dstride, spatial, temporal, depth);
150  else
151  denoise_temporal(src, dst, frame_ant,
152  w, h, sstride, dstride, temporal, depth);
153  emms_c();
154  return 0;
155 }
156 
157 #define denoise(...) \
158  do { \
159  int ret = AVERROR_BUG; \
160  switch (s->depth) { \
161  case 8: ret = denoise_depth(__VA_ARGS__, 8); break; \
162  case 9: ret = denoise_depth(__VA_ARGS__, 9); break; \
163  case 10: ret = denoise_depth(__VA_ARGS__, 10); break; \
164  case 12: ret = denoise_depth(__VA_ARGS__, 12); break; \
165  case 14: ret = denoise_depth(__VA_ARGS__, 14); break; \
166  case 16: ret = denoise_depth(__VA_ARGS__, 16); break; \
167  } \
168  if (ret < 0) { \
169  av_frame_free(&out); \
170  if (!direct) \
171  av_frame_free(&in); \
172  return ret; \
173  } \
174  } while (0)
175 
176 static void precalc_coefs(double dist25, int depth, int16_t *ct)
177 {
178  int i;
179  double gamma, simil, C;
180 
181  gamma = log(0.25) / log(1.0 - FFMIN(dist25,252.0)/255.0 - 0.00001);
182 
183  for (i = -(256<<LUT_BITS); i < 256<<LUT_BITS; i++) {
184  double f = (i * (1 << (9-LUT_BITS)) + (1<<(8-LUT_BITS)) - 1) / 512.0; // midpoint of the bin
185  simil = FFMAX(0, 1.0 - fabs(f) / 255.0);
186  C = pow(simil, gamma) * 256.0 * f;
187  ct[(256<<LUT_BITS)+i] = lrint(C);
188  }
189 
190  ct[0] = !!dist25;
191 }
192 
193 #define PARAM1_DEFAULT 4.0
194 #define PARAM2_DEFAULT 3.0
195 #define PARAM3_DEFAULT 6.0
196 
198 {
199  HQDN3DContext *s = ctx->priv;
200 
201  if (!s->strength[LUMA_SPATIAL])
202  s->strength[LUMA_SPATIAL] = PARAM1_DEFAULT;
203  if (!s->strength[CHROMA_SPATIAL])
204  s->strength[CHROMA_SPATIAL] = PARAM2_DEFAULT * s->strength[LUMA_SPATIAL] / PARAM1_DEFAULT;
205  if (!s->strength[LUMA_TMP])
206  s->strength[LUMA_TMP] = PARAM3_DEFAULT * s->strength[LUMA_SPATIAL] / PARAM1_DEFAULT;
207  if (!s->strength[CHROMA_TMP])
208  s->strength[CHROMA_TMP] = s->strength[LUMA_TMP] * s->strength[CHROMA_SPATIAL] / s->strength[LUMA_SPATIAL];
209 
210  av_log(ctx, AV_LOG_VERBOSE, "ls:%f cs:%f lt:%f ct:%f\n",
211  s->strength[LUMA_SPATIAL], s->strength[CHROMA_SPATIAL],
212  s->strength[LUMA_TMP], s->strength[CHROMA_TMP]);
213 
214  return 0;
215 }
216 
218 {
219  HQDN3DContext *s = ctx->priv;
220 
221  av_freep(&s->coefs[0]);
222  av_freep(&s->coefs[1]);
223  av_freep(&s->coefs[2]);
224  av_freep(&s->coefs[3]);
225  av_freep(&s->line[0]);
226  av_freep(&s->line[1]);
227  av_freep(&s->line[2]);
228  av_freep(&s->frame_prev[0]);
229  av_freep(&s->frame_prev[1]);
230  av_freep(&s->frame_prev[2]);
231 }
232 
233 static const enum AVPixelFormat pix_fmts[] = {
245 };
246 
248 {
249  HQDN3DContext *s = ctx->priv;
250 
251  for (int i = 0; i < 4; i++)
252  precalc_coefs(s->strength[i], s->depth, s->coefs[i]);
253 }
254 
256 {
257  AVFilterContext *ctx = inlink->dst;
258  HQDN3DContext *s = inlink->dst->priv;
260  int i, depth;
261 
262  uninit(inlink->dst);
263 
264  s->hsub = desc->log2_chroma_w;
265  s->vsub = desc->log2_chroma_h;
266  s->depth = depth = desc->comp[0].depth;
267 
268  for (i = 0; i < 3; i++) {
269  s->line[i] = av_malloc_array(inlink->w, sizeof(*s->line[i]));
270  if (!s->line[i])
271  return AVERROR(ENOMEM);
272  }
273 
274  for (i = 0; i < 4; i++) {
275  s->coefs[i] = av_malloc((512<<LUT_BITS) * sizeof(int16_t));
276  if (!s->coefs[i])
277  return AVERROR(ENOMEM);
278  }
279 
280  calc_coefs(ctx);
281 
282 #if ARCH_X86
284 #endif
285 
286  return 0;
287 }
288 
289 typedef struct ThreadData {
290  AVFrame *in, *out;
291  int direct;
292 } ThreadData;
293 
294 static int do_denoise(AVFilterContext *ctx, void *data, int job_nr, int n_jobs)
295 {
296  HQDN3DContext *s = ctx->priv;
297  const ThreadData *td = data;
298  AVFrame *out = td->out;
299  AVFrame *in = td->in;
300  int direct = td->direct;
301 
302  denoise(s, in->data[job_nr], out->data[job_nr],
303  s->line[job_nr], &s->frame_prev[job_nr],
304  AV_CEIL_RSHIFT(in->width, (!!job_nr * s->hsub)),
305  AV_CEIL_RSHIFT(in->height, (!!job_nr * s->vsub)),
306  in->linesize[job_nr], out->linesize[job_nr],
307  s->coefs[job_nr ? CHROMA_SPATIAL : LUMA_SPATIAL],
308  s->coefs[job_nr ? CHROMA_TMP : LUMA_TMP]);
309 
310  return 0;
311 }
312 
314 {
315  AVFilterContext *ctx = inlink->dst;
316  AVFilterLink *outlink = ctx->outputs[0];
317 
318  AVFrame *out;
319  int direct = av_frame_is_writable(in) && !ctx->is_disabled;
320  ThreadData td;
321 
322  if (direct) {
323  out = in;
324  } else {
325  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
326  if (!out) {
327  av_frame_free(&in);
328  return AVERROR(ENOMEM);
329  }
330 
332  }
333 
334  td.in = in;
335  td.out = out;
336  td.direct = direct;
337  /* one thread per plane */
339 
340  if (ctx->is_disabled) {
341  av_frame_free(&out);
342  return ff_filter_frame(outlink, in);
343  }
344 
345  if (!direct)
346  av_frame_free(&in);
347 
348  return ff_filter_frame(outlink, out);
349 }
350 
351 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
352  char *res, int res_len, int flags)
353 {
354  int ret;
355 
356  ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
357  if (ret < 0)
358  return ret;
359 
360  calc_coefs(ctx);
361 
362  return 0;
363 }
364 
365 #define OFFSET(x) offsetof(HQDN3DContext, x)
366 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
367 static const AVOption hqdn3d_options[] = {
368  { "luma_spatial", "spatial luma strength", OFFSET(strength[LUMA_SPATIAL]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
369  { "chroma_spatial", "spatial chroma strength", OFFSET(strength[CHROMA_SPATIAL]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
370  { "luma_tmp", "temporal luma strength", OFFSET(strength[LUMA_TMP]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
371  { "chroma_tmp", "temporal chroma strength", OFFSET(strength[CHROMA_TMP]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
372  { NULL }
373 };
374 
375 AVFILTER_DEFINE_CLASS(hqdn3d);
376 
378  {
379  .name = "default",
380  .type = AVMEDIA_TYPE_VIDEO,
381  .config_props = config_input,
382  .filter_frame = filter_frame,
383  },
384 };
385 
386 
388  .name = "hqdn3d",
389  .description = NULL_IF_CONFIG_SMALL("Apply a High Quality 3D Denoiser."),
390  .priv_size = sizeof(HQDN3DContext),
391  .priv_class = &hqdn3d_class,
392  .init = init,
393  .uninit = uninit,
398  .process_command = process_command,
399 };
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_hqdn3d.c:197
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:116
vf_hqdn3d.h
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
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:46
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
out
FILE * out
Definition: movenc.c:55
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1062
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3170
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
normalize.log
log
Definition: normalize.py:21
LUT_BITS
#define LUT_BITS
Definition: vf_hqdn3d.c:45
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:162
PARAM2_DEFAULT
#define PARAM2_DEFAULT
Definition: vf_hqdn3d.c:194
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
pixdesc.h
AVFrame::width
int width
Definition: frame.h:461
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:429
data
const char data[16]
Definition: mxf.c:149
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:502
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:225
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:106
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
ThreadData::out
AVFrame * out
Definition: af_adeclick.c:526
video.h
lowpass
static av_always_inline uint32_t lowpass(int prev, int cur, int16_t *coef, int depth)
Definition: vf_hqdn3d.c:52
ThreadData::in
AVFrame * in
Definition: af_adecorrelate.c:155
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:410
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_hqdn3d.c:255
STORE
#define STORE(x, val)
Definition: vf_hqdn3d.c:48
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:500
FLAGS
#define FLAGS
Definition: vf_hqdn3d.c:366
OFFSET
#define OFFSET(x)
Definition: vf_hqdn3d.c:365
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
PARAM3_DEFAULT
#define PARAM3_DEFAULT
Definition: vf_hqdn3d.c:195
CHROMA_TMP
#define CHROMA_TMP
Definition: vf_hqdn3d.h:45
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:505
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:514
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:37
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:86
emms_c
#define emms_c()
Definition: emms.h:63
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:515
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:60
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_hqdn3d.c:217
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition: opt.h:267
ThreadData::direct
int direct
Definition: vf_hqdn3d.c:291
filters.h
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:499
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:513
ctx
AVFormatContext * ctx
Definition: movenc.c:49
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:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
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:87
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:713
avfilter_vf_hqdn3d_inputs
static const AVFilterPad avfilter_vf_hqdn3d_inputs[]
Definition: vf_hqdn3d.c:377
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:85
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:504
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:503
PARAM1_DEFAULT
#define PARAM1_DEFAULT
Definition: vf_hqdn3d.c:193
f
f
Definition: af_crystalizer.c:122
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:94
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
LUMA_SPATIAL
#define LUMA_SPATIAL
Definition: vf_hqdn3d.h:42
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:507
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(hqdn3d)
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:509
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:649
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:901
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:59
hqdn3d_options
static const AVOption hqdn3d_options[]
Definition: vf_hqdn3d.c:367
do_denoise
static int do_denoise(AVFilterContext *ctx, void *data, int job_nr, int n_jobs)
Definition: vf_hqdn3d.c:294
attributes.h
precalc_coefs
static void precalc_coefs(double dist25, int depth, int16_t *ct)
Definition: vf_hqdn3d.c:176
denoise
#define denoise(...)
Definition: vf_hqdn3d.c:157
emms.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:31
common.h
ThreadData
Used for passing data between threads.
Definition: dsddec.c:71
av_always_inline
#define av_always_inline
Definition: attributes.h:49
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_hqdn3d.c:233
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:107
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:81
LUMA_TMP
#define LUMA_TMP
Definition: vf_hqdn3d.h:43
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:501
CHROMA_SPATIAL
#define CHROMA_SPATIAL
Definition: vf_hqdn3d.h:44
AVFilter
Filter definition.
Definition: avfilter.h:201
ret
ret
Definition: filter_design.txt:187
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:506
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:511
ff_vf_hqdn3d
const AVFilter ff_vf_hqdn3d
Definition: vf_hqdn3d.c:387
AVFrame::height
int height
Definition: frame.h:461
ff_filter_execute
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: avfilter.c:1667
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
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:78
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
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:152
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:77
mem.h
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:313
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
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:125
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:80
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:190
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
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:434
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:79
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:508
h
h
Definition: vp9dsp_template.c:2070
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:512
calc_coefs
static void calc_coefs(AVFilterContext *ctx)
Definition: vf_hqdn3d.c:247
src
#define src
Definition: vp8dsp.c:248
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:351
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:510