vf_hqdn3d.c File Reference

high quality 3d video denoiser, ported from MPlayer libmpcodecs/vf_hqdn3d.c. More...

#include <float.h>
#include "config.h"
#include "libavutil/common.h"
#include "libavutil/pixdesc.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
#include "vf_hqdn3d.h"
Include dependency graph for vf_hqdn3d.c:

Go to the source code of this file.

Macros

#define LUT_BITS   (depth==16 ? 8 : 4)
 
#define LOAD(x)
 
#define STORE(x, val)
 
#define denoise(...)
 
#define PARAM1_DEFAULT   4.0
 
#define PARAM2_DEFAULT   3.0
 
#define PARAM3_DEFAULT   6.0
 
#define OFFSET(x)   offsetof(HQDN3DContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
 

Functions

static av_always_inline uint32_t lowpass (int prev, int cur, int16_t *coef, int depth)
 
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)
 
static av_always_inline void denoise_spatial (HQDN3DContext *hqdn3d, 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)
 
static av_always_inline void denoise_depth (HQDN3DContext *hqdn3d, 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)
 
static int16_t * precalc_coefs (double dist25, int depth)
 
static int init (AVFilterContext *ctx)
 
static void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 

Variables

static const AVOption options []
 
static const AVClass hqdn3d_class
 
static const AVFilterPad avfilter_vf_hqdn3d_inputs []
 
static const AVFilterPad avfilter_vf_hqdn3d_outputs []
 
AVFilter avfilter_vf_hqdn3d
 

Detailed Description

high quality 3d video denoiser, ported from MPlayer libmpcodecs/vf_hqdn3d.c.

Definition in file vf_hqdn3d.c.

Macro Definition Documentation

#define denoise (   ...)
Value:
switch (hqdn3d->depth) {\
case 8: denoise_depth(__VA_ARGS__, 8); break;\
case 9: denoise_depth(__VA_ARGS__, 9); break;\
case 10: denoise_depth(__VA_ARGS__, 10); break;\
case 16: denoise_depth(__VA_ARGS__, 16); break;\
}
static av_always_inline void denoise_depth(HQDN3DContext *hqdn3d, 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:123

Definition at line 151 of file vf_hqdn3d.c.

Referenced by filter_frame().

Definition at line 312 of file vf_hqdn3d.c.

#define LOAD (   x)
Value:
(((depth == 8 ? src[x] : AV_RN16A(src + (x) * 2)) << (16 - depth))\
+ (((1 << (16 - depth)) - 1) >> 1))
Discrete Time axis x
int depth
Definition: v4l.c:62
AVS_Value src
Definition: avisynth_c.h:523
#define AV_RN16A(p)
Definition: intreadwrite.h:514

Definition at line 44 of file vf_hqdn3d.c.

Referenced by denoise_depth(), denoise_spatial(), and denoise_temporal().

#define LUT_BITS   (depth==16 ? 8 : 4)

Definition at line 43 of file vf_hqdn3d.c.

Referenced by denoise_spatial(), denoise_temporal(), lowpass(), and precalc_coefs().

#define OFFSET (   x)    offsetof(HQDN3DContext, x)

Definition at line 311 of file vf_hqdn3d.c.

#define PARAM1_DEFAULT   4.0

Definition at line 180 of file vf_hqdn3d.c.

Referenced by init().

#define PARAM2_DEFAULT   3.0

Definition at line 181 of file vf_hqdn3d.c.

Referenced by init().

#define PARAM3_DEFAULT   6.0

Definition at line 182 of file vf_hqdn3d.c.

Referenced by init().

#define STORE (   x,
  val 
)
Value:
(depth == 8 ? dst[x] = (val) >> (16 - depth) : \
AV_WN16A(dst + (x) * 2, (val) >> (16 - depth)))
Discrete Time axis x
int depth
Definition: v4l.c:62
#define AV_WN16A(p, v)
Definition: intreadwrite.h:526
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160

Definition at line 46 of file vf_hqdn3d.c.

Referenced by denoise_spatial(), and denoise_temporal().

Function Documentation

static int config_input ( AVFilterLink inlink)
static

Definition at line 248 of file vf_hqdn3d.c.

static av_always_inline void denoise_depth ( HQDN3DContext hqdn3d,
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 
)
static

Definition at line 123 of file vf_hqdn3d.c.

static av_always_inline void denoise_spatial ( HQDN3DContext hqdn3d,
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 
)
static

Definition at line 79 of file vf_hqdn3d.c.

Referenced by denoise_depth().

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 
)
static

Definition at line 57 of file vf_hqdn3d.c.

Referenced by denoise_depth().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 274 of file vf_hqdn3d.c.

static int init ( AVFilterContext ctx)
static

Definition at line 184 of file vf_hqdn3d.c.

static av_always_inline uint32_t lowpass ( int  prev,
int  cur,
int16_t *  coef,
int  depth 
)
static

Definition at line 50 of file vf_hqdn3d.c.

Referenced by denoise_spatial(), and denoise_temporal().

static int16_t* precalc_coefs ( double  dist25,
int  depth 
)
static

Definition at line 159 of file vf_hqdn3d.c.

Referenced by config_input().

static int query_formats ( AVFilterContext ctx)
static

Definition at line 218 of file vf_hqdn3d.c.

static void uninit ( AVFilterContext ctx)
static

Definition at line 204 of file vf_hqdn3d.c.

Variable Documentation

AVFilter avfilter_vf_hqdn3d
Initial value:
= {
.name = "hqdn3d",
.description = NULL_IF_CONFIG_SMALL("Apply a High Quality 3D Denoiser."),
.priv_size = sizeof(HQDN3DContext),
.priv_class = &hqdn3d_class,
.init = init,
}
static const AVFilterPad avfilter_vf_hqdn3d_inputs[]
Definition: vf_hqdn3d.c:328
static const AVFilterPad avfilter_vf_hqdn3d_outputs[]
Definition: vf_hqdn3d.c:339
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
static int init(AVFilterContext *ctx)
Definition: vf_hqdn3d.c:184
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static void uninit(AVFilterContext *ctx)
Definition: vf_hqdn3d.c:204
static const AVClass hqdn3d_class
Definition: vf_hqdn3d.c:321
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
static int query_formats(AVFilterContext *ctx)
Definition: vf_hqdn3d.c:218

Definition at line 347 of file vf_hqdn3d.c.

const AVFilterPad avfilter_vf_hqdn3d_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
{ NULL }
}
static int config_input(AVFilterLink *inlink)
Definition: vf_hqdn3d.c:248
NULL
Definition: eval.c:55
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_hqdn3d.c:274

Definition at line 328 of file vf_hqdn3d.c.

const AVFilterPad avfilter_vf_hqdn3d_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
NULL
Definition: eval.c:55

Definition at line 339 of file vf_hqdn3d.c.

const AVClass hqdn3d_class
static
Initial value:
= {
.class_name = "hqdn3d",
.item_name = av_default_item_name,
.option = options,
}
static const AVOption options[]
Definition: vf_hqdn3d.c:313
av_default_item_name
LIBAVUTIL_VERSION_INT
Definition: eval.c:55

Definition at line 321 of file vf_hqdn3d.c.

const AVOption options[]
static
Initial value:
= {
{ "luma_spatial", "spatial luma strength", OFFSET(strength[LUMA_SPATIAL]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
{ "chroma_spatial", "spatial chroma strength", OFFSET(strength[CHROMA_SPATIAL]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
{ "luma_tmp", "temporal luma strength", OFFSET(strength[LUMA_TMP]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
{ "chroma_tmp", "temporal chroma strength", OFFSET(strength[CHROMA_TMP]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS },
{ NULL },
}
#define LUMA_SPATIAL
Definition: vf_hqdn3d.h:42
#define FLAGS
Definition: vf_hqdn3d.c:312
#define CHROMA_SPATIAL
Definition: vf_hqdn3d.h:44
#define OFFSET(x)
Definition: vf_hqdn3d.c:311
NULL
Definition: eval.c:55
#define LUMA_TMP
Definition: vf_hqdn3d.h:43
#define CHROMA_TMP
Definition: vf_hqdn3d.h:45

Definition at line 313 of file vf_hqdn3d.c.