FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
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/attributes.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"

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 *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)
 
static av_always_inline void 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)
 
static int16_t * precalc_coefs (double dist25, int depth)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
 AVFILTER_DEFINE_CLASS (hqdn3d)
 

Variables

static const AVOption hqdn3d_options []
 
static const AVFilterPad avfilter_vf_hqdn3d_inputs []
 
static const AVFilterPad avfilter_vf_hqdn3d_outputs []
 
AVFilter ff_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 LUT_BITS   (depth==16 ? 8 : 4)

Definition at line 44 of file vf_hqdn3d.c.

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

#define LOAD (   x)
Value:
(((depth == 8 ? src[x] : AV_RN16A(src + (x) * 2)) << (16 - depth))\
+ (((1 << (16 - depth)) - 1) >> 1))

Definition at line 45 of file vf_hqdn3d.c.

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

#define STORE (   x,
  val 
)
Value:
(depth == 8 ? dst[x] = (val) >> (16 - depth) : \
AV_WN16A(dst + (x) * 2, (val) >> (16 - depth)))

Definition at line 47 of file vf_hqdn3d.c.

Referenced by denoise_spatial(), and denoise_temporal().

#define denoise (   ...)
Value:
switch (s->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;\
}

Definition at line 153 of file vf_hqdn3d.c.

Referenced by filter_frame().

#define PARAM1_DEFAULT   4.0

Definition at line 182 of file vf_hqdn3d.c.

Referenced by init().

#define PARAM2_DEFAULT   3.0

Definition at line 183 of file vf_hqdn3d.c.

Referenced by init().

#define PARAM3_DEFAULT   6.0

Definition at line 184 of file vf_hqdn3d.c.

Referenced by init().

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

Definition at line 322 of file vf_hqdn3d.c.

Definition at line 323 of file vf_hqdn3d.c.

Function Documentation

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

Definition at line 51 of file vf_hqdn3d.c.

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 58 of file vf_hqdn3d.c.

Referenced by denoise_depth().

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

Definition at line 80 of file vf_hqdn3d.c.

Referenced by denoise_depth().

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

Definition at line 124 of file vf_hqdn3d.c.

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

Definition at line 161 of file vf_hqdn3d.c.

Referenced by config_input().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 186 of file vf_hqdn3d.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 206 of file vf_hqdn3d.c.

Referenced by config_input().

static int query_formats ( AVFilterContext ctx)
static

Definition at line 220 of file vf_hqdn3d.c.

static int config_input ( AVFilterLink inlink)
static

Definition at line 250 of file vf_hqdn3d.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 278 of file vf_hqdn3d.c.

AVFILTER_DEFINE_CLASS ( hqdn3d  )

Variable Documentation

const AVOption hqdn3d_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 }
}

Definition at line 324 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 }
}

Definition at line 334 of file vf_hqdn3d.c.

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

Definition at line 345 of file vf_hqdn3d.c.

AVFilter ff_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,
}

Definition at line 353 of file vf_hqdn3d.c.