FFmpeg
Loading...
Searching...
No Matches
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/mem.h"
#include "libavutil/pixdesc.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "filters.h"
#include "video.h"
#include "vf_hqdn3d.h"

Go to the source code of this file.

Data Structures

struct  ThreadData
 Used for passing data between threads. More...
 

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)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_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 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)
 
static void precalc_coefs (double dist25, int depth, int16_t *ct)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static void calc_coefs (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static int do_denoise (AVFilterContext *ctx, void *data, int job_nr, int n_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 
 AVFILTER_DEFINE_CLASS (hqdn3d)
 

Variables

static enum AVPixelFormat pix_fmts []
 
static const AVOption hqdn3d_options []
 
static const AVFilterPad avfilter_vf_hqdn3d_inputs []
 
const FFFilter 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

◆ LUT_BITS

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

Definition at line 44 of file vf_hqdn3d.c.

◆ LOAD

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

Definition at line 45 of file vf_hqdn3d.c.

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

◆ STORE

#define STORE ( x,
val )
Value:
(depth == 8 ? dst[x] = (val) >> (16 - depth) : \
AV_WN16A(dst + (x) * 2, (val) >> (16 - depth)))
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static double val(void *priv, double ch)
Definition aeval.c:77

Definition at line 47 of file vf_hqdn3d.c.

Referenced by denoise_spatial(), and denoise_temporal().

◆ denoise

#define denoise ( ...)
Value:
do { \
int ret = AVERROR_BUG; \
switch (s->depth) { \
case 8: ret = denoise_depth(__VA_ARGS__, 8); break; \
case 9: ret = denoise_depth(__VA_ARGS__, 9); break; \
case 10: ret = denoise_depth(__VA_ARGS__, 10); break; \
case 12: ret = denoise_depth(__VA_ARGS__, 12); break; \
case 14: ret = denoise_depth(__VA_ARGS__, 14); break; \
case 16: ret = denoise_depth(__VA_ARGS__, 16); break; \
} \
if (ret < 0) \
return ret; \
} while (0)
#define s(width, name)
Definition cbs_vp9.c:198
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition error.h:52
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

Definition at line 155 of file vf_hqdn3d.c.

Referenced by denoise_vaapi_build_filter_params(), do_denoise(), and filter_frame().

◆ PARAM1_DEFAULT

#define PARAM1_DEFAULT   4.0

Definition at line 187 of file vf_hqdn3d.c.

Referenced by init().

◆ PARAM2_DEFAULT

#define PARAM2_DEFAULT   3.0

Definition at line 188 of file vf_hqdn3d.c.

Referenced by init().

◆ PARAM3_DEFAULT

#define PARAM3_DEFAULT   6.0

Definition at line 189 of file vf_hqdn3d.c.

Referenced by init().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 386 of file vf_hqdn3d.c.

◆ FLAGS

Function Documentation

◆ lowpass()

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.

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

Definition at line 58 of file vf_hqdn3d.c.

Referenced by denoise_depth().

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

Definition at line 80 of file vf_hqdn3d.c.

Referenced by denoise_depth().

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

Definition at line 124 of file vf_hqdn3d.c.

◆ precalc_coefs()

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

Definition at line 170 of file vf_hqdn3d.c.

Referenced by calc_coefs().

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 191 of file vf_hqdn3d.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 211 of file vf_hqdn3d.c.

Referenced by config_input().

◆ calc_coefs()

static void calc_coefs ( AVFilterContext * ctx)
static

Definition at line 241 of file vf_hqdn3d.c.

Referenced by config_input(), and process_command().

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 249 of file vf_hqdn3d.c.

Referenced by filter_frame().

◆ do_denoise()

static int do_denoise ( AVFilterContext * ctx,
void * data,
int job_nr,
int n_jobs )
static

Definition at line 291 of file vf_hqdn3d.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink * inlink,
AVFrame * in )
static

Definition at line 309 of file vf_hqdn3d.c.

◆ process_command()

static int process_command ( AVFilterContext * ctx,
const char * cmd,
const char * args,
char * res,
int res_len,
int flags )
static

Definition at line 372 of file vf_hqdn3d.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( hqdn3d )

Variable Documentation

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
}
#define AV_PIX_FMT_YUV420P16
Definition pixfmt.h:556
#define AV_PIX_FMT_YUV444P12
Definition pixfmt.h:552
#define AV_PIX_FMT_YUV444P9
Definition pixfmt.h:544
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:545
#define AV_PIX_FMT_YUV440P12
Definition pixfmt.h:551
#define AV_PIX_FMT_YUV422P9
Definition pixfmt.h:543
#define AV_PIX_FMT_YUV420P12
Definition pixfmt.h:549
#define AV_PIX_FMT_YUV422P12
Definition pixfmt.h:550
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:546
#define AV_PIX_FMT_YUV420P9
Definition pixfmt.h:542
#define AV_PIX_FMT_YUV420P14
Definition pixfmt.h:553
@ 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_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_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_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
#define AV_PIX_FMT_YUV422P14
Definition pixfmt.h:554
#define AV_PIX_FMT_YUV422P16
Definition pixfmt.h:557
#define AV_PIX_FMT_YUV440P10
Definition pixfmt.h:547
#define AV_PIX_FMT_YUV444P14
Definition pixfmt.h:555
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:558
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:548

Definition at line 227 of file vf_hqdn3d.c.

◆ hqdn3d_options

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 }
}
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition opt.h:266
#define CHROMA_SPATIAL
Definition vf_hqdn3d.h:46
#define LUMA_TMP
Definition vf_hqdn3d.h:45
#define CHROMA_TMP
Definition vf_hqdn3d.h:47
#define LUMA_SPATIAL
Definition vf_hqdn3d.h:44

Definition at line 388 of file vf_hqdn3d.c.

◆ avfilter_vf_hqdn3d_inputs

const AVFilterPad avfilter_vf_hqdn3d_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
}
static int config_input(AVFilterLink *inlink)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200

Definition at line 398 of file vf_hqdn3d.c.

◆ ff_vf_hqdn3d

const FFFilter ff_vf_hqdn3d
Initial value:
= {
.p.name = "hqdn3d",
.p.description = NULL_IF_CONFIG_SMALL("Apply a High Quality 3D Denoiser."),
.p.priv_class = &hqdn3d_class,
.priv_size = sizeof(HQDN3DContext),
.init = init,
.process_command = process_command,
}
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
#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:204
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:244
#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
static const AVFilterPad avfilter_vf_hqdn3d_inputs[]
Definition vf_hqdn3d.c:398
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

Definition at line 408 of file vf_hqdn3d.c.