FFmpeg
Loading...
Searching...
No Matches
vf_dctdnoiz.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/eval.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#include "libavutil/opt.h"
#include "filters.h"
#include "video.h"

Go to the source code of this file.

Data Structures

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

Macros

#define MAX_THREADS   8
 
#define MIN_NBITS   3 /* blocksize = 1<<3 = 8 */
 
#define MAX_NBITS   4 /* blocksize = 1<<4 = 16 */
 
#define DEFAULT_NBITS   3
 
#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define DEF_FILTER_FREQ_FUNCS(bsize)
 
#define DCT3X3_0_0   0.5773502691896258f /* 1/sqrt(3) */
 
#define DCT3X3_0_1   0.5773502691896258f /* 1/sqrt(3) */
 
#define DCT3X3_0_2   0.5773502691896258f /* 1/sqrt(3) */
 
#define DCT3X3_1_0   0.7071067811865475f /* 1/sqrt(2) */
 
#define DCT3X3_1_2   -0.7071067811865475f /* -1/sqrt(2) */
 
#define DCT3X3_2_0   0.4082482904638631f /* 1/sqrt(6) */
 
#define DCT3X3_2_1   -0.8164965809277261f /* -2/sqrt(6) */
 
#define DCT3X3_2_2   0.4082482904638631f /* 1/sqrt(6) */
 
#define DECLARE_COLOR_FUNCS(name, r, g, b)
 

Enumerations

enum  { VAR_C , VAR_VARS_NB }
 

Functions

 AVFILTER_DEFINE_CLASS (dctdnoiz)
 
static void av_always_inline fdct8_1d (float *dst, const float *src, int dst_stridea, int dst_strideb, int src_stridea, int src_strideb)
 
static void av_always_inline idct8_1d (float *dst, const float *src, int dst_stridea, int dst_strideb, int src_stridea, int src_strideb, int add)
 
static void av_always_inline fdct16_1d (float *dst, const float *src, int dst_stridea, int dst_strideb, int src_stridea, int src_strideb)
 
static void av_always_inline idct16_1d (float *dst, const float *src, int dst_stridea, int dst_strideb, int src_stridea, int src_strideb, int add)
 
static av_always_inline void color_decorrelation (float **dst, int dst_linesize, const uint8_t **src, int src_linesize, int w, int h, int r, int g, int b)
 
static av_always_inline void color_correlation (uint8_t **dst, int dst_linesize, float **src, int src_linesize, int w, int h, int r, int g, int b)
 
static av_always_inline void color_decorrelation_gbrp (float **dst, int dst_linesize, const uint8_t **src, int src_linesize, int w, int h)
 
static av_always_inline void color_correlation_gbrp (uint8_t **dst, int dst_linesize, float **src, int src_linesize, int w, int h)
 
static int config_input (AVFilterLink *inlink)
 
static av_cold int init (AVFilterContext *ctx)
 
static int filter_slice (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const char *const var_names [] = { "c", NULL }
 A simple, relatively efficient and slow DCT image denoiser.
 
static const AVOption dctdnoiz_options []
 
static enum AVPixelFormat pix_fmts []
 
static const AVFilterPad dctdnoiz_inputs []
 
const FFFilter ff_vf_dctdnoiz
 

Macro Definition Documentation

◆ MAX_THREADS

#define MAX_THREADS   8

Definition at line 43 of file vf_dctdnoiz.c.

◆ MIN_NBITS

#define MIN_NBITS   3 /* blocksize = 1<<3 = 8 */

Definition at line 77 of file vf_dctdnoiz.c.

◆ MAX_NBITS

#define MAX_NBITS   4 /* blocksize = 1<<4 = 16 */

Definition at line 78 of file vf_dctdnoiz.c.

◆ DEFAULT_NBITS

#define DEFAULT_NBITS   3

Definition at line 79 of file vf_dctdnoiz.c.

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 81 of file vf_dctdnoiz.c.

◆ FLAGS

Definition at line 82 of file vf_dctdnoiz.c.

◆ DEF_FILTER_FREQ_FUNCS

#define DEF_FILTER_FREQ_FUNCS ( bsize)

Definition at line 356 of file vf_dctdnoiz.c.

◆ DCT3X3_0_0

#define DCT3X3_0_0   0.5773502691896258f /* 1/sqrt(3) */

◆ DCT3X3_0_1

#define DCT3X3_0_1   0.5773502691896258f /* 1/sqrt(3) */

◆ DCT3X3_0_2

#define DCT3X3_0_2   0.5773502691896258f /* 1/sqrt(3) */

◆ DCT3X3_1_0

#define DCT3X3_1_0   0.7071067811865475f /* 1/sqrt(2) */

◆ DCT3X3_1_2

#define DCT3X3_1_2   -0.7071067811865475f /* -1/sqrt(2) */

◆ DCT3X3_2_0

#define DCT3X3_2_0   0.4082482904638631f /* 1/sqrt(6) */

◆ DCT3X3_2_1

#define DCT3X3_2_1   -0.8164965809277261f /* -2/sqrt(6) */

◆ DCT3X3_2_2

#define DCT3X3_2_2   0.4082482904638631f /* 1/sqrt(6) */

◆ DECLARE_COLOR_FUNCS

#define DECLARE_COLOR_FUNCS ( name,
r,
g,
b )
Value:
static void color_decorrelation_##name(float **dst, int dst_linesize, \
const uint8_t **src, int src_linesize, \
int w, int h) \
{ \
color_decorrelation(dst, dst_linesize, src, src_linesize, w, h, r, g, b); \
} \
\
static void color_correlation_##name(uint8_t **dst, int dst_linesize, \
float **src, int src_linesize, \
int w, int h) \
{ \
color_correlation(dst, dst_linesize, src, src_linesize, w, h, r, g, b); \
}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
#define r
Definition input.c:42
#define b
Definition input.c:43
uint8_t w
Definition llvidencdsp.c:39
const char * name
Definition qsvenc.c:142
#define src
Definition vp8dsp.c:248
const char * g
Definition vf_curves.c:128

Definition at line 464 of file vf_dctdnoiz.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
VAR_C 
VAR_VARS_NB 

Definition at line 41 of file vf_dctdnoiz.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( dctdnoiz )

◆ fdct8_1d()

static void av_always_inline fdct8_1d ( float * dst,
const float * src,
int dst_stridea,
int dst_strideb,
int src_stridea,
int src_strideb )
static

Definition at line 95 of file vf_dctdnoiz.c.

◆ idct8_1d()

static void av_always_inline idct8_1d ( float * dst,
const float * src,
int dst_stridea,
int dst_strideb,
int src_stridea,
int src_strideb,
int add )
static

Definition at line 133 of file vf_dctdnoiz.c.

Referenced by itxfm_wrap().

◆ fdct16_1d()

static void av_always_inline fdct16_1d ( float * dst,
const float * src,
int dst_stridea,
int dst_strideb,
int src_stridea,
int src_strideb )
static

Definition at line 177 of file vf_dctdnoiz.c.

◆ idct16_1d()

static void av_always_inline idct16_1d ( float * dst,
const float * src,
int dst_stridea,
int dst_strideb,
int src_stridea,
int src_strideb,
int add )
static

Definition at line 261 of file vf_dctdnoiz.c.

Referenced by itxfm_wrap().

◆ color_decorrelation()

static av_always_inline void color_decorrelation ( float ** dst,
int dst_linesize,
const uint8_t ** src,
int src_linesize,
int w,
int h,
int r,
int g,
int b )
static

Definition at line 414 of file vf_dctdnoiz.c.

◆ color_correlation()

static av_always_inline void color_correlation ( uint8_t ** dst,
int dst_linesize,
float ** src,
int src_linesize,
int w,
int h,
int r,
int g,
int b )
static

Definition at line 439 of file vf_dctdnoiz.c.

◆ color_decorrelation_gbrp()

static av_always_inline void color_decorrelation_gbrp ( float ** dst,
int dst_linesize,
const uint8_t ** src,
int src_linesize,
int w,
int h )
static

Definition at line 482 of file vf_dctdnoiz.c.

Referenced by color_decorrelation_gbrp(), and config_input().

◆ color_correlation_gbrp()

static av_always_inline void color_correlation_gbrp ( uint8_t ** dst,
int dst_linesize,
float ** src,
int src_linesize,
int w,
int h )
static

Definition at line 509 of file vf_dctdnoiz.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 536 of file vf_dctdnoiz.c.

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 626 of file vf_dctdnoiz.c.

◆ filter_slice()

static int filter_slice ( AVFilterContext * ctx,
void * arg,
int jobnr,
int nb_jobs )
static

Definition at line 670 of file vf_dctdnoiz.c.

◆ filter_frame()

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

Definition at line 718 of file vf_dctdnoiz.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 789 of file vf_dctdnoiz.c.

Variable Documentation

◆ var_names

const char* const var_names[] = { "c", NULL }
static

A simple, relatively efficient and slow DCT image denoiser.

See also
http://www.ipol.im/pub/art/2011/ys-dct/

The DCT factorization used is based on "Fast and numerically stable algorithms for discrete cosine transforms" from Gerlind Plonkaa & Manfred Tasche (DOI: 10.1016/j.laa.2004.07.015).

Definition at line 40 of file vf_dctdnoiz.c.

◆ dctdnoiz_options

const AVOption dctdnoiz_options[]
static
Initial value:
= {
{ "sigma", "set noise sigma constant", OFFSET(sigma), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, 999, .flags = FLAGS },
{ "s", "set noise sigma constant", OFFSET(sigma), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, 999, .flags = FLAGS },
{ "overlap", "set number of block overlapping pixels", OFFSET(overlap), AV_OPT_TYPE_INT, {.i64=-1}, -1, (1<<MAX_NBITS)-1, .flags = FLAGS },
{ "expr", "set coefficient factor expression", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "e", "set coefficient factor expression", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "n", "set the block size, expressed in bits", OFFSET(n), AV_OPT_TYPE_INT, {.i64=DEFAULT_NBITS}, MIN_NBITS, MAX_NBITS, .flags = FLAGS },
{ NULL }
}
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
#define MAX_NBITS
Definition vf_dctdnoiz.c:78
#define DEFAULT_NBITS
Definition vf_dctdnoiz.c:79
#define MIN_NBITS
Definition vf_dctdnoiz.c:77

Definition at line 83 of file vf_dctdnoiz.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
}
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition pixfmt.h:75
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition pixfmt.h:76
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165

Definition at line 660 of file vf_dctdnoiz.c.

◆ dctdnoiz_inputs

const AVFilterPad dctdnoiz_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_input,
},
}
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 806 of file vf_dctdnoiz.c.

◆ ff_vf_dctdnoiz

const FFFilter ff_vf_dctdnoiz
Initial value:
= {
.p.name = "dctdnoiz",
.p.description = NULL_IF_CONFIG_SMALL("Denoise frames using 2D DCT."),
.p.priv_class = &dctdnoiz_class,
.priv_size = sizeof(DCTdnoizContext),
.init = init,
}
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition avfilter.h:196
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
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 dctdnoiz_inputs[]
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 815 of file vf_dctdnoiz.c.