vf_gradfun.c File Reference

gradfun debanding filter, ported from MPlayer libmpcodecs/vf_gradfun.c More...

#include "libavutil/imgutils.h"
#include "libavutil/common.h"
#include "libavutil/cpu.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "gradfun.h"
#include "internal.h"
#include "video.h"
Include dependency graph for vf_gradfun.c:

Go to the source code of this file.

Macros

#define OFFSET(x)   offsetof(GradFunContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

 DECLARE_ALIGNED (16, static const uint16_t, dither)[8][8]
 
void ff_gradfun_filter_line_c (uint8_t *dst, const uint8_t *src, const uint16_t *dc, int width, int thresh, const uint16_t *dithers)
 
void ff_gradfun_blur_line_c (uint16_t *dc, uint16_t *buf, const uint16_t *buf1, const uint8_t *src, int src_linesize, int width)
 
static void filter (GradFunContext *ctx, uint8_t *dst, const uint8_t *src, int width, int height, int dst_linesize, int src_linesize, int r)
 
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 (gradfun)
 

Variables

static const AVOption gradfun_options []
 
static const AVFilterPad avfilter_vf_gradfun_inputs []
 
static const AVFilterPad avfilter_vf_gradfun_outputs []
 
AVFilter avfilter_vf_gradfun
 

Detailed Description

gradfun debanding filter, ported from MPlayer libmpcodecs/vf_gradfun.c

Apply a boxblur debanding algorithm (based on the gradfun2db Avisynth filter by prunedtree). Foreach pixel, if it's within threshold of the blurred value, make it closer. So now we have a smoothed and higher bitdepth version of all the shallow gradients, while leaving detailed areas untouched. Dither it back to 8bit.

Definition in file vf_gradfun.c.

Macro Definition Documentation

Definition at line 225 of file vf_gradfun.c.

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

Definition at line 224 of file vf_gradfun.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( gradfun  )
static int config_input ( AVFilterLink inlink)
static

Definition at line 164 of file vf_gradfun.c.

DECLARE_ALIGNED ( 16  ,
static const  uint16_t,
dither   
)
void ff_gradfun_blur_line_c ( uint16_t *  dc,
uint16_t *  buf,
const uint16_t *  buf1,
const uint8_t src,
int  src_linesize,
int  width 
)

Definition at line 72 of file vf_gradfun.c.

Referenced by init().

void ff_gradfun_filter_line_c ( uint8_t dst,
const uint8_t src,
const uint16_t *  dc,
int  width,
int  thresh,
const uint16_t *  dithers 
)

Definition at line 58 of file vf_gradfun.c.

Referenced by init().

static void filter ( GradFunContext ctx,
uint8_t dst,
const uint8_t src,
int  width,
int  height,
int  dst_linesize,
int  src_linesize,
int  r 
)
static

Definition at line 83 of file vf_gradfun.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 182 of file vf_gradfun.c.

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 124 of file vf_gradfun.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 148 of file vf_gradfun.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 142 of file vf_gradfun.c.

Variable Documentation

AVFilter avfilter_vf_gradfun
Initial value:
= {
.name = "gradfun",
.description = NULL_IF_CONFIG_SMALL("Debands video quickly using gradients."),
.priv_size = sizeof(GradFunContext),
.priv_class = &gradfun_class,
.init = init,
}
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
static const AVFilterPad avfilter_vf_gradfun_outputs[]
Definition: vf_gradfun.c:245
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_gradfun.c:142
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_cold int init(AVFilterContext *ctx)
Definition: vf_gradfun.c:124
struct GradFunContext GradFunContext
Holds instance-specific information for gradfun.
static const AVFilterPad avfilter_vf_gradfun_inputs[]
Definition: vf_gradfun.c:235
static int query_formats(AVFilterContext *ctx)
Definition: vf_gradfun.c:148
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

Definition at line 253 of file vf_gradfun.c.

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

Definition at line 235 of file vf_gradfun.c.

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

Definition at line 245 of file vf_gradfun.c.

const AVOption gradfun_options[]
static
Initial value:
= {
{ "strength", "The maximum amount by which the filter will change any one pixel.", OFFSET(strength), AV_OPT_TYPE_FLOAT, { .dbl = 1.2 }, 0.51, 64, FLAGS },
{ "radius", "The neighborhood to fit the gradient to.", OFFSET(radius), AV_OPT_TYPE_INT, { .i64 = 16 }, 4, 32, FLAGS },
{ NULL },
}
NULL
Definition: eval.c:55
#define FLAGS
Definition: vf_gradfun.c:225
#define OFFSET(x)
Definition: vf_gradfun.c:224

Definition at line 227 of file vf_gradfun.c.