Libav
Macros | Functions | Variables
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"

Go to the source code of this file.

Macros

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

Functions

void ff_gradfun_filter_line_c (uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers)
 
void ff_gradfun_blur_line_c (uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint8_t *src, int src_linesize, int width)
 
static void filter (GradFunContext *ctx, uint8_t *dst, 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)
 

Variables

static const uint16_t dither [8][8]
 
static const AVOption options []
 
static const AVClass gradfun_class
 
static const AVFilterPad avfilter_vf_gradfun_inputs []
 
static const AVFilterPad avfilter_vf_gradfun_outputs []
 
AVFilter ff_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

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

Definition at line 227 of file vf_gradfun.c.

#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM

Definition at line 228 of file vf_gradfun.c.

Function Documentation

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

Definition at line 57 of file vf_gradfun.c.

Referenced by init().

void ff_gradfun_blur_line_c ( uint16_t *  dc,
uint16_t *  buf,
uint16_t *  buf1,
uint8_t src,
int  src_linesize,
int  width 
)

Definition at line 71 of file vf_gradfun.c.

Referenced by init().

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

Definition at line 82 of file vf_gradfun.c.

Referenced by filter_frame().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 124 of file vf_gradfun.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 142 of file vf_gradfun.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 148 of file vf_gradfun.c.

static int config_input ( AVFilterLink inlink)
static

Definition at line 163 of file vf_gradfun.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 182 of file vf_gradfun.c.

Variable Documentation

const uint16_t dither[8][8]
static
Initial value:
= {
{0x00,0x60,0x18,0x78,0x06,0x66,0x1E,0x7E},
{0x40,0x20,0x58,0x38,0x46,0x26,0x5E,0x3E},
{0x10,0x70,0x08,0x68,0x16,0x76,0x0E,0x6E},
{0x50,0x30,0x48,0x28,0x56,0x36,0x4E,0x2E},
{0x04,0x64,0x1C,0x7C,0x02,0x62,0x1A,0x7A},
{0x44,0x24,0x5C,0x3C,0x42,0x22,0x5A,0x3A},
{0x14,0x74,0x0C,0x6C,0x12,0x72,0x0A,0x6A},
{0x54,0x34,0x4C,0x2C,0x52,0x32,0x4A,0x2A},
}

Definition at line 46 of file vf_gradfun.c.

Referenced by ac3_decode_transform_coeffs_ch(), filter(), quantize_triangular_ns(), render_charset(), and rv40_loop_filter().

const AVOption 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:228
#define OFFSET(x)
Definition: vf_gradfun.c:227

Definition at line 229 of file vf_gradfun.c.

const AVClass gradfun_class
static
Initial value:
= {
.class_name = "gradfun",
.item_name = av_default_item_name,
.option = options,
}
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
static const AVOption options[]
Definition: vf_gradfun.c:229
av_default_item_name
Definition: dnxhdenc.c:45

Definition at line 235 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:163
NULL
Definition: eval.c:55

Definition at line 242 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 252 of file vf_gradfun.c.

AVFilter ff_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:122
Holds instance-specific information for gradfun.
Definition: gradfun.h:28
static const AVClass gradfun_class
Definition: vf_gradfun.c:235
static const AVFilterPad avfilter_vf_gradfun_outputs[]
Definition: vf_gradfun.c:252
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. ...
Definition: internal.h:142
static av_cold int init(AVFilterContext *ctx)
Definition: vf_gradfun.c:124
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:111
static const AVFilterPad avfilter_vf_gradfun_inputs[]
Definition: vf_gradfun.c:242
static int query_formats(AVFilterContext *ctx)
Definition: vf_gradfun.c:148

Definition at line 260 of file vf_gradfun.c.