FFmpeg
Macros | Functions | Variables
vf_gradfun.c File Reference
#include "libavutil/emms.h"
#include "libavutil/imgutils.h"
#include "libavutil/common.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "filters.h"
#include "gradfun.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|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

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 config_input (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
 AVFILTER_DEFINE_CLASS (gradfun)
 

Variables

static const uint16_t dither [8][8]
 
static enum AVPixelFormat pix_fmts []
 
static const AVOption gradfun_options []
 
static const AVFilterPad avfilter_vf_gradfun_inputs []
 
const 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). For each pixel, if it is within the 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

◆ OFFSET

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

Definition at line 220 of file vf_gradfun.c.

◆ FLAGS

Definition at line 221 of file vf_gradfun.c.

Function Documentation

◆ ff_gradfun_filter_line_c()

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().

◆ ff_gradfun_blur_line_c()

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().

◆ filter()

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().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 125 of file vf_gradfun.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 144 of file vf_gradfun.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 159 of file vf_gradfun.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 178 of file vf_gradfun.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( gradfun  )

Variable Documentation

◆ dither

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 47 of file vf_gradfun.c.

Referenced by filter().

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ gradfun_options

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 }
}

Definition at line 223 of file vf_gradfun.c.

◆ avfilter_vf_gradfun_inputs

const AVFilterPad avfilter_vf_gradfun_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
}

Definition at line 231 of file vf_gradfun.c.

◆ ff_vf_gradfun

const 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,
}

Definition at line 240 of file vf_gradfun.c.

FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
ff_video_default_filterpad
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
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_gradfun.c:150
NULL
#define NULL
Definition: coverity.c:32
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_gradfun.c:144
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_gradfun.c:178
OFFSET
#define OFFSET(x)
Definition: vf_gradfun.c:220
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
avfilter_vf_gradfun_inputs
static const AVFilterPad avfilter_vf_gradfun_inputs[]
Definition: vf_gradfun.c:231
FLAGS
#define FLAGS
Definition: vf_gradfun.c:221
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#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:182
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AV_PIX_FMT_YUV444P
@ 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_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_gradfun.c:159
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ 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_YUV411P
@ 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_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_gradfun.c:125
GradFunContext
Holds instance-specific information for gradfun.
Definition: gradfun.h:28