FFmpeg
Loading...
Searching...
No Matches
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/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)
 
#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 FFFilter 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)
Value:
offsetof(GradFunContext, x)
Holds instance-specific information for gradfun.
Definition gradfun.h:28

Definition at line 218 of file vf_gradfun.c.

◆ FLAGS

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

Referenced by gradfun_filter_line_ssse3(), and 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 71 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 82 of file vf_gradfun.c.

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 123 of file vf_gradfun.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 142 of file vf_gradfun.c.

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 157 of file vf_gradfun.c.

◆ filter_frame()

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

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

Referenced by ac3_decode_transform_coeffs_ch(), aptx_invert_quantization(), aptx_process_subband(), aptx_quantize_difference(), check_yuv2nv12cX(), check_yuv2yuv1(), check_yuv2yuvX(), DECL_FUNC(), DECL_SETUP(), dither_to_mask(), encode_frame(), ff_mpadsp_apply_window_fixed_armv6(), ff_mpadsp_apply_window_fixed_neon(), ff_mpadsp_apply_window_float_neon(), ff_sws_dither_height(), ff_yuv2planeX_8_neon(), filter(), filter(), filter(), render_charset(), rv40_loop_filter(), set_frame(), store_slice16_c(), store_slice_c(), store_slice_c(), validate_params(), yuv2NBPS(), yuv2plane1_8_c(), yuv2plane1_8_lsx(), yuv2planeX(), yuv2planeX_8_16(), yuv2planeX_8_c(), yuv2planeX_8_lasx(), yuv2planeX_8_lsx(), yuv2planeX_8_ref(), yuv2planeX_u(), and yuv420_abgr32_lsx().

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
}
@ 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_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ 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_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165

Definition at line 148 of file vf_gradfun.c.

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

Definition at line 221 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,
},
}
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 229 of file vf_gradfun.c.

◆ ff_vf_gradfun

const FFFilter ff_vf_gradfun
Initial value:
= {
.p.name = "gradfun",
.p.description = NULL_IF_CONFIG_SMALL("Debands video quickly using gradients."),
.p.priv_class = &gradfun_class,
.priv_size = sizeof(GradFunContext),
.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
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_gradfun_inputs[]
Definition vf_gradfun.c:229
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 238 of file vf_gradfun.c.