FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
vf_unsharp.c File Reference

blur / sharpen filter, ported to FFmpeg from MPlayer libmpcodecs/unsharp.c. More...

#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "unsharp.h"
#include "unsharp_opencl.h"

Go to the source code of this file.

Macros

#define OFFSET(x)   offsetof(UnsharpContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define MIN_SIZE   3
 
#define MAX_SIZE   63
 

Functions

static void apply_unsharp (uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int width, int height, UnsharpFilterParam *fp)
 
static int apply_unsharp_c (AVFilterContext *ctx, AVFrame *in, AVFrame *out)
 
static void set_filter_param (UnsharpFilterParam *fp, int msize_x, int msize_y, float amount)
 
static av_cold int init (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int init_filter_param (AVFilterContext *ctx, UnsharpFilterParam *fp, const char *effect_type, int width)
 
static int config_props (AVFilterLink *link)
 
static void free_filter_param (UnsharpFilterParam *fp)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int filter_frame (AVFilterLink *link, AVFrame *in)
 
 AVFILTER_DEFINE_CLASS (unsharp)
 

Variables

static const AVOption unsharp_options []
 
static const AVFilterPad avfilter_vf_unsharp_inputs []
 
static const AVFilterPad avfilter_vf_unsharp_outputs []
 
AVFilter ff_vf_unsharp
 

Detailed Description

blur / sharpen filter, ported to FFmpeg from MPlayer libmpcodecs/unsharp.c.

This code is based on:

An Efficient algorithm for Gaussian blur using finite-state machines Frederick M. Waltz and John W. V. Miller

SPIE Conf. on Machine Vision Systems for Inspection and Metrology VII Originally published Boston, Nov 98

http://www.engin.umd.umich.edu/~jwvm/ece581/21_GBlur.pdf

Definition in file vf_unsharp.c.

Macro Definition Documentation

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

Definition at line 261 of file vf_unsharp.c.

Definition at line 262 of file vf_unsharp.c.

#define MIN_SIZE   3

Definition at line 263 of file vf_unsharp.c.

#define MAX_SIZE   63

Definition at line 264 of file vf_unsharp.c.

Function Documentation

static void apply_unsharp ( uint8_t dst,
int  dst_stride,
const uint8_t src,
int  src_stride,
int  width,
int  height,
UnsharpFilterParam fp 
)
static

Definition at line 51 of file vf_unsharp.c.

Referenced by apply_unsharp_c().

static int apply_unsharp_c ( AVFilterContext ctx,
AVFrame in,
AVFrame out 
)
static

Definition at line 105 of file vf_unsharp.c.

Referenced by init().

static void set_filter_param ( UnsharpFilterParam fp,
int  msize_x,
int  msize_y,
float  amount 
)
static

Definition at line 123 of file vf_unsharp.c.

Referenced by init().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 135 of file vf_unsharp.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 158 of file vf_unsharp.c.

static int init_filter_param ( AVFilterContext ctx,
UnsharpFilterParam fp,
const char *  effect_type,
int  width 
)
static

Definition at line 171 of file vf_unsharp.c.

Referenced by config_props().

static int config_props ( AVFilterLink link)
static

Definition at line 194 of file vf_unsharp.c.

static void free_filter_param ( UnsharpFilterParam fp)
static

Definition at line 213 of file vf_unsharp.c.

Referenced by uninit().

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 221 of file vf_unsharp.c.

static int filter_frame ( AVFilterLink link,
AVFrame in 
)
static

Definition at line 233 of file vf_unsharp.c.

AVFILTER_DEFINE_CLASS ( unsharp  )

Variable Documentation

const AVOption unsharp_options[]
static
Initial value:
= {
{ "luma_msize_x", "set luma matrix horizontal size", OFFSET(lmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "lx", "set luma matrix horizontal size", OFFSET(lmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "luma_msize_y", "set luma matrix vertical size", OFFSET(lmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "ly", "set luma matrix vertical size", OFFSET(lmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "luma_amount", "set luma effect strength", OFFSET(lamount), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, -2, 5, FLAGS },
{ "la", "set luma effect strength", OFFSET(lamount), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, -2, 5, FLAGS },
{ "chroma_msize_x", "set chroma matrix horizontal size", OFFSET(cmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "cx", "set chroma matrix horizontal size", OFFSET(cmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "chroma_msize_y", "set chroma matrix vertical size", OFFSET(cmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "cy", "set chroma matrix vertical size", OFFSET(cmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "chroma_amount", "set chroma effect strength", OFFSET(camount), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -2, 5, FLAGS },
{ "ca", "set chroma effect strength", OFFSET(camount), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -2, 5, FLAGS },
{ "opencl", "use OpenCL filtering capabilities", OFFSET(opencl), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
{ NULL }
}

Definition at line 265 of file vf_unsharp.c.

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

Definition at line 284 of file vf_unsharp.c.

const AVFilterPad avfilter_vf_unsharp_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}

Definition at line 294 of file vf_unsharp.c.

AVFilter ff_vf_unsharp
Initial value:
= {
.name = "unsharp",
.description = NULL_IF_CONFIG_SMALL("Sharpen or blur the input video."),
.priv_size = sizeof(UnsharpContext),
.priv_class = &unsharp_class,
.init = init,
}

Definition at line 302 of file vf_unsharp.c.