vf_unsharp.c File Reference

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

#include <float.h>
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
#include "libavutil/common.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
Include dependency graph for vf_unsharp.c:

Go to the source code of this file.

Data Structures

struct  FilterParam
 
struct  UnsharpContext
 

Macros

#define MIN_MATRIX_SIZE   3
 
#define MAX_MATRIX_SIZE   63
 
#define SHIFTUP(x, shift)   (-((-(x))>>(shift)))
 
#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
 

Typedefs

typedef struct FilterParam FilterParam
 

Functions

static void apply_unsharp (uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int width, int height, FilterParam *fp)
 
static void set_filter_param (FilterParam *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, FilterParam *fp, const char *effect_type, int width)
 
static int config_props (AVFilterLink *link)
 
static void free_filter_param (FilterParam *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 avfilter_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

Definition at line 251 of file vf_unsharp.c.

#define MAX_MATRIX_SIZE   63

Definition at line 51 of file vf_unsharp.c.

Referenced by apply_unsharp().

#define MAX_SIZE   63

Definition at line 253 of file vf_unsharp.c.

#define MIN_MATRIX_SIZE   3

Definition at line 50 of file vf_unsharp.c.

#define MIN_SIZE   3

Definition at line 252 of file vf_unsharp.c.

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

Definition at line 250 of file vf_unsharp.c.

#define SHIFTUP (   x,
  shift 
)    (-((-(x))>>(shift)))

Definition at line 54 of file vf_unsharp.c.

Referenced by config_props(), and filter_frame().

Typedef Documentation

typedef struct FilterParam FilterParam

Function Documentation

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

Definition at line 76 of file vf_unsharp.c.

Referenced by filter_frame().

AVFILTER_DEFINE_CLASS ( unsharp  )
static int config_props ( AVFilterLink link)
static

Definition at line 192 of file vf_unsharp.c.

static int filter_frame ( AVFilterLink link,
AVFrame in 
)
static

Definition at line 227 of file vf_unsharp.c.

static void free_filter_param ( FilterParam fp)
static

Definition at line 211 of file vf_unsharp.c.

Referenced by uninit().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 146 of file vf_unsharp.c.

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

Definition at line 170 of file vf_unsharp.c.

Referenced by config_props().

static int query_formats ( AVFilterContext ctx)
static

Definition at line 157 of file vf_unsharp.c.

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

Definition at line 134 of file vf_unsharp.c.

Referenced by init().

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 219 of file vf_unsharp.c.

Variable Documentation

AVFilter avfilter_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,
}
static const AVFilterPad avfilter_vf_unsharp_inputs[]
Definition: vf_unsharp.c:272
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
static av_cold int init(AVFilterContext *ctx)
Definition: vf_unsharp.c:146
static const AVFilterPad avfilter_vf_unsharp_outputs[]
Definition: vf_unsharp.c:282
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_unsharp.c:219
static int query_formats(AVFilterContext *ctx)
Definition: vf_unsharp.c:157
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 290 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 }
}
static int filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_unsharp.c:227
static int config_props(AVFilterLink *link)
Definition: vf_unsharp.c:192
NULL
Definition: eval.c:55

Definition at line 272 of file vf_unsharp.c.

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

Definition at line 282 of file vf_unsharp.c.

const AVOption unsharp_options[]
static
Initial value:
= {
{ "luma_msize_x", "luma matrix horizontal size", OFFSET(lmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "lx", "luma matrix horizontal size", OFFSET(lmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "luma_msize_y", "luma matrix vertical size", OFFSET(lmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "ly", "luma matrix vertical size", OFFSET(lmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "luma_amount", "luma effect strength", OFFSET(lamount), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, -2, 5, FLAGS },
{ "la", "luma effect strength", OFFSET(lamount), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, -2, 5, FLAGS },
{ "chroma_msize_x", "chroma matrix horizontal size", OFFSET(cmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "cx", "chroma matrix horizontal size", OFFSET(cmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "chroma_msize_y", "chroma matrix vertical size", OFFSET(cmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "cy", "chroma matrix vertical size", OFFSET(cmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "chroma_amount", "chroma effect strength", OFFSET(camount), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -2, 5, FLAGS },
{ "ca", "chroma effect strength", OFFSET(camount), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -2, 5, FLAGS },
{ NULL },
}
#define FLAGS
Definition: vf_unsharp.c:251
#define MAX_SIZE
Definition: vf_unsharp.c:253
#define OFFSET(x)
Definition: vf_unsharp.c:250
#define MIN_SIZE
Definition: vf_unsharp.c:252
NULL
Definition: eval.c:55

Definition at line 254 of file vf_unsharp.c.