FFmpeg
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
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"

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)
 

Functions

 AVFILTER_DEFINE_CLASS (unsharp)
 
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, double amount)
 
static av_cold int init (AVFilterContext *ctx, const char *args)
 
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, AVFilterBufferRef *in)
 

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

#define MIN_MATRIX_SIZE   3

Definition at line 50 of file vf_unsharp.c.

#define MAX_MATRIX_SIZE   63

Definition at line 51 of file vf_unsharp.c.

Referenced by apply_unsharp().

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

Definition at line 54 of file vf_unsharp.c.

Referenced by config_props(), and filter_frame().

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

Definition at line 76 of file vf_unsharp.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( unsharp  )
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 98 of file vf_unsharp.c.

Referenced by filter_frame().

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

Definition at line 156 of file vf_unsharp.c.

Referenced by init().

static av_cold int init ( AVFilterContext ctx,
const char *  args 
)
static

Definition at line 168 of file vf_unsharp.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 190 of file vf_unsharp.c.

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

Definition at line 203 of file vf_unsharp.c.

Referenced by config_props().

static int config_props ( AVFilterLink link)
static

Definition at line 225 of file vf_unsharp.c.

static void free_filter_param ( FilterParam fp)
static

Definition at line 244 of file vf_unsharp.c.

Referenced by uninit().

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 252 of file vf_unsharp.c.

static int filter_frame ( AVFilterLink link,
AVFilterBufferRef in 
)
static

Definition at line 261 of file vf_unsharp.c.

Variable Documentation

const AVOption unsharp_options[]
static
Initial value:
= {
{ "luma_msize_x", "set luma matrix x size", OFFSET(luma_msize_x), AV_OPT_TYPE_INT, {.i64=5}, 3, 63 },
{ "lx", "set luma matrix x size", OFFSET(luma_msize_x), AV_OPT_TYPE_INT, {.i64=5}, 3, 63 },
{ "luma_msize_y", "set luma matrix y size", OFFSET(luma_msize_y), AV_OPT_TYPE_INT, {.i64=5}, 3, 63 },
{ "ly", "set luma matrix y size", OFFSET(luma_msize_y), AV_OPT_TYPE_INT, {.i64=5}, 3, 63 },
{ "luma_amount", "set luma effect amount", OFFSET(luma_amount), AV_OPT_TYPE_DOUBLE, {.dbl=1.0}, -DBL_MAX, DBL_MAX },
{ "la", "set luma effect amount", OFFSET(luma_amount), AV_OPT_TYPE_DOUBLE, {.dbl=1.0}, -DBL_MAX, DBL_MAX },
{ "chroma_msize_x", "set chroma matrix x size", OFFSET(chroma_msize_x), AV_OPT_TYPE_INT, {.i64=5}, 3, 63 },
{ "cx", "set chroma matrix x size", OFFSET(chroma_msize_x), AV_OPT_TYPE_INT, {.i64=5}, 3, 63 },
{ "chroma_msize_y", "set chroma matrix y size", OFFSET(chroma_msize_y), AV_OPT_TYPE_INT, {.i64=5}, 3, 63 },
{ "cy" , "set chroma matrix y size", OFFSET(chroma_msize_y), AV_OPT_TYPE_INT, {.i64=5}, 3, 63 },
{ "chroma_amount", "set chroma effect strenght", OFFSET(chroma_amount), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -DBL_MAX, DBL_MAX },
{ "ca", "set chroma effect strenght", OFFSET(chroma_amount), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -DBL_MAX, DBL_MAX },
{ NULL }
}

Definition at line 78 of file vf_unsharp.c.

const AVFilterPad avfilter_vf_unsharp_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_props,
.min_perms = AV_PERM_READ,
},
{ 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 295 of file vf_unsharp.c.

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

Definition at line 303 of file vf_unsharp.c.