FFmpeg
Data Structures | Macros | Functions | Variables
vf_blurdetect.c File Reference
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/qsort.h"
#include "internal.h"
#include "edge_common.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  BLRContext
 

Macros

#define OFFSET(x)   offsetof(BLRContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 

Functions

static int comp (const float *a, const float *b)
 
 AVFILTER_DEFINE_CLASS (blurdetect)
 
static av_cold int blurdetect_init (AVFilterContext *ctx)
 
static int blurdetect_config_input (AVFilterLink *inlink)
 
static float edge_width (BLRContext *blr, int i, int j, int8_t dir, int w, int h, int edge, const uint8_t *src, int src_linesize)
 
static float calculate_blur (BLRContext *s, int w, int h, int hsub, int vsub, int8_t *dir, int dir_linesize, uint8_t *dst, int dst_linesize, uint8_t *src, int src_linesize)
 
static void set_meta (AVDictionary **metadata, const char *key, float d)
 
static int blurdetect_filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static av_cold void blurdetect_uninit (AVFilterContext *ctx)
 

Variables

static const AVOption blurdetect_options []
 
static enum AVPixelFormat pix_fmts []
 
static const AVFilterPad blurdetect_inputs []
 
const AVFilter ff_vf_blurdetect
 

Detailed Description

No-reference blurdetect filter

Implementing: Marziliano, Pina, et al. "A no-reference perceptual blur metric." Proceedings. International conference on image processing. Vol. 3. IEEE, 2002. https://infoscience.epfl.ch/record/111802/files/14%20A%20no-reference%20perceptual%20blur%20metric.pdf

Author
Thilo Borgmann <thilo.borgmann at mail.de>

Definition in file vf_blurdetect.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 69 of file vf_blurdetect.c.

◆ FLAGS

Definition at line 70 of file vf_blurdetect.c.

Function Documentation

◆ comp()

static int comp ( const float a,
const float b 
)
static

Definition at line 40 of file vf_blurdetect.c.

Referenced by calculate_blur().

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( blurdetect  )

◆ blurdetect_init()

static av_cold int blurdetect_init ( AVFilterContext ctx)
static

Definition at line 84 of file vf_blurdetect.c.

◆ blurdetect_config_input()

static int blurdetect_config_input ( AVFilterLink inlink)
static

Definition at line 94 of file vf_blurdetect.c.

◆ edge_width()

static float edge_width ( BLRContext blr,
int  i,
int  j,
int8_t  dir,
int  w,
int  h,
int  edge,
const uint8_t *  src,
int  src_linesize 
)
static

Definition at line 125 of file vf_blurdetect.c.

Referenced by calculate_blur().

◆ calculate_blur()

static float calculate_blur ( BLRContext s,
int  w,
int  h,
int  hsub,
int  vsub,
int8_t *  dir,
int  dir_linesize,
uint8_t *  dst,
int  dst_linesize,
uint8_t *  src,
int  src_linesize 
)
static

Definition at line 191 of file vf_blurdetect.c.

Referenced by blurdetect_filter_frame().

◆ set_meta()

static void set_meta ( AVDictionary **  metadata,
const char *  key,
float  d 
)
static

Definition at line 249 of file vf_blurdetect.c.

Referenced by blurdetect_filter_frame().

◆ blurdetect_filter_frame()

static int blurdetect_filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 256 of file vf_blurdetect.c.

◆ blurdetect_uninit()

static av_cold void blurdetect_uninit ( AVFilterContext ctx)
static

Definition at line 323 of file vf_blurdetect.c.

Variable Documentation

◆ blurdetect_options

const AVOption blurdetect_options[]
static
Initial value:
= {
{ "high", "set high threshold", OFFSET(high), AV_OPT_TYPE_FLOAT, {.dbl=30/255.}, 0, 1, FLAGS },
{ "low", "set low threshold", OFFSET(low), AV_OPT_TYPE_FLOAT, {.dbl=15/255.}, 0, 1, FLAGS },
{ "radius", "search radius for maxima detection", OFFSET(radius), AV_OPT_TYPE_INT, {.i64=50}, 1, 100, FLAGS },
{ "block_pct", "block pooling threshold when calculating blurriness", OFFSET(block_pct), AV_OPT_TYPE_INT, {.i64=80}, 1, 100, FLAGS },
{ "block_width", "block size for block-based abbreviation of blurriness", OFFSET(block_width), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, FLAGS },
{ "block_height", "block size for block-based abbreviation of blurriness", OFFSET(block_height), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, FLAGS },
{ "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=1}, 0, 15, FLAGS },
{ NULL }
}

Definition at line 71 of file vf_blurdetect.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ blurdetect_inputs

const AVFilterPad blurdetect_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = blurdetect_config_input,
.filter_frame = blurdetect_filter_frame,
},
}

Definition at line 351 of file vf_blurdetect.c.

◆ ff_vf_blurdetect

const AVFilter ff_vf_blurdetect
Initial value:
= {
.name = "blurdetect",
.description = NULL_IF_CONFIG_SMALL("Blurdetect filter."),
.priv_size = sizeof(BLRContext),
.priv_class = &blurdetect_class,
}

Definition at line 360 of file vf_blurdetect.c.

FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:162
blurdetect_init
static av_cold int blurdetect_init(AVFilterContext *ctx)
Definition: vf_blurdetect.c:84
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
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_blurdetect.c:339
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
FLAGS
#define FLAGS
Definition: vf_blurdetect.c:70
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:283
BLRContext
Definition: vf_blurdetect.c:45
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_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:86
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:108
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_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:87
OFFSET
#define OFFSET(x)
Definition: vf_blurdetect.c:69
NULL
#define NULL
Definition: coverity.c:32
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:85
blurdetect_uninit
static av_cold void blurdetect_uninit(AVFilterContext *ctx)
Definition: vf_blurdetect.c:323
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:365
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:106
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:238
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:107
blurdetect_inputs
static const AVFilterPad blurdetect_inputs[]
Definition: vf_blurdetect.c:351
blurdetect_filter_frame
static int blurdetect_filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_blurdetect.c:256
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
AVFILTER_FLAG_METADATA_ONLY
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition: avfilter.h:133
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
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
planes
static const struct @386 planes[]
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
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
blurdetect_config_input
static int blurdetect_config_input(AVFilterLink *inlink)
Definition: vf_blurdetect.c:94
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
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:173