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"

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 []
 
static const AVFilterPad blurdetect_outputs []
 
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 68 of file vf_blurdetect.c.

◆ FLAGS

Definition at line 69 of file vf_blurdetect.c.

Function Documentation

◆ comp()

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

Definition at line 39 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 83 of file vf_blurdetect.c.

◆ blurdetect_config_input()

static int blurdetect_config_input ( AVFilterLink inlink)
static

Definition at line 93 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 124 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 190 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 248 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 255 of file vf_blurdetect.c.

◆ blurdetect_uninit()

static av_cold void blurdetect_uninit ( AVFilterContext ctx)
static

Definition at line 322 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 70 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 350 of file vf_blurdetect.c.

◆ blurdetect_outputs

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

Definition at line 359 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 366 of file vf_blurdetect.c.

FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:170
blurdetect_init
static av_cold int blurdetect_init(AVFilterContext *ctx)
Definition: vf_blurdetect.c:83
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_blurdetect.c:338
init
static int init
Definition: av_tx.c:47
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
FLAGS
#define FLAGS
Definition: vf_blurdetect.c:69
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:248
BLRContext
Definition: vf_blurdetect.c:44
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:79
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:101
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:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
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:80
OFFSET
#define OFFSET(x)
Definition: vf_blurdetect.c:68
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:78
blurdetect_uninit
static av_cold void blurdetect_uninit(AVFilterContext *ctx)
Definition: vf_blurdetect.c:322
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
planes
static const struct @335 planes[]
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:117
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:167
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
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:100
blurdetect_inputs
static const AVFilterPad blurdetect_inputs[]
Definition: vf_blurdetect.c:350
blurdetect_filter_frame
static int blurdetect_filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_blurdetect.c:255
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
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:143
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:71
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
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:70
blurdetect_outputs
static const AVFilterPad blurdetect_outputs[]
Definition: vf_blurdetect.c:359
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
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:73
blurdetect_config_input
static int blurdetect_config_input(AVFilterLink *inlink)
Definition: vf_blurdetect.c:93
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:72
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:285
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:166