FFmpeg
Data Structures | Macros | Functions | Variables
vf_photosensitivity.c File Reference
#include <float.h>
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  PhotosensitivityFrame
 
struct  PhotosensitivityContext
 
struct  ThreadData_convert_frame
 
struct  ThreadData_blend_frame
 

Macros

#define MAX_FRAMES   240
 
#define GRID_SIZE   8
 
#define NUM_CHANNELS   3
 
#define OFFSET(x)   offsetof(PhotosensitivityContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define NUM_CELLS   (GRID_SIZE * GRID_SIZE)
 

Functions

 AVFILTER_DEFINE_CLASS (photosensitivity)
 
static int convert_frame_partial (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static void convert_frame (AVFilterContext *ctx, AVFrame *in, PhotosensitivityFrame *out, int skip)
 
static int blend_frame_partial (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static void blend_frame (AVFilterContext *ctx, AVFrame *target, AVFrame *source, float factor)
 
static int get_badness (PhotosensitivityFrame *a, PhotosensitivityFrame *b)
 
static int config_input (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption photosensitivity_options []
 
static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
const AVFilter ff_vf_photosensitivity
 

Macro Definition Documentation

◆ MAX_FRAMES

#define MAX_FRAMES   240

Definition at line 32 of file vf_photosensitivity.c.

◆ GRID_SIZE

#define GRID_SIZE   8

Definition at line 33 of file vf_photosensitivity.c.

◆ NUM_CHANNELS

#define NUM_CHANNELS   3

Definition at line 34 of file vf_photosensitivity.c.

◆ OFFSET

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

Definition at line 58 of file vf_photosensitivity.c.

◆ FLAGS

Definition at line 59 of file vf_photosensitivity.c.

◆ NUM_CELLS

#define NUM_CELLS   (GRID_SIZE * GRID_SIZE)

Definition at line 80 of file vf_photosensitivity.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( photosensitivity  )

◆ convert_frame_partial()

static int convert_frame_partial ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 82 of file vf_photosensitivity.c.

Referenced by convert_frame().

◆ convert_frame()

static void convert_frame ( AVFilterContext ctx,
AVFrame in,
PhotosensitivityFrame out,
int  skip 
)
static

Definition at line 130 of file vf_photosensitivity.c.

Referenced by filter_frame().

◆ blend_frame_partial()

static int blend_frame_partial ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 147 of file vf_photosensitivity.c.

Referenced by blend_frame().

◆ blend_frame()

static void blend_frame ( AVFilterContext ctx,
AVFrame target,
AVFrame source,
float  factor 
)
static

Definition at line 170 of file vf_photosensitivity.c.

Referenced by filter_frame().

◆ get_badness()

static int get_badness ( PhotosensitivityFrame a,
PhotosensitivityFrame b 
)
static

Definition at line 180 of file vf_photosensitivity.c.

Referenced by filter_frame().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 196 of file vf_photosensitivity.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 207 of file vf_photosensitivity.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 296 of file vf_photosensitivity.c.

Variable Documentation

◆ photosensitivity_options

const AVOption photosensitivity_options[]
static
Initial value:
= {
{ "frames", "set how many frames to use", OFFSET(nb_frames), AV_OPT_TYPE_INT, {.i64=30}, 2, MAX_FRAMES, FLAGS },
{ "f", "set how many frames to use", OFFSET(nb_frames), AV_OPT_TYPE_INT, {.i64=30}, 2, MAX_FRAMES, FLAGS },
{ "threshold", "set detection threshold factor (lower is stricter)", OFFSET(threshold_multiplier), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0.1, FLT_MAX, FLAGS },
{ "t", "set detection threshold factor (lower is stricter)", OFFSET(threshold_multiplier), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0.1, FLT_MAX, FLAGS },
{ "skip", "set pixels to skip when sampling frames", OFFSET(skip), AV_OPT_TYPE_INT, {.i64=1}, 1, 1024, FLAGS },
{ "bypass", "leave frames unchanged", OFFSET(bypass), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
{ NULL }
}

Definition at line 61 of file vf_photosensitivity.c.

◆ inputs

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

Definition at line 303 of file vf_photosensitivity.c.

◆ outputs

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

Definition at line 312 of file vf_photosensitivity.c.

◆ ff_vf_photosensitivity

const AVFilter ff_vf_photosensitivity
Initial value:
= {
.name = "photosensitivity",
.description = NULL_IF_CONFIG_SMALL("Filter out photosensitive epilepsy seizure-inducing flashes."),
.priv_size = sizeof(PhotosensitivityContext),
.priv_class = &photosensitivity_class,
}

Definition at line 319 of file vf_photosensitivity.c.

config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_photosensitivity.c:196
PhotosensitivityContext
Definition: vf_photosensitivity.c:40
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_photosensitivity.c:296
OFFSET
#define OFFSET(x)
Definition: vf_photosensitivity.c:58
outputs
static const AVFilterPad outputs[]
Definition: vf_photosensitivity.c:312
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
NULL
#define NULL
Definition: coverity.c:32
FLAGS
#define FLAGS
Definition: vf_photosensitivity.c:59
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
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
FILTER_PIXFMTS
#define FILTER_PIXFMTS(...)
Definition: internal.h:176
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_photosensitivity.c:207
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
MAX_FRAMES
#define MAX_FRAMES
Definition: vf_photosensitivity.c:32
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
inputs
static const AVFilterPad inputs[]
Definition: vf_photosensitivity.c:303
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191