FFmpeg
Data Structures | Macros | Functions | Variables
vf_photosensitivity.c File Reference
#include <float.h>
#include "libavutil/opt.h"
#include "avfilter.h"
#include "filters.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 []
 
const AVFilter ff_vf_photosensitivity
 

Macro Definition Documentation

◆ MAX_FRAMES

#define MAX_FRAMES   240

Definition at line 29 of file vf_photosensitivity.c.

◆ GRID_SIZE

#define GRID_SIZE   8

Definition at line 30 of file vf_photosensitivity.c.

◆ NUM_CHANNELS

#define NUM_CHANNELS   3

Definition at line 31 of file vf_photosensitivity.c.

◆ OFFSET

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

Definition at line 55 of file vf_photosensitivity.c.

◆ FLAGS

Definition at line 56 of file vf_photosensitivity.c.

◆ NUM_CELLS

#define NUM_CELLS   (GRID_SIZE * GRID_SIZE)

Definition at line 77 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 79 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 127 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 144 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 167 of file vf_photosensitivity.c.

Referenced by filter_frame().

◆ get_badness()

static int get_badness ( PhotosensitivityFrame a,
PhotosensitivityFrame b 
)
static

Definition at line 177 of file vf_photosensitivity.c.

Referenced by filter_frame().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 193 of file vf_photosensitivity.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 204 of file vf_photosensitivity.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 293 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 58 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 300 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 309 of file vf_photosensitivity.c.

config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_photosensitivity.c:193
PhotosensitivityContext
Definition: vf_photosensitivity.c:37
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_photosensitivity.c:293
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
OFFSET
#define OFFSET(x)
Definition: vf_photosensitivity.c:55
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
NULL
#define NULL
Definition: coverity.c:32
FLAGS
#define FLAGS
Definition: vf_photosensitivity.c:56
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
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:94
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_photosensitivity.c:204
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
FILTER_PIXFMTS
#define FILTER_PIXFMTS(...)
Definition: filters.h:248
MAX_FRAMES
#define MAX_FRAMES
Definition: vf_photosensitivity.c:29
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
inputs
static const AVFilterPad inputs[]
Definition: vf_photosensitivity.c:300
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
skip
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
Definition: bitstream_template.h:375