Go to the documentation of this file.
29 #define MAX_FRAMES 240
31 #define NUM_CHANNELS 3
55 #define OFFSET(x) offsetof(PhotosensitivityContext, x)
56 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
61 {
"threshold",
"set detection threshold factor (lower is stricter)",
OFFSET(threshold_multiplier),
AV_OPT_TYPE_FLOAT, {.dbl=1}, 0.1, FLT_MAX,
FLAGS },
62 {
"t",
"set detection threshold factor (lower is stricter)",
OFFSET(threshold_multiplier),
AV_OPT_TYPE_FLOAT, {.dbl=1}, 0.1, FLT_MAX,
FLAGS },
77 #define NUM_CELLS (GRID_SIZE * GRID_SIZE)
81 int cell, gx, gy, x0, x1, y0, y1, x, y,
c, area;
105 for (y = y0; y < y1; y +=
skip) {
107 for (x = x0; x < x1; x +=
skip) {
150 const uint16_t s_mul = td->
s_mul;
151 const uint16_t t_mul = 0x100 - s_mul;
159 for (x = 0; x < linesize; x++) {
160 *t = (*t * t_mul + *
s * s_mul) >> 8;
179 int badness, x, y,
c;
184 badness +=
abs((
int)
a->grid[y][x][
c] - (
int)
b->grid[y][x][
c]);
199 s->badness_threshold = (int)(
GRID_SIZE *
GRID_SIZE * 4 * 256 *
s->nb_frames *
s->threshold_multiplier / 128);
206 int this_badness, current_badness, fixed_badness, new_badness,
i, res;
219 for (
i = 1;
i <
s->nb_frames;
i++)
220 current_badness +=
i *
s->history[(
s->history_pos +
i) %
s->nb_frames];
221 current_badness /=
s->nb_frames;
225 new_badness = current_badness + this_badness;
227 current_badness, new_badness,
s->badness_threshold,
228 100 * new_badness /
s->badness_threshold, new_badness < s->badness_threshold ?
"OK" :
"EXCEEDED");
230 fixed_badness = new_badness;
231 if (new_badness < s->badness_threshold || !
s->last_frame_av ||
s->bypass) {
234 s->last_frame_av =
src = in;
235 s->last_frame_e = ef;
236 s->history[
s->history_pos] = this_badness;
238 factor = (
float)(
s->badness_threshold - current_badness) / (new_badness - current_badness);
241 s->history[
s->history_pos] = 0;
252 fixed_badness = current_badness + this_badness;
254 current_badness, fixed_badness,
s->badness_threshold,
255 100 * new_badness /
s->badness_threshold,
factor);
256 s->last_frame_e = ef;
257 s->history[
s->history_pos] = this_badness;
259 src =
s->last_frame_av;
262 s->history_pos = (
s->history_pos + 1) %
s->nb_frames;
271 metadata = &
out->metadata;
310 .
name =
"photosensitivity",
311 .description =
NULL_IF_CONFIG_SMALL(
"Filter out photosensitive epilepsy seizure-inducing flashes."),
313 .priv_class = &photosensitivity_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
AVFILTER_DEFINE_CLASS(photosensitivity)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int config_input(AVFilterLink *inlink)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
#define AV_LOG_VERBOSE
Detailed information.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
const char * name
Filter name.
A link between two filters.
static int convert_frame_partial(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold void uninit(AVFilterContext *ctx)
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
static const AVOption photosensitivity_options[]
PhotosensitivityFrame last_frame_e
const AVFilter ff_vf_photosensitivity
A filter pad used for either input or output.
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
uint8_t grid[GRID_SIZE][GRID_SIZE][4]
#define FILTER_OUTPUTS(array)
static void convert_frame(AVFilterContext *ctx, AVFrame *in, PhotosensitivityFrame *out, int skip)
int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
Make sure a frame is writable.
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
PhotosensitivityFrame * out
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a source
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static void blend_frame(AVFilterContext *ctx, AVFrame *target, AVFrame *source, float factor)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
#define i(width, name, range_min, range_max)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
const char * name
Pad name.
#define FILTER_PIXFMTS(...)
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
static int blend_frame_partial(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
@ AV_OPT_TYPE_INT
Underlying C type is int.
static const int factor[16]
static const AVFilterPad inputs[]
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
static int get_badness(PhotosensitivityFrame *a, PhotosensitivityFrame *b)
float threshold_multiplier
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.