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

Go to the source code of this file.

Data Structures

struct  BlackDetectContext
 

Macros

#define OFFSET(x)   offsetof(BlackDetectContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define YUVJ_FORMATS   AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P
 

Functions

 AVFILTER_DEFINE_CLASS (blackdetect)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static void check_black_end (AVFilterContext *ctx)
 
static int black_counter (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *picref)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption blackdetect_options []
 
static enum AVPixelFormat yuvj_formats []
 
static const AVFilterPad blackdetect_inputs []
 
static const AVFilterPad blackdetect_outputs []
 
AVFilter ff_vf_blackdetect
 

Detailed Description

Video black detector, loosely based on blackframe with extended syntax and features

Definition in file vf_blackdetect.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 54 of file vf_blackdetect.c.

◆ FLAGS

Definition at line 55 of file vf_blackdetect.c.

◆ YUVJ_FORMATS

Definition at line 69 of file vf_blackdetect.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( blackdetect  )

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 76 of file vf_blackdetect.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 107 of file vf_blackdetect.c.

◆ check_black_end()

static void check_black_end ( AVFilterContext ctx)
static

Definition at line 137 of file vf_blackdetect.c.

Referenced by filter_frame(), and uninit().

◆ black_counter()

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

Definition at line 150 of file vf_blackdetect.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame picref 
)
static

Definition at line 188 of file vf_blackdetect.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 230 of file vf_blackdetect.c.

Variable Documentation

◆ blackdetect_options

const AVOption blackdetect_options[]
static
Initial value:
= {
{ "d", "set minimum detected black duration in seconds", OFFSET(black_min_duration_time), AV_OPT_TYPE_DOUBLE, {.dbl=2}, 0, DBL_MAX, FLAGS },
{ "black_min_duration", "set minimum detected black duration in seconds", OFFSET(black_min_duration_time), AV_OPT_TYPE_DOUBLE, {.dbl=2}, 0, DBL_MAX, FLAGS },
{ "picture_black_ratio_th", "set the picture black ratio threshold", OFFSET(picture_black_ratio_th), AV_OPT_TYPE_DOUBLE, {.dbl=.98}, 0, 1, FLAGS },
{ "pic_th", "set the picture black ratio threshold", OFFSET(picture_black_ratio_th), AV_OPT_TYPE_DOUBLE, {.dbl=.98}, 0, 1, FLAGS },
{ "pixel_black_th", "set the pixel black threshold", OFFSET(pixel_black_th), AV_OPT_TYPE_DOUBLE, {.dbl=.10}, 0, 1, FLAGS },
{ "pix_th", "set the pixel black threshold", OFFSET(pixel_black_th), AV_OPT_TYPE_DOUBLE, {.dbl=.10}, 0, 1, FLAGS },
{ NULL }
}

Definition at line 57 of file vf_blackdetect.c.

◆ yuvj_formats

enum AVPixelFormat yuvj_formats[]
static
Initial value:

Definition at line 72 of file vf_blackdetect.c.

Referenced by config_input().

◆ blackdetect_inputs

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

Definition at line 243 of file vf_blackdetect.c.

◆ blackdetect_outputs

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

Definition at line 253 of file vf_blackdetect.c.

◆ ff_vf_blackdetect

AVFilter ff_vf_blackdetect
Initial value:
= {
.name = "blackdetect",
.description = NULL_IF_CONFIG_SMALL("Detect video intervals that are (almost) black."),
.priv_size = sizeof(BlackDetectContext),
.priv_class = &blackdetect_class,
}

Definition at line 261 of file vf_blackdetect.c.

YUVJ_FORMATS
#define YUVJ_FORMATS
Definition: vf_blackdetect.c:69
blackdetect_inputs
static const AVFilterPad blackdetect_inputs[]
Definition: vf_blackdetect.c:243
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_blackdetect.c:230
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:227
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_blackdetect.c:107
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
NULL
#define NULL
Definition: coverity.c:32
inputs
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 inputs
Definition: filter_design.txt:243
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
FLAGS
#define FLAGS
Definition: vf_blackdetect.c:55
BlackDetectContext
Definition: vf_blackdetect.c:34
blackdetect_outputs
static const AVFilterPad blackdetect_outputs[]
Definition: vf_blackdetect.c:253
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
Definition: vf_blackdetect.c:188
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
OFFSET
#define OFFSET(x)
Definition: vf_blackdetect.c:54
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_blackdetect.c:76