FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vf_signalstats.c File Reference
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "filters.h"

Go to the source code of this file.

Data Structures

struct  SignalstatsContext
 
struct  ThreadData
 Used for passing data between threads. More...
 
struct  ThreadDataHueSatMetrics
 

Macros

#define OFFSET(x)   offsetof(SignalstatsContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define FILTER(i, j)
 
#define FILTER3(j)   (FILTER(-1, j) && FILTER(0, j) && FILTER(1, j))
 
#define VREP_START   4
 
#define SET_META(key, fmt, val)
 

Enumerations

enum  FilterMode {
  FILTER_8TAP_SMOOTH, FILTER_8TAP_REGULAR, FILTER_8TAP_SHARP, FILTER_BILINEAR,
  N_FILTERS, FILTER_SWITCHABLE = N_FILTERS, MODE_WIRES, MODE_COLORMIX,
  MODE_CANNY, NB_MODE, MODE_NONE, MODE_INTERLEAVE,
  MODE_DEINTERLEAVE, FILTER_NONE = -1, FILTER_TOUT, FILTER_VREP,
  FILTER_BRNG, FILT_NUMB
}
 

Functions

 AVFILTER_DEFINE_CLASS (signalstats)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static AVFramealloc_frame (enum AVPixelFormat pixfmt, int w, int h)
 
static int config_output (AVFilterLink *outlink)
 
static void burn_frame8 (const SignalstatsContext *s, AVFrame *f, int x, int y)
 
static void burn_frame16 (const SignalstatsContext *s, AVFrame *f, int x, int y)
 
static int filter8_brng (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter16_brng (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_tout_outlier (uint8_t x, uint8_t y, uint8_t z)
 
static int filter8_tout (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter16_tout (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter8_vrep (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter16_vrep (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int compute_sat_hue_metrics8 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int compute_sat_hue_metrics16 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static unsigned compute_bit_depth (uint16_t mask)
 
static int filter_frame (AVFilterLink *link, AVFrame *in)
 

Variables

static const AVOption signalstats_options []
 
static enum AVPixelFormat pix_fmts []
 
struct {
   const char *   name
 
   int(*   process8 )(AVFilterContext *ctx, void
      *arg, int jobnr, int nb_jobs)
 
   int(*   process16 )(AVFilterContext *ctx, void
      *arg, int jobnr, int nb_jobs)
 
filters_def []
 
static const AVFilterPad signalstats_inputs []
 
static const AVFilterPad signalstats_outputs []
 
const AVFilter ff_vf_signalstats
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 71 of file vf_signalstats.c.

◆ FLAGS

Definition at line 72 of file vf_signalstats.c.

◆ FILTER

#define FILTER (   i,
 
)
Value:
filter_tout_outlier(p[(y-j) * lw + x + i], \
p[ y * lw + x + i], \
p[(y+j) * lw + x + i])

◆ FILTER3

#define FILTER3 (   j)    (FILTER(-1, j) && FILTER(0, j) && FILTER(1, j))

◆ VREP_START

#define VREP_START   4

Definition at line 376 of file vf_signalstats.c.

◆ SET_META

#define SET_META (   key,
  fmt,
  val 
)
Value:
do { \
snprintf(metabuf, sizeof(metabuf), fmt, val); \
av_dict_set(&out->metadata, "lavfi.signalstats." key, metabuf, 0); \
} while (0)

Enumeration Type Documentation

◆ FilterMode

enum FilterMode
Enumerator
FILTER_8TAP_SMOOTH 
FILTER_8TAP_REGULAR 
FILTER_8TAP_SHARP 
FILTER_BILINEAR 
N_FILTERS 
FILTER_SWITCHABLE 
MODE_WIRES 
MODE_COLORMIX 
MODE_CANNY 
NB_MODE 
MODE_NONE 
MODE_INTERLEAVE 
MODE_DEINTERLEAVE 
FILTER_NONE 
FILTER_TOUT 
FILTER_VREP 
FILTER_BRNG 
FILT_NUMB 

Definition at line 29 of file vf_signalstats.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( signalstats  )

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 90 of file vf_signalstats.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 107 of file vf_signalstats.c.

◆ alloc_frame()

static AVFrame* alloc_frame ( enum AVPixelFormat  pixfmt,
int  w,
int  h 
)
static

Definition at line 136 of file vf_signalstats.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 154 of file vf_signalstats.c.

◆ burn_frame8()

static void burn_frame8 ( const SignalstatsContext s,
AVFrame f,
int  x,
int  y 
)
static

Definition at line 194 of file vf_signalstats.c.

Referenced by filter8_brng(), filter8_tout(), and filter8_vrep().

◆ burn_frame16()

static void burn_frame16 ( const SignalstatsContext s,
AVFrame f,
int  x,
int  y 
)
static

Definition at line 203 of file vf_signalstats.c.

Referenced by filter16_brng(), filter16_tout(), and filter16_vrep().

◆ filter8_brng()

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

Definition at line 213 of file vf_signalstats.c.

◆ filter16_brng()

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

Definition at line 247 of file vf_signalstats.c.

◆ filter_tout_outlier()

static int filter_tout_outlier ( uint8_t  x,
uint8_t  y,
uint8_t  z 
)
static

Definition at line 282 of file vf_signalstats.c.

◆ filter8_tout()

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

Definition at line 287 of file vf_signalstats.c.

◆ filter16_tout()

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

Definition at line 335 of file vf_signalstats.c.

◆ filter8_vrep()

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

Definition at line 378 of file vf_signalstats.c.

◆ filter16_vrep()

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

Definition at line 412 of file vf_signalstats.c.

◆ compute_sat_hue_metrics8()

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

Definition at line 458 of file vf_signalstats.c.

Referenced by filter_frame().

◆ compute_sat_hue_metrics16()

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

Definition at line 496 of file vf_signalstats.c.

Referenced by filter_frame().

◆ compute_bit_depth()

static unsigned compute_bit_depth ( uint16_t  mask)
static

Definition at line 535 of file vf_signalstats.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink link,
AVFrame in 
)
static

Definition at line 540 of file vf_signalstats.c.

Variable Documentation

◆ signalstats_options

const AVOption signalstats_options[]
static
Initial value:
= {
{"stat", "set statistics filters", OFFSET(filters), AV_OPT_TYPE_FLAGS, {.i64=0}, 0, INT_MAX, FLAGS, .unit = "filters"},
{"tout", "analyze pixels for temporal outliers", 0, AV_OPT_TYPE_CONST, {.i64=1<<FILTER_TOUT}, 0, 0, FLAGS, .unit = "filters"},
{"vrep", "analyze video lines for vertical line repetition", 0, AV_OPT_TYPE_CONST, {.i64=1<<FILTER_VREP}, 0, 0, FLAGS, .unit = "filters"},
{"brng", "analyze for pixels outside of broadcast range", 0, AV_OPT_TYPE_CONST, {.i64=1<<FILTER_BRNG}, 0, 0, FLAGS, .unit = "filters"},
{"out", "set video filter", OFFSET(outfilter), AV_OPT_TYPE_INT, {.i64=FILTER_NONE}, -1, FILT_NUMB-1, FLAGS, .unit = "out"},
{"tout", "highlight pixels that depict temporal outliers", 0, AV_OPT_TYPE_CONST, {.i64=FILTER_TOUT}, 0, 0, FLAGS, .unit = "out"},
{"vrep", "highlight video lines that depict vertical line repetition", 0, AV_OPT_TYPE_CONST, {.i64=FILTER_VREP}, 0, 0, FLAGS, .unit = "out"},
{"brng", "highlight pixels that are outside of broadcast range", 0, AV_OPT_TYPE_CONST, {.i64=FILTER_BRNG}, 0, 0, FLAGS, .unit = "out"},
{"c", "set highlight color", OFFSET(rgba_color), AV_OPT_TYPE_COLOR, {.str="yellow"}, .flags=FLAGS},
{"color", "set highlight color", OFFSET(rgba_color), AV_OPT_TYPE_COLOR, {.str="yellow"}, .flags=FLAGS},
{NULL}
}

Definition at line 74 of file vf_signalstats.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ name

const char* name

Definition at line 448 of file vf_signalstats.c.

Referenced by filter_frame().

◆ process8

int(* process8) (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)

Definition at line 449 of file vf_signalstats.c.

Referenced by filter_frame().

◆ process16

int(* process16) (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)

Definition at line 450 of file vf_signalstats.c.

Referenced by filter_frame().

◆ filters_def

const { ... } filters_def[]
Initial value:

Referenced by filter_frame().

◆ signalstats_inputs

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

Definition at line 814 of file vf_signalstats.c.

◆ signalstats_outputs

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

Definition at line 822 of file vf_signalstats.c.

◆ ff_vf_signalstats

const AVFilter ff_vf_signalstats
Initial value:
= {
.name = "signalstats",
.description = "Generate statistics from video analysis.",
.init = init,
.uninit = uninit,
.priv_size = sizeof(SignalstatsContext),
.priv_class = &signalstats_class,
}

Definition at line 830 of file vf_signalstats.c.

FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
out
FILE * out
Definition: movenc.c:55
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_signalstats.c:90
filter8_brng
static int filter8_brng(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_signalstats.c:213
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:502
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
FLAGS
#define FLAGS
Definition: vf_signalstats.c:72
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:500
val
static double val(void *priv, double ch)
Definition: aeval.c:77
filter16_tout
static int filter16_tout(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_signalstats.c:335
filter_tout_outlier
static int filter_tout_outlier(uint8_t x, uint8_t y, uint8_t z)
Definition: vf_signalstats.c:282
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_signalstats.c:121
FILT_NUMB
@ FILT_NUMB
Definition: vf_signalstats.c:34
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:505
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:283
SignalstatsContext
Definition: vf_signalstats.c:37
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_signalstats.c:107
FILTER_VREP
@ FILTER_VREP
Definition: vf_signalstats.c:32
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:514
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:86
OFFSET
#define OFFSET(x)
Definition: vf_signalstats.c:71
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:515
filters
#define filters(fmt, type, inverse, clp, inverset, clip, one, clip_fn, packed)
Definition: af_crystalizer.c:55
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:499
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:513
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:73
key
const char * key
Definition: hwcontext_opencl.c:189
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
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:87
NULL
#define NULL
Definition: coverity.c:32
FILTER_BRNG
@ FILTER_BRNG
Definition: vf_signalstats.c:33
filter8_tout
static int filter8_tout(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_signalstats.c:287
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:85
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
Definition: opt.h:323
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:504
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:503
signalstats_inputs
static const AVFilterPad signalstats_inputs[]
Definition: vf_signalstats.c:814
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_signalstats.c:540
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:507
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:509
signalstats_outputs
static const AVFilterPad signalstats_outputs[]
Definition: vf_signalstats.c:822
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
FILTER_TOUT
@ FILTER_TOUT
Definition: vf_signalstats.c:31
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_signalstats.c:154
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:107
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:501
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:506
filter16_brng
static int filter16_brng(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_signalstats.c:247
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:511
FILTER_NONE
@ FILTER_NONE
Definition: vf_signalstats.c:30
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
filter8_vrep
static int filter8_vrep(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_signalstats.c:378
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:78
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:152
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:77
filter16_vrep
static int filter16_vrep(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_signalstats.c:412
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:80
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition: opt.h:255
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:508
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:512
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:510