FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
vf_signalstats.c File Reference
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  SignalstatsContext
 
struct  ThreadData
 
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 DEPTH   256
 
#define SET_META(key, fmt, val)
 

Enumerations

enum  FilterMode {
  FILTER_8TAP_SMOOTH, FILTER_8TAP_REGULAR, FILTER_8TAP_SHARP, FILTER_BILINEAR,
  FILTER_SWITCHABLE, MODE_WIRES, MODE_COLORMIX, 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 int query_formats (AVFilterContext *ctx)
 
static AVFramealloc_frame (enum AVPixelFormat pixfmt, int w, int h)
 
static int config_props (AVFilterLink *outlink)
 
static void burn_frame (const SignalstatsContext *s, AVFrame *f, int x, int y)
 
static int filter_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 filter_tout (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_vrep (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int compute_sat_hue_metrics (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *link, AVFrame *in)
 

Variables

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

Macro Definition Documentation

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

Definition at line 65 of file vf_signalstats.c.

Definition at line 66 of file vf_signalstats.c.

#define FILTER (   i,
 
)
Value:
filter_tout_outlier(p[(y-j) * lw + x + i], \
p[ y * lw + x + i], \
p[(y+j) * lw + x + i])
float y
static int filter_tout_outlier(uint8_t x, uint8_t y, uint8_t z)
#define FILTER3 (   j)    (FILTER(-1, j) && FILTER(0, j) && FILTER(1, j))

Referenced by filter_tout().

#define VREP_START   4

Definition at line 272 of file vf_signalstats.c.

Referenced by filter_vrep().

#define DEPTH   256

Definition at line 318 of file vf_signalstats.c.

Referenced by filter_frame().

#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)
const char const char void * val
Definition: avisynth_c.h:634
const char * fmt
Definition: avisynth_c.h:632
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:69
#define snprintf
Definition: snprintf.h:34
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out

Referenced by filter_frame().

Enumeration Type Documentation

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

Definition at line 27 of file vf_signalstats.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( signalstats  )
static av_cold int init ( AVFilterContext ctx)
static

Definition at line 84 of file vf_signalstats.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 101 of file vf_signalstats.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 110 of file vf_signalstats.c.

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

Definition at line 127 of file vf_signalstats.c.

Referenced by config_props().

static int config_props ( AVFilterLink outlink)
static

Definition at line 145 of file vf_signalstats.c.

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

Definition at line 176 of file vf_signalstats.c.

Referenced by filter_brng(), filter_tout(), and filter_vrep().

static int filter_brng ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 185 of file vf_signalstats.c.

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

Definition at line 219 of file vf_signalstats.c.

static int filter_tout ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 224 of file vf_signalstats.c.

static int filter_vrep ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 274 of file vf_signalstats.c.

static int compute_sat_hue_metrics ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 320 of file vf_signalstats.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink link,
AVFrame in 
)
static

Definition at line 358 of file vf_signalstats.c.

Variable Documentation

const AVOption signalstats_options[]
static
Initial value:
= {
{"stat", "set statistics filters", OFFSET(filters), AV_OPT_TYPE_FLAGS, {.i64=0}, 0, INT_MAX, FLAGS, "filters"},
{"tout", "analyze pixels for temporal outliers", 0, AV_OPT_TYPE_CONST, {.i64=1<<FILTER_TOUT}, 0, 0, FLAGS, "filters"},
{"vrep", "analyze video lines for vertical line repetition", 0, AV_OPT_TYPE_CONST, {.i64=1<<FILTER_VREP}, 0, 0, FLAGS, "filters"},
{"brng", "analyze for pixels outside of broadcast range", 0, AV_OPT_TYPE_CONST, {.i64=1<<FILTER_BRNG}, 0, 0, FLAGS, "filters"},
{"out", "set video filter", OFFSET(outfilter), AV_OPT_TYPE_INT, {.i64=FILTER_NONE}, -1, FILT_NUMB-1, FLAGS, "out"},
{"tout", "highlight pixels that depict temporal outliers", 0, AV_OPT_TYPE_CONST, {.i64=FILTER_TOUT}, 0, 0, FLAGS, "out"},
{"vrep", "highlight video lines that depict vertical line repetition", 0, AV_OPT_TYPE_CONST, {.i64=FILTER_VREP}, 0, 0, FLAGS, "out"},
{"brng", "highlight pixels that are outside of broadcast range", 0, AV_OPT_TYPE_CONST, {.i64=FILTER_BRNG}, 0, 0, FLAGS, "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}
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
#define FLAGS
static const struct PPFilter filters[]
Definition: postprocess.c:137

Definition at line 68 of file vf_signalstats.c.

const char* name

Definition at line 309 of file vf_signalstats.c.

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

Definition at line 310 of file vf_signalstats.c.

Referenced by filter_frame(), and swscale().

const { ... } filters_def[]
Initial value:
= {
{"TOUT", filter_tout},
{"VREP", filter_vrep},
{"BRNG", filter_brng},
{NULL}
}
#define NULL
Definition: coverity.c:32
static int filter_brng(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_vrep(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_tout(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)

Referenced by filter_frame().

const AVFilterPad signalstats_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *link, AVFrame *in)

Definition at line 566 of file vf_signalstats.c.

const AVFilterPad signalstats_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_props,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_props(AVFilterLink *outlink)

Definition at line 575 of file vf_signalstats.c.

AVFilter ff_vf_signalstats
Initial value:
= {
.name = "signalstats",
.description = "Generate statistics from video analysis.",
.init = init,
.uninit = uninit,
.query_formats = query_formats,
.priv_size = sizeof(SignalstatsContext),
.priv_class = &signalstats_class,
}
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:248
static const AVFilterPad signalstats_outputs[]
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:442
static const AVFilterPad signalstats_inputs[]
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:239
static int flags
Definition: cpu.c:47
static int query_formats(AVFilterContext *ctx)
static av_cold int init(AVFilterContext *ctx)

Definition at line 584 of file vf_signalstats.c.