FFmpeg
Data Structures | Macros | Functions | Variables
vf_datascope.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/xga_font_data.h"
#include "avfilter.h"
#include "drawutils.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  DatascopeContext
 
struct  ThreadData
 Used for passing data between threads. More...
 
struct  PixscopeContext
 
struct  PixelValues
 
struct  OscilloscopeContext
 

Macros

#define OFFSET(x)   offsetof(DatascopeContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define FLAGSR   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
#define POFFSET(x)   offsetof(PixscopeContext, x)
 
#define SQR(x)   ((x)*(x))
 
#define OOFFSET(x)   offsetof(OscilloscopeContext, x)
 

Functions

 AVFILTER_DEFINE_CLASS (datascope)
 
static int query_formats (AVFilterContext *ctx)
 
static void draw_text (FFDrawContext *draw, AVFrame *frame, FFDrawColor *color, int x0, int y0, const uint8_t *text, int vertical)
 
static void pick_color8 (FFDrawContext *draw, FFDrawColor *color, AVFrame *in, int x, int y, int *value)
 
static void pick_color16 (FFDrawContext *draw, FFDrawColor *color, AVFrame *in, int x, int y, int *value)
 
static void reverse_color8 (FFDrawContext *draw, FFDrawColor *color, FFDrawColor *reverse)
 
static void reverse_color16 (FFDrawContext *draw, FFDrawColor *color, FFDrawColor *reverse)
 
static int filter_color2 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_color (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_mono (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int config_input (AVFilterLink *inlink)
 
static int config_output (AVFilterLink *outlink)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 
 AVFILTER_DEFINE_CLASS (pixscope)
 
static int pixscope_config_input (AVFilterLink *inlink)
 
static int pixscope_filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int pixscope_process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 
 AVFILTER_DEFINE_CLASS (oscilloscope)
 
static void oscilloscope_uninit (AVFilterContext *ctx)
 
static void draw_line (FFDrawContext *draw, int x0, int y0, int x1, int y1, AVFrame *out, FFDrawColor *color)
 
static void draw_trace8 (OscilloscopeContext *s, AVFrame *frame)
 
static void draw_trace16 (OscilloscopeContext *s, AVFrame *frame)
 
static void update_oscilloscope (AVFilterContext *ctx)
 
static int oscilloscope_config_input (AVFilterLink *inlink)
 
static void draw_scope (OscilloscopeContext *s, int x0, int y0, int x1, int y1, AVFrame *out, PixelValues *p, int state)
 
static int oscilloscope_filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
static int oscilloscope_process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 

Variables

static const AVOption datascope_options []
 
static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
const AVFilter ff_vf_datascope
 
static const AVOption pixscope_options []
 
static const AVFilterPad pixscope_inputs []
 
static const AVFilterPad pixscope_outputs []
 
const AVFilter ff_vf_pixscope
 
static const AVOption oscilloscope_options []
 
static const AVFilterPad oscilloscope_inputs []
 
static const AVFilterPad oscilloscope_outputs []
 
const AVFilter ff_vf_oscilloscope
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 57 of file vf_datascope.c.

◆ FLAGS

Definition at line 58 of file vf_datascope.c.

◆ FLAGSR

Definition at line 59 of file vf_datascope.c.

◆ POFFSET

#define POFFSET (   x)    offsetof(PixscopeContext, x)

Definition at line 494 of file vf_datascope.c.

◆ SQR

#define SQR (   x)    ((x)*(x))

Definition at line 565 of file vf_datascope.c.

◆ OOFFSET

#define OOFFSET (   x)    offsetof(OscilloscopeContext, x)

Definition at line 800 of file vf_datascope.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS() [1/3]

AVFILTER_DEFINE_CLASS ( datascope  )

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 81 of file vf_datascope.c.

◆ draw_text()

static void draw_text ( FFDrawContext draw,
AVFrame frame,
FFDrawColor color,
int  x0,
int  y0,
const uint8_t *  text,
int  vertical 
)
static

◆ pick_color8()

static void pick_color8 ( FFDrawContext draw,
FFDrawColor color,
AVFrame in,
int  x,
int  y,
int value 
)
static

Definition at line 109 of file vf_datascope.c.

Referenced by config_input(), oscilloscope_config_input(), and pixscope_config_input().

◆ pick_color16()

static void pick_color16 ( FFDrawContext draw,
FFDrawColor color,
AVFrame in,
int  x,
int  y,
int value 
)
static

Definition at line 127 of file vf_datascope.c.

Referenced by config_input(), oscilloscope_config_input(), and pixscope_config_input().

◆ reverse_color8()

static void reverse_color8 ( FFDrawContext draw,
FFDrawColor color,
FFDrawColor reverse 
)
static

Definition at line 145 of file vf_datascope.c.

Referenced by config_input().

◆ reverse_color16()

static void reverse_color16 ( FFDrawContext draw,
FFDrawColor color,
FFDrawColor reverse 
)
static

Definition at line 157 of file vf_datascope.c.

Referenced by config_input().

◆ filter_color2()

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

Definition at line 177 of file vf_datascope.c.

Referenced by config_input().

◆ filter_color()

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

Definition at line 224 of file vf_datascope.c.

Referenced by config_input().

◆ filter_mono()

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

Definition at line 267 of file vf_datascope.c.

Referenced by config_input().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 309 of file vf_datascope.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 380 of file vf_datascope.c.

Referenced by process_command().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 411 of file vf_datascope.c.

◆ process_command()

static int process_command ( AVFilterContext ctx,
const char *  cmd,
const char *  args,
char *  res,
int  res_len,
int  flags 
)
static

Definition at line 422 of file vf_datascope.c.

◆ AVFILTER_DEFINE_CLASS() [2/3]

AVFILTER_DEFINE_CLASS ( pixscope  )

◆ pixscope_config_input()

static int pixscope_config_input ( AVFilterLink inlink)
static

Definition at line 509 of file vf_datascope.c.

Referenced by pixscope_process_command().

◆ pixscope_filter_frame()

static int pixscope_filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 567 of file vf_datascope.c.

◆ pixscope_process_command()

static int pixscope_process_command ( AVFilterContext ctx,
const char *  cmd,
const char *  args,
char *  res,
int  res_len,
int  flags 
)
static

Definition at line 712 of file vf_datascope.c.

◆ AVFILTER_DEFINE_CLASS() [3/3]

AVFILTER_DEFINE_CLASS ( oscilloscope  )

◆ oscilloscope_uninit()

static void oscilloscope_uninit ( AVFilterContext ctx)
static

Definition at line 821 of file vf_datascope.c.

◆ draw_line()

static void draw_line ( FFDrawContext draw,
int  x0,
int  y0,
int  x1,
int  y1,
AVFrame out,
FFDrawColor color 
)
static

Definition at line 828 of file vf_datascope.c.

Referenced by draw_trace16(), and draw_trace8().

◆ draw_trace8()

static void draw_trace8 ( OscilloscopeContext s,
AVFrame frame 
)
static

Definition at line 876 of file vf_datascope.c.

Referenced by oscilloscope_config_input().

◆ draw_trace16()

static void draw_trace16 ( OscilloscopeContext s,
AVFrame frame 
)
static

Definition at line 895 of file vf_datascope.c.

Referenced by oscilloscope_config_input().

◆ update_oscilloscope()

static void update_oscilloscope ( AVFilterContext ctx)
static

Definition at line 913 of file vf_datascope.c.

Referenced by oscilloscope_config_input(), and oscilloscope_process_command().

◆ oscilloscope_config_input()

static int oscilloscope_config_input ( AVFilterLink inlink)
static

Definition at line 936 of file vf_datascope.c.

◆ draw_scope()

static void draw_scope ( OscilloscopeContext s,
int  x0,
int  y0,
int  x1,
int  y1,
AVFrame out,
PixelValues p,
int  state 
)
static

Definition at line 991 of file vf_datascope.c.

Referenced by oscilloscope_filter_frame().

◆ oscilloscope_filter_frame()

static int oscilloscope_filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 1050 of file vf_datascope.c.

◆ oscilloscope_process_command()

static int oscilloscope_process_command ( AVFilterContext ctx,
const char *  cmd,
const char *  args,
char *  res,
int  res_len,
int  flags 
)
static

Definition at line 1115 of file vf_datascope.c.

Variable Documentation

◆ datascope_options

const AVOption datascope_options[]
static
Initial value:
= {
{ "size", "set output size", OFFSET(ow), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
{ "s", "set output size", OFFSET(ow), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
{ "x", "set x offset", OFFSET(x), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGSR },
{ "y", "set y offset", OFFSET(y), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGSR },
{ "mode", "set scope mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGSR, "mode" },
{ "mono", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGSR, "mode" },
{ "color", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGSR, "mode" },
{ "color2", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGSR, "mode" },
{ "axis", "draw column/row numbers", OFFSET(axis), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGSR },
{ "opacity", "set background opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, FLAGSR },
{ "format", "set display number format", OFFSET(dformat), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGSR, "format" },
{ "hex", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGSR, "format" },
{ "dec", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGSR, "format" },
{ "components", "set components to display", OFFSET(components), AV_OPT_TYPE_INT, {.i64=15}, 1, 15, FLAGSR },
{ NULL }
}

Definition at line 61 of file vf_datascope.c.

◆ inputs

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

Definition at line 434 of file vf_datascope.c.

◆ outputs

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

Definition at line 444 of file vf_datascope.c.

◆ ff_vf_datascope

const AVFilter ff_vf_datascope
Initial value:
= {
.name = "datascope",
.description = NULL_IF_CONFIG_SMALL("Video data analysis."),
.priv_size = sizeof(DatascopeContext),
.priv_class = &datascope_class,
}

Definition at line 453 of file vf_datascope.c.

◆ pixscope_options

const AVOption pixscope_options[]
static
Initial value:
= {
{ "x", "set scope x offset", POFFSET(xpos), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGSR },
{ "y", "set scope y offset", POFFSET(ypos), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGSR },
{ "w", "set scope width", POFFSET(w), AV_OPT_TYPE_INT, {.i64=7}, 1, 80, FLAGSR },
{ "h", "set scope height", POFFSET(h), AV_OPT_TYPE_INT, {.i64=7}, 1, 80, FLAGSR },
{ "o", "set window opacity", POFFSET(o), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGSR },
{ "wx", "set window x offset", POFFSET(wx), AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1, 1, FLAGSR },
{ "wy", "set window y offset", POFFSET(wy), AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1, 1, FLAGSR },
{ NULL }
}

Definition at line 496 of file vf_datascope.c.

◆ pixscope_inputs

const AVFilterPad pixscope_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = pixscope_filter_frame,
.config_props = pixscope_config_input,
},
{ NULL }
}

Definition at line 724 of file vf_datascope.c.

◆ pixscope_outputs

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

Definition at line 734 of file vf_datascope.c.

◆ ff_vf_pixscope

const AVFilter ff_vf_pixscope
Initial value:
= {
.name = "pixscope",
.description = NULL_IF_CONFIG_SMALL("Pixel data analysis."),
.priv_size = sizeof(PixscopeContext),
.priv_class = &pixscope_class,
}

Definition at line 742 of file vf_datascope.c.

◆ oscilloscope_options

const AVOption oscilloscope_options[]
static
Initial value:
= {
{ "x", "set scope x position", OOFFSET(xpos), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGSR },
{ "y", "set scope y position", OOFFSET(ypos), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGSR },
{ "s", "set scope size", OOFFSET(size), AV_OPT_TYPE_FLOAT, {.dbl=0.8}, 0, 1, FLAGSR },
{ "t", "set scope tilt", OOFFSET(tilt), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGSR },
{ "o", "set trace opacity", OOFFSET(o), AV_OPT_TYPE_FLOAT, {.dbl=0.8}, 0, 1, FLAGSR },
{ "tx", "set trace x position", OOFFSET(tx), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGSR },
{ "ty", "set trace y position", OOFFSET(ty), AV_OPT_TYPE_FLOAT, {.dbl=0.9}, 0, 1, FLAGSR },
{ "tw", "set trace width", OOFFSET(twidth), AV_OPT_TYPE_FLOAT, {.dbl=0.8},.1, 1, FLAGSR },
{ "th", "set trace height", OOFFSET(theight), AV_OPT_TYPE_FLOAT, {.dbl=0.3},.1, 1, FLAGSR },
{ "c", "set components to trace", OOFFSET(components), AV_OPT_TYPE_INT, {.i64=7}, 0, 15, FLAGSR },
{ "g", "draw trace grid", OOFFSET(grid), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGSR },
{ "st", "draw statistics", OOFFSET(statistics), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGSR },
{ "sc", "draw scope", OOFFSET(scope), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGSR },
{ NULL }
}

Definition at line 802 of file vf_datascope.c.

◆ oscilloscope_inputs

const AVFilterPad oscilloscope_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = oscilloscope_filter_frame,
.config_props = oscilloscope_config_input,
.needs_writable = 1,
},
{ NULL }
}

Definition at line 1129 of file vf_datascope.c.

◆ oscilloscope_outputs

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

Definition at line 1140 of file vf_datascope.c.

◆ ff_vf_oscilloscope

const AVFilter ff_vf_oscilloscope
Initial value:
= {
.name = "oscilloscope",
.description = NULL_IF_CONFIG_SMALL("2D Video Oscilloscope."),
.priv_size = sizeof(OscilloscopeContext),
.priv_class = &oscilloscope_class,
}

Definition at line 1148 of file vf_datascope.c.

pixscope_inputs
static const AVFilterPad pixscope_inputs[]
Definition: vf_datascope.c:724
pixscope_outputs
static const AVFilterPad pixscope_outputs[]
Definition: vf_datascope.c:734
pixscope_process_command
static int pixscope_process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_datascope.c:712
w
uint8_t w
Definition: llviddspenc.c:39
OFFSET
#define OFFSET(x)
Definition: vf_datascope.c:57
OOFFSET
#define OOFFSET(x)
Definition: vf_datascope.c:800
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_datascope.c:422
oscilloscope_uninit
static void oscilloscope_uninit(AVFilterContext *ctx)
Definition: vf_datascope.c:821
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_datascope.c:380
inputs
static const AVFilterPad inputs[]
Definition: vf_datascope.c:434
oscilloscope_outputs
static const AVFilterPad oscilloscope_outputs[]
Definition: vf_datascope.c:1140
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_datascope.c:81
POFFSET
#define POFFSET(x)
Definition: vf_datascope.c:494
NULL
#define NULL
Definition: coverity.c:32
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:235
DatascopeContext
Definition: vf_datascope.c:33
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
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_datascope.c:309
FLAGS
#define FLAGS
Definition: vf_datascope.c:58
oscilloscope_process_command
static int oscilloscope_process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_datascope.c:1115
outputs
static const AVFilterPad outputs[]
Definition: vf_datascope.c:444
size
int size
Definition: twinvq_data.h:10344
oscilloscope_inputs
static const AVFilterPad oscilloscope_inputs[]
Definition: vf_datascope.c:1129
pixscope_filter_frame
static int pixscope_filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_datascope.c:567
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:126
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
OscilloscopeContext
Definition: vf_datascope.c:758
PixscopeContext
Definition: vf_datascope.c:465
FLAGSR
#define FLAGSR
Definition: vf_datascope.c:59
mode
mode
Definition: ebur128.h:83
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
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
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_datascope.c:411
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
pixscope_config_input
static int pixscope_config_input(AVFilterLink *inlink)
Definition: vf_datascope.c:509
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:279
h
h
Definition: vp9dsp_template.c:2038
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
oscilloscope_filter_frame
static int oscilloscope_filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_datascope.c:1050
oscilloscope_config_input
static int oscilloscope_config_input(AVFilterLink *inlink)
Definition: vf_datascope.c:936