FFmpeg
Data Structures | Macros | Functions | Variables
vf_codecview.c File Reference
#include "libavutil/imgutils.h"
#include "libavutil/motion_vector.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "qp_table.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  CodecViewContext
 

Macros

#define MV_P_FOR   (1<<0)
 
#define MV_B_FOR   (1<<1)
 
#define MV_B_BACK   (1<<2)
 
#define MV_TYPE_FOR   (1<<0)
 
#define MV_TYPE_BACK   (1<<1)
 
#define FRAME_TYPE_I   (1<<0)
 
#define FRAME_TYPE_P   (1<<1)
 
#define FRAME_TYPE_B   (1<<2)
 
#define OFFSET(x)   offsetof(CodecViewContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define CONST(name, help, val, unit)   { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit }
 

Functions

 AVFILTER_DEFINE_CLASS (codecview)
 
static int query_formats (AVFilterContext *ctx)
 
static int clip_line (int *sx, int *sy, int *ex, int *ey, int maxx)
 
static void draw_line (uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color)
 Draw a line from (ex, ey) -> (sx, sy). More...
 
static void draw_arrow (uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color, int tail, int direction)
 Draw an arrow from (ex, ey) -> (sx, sy). More...
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
static int config_input (AVFilterLink *inlink)
 

Variables

static const AVOption codecview_options []
 
static const AVFilterPad codecview_inputs []
 
static const AVFilterPad codecview_outputs []
 
AVFilter ff_vf_codecview
 

Detailed Description

Codec debug viewer filter.

All the MV drawing code from Michael Niedermayer is extracted from libavcodec/mpegvideo.c.

TODO: segmentation

Definition in file vf_codecview.c.

Macro Definition Documentation

◆ MV_P_FOR

#define MV_P_FOR   (1<<0)

Definition at line 39 of file vf_codecview.c.

◆ MV_B_FOR

#define MV_B_FOR   (1<<1)

Definition at line 40 of file vf_codecview.c.

◆ MV_B_BACK

#define MV_B_BACK   (1<<2)

Definition at line 41 of file vf_codecview.c.

◆ MV_TYPE_FOR

#define MV_TYPE_FOR   (1<<0)

Definition at line 42 of file vf_codecview.c.

◆ MV_TYPE_BACK

#define MV_TYPE_BACK   (1<<1)

Definition at line 43 of file vf_codecview.c.

◆ FRAME_TYPE_I

#define FRAME_TYPE_I   (1<<0)

Definition at line 44 of file vf_codecview.c.

◆ FRAME_TYPE_P

#define FRAME_TYPE_P   (1<<1)

Definition at line 45 of file vf_codecview.c.

◆ FRAME_TYPE_B

#define FRAME_TYPE_B   (1<<2)

Definition at line 46 of file vf_codecview.c.

◆ OFFSET

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

Definition at line 57 of file vf_codecview.c.

◆ FLAGS

Definition at line 58 of file vf_codecview.c.

◆ CONST

#define CONST (   name,
  help,
  val,
  unit 
)    { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit }

Definition at line 59 of file vf_codecview.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( codecview  )

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 81 of file vf_codecview.c.

◆ clip_line()

static int clip_line ( int sx,
int sy,
int ex,
int ey,
int  maxx 
)
static

Definition at line 92 of file vf_codecview.c.

Referenced by draw_line().

◆ draw_line()

static void draw_line ( uint8_t buf,
int  sx,
int  sy,
int  ex,
int  ey,
int  w,
int  h,
int  stride,
int  color 
)
static

Draw a line from (ex, ey) -> (sx, sy).

Parameters
wwidth of the image
hheight of the image
stridestride/linesize of the image
colorcolor of the arrow

Definition at line 120 of file vf_codecview.c.

Referenced by draw_arrow().

◆ draw_arrow()

static void draw_arrow ( uint8_t buf,
int  sx,
int  sy,
int  ex,
int  ey,
int  w,
int  h,
int  stride,
int  color,
int  tail,
int  direction 
)
static

Draw an arrow from (ex, ey) -> (sx, sy).

Parameters
wwidth of the image
hheight of the image
stridestride/linesize of the image
colorcolor of the arrow

Definition at line 178 of file vf_codecview.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 216 of file vf_codecview.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 291 of file vf_codecview.c.

Variable Documentation

◆ codecview_options

const AVOption codecview_options[]
static
Initial value:
= {
{ "mv", "set motion vectors to visualize", OFFSET(mv), AV_OPT_TYPE_FLAGS, {.i64=0}, 0, INT_MAX, FLAGS, "mv" },
CONST("pf", "forward predicted MVs of P-frames", MV_P_FOR, "mv"),
CONST("bf", "forward predicted MVs of B-frames", MV_B_FOR, "mv"),
CONST("bb", "backward predicted MVs of B-frames", MV_B_BACK, "mv"),
{ "qp", NULL, OFFSET(qp), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, .flags = FLAGS },
{ "mv_type", "set motion vectors type", OFFSET(mv_type), AV_OPT_TYPE_FLAGS, {.i64=0}, 0, INT_MAX, FLAGS, "mv_type" },
{ "mvt", "set motion vectors type", OFFSET(mv_type), AV_OPT_TYPE_FLAGS, {.i64=0}, 0, INT_MAX, FLAGS, "mv_type" },
CONST("fp", "forward predicted MVs", MV_TYPE_FOR, "mv_type"),
CONST("bp", "backward predicted MVs", MV_TYPE_BACK, "mv_type"),
{ "frame_type", "set frame types to visualize motion vectors of", OFFSET(frame_type), AV_OPT_TYPE_FLAGS, {.i64=0}, 0, INT_MAX, FLAGS, "frame_type" },
{ "ft", "set frame types to visualize motion vectors of", OFFSET(frame_type), AV_OPT_TYPE_FLAGS, {.i64=0}, 0, INT_MAX, FLAGS, "frame_type" },
CONST("if", "I-frames", FRAME_TYPE_I, "frame_type"),
CONST("pf", "P-frames", FRAME_TYPE_P, "frame_type"),
CONST("bf", "B-frames", FRAME_TYPE_B, "frame_type"),
{ NULL }
}

Definition at line 61 of file vf_codecview.c.

◆ codecview_inputs

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

Definition at line 302 of file vf_codecview.c.

◆ codecview_outputs

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

Definition at line 313 of file vf_codecview.c.

◆ ff_vf_codecview

AVFilter ff_vf_codecview
Initial value:
= {
.name = "codecview",
.description = NULL_IF_CONFIG_SMALL("Visualize information about some codecs."),
.priv_size = sizeof(CodecViewContext),
.priv_class = &codecview_class,
}

Definition at line 321 of file vf_codecview.c.

MV_B_FOR
#define MV_B_FOR
Definition: vf_codecview.c:40
mv
static const int8_t mv[256][2]
Definition: 4xm.c:78
MV_P_FOR
#define MV_P_FOR
Definition: vf_codecview.c:39
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_codecview.c:81
CONST
#define CONST(name, help, val, unit)
Definition: vf_codecview.c:59
OFFSET
#define OFFSET(x)
Definition: vf_codecview.c:57
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
codecview_inputs
static const AVFilterPad codecview_inputs[]
Definition: vf_codecview.c:302
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
MV_B_BACK
#define MV_B_BACK
Definition: vf_codecview.c:41
CodecViewContext
Definition: vf_codecview.c:48
FRAME_TYPE_I
#define FRAME_TYPE_I
Definition: vf_codecview.c:44
codecview_outputs
static const AVFilterPad codecview_outputs[]
Definition: vf_codecview.c:313
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
frame_type
frame_type
Definition: jpeg2000_parser.c:31
FRAME_TYPE_B
#define FRAME_TYPE_B
Definition: vf_codecview.c:46
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_codecview.c:216
FLAGS
#define FLAGS
Definition: vf_codecview.c:58
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
MV_TYPE_FOR
#define MV_TYPE_FOR
Definition: vf_codecview.c:42
MV_TYPE_BACK
#define MV_TYPE_BACK
Definition: vf_codecview.c:43
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:224
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_codecview.c:291
FRAME_TYPE_P
#define FRAME_TYPE_P
Definition: vf_codecview.c:45