Skip to content

Commit

Permalink
vf_codecview: added i-frames support
Browse files Browse the repository at this point in the history
  • Loading branch information
davsinghm committed May 7, 2016
1 parent 45112cd commit b5c83ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions doc/filters.texi
Expand Up @@ -4727,10 +4727,12 @@ Set frame types to display motion vectors of.
Available flags for @var{frames} are:

@table @samp
@item if
intra-coded frames (I-frames)
@item pf
predicted frames (p-frames)
predicted frames (P-frames)
@item bf
bi-directionally predicted frames (b-frames)
bi-directionally predicted frames (B-frames)
@end table

@item qp
Expand Down
10 changes: 7 additions & 3 deletions libavfilter/vf_codecview.c
Expand Up @@ -37,8 +37,9 @@

#define MV_FOR (1<<0)
#define MV_BACK (1<<1)
#define FRAME_TYPE_P (1<<0)
#define FRAME_TYPE_B (1<<1)
#define FRAME_TYPE_I (1<<0)
#define FRAME_TYPE_P (1<<1)
#define FRAME_TYPE_B (1<<2)

typedef struct {
const AVClass *class;
Expand All @@ -57,6 +58,7 @@ static const AVOption codecview_options[] = {
CONST("fp", "forward predicted MVs", MV_FOR, "mv"),
CONST("bp", "backward predicted MVs", MV_BACK, "mv"),
{ "frames", "set frame types to display MVs of", OFFSET(frames), AV_OPT_TYPE_FLAGS, {.i64=3}, 0, INT_MAX, FLAGS, "frames" },
CONST("if", "i-frames", FRAME_TYPE_I, "frames"),
CONST("pf", "p-frames", FRAME_TYPE_P, "frames"),
CONST("bf", "b-frames", FRAME_TYPE_B, "frames"),
{ "qp", NULL, OFFSET(qp), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, .flags = FLAGS },
Expand Down Expand Up @@ -238,8 +240,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
for (i = 0; i < sd->size / sizeof(*mvs); i++) {
const AVMotionVector *mv = &mvs[i];
const int direction = mv->source > 0;
if ((direction == 0 && (s->mv & MV_FOR) && (s->frames & FRAME_TYPE_P) && frame->pict_type == AV_PICTURE_TYPE_P) ||
if ((direction == 0 && (s->mv & MV_FOR) && (s->frames & FRAME_TYPE_I) && frame->pict_type == AV_PICTURE_TYPE_I) ||
(direction == 0 && (s->mv & MV_FOR) && (s->frames & FRAME_TYPE_P) && frame->pict_type == AV_PICTURE_TYPE_P) ||
(direction == 0 && (s->mv & MV_FOR) && (s->frames & FRAME_TYPE_B) && frame->pict_type == AV_PICTURE_TYPE_B) ||
(direction == 1 && (s->mv & MV_BACK) && (s->frames & FRAME_TYPE_I) && frame->pict_type == AV_PICTURE_TYPE_I) ||
(direction == 1 && (s->mv & MV_BACK) && (s->frames & FRAME_TYPE_B) && frame->pict_type == AV_PICTURE_TYPE_B))
draw_arrow(frame->data[0], mv->dst_x, mv->dst_y, mv->src_x, mv->src_y,
frame->width, frame->height, frame->linesize[0],
Expand Down

0 comments on commit b5c83ee

Please sign in to comment.