Skip to content

Commit

Permalink
lavfi: Add drawbox_vaapi filter
Browse files Browse the repository at this point in the history
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
  • Loading branch information
xhaihao committed Apr 18, 2024
1 parent 42eb10e commit 5c55e4e
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 0 deletions.
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -3957,6 +3957,7 @@ vstack_qsv_filter_select="qsvvpp"
xstack_qsv_filter_deps="libmfx"
xstack_qsv_filter_select="qsvvpp"
pad_vaapi_filter_deps="vaapi_1"
drawbox_vaapi_filter_deps="vaapi_1"

# examples
avio_http_serve_files_deps="avformat avutil fork"
Expand Down
85 changes: 85 additions & 0 deletions doc/filters.texi
Original file line number Diff line number Diff line change
Expand Up @@ -28032,6 +28032,91 @@ input sample aspect ratio
input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
@end table

@section drawbox_vaapi

Draw a colored box on the input image.

It accepts the following parameters:

@table @option
@item x
@item y
The expressions which specify the top left corner coordinates of the box. It defaults to 0.

@item width, w
@item height, h
The expressions which specify the width and height of the box; if 0 they are interpreted as
the input width and height. It defaults to 0.

@item color, c
Specify the color of the box to write. For the general syntax of this option,
check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.

@item thickness, t
The expression which sets the thickness of the box edge.
A value of @code{fill} will create a filled box. Default value is @code{3}.

See below for the list of accepted constants.

@item replace
With value @code{1}, the pixels of the painted box will overwrite the video's color and alpha pixels.
Default is @code{0}, which composites the box onto the input video.
@end table

The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
following constants:

@table @option
@item in_h, ih
@item in_w, iw
The input width and height.

@item x
@item y
The x and y offset coordinates where the box is drawn.

@item w
@item h
The width and height of the drawn box.

@item t
The thickness of the drawn box.

@end table

@subsection Examples

@itemize
@item
Draw a black box around the edge of the input image:
@example
drawbox
@end example

@item
Draw a box with color red and an opacity of 50%:
@example
drawbox=10:20:200:60:red@@0.5
@end example

The previous example can be specified as:
@example
drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
@end example

@item
Fill the box with pink color:
@example
drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=fill
@end example

@item
Draw a 2-pixel red 2.40:1 mask:
@example
drawbox=x=-t:y=0.5*(ih-iw/2.4)-t:w=iw+t*2:h=iw/2.4+t*2:t=2:c=red
@end example
@end itemize

@c man end VAAPI VIDEO FILTERS

@chapter Vulkan Video Filters
Expand Down
1 change: 1 addition & 0 deletions libavfilter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ OBJS-$(CONFIG_HSTACK_QSV_FILTER) += vf_stack_qsv.o framesync.o
OBJS-$(CONFIG_VSTACK_QSV_FILTER) += vf_stack_qsv.o framesync.o
OBJS-$(CONFIG_XSTACK_QSV_FILTER) += vf_stack_qsv.o framesync.o
OBJS-$(CONFIG_PAD_VAAPI_FILTER) += vf_pad_vaapi.o vaapi_vpp.o
OBJS-$(CONFIG_DRAWBOX_VAAPI_FILTER) += vf_drawbox_vaapi.o vaapi_vpp.o

OBJS-$(CONFIG_ALLRGB_FILTER) += vsrc_testsrc.o
OBJS-$(CONFIG_ALLYUV_FILTER) += vsrc_testsrc.o
Expand Down
1 change: 1 addition & 0 deletions libavfilter/allfilters.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ extern const AVFilter ff_vf_hstack_qsv;
extern const AVFilter ff_vf_vstack_qsv;
extern const AVFilter ff_vf_xstack_qsv;
extern const AVFilter ff_vf_pad_vaapi;
extern const AVFilter ff_vf_drawbox_vaapi;

extern const AVFilter ff_vsrc_allrgb;
extern const AVFilter ff_vsrc_allyuv;
Expand Down
Loading

0 comments on commit 5c55e4e

Please sign in to comment.