Overlay one video on the top of another.
It takes two inputs and has one output. The first input is the "main" video on
which the
second input is overlaid. This filter requires same memory layout for all the
inputs.
An example command to use this filter to overlay an image LOGO at the top-left
corner of
the INPUT video and both inputs are yuv420p format:
FFMPEG -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format
vaapi \
-i INPUT -i LOGO -filter_complex \
"[0:v]hwupload[a], [1:v]format=yuv420p, hwupload[b], [a][b]overlay_vaapi,
hwdownload" \
OUTPUT
Signed-off-by: Xinpeng Sun
Signed-off-by: Zachary Zhou
---
configure | 3 +
doc/filters.texi | 51
libavfilter/Makefile | 1 +
libavfilter/allfilters.c | 1 +
libavfilter/vf_overlay_vaapi.c | 426 +
5 files changed, 482 insertions(+)
create mode 100644 libavfilter/vf_overlay_vaapi.c
diff --git a/configure b/configure
index ab761c7183..19fe94729f 100755
--- a/configure
+++ b/configure
@@ -3533,6 +3533,7 @@ openclsrc_filter_deps="opencl"
overlay_opencl_filter_deps="opencl"
overlay_qsv_filter_deps="libmfx"
overlay_qsv_filter_select="qsvvpp"
+overlay_vaapi_filter_deps="vaapi"
overlay_vulkan_filter_deps="vulkan libglslang"
owdenoise_filter_deps="gpl"
pad_opencl_filter_deps="opencl"
@@ -3592,6 +3593,7 @@ tonemap_vaapi_filter_deps="vaapi
VAProcFilterParameterBufferHDRToneMapping"
tonemap_opencl_filter_deps="opencl const_nan"
transpose_opencl_filter_deps="opencl"
transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
+overlay_vaapi_filter_deps="vaapi VAProcPipelineCaps_blend_flags"
unsharp_opencl_filter_deps="opencl"
uspp_filter_deps="gpl avcodec"
vaguedenoiser_filter_deps="gpl"
@@ -6599,6 +6601,7 @@ if enabled vaapi; then
check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
check_type "va/va.h va/va_vpp.h"
"VAProcFilterParameterBufferHDRToneMapping"
check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
+check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" blend_flags
check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC"
check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG"
check_type "va/va.h va/va_enc_vp8.h" "VAEncPictureParameterBufferVP8"
diff --git a/doc/filters.texi b/doc/filters.texi
index 70fd7a4cc7..fbf7264b94 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21732,6 +21732,57 @@ To enable compilation of these filters you need to
configure FFmpeg with
To use vaapi filters, you need to setup the vaapi device correctly. For more
information, please read @url{https://trac.ffmpeg.org/wiki/Hardware/VAAPI}
+@section overlay_vaapi
+
+Overlay one video on the top of another.
+
+It takes two inputs and has one output. The first input is the "main" video on
which the second input is overlaid.
+This filter requires same memory layout for all the inputs. So, format
conversion may be needed.
+
+The filter accepts the following options:
+
+@table @option
+
+@item x
+Set the x coordinate of the overlaid video on the main video.
+Default value is @code{0}.
+
+@item y
+Set the y coordinate of the overlaid video on the main video.
+Default value is @code{0}.
+
+@item w
+Set the width of the overlaid video on the main video.
+Default value is the width of input overlay video.
+
+@item h
+Set the height of the overlaid video on the main video.
+Default value is the height of input overlay video.
+
+@item alpha
+Set blocking detection thresholds. Allowed range is 0.0 to 1.0, it
+requires an input video with alpha channel.
+Default value is @code{0.0}.
+
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Overlay an image LOGO at the top-left corner of the INPUT video. Both inputs
for this filter are yuv420p format.
+@example
+-i INPUT -i LOGO -filter_complex "[0:v]hwupload[a], [1:v]format=yuv420p,
hwupload[b], [a][b]overlay_vaapi" OUTPUT
+@end example
+@item
+Overlay an image LOGO at the offset (200, 100) from the top-left corner of the
INPUT video.
+The inputs have same memory layout for color channels, the overlay has
additional alpha plane, like INPUT is yuv420p, and the LOGO is yuva420p.
+@example
+-i INPUT -i LOGO -filter_complex "[0:v]hwupload[a], [1:v]format=yuva420p,
hwupload[b], [a][b]overlay_vaapi=x=200:y=100:w=400:h=300:alpha=1.0, hwdownload,
format=nv12" OUTPUT
+@end example
+
+@end itemize
+
@section tonemap_vaapi
Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with
tone-mapping.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 089880a39d..96fce9e84f 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -326,6 +326,7 @@ OBJS-$(CONFIG_OVERLAY_FILTER)+=
vf_overlay.o framesync.o
OBJS-$(CONFIG_OVERLAY_OPENCL_FILTER) += vf_overlay_opencl.o opencl.o \