[FFmpeg-devel] [PATCH v3] avfilter: add overlay vaapi filter
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/M
[FFmpeg-devel] [PATCH v1 1/2] lavu/pixfmt: add new pixel format a2r10g10b10/a2b10g10r10
Add two 10 bit RGBA pixel format for hardware color space conversion support in VAAPI and QSV: 2:10:10:10 10 bit: A2R10G10B10 2:10:10:10 10 bit: A2B10G10R10 Add query support in fate. Signed-off-by: Xinpeng Sun --- libavutil/pixdesc.c | 26 ++ libavutil/pixfmt.h | 3 +++ libavutil/version.h | 2 +- tests/ref/fate/sws-pixdesc-query | 12 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 05dd4a1e20..0ea0332d1d 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -540,6 +540,32 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, }, +[AV_PIX_FMT_A2R10G10B10] = { +.name = "a2r10g10b10", +.nb_components = 4, +.log2_chroma_w = 0, +.log2_chroma_h = 0, +.comp = { +{ 0, 32, 20, 0, 10, 31, 9, 21 }, /* R */ +{ 0, 32, 10, 0, 10, 31, 9, 11 }, /* G */ +{ 0, 32, 0, 0, 10, 31, 9, 1 }, /* B */ +{ 0, 32, 30, 0, 2, 31, 1, 31 }, /* A */ +}, +.flags = AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, +}, +[AV_PIX_FMT_A2B10G10R10] = { +.name = "a2b10g10r10", +.nb_components = 4, +.log2_chroma_w = 0, +.log2_chroma_h = 0, +.comp = { +{ 0, 32, 0, 0, 10, 31, 9, 1 }, /* R */ +{ 0, 32, 10, 0, 10, 31, 9, 11 }, /* G */ +{ 0, 32, 20, 0, 10, 31, 9, 21 }, /* B */ +{ 0, 32, 30, 0, 2, 31, 1, 31 }, /* A */ +}, +.flags = AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, +}, [AV_PIX_FMT_0RGB] = { .name = "0rgb", .nb_components= 3, diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index d78e863d4b..7ceaccd56e 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -348,6 +348,9 @@ enum AVPixelFormat { AV_PIX_FMT_NV24, ///< planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) AV_PIX_FMT_NV42, ///< as above, but U and V bytes are swapped +AV_PIX_FMT_A2R10G10B10, ///packed ARGB 2:10:10:10, 32bpp, ARGBARGB... +AV_PIX_FMT_A2B10G10R10, ///packed ABGR 2:10:10:10, 32bpp, ABGRABGR... + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; diff --git a/libavutil/version.h b/libavutil/version.h index 3395769857..af3abf7265 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 35 +#define LIBAVUTIL_VERSION_MINOR 36 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query index e23492293e..7316abab44 100644 --- a/tests/ref/fate/sws-pixdesc-query +++ b/tests/ref/fate/sws-pixdesc-query @@ -33,6 +33,8 @@ is16BPS: yuva444p16le isNBPS: + a2b10g10r10 + a2r10g10b10 gbrap10be gbrap10le gbrap12be @@ -363,6 +365,8 @@ isSemiPlanarYUV: isRGB: 0bgr 0rgb + a2b10g10r10 + a2r10g10b10 bayer_bggr16be bayer_bggr16le bayer_bggr8 @@ -507,6 +511,8 @@ Bayer: AnyRGB: 0bgr 0rgb + a2b10g10r10 + a2r10g10b10 bayer_bggr16be bayer_bggr16le bayer_bggr8 @@ -579,6 +585,8 @@ AnyRGB: rgba64le ALPHA: + a2b10g10r10 + a2r10g10b10 ayuv64be ayuv64le bgr32 @@ -631,6 +639,8 @@ ALPHA: Packed: 0bgr 0rgb + a2b10g10r10 + a2r10g10b10 ayuv64be ayuv64le bayer_bggr16be @@ -800,6 +810,8 @@ Planar: PackedRGB: 0bgr 0rgb + a2b10g10r10 + a2r10g10b10 bayer_bggr16be bayer_bggr16le bayer_bggr8 -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v1 2/2] lavu/hwcontext_vaapi: add vaapi_format_map support for A2R10G10B10/A2B10G10R10
Enalbe the color space convertions p010->a2r10g10b10/a2b10g10r10 in VAAPI. Signed-off-by: Xinpeng Sun --- libavutil/hwcontext_vaapi.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index cf117640f2..3aaa5ff0b5 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -133,6 +133,12 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = { #endif MAP(ARGB, RGB32, ARGB, 0), MAP(XRGB, RGB32, 0RGB, 0), +#ifdef VA_FOURCC_A2R10G10B10 +MAP(A2R10G10B10, RGB32_10, A2R10G10B10, 0), +#endif +#ifdef VA_FOURCC_A2B10G10R10 +MAP(A2B10G10R10, RGB32_10, A2B10G10R10, 0), +#endif }; #undef MAP -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v1] avfilter: Add tonemap vaapi filter for H2S
It performs HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with tone-mapping. It supports HDR10 only as input temporarily. H2S: P010 -> NV12 An example command to use this filter with vaapi codecs: FFMPEG -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi \ -i INPUT -vf 'tonemap_vaapi=h2s,hwdownload,format=nv12' -pix_fmt nv12 \ -f rawvideo -y OUTPUT Signed-off-by: Xinpeng Sun Signed-off-by: Zachary Zhou --- doc/filters.texi | 30 libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vaapi_vpp.c| 5 + libavfilter/vf_tonemap_vaapi.c | 272 + 5 files changed, 309 insertions(+) create mode 100644 libavfilter/vf_tonemap_vaapi.c diff --git a/doc/filters.texi b/doc/filters.texi index 6800124574..b1c466ba24 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -20754,6 +20754,36 @@ Convert HDR(PQ/HLG) video to bt2020-transfer-characteristic p010 format using li @end example @end itemize +@section tonemap_vappi + +Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with tone-mapping. +It maps the dynamic range of HDR10 content to the SDR content. +It only accepts HDR10 as input temporarilly. + +It accepts the following parameters: + +@table @option +@item type +Specify the tone-mapping operator to be used. + +Possible values are: +@table @var +@item h2s +Perform H2S(HDR to SDR), convert from p010 to nv12 +@end table + +@end table + +@subsection Example + +@itemize +@item +Convert HDR video to SDR video from p010 format to nv12 format. +@example +-i INPUT -vf "tonemap_vaapi=h2s" OUTPUT +@end example +@end itemize + @section unsharp_opencl Sharpen or blur the input video. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index fce930360d..90a0e9945e 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -410,6 +410,7 @@ OBJS-$(CONFIG_TMIX_FILTER) += vf_mix.o framesync.o OBJS-$(CONFIG_TONEMAP_FILTER)+= vf_tonemap.o colorspace.o OBJS-$(CONFIG_TONEMAP_OPENCL_FILTER) += vf_tonemap_opencl.o colorspace.o opencl.o \ opencl/tonemap.o opencl/colorspace_common.o +OBJS-$(CONFIG_TONEMAP_VAAPI_FILTER) += vf_tonemap_vaapi.o vaapi_vpp.o OBJS-$(CONFIG_TPAD_FILTER) += vf_tpad.o OBJS-$(CONFIG_TRANSPOSE_FILTER) += vf_transpose.o OBJS-$(CONFIG_TRANSPOSE_NPP_FILTER) += vf_transpose_npp.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 7c1e19e1da..b2fb1f8a98 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -390,6 +390,7 @@ extern AVFilter ff_vf_tlut2; extern AVFilter ff_vf_tmix; extern AVFilter ff_vf_tonemap; extern AVFilter ff_vf_tonemap_opencl; +extern AVFilter ff_vf_tonemap_vaapi; extern AVFilter ff_vf_tpad; extern AVFilter ff_vf_transpose; extern AVFilter ff_vf_transpose_npp; diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c index b5b245c8af..5776243fa0 100644 --- a/libavfilter/vaapi_vpp.c +++ b/libavfilter/vaapi_vpp.c @@ -257,6 +257,11 @@ static const VAAPIColourProperties vaapi_colour_standard_map[] = { { VAProcColorStandardSMPTE170M, 6, 6, 6 }, { VAProcColorStandardSMPTE240M, 7, 7, 7 }, { VAProcColorStandardGenericFilm, 8, 1, 1 }, + +#if VA_CHECK_VERSION(2, 3, 0) +{ VAProcColorStandardExplicit,9, 16, AVCOL_SPC_BT2020_NCL}, +#endif + #if VA_CHECK_VERSION(1, 1, 0) { VAProcColorStandardSRGB,1, 13, 0 }, { VAProcColorStandardXVYCC601,1, 11, 5 }, diff --git a/libavfilter/vf_tonemap_vaapi.c b/libavfilter/vf_tonemap_vaapi.c new file mode 100644 index 00..27ee17bf00 --- /dev/null +++ b/libavfilter/vf_tonemap_vaapi.c @@ -0,0 +1,272 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include + +#include "libavutil/avassert.h" +#include "libavutil/mem.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "libavutil/mastering_display_metadata.h" + +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#in
[FFmpeg-devel] [PATCH v2] avfilter: Add tonemap vaapi filter for H2S
It performs HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with tone-mapping. It only supports HDR10 as input temporarily. An example command to use this filter with vaapi codecs: FFMPEG -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi \ -i INPUT -vf 'tonemap_vaapi=format=p010' -c:v hevc_vaapi -profile 2 OUTPUT Signed-off-by: Xinpeng Sun Signed-off-by: Zachary Zhou --- configure | 2 + doc/filters.texi | 81 +++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_tonemap_vaapi.c | 420 + 5 files changed, 505 insertions(+) create mode 100644 libavfilter/vf_tonemap_vaapi.c diff --git a/configure b/configure index 2519e6421f..5e99de6cd9 100755 --- a/configure +++ b/configure @@ -3575,6 +3575,7 @@ tinterlace_filter_deps="gpl" tinterlace_merge_test_deps="tinterlace_filter" tinterlace_pad_test_deps="tinterlace_filter" tonemap_filter_deps="const_nan" +tonemap_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer_output_hdr_metadata" tonemap_opencl_filter_deps="opencl const_nan" transpose_opencl_filter_deps="opencl" transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags" @@ -6575,6 +6576,7 @@ if enabled vaapi; then check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC" check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth +check_struct "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer" output_hdr_metadata check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC" check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG" diff --git a/doc/filters.texi b/doc/filters.texi index 16bf2df6c2..7232783256 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -20965,6 +20965,87 @@ Apply a strong blur of both luma and chroma parameters: @c man end OPENCL VIDEO FILTERS +@chapter VAAPI Video Filters +@c man begin VAAPI VIDEO FILTERS + +VAAPI Video filters are usually used with VAAPI decoder and VAAPI encoder. Below is a description of VAAPI video filters. + +To enable compilation of these filters you need to configure FFmpeg with +@code{--enable-vaapi}. + +Running VAAPI filters requires you to initialize a hardware device and to pass that device to all filters in any filter graph. +@table @option + +@item -hwaccel vaapi +Specify the hardware accelerator as @var{vaapi}. + +@item -vaapi_device @var{driver_path} +Specify the vaapi driver path with @var{driver_path}. + +@item -hwaccel_output_format @var{vaapi} +Specify the output format of hardware accelerator as @var{vaapi}. All VAAPI hardware surfaces in ffmpeg are represented by the @var{vaapi} pixfmt. + +@end table + +@itemize +@item +Example of running tonemap_vaapi filter with default parameters on it. +@example +-hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i INPUT -vf "tonemap_vaapi, hwdownload" OUTPUT +@end example +@end itemize + +Since VAAPI filters are not able to access frame data in arbitrary memory, so if you use a decoder other than VAAPI decoder before VAAPI filters, all frame data needs to be uploaded(@ref{hwupload}) to hardware surfaces connected to the appropriate device before being used. Also if you add a encoder other than VAAPI encoder after VAAPI filters, the hardware surfaces should be downloaded(@ref{hwdownload}) back to normal memory. Note that @ref{hwupload} will upload to a surface with the same layout as the software frame, so it may be necessary to add a @ref{format} filter immediately before to get the input into the right format and @ref{hwdownload} does not support all formats on the output - it may be necessary to insert an additional @ref{format} filter immediately following in the graph to get the output in a supported format. + +@section tonemap_vappi + +Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with tone-mapping. +It maps the dynamic range of HDR10 content to the SDR content. +It only accepts HDR10 as input temporarily. + +It accepts the following parameters: + +@table @option +@item format +Specify the output pixel format. + +Currently supported formats are: +@table @var +@item p010 +@item nv12 +@end table + +Default is nv12. + +@item primaries, p +Set the output color primaries. + +Default is same as input. + +@item transfer, t +Set the output transfer characteristics. + +Default is bt709. + +@item matrix, m +Set the output colorspace matrix. + +Default is same as input. + +@end table + +@subsection Example + +@itemize +@item +Convert HDR(HDR10) video to bt2020-transfer-characteristic p010
[FFmpeg-devel] [PATCH v3] avfilter: Add tonemap vaapi filter for H2S
It performs HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with tone-mapping. It only supports HDR10 as input temporarily. An example command to use this filter with vaapi codecs: FFMPEG -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi \ -i INPUT -vf 'tonemap_vaapi=format=p010' -c:v hevc_vaapi -profile 2 OUTPUT Signed-off-by: Xinpeng Sun Signed-off-by: Zachary Zhou --- configure | 2 + doc/filters.texi | 81 +++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_tonemap_vaapi.c | 420 + 5 files changed, 505 insertions(+) create mode 100644 libavfilter/vf_tonemap_vaapi.c diff --git a/configure b/configure index ca7137f341..5272fb2a57 100755 --- a/configure +++ b/configure @@ -3576,6 +3576,7 @@ tinterlace_filter_deps="gpl" tinterlace_merge_test_deps="tinterlace_filter" tinterlace_pad_test_deps="tinterlace_filter" tonemap_filter_deps="const_nan" +tonemap_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer_output_hdr_metadata" tonemap_opencl_filter_deps="opencl const_nan" transpose_opencl_filter_deps="opencl" transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags" @@ -6576,6 +6577,7 @@ if enabled vaapi; then check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC" check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth +check_struct "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer" output_hdr_metadata check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC" check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG" diff --git a/doc/filters.texi b/doc/filters.texi index 5fdec6f015..7223ab89a3 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -20972,6 +20972,87 @@ Apply a strong blur of both luma and chroma parameters: @c man end OPENCL VIDEO FILTERS +@chapter VAAPI Video Filters +@c man begin VAAPI VIDEO FILTERS + +VAAPI Video filters are usually used with VAAPI decoder and VAAPI encoder. Below is a description of VAAPI video filters. + +To enable compilation of these filters you need to configure FFmpeg with +@code{--enable-vaapi}. + +Running VAAPI filters requires you to initialize a hardware device and to pass that device to all filters in any filter graph. +@table @option + +@item -hwaccel vaapi +Specify the hardware accelerator as @var{vaapi}. + +@item -vaapi_device @var{driver_path} +Specify the vaapi driver path with @var{driver_path}. + +@item -hwaccel_output_format @var{vaapi} +Specify the output format of hardware accelerator as @var{vaapi}. All VAAPI hardware surfaces in ffmpeg are represented by the @var{vaapi} pixfmt. + +@end table + +@itemize +@item +Example of running tonemap_vaapi filter with default parameters on it. +@example +-hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i INPUT -vf "tonemap_vaapi, hwdownload" OUTPUT +@end example +@end itemize + +Since VAAPI filters are not able to access frame data in arbitrary memory, so if you use a decoder other than VAAPI decoder before VAAPI filters, all frame data needs to be uploaded(@ref{hwupload}) to hardware surfaces connected to the appropriate device before being used. Also if you add a encoder other than VAAPI encoder after VAAPI filters, the hardware surfaces should be downloaded(@ref{hwdownload}) back to normal memory. Note that @ref{hwupload} will upload to a surface with the same layout as the software frame, so it may be necessary to add a @ref{format} filter immediately before to get the input into the right format and @ref{hwdownload} does not support all formats on the output - it may be necessary to insert an additional @ref{format} filter immediately following in the graph to get the output in a supported format. + +@section tonemap_vappi + +Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with tone-mapping. +It maps the dynamic range of HDR10 content to the SDR content. +It only accepts HDR10 as input temporarily. + +It accepts the following parameters: + +@table @option +@item format +Specify the output pixel format. + +Currently supported formats are: +@table @var +@item p010 +@item nv12 +@end table + +Default is nv12. + +@item primaries, p +Set the output color primaries. + +Default is same as input. + +@item transfer, t +Set the output transfer characteristics. + +Default is bt709. + +@item matrix, m +Set the output colorspace matrix. + +Default is same as input. + +@end table + +@subsection Example + +@itemize +@item +Convert HDR(HDR10) video to bt2020-transfer-characteristic p010
[FFmpeg-devel] [PATCH v1] avfilter: add overlay vaapi filter
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 | 432 + 5 files changed, 488 insertions(+) create mode 100644 libavfilter/vf_overlay_vaapi.c diff --git a/configure b/configure index eec43c3b06..9969c9e984 100755 --- a/configure +++ b/configure @@ -3527,6 +3527,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" owdenoise_filter_deps="gpl" pan_filter_deps="swresample" perspective_filter_deps="gpl" @@ -3584,6 +3585,7 @@ tonemap_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer_output_hdr_metada 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" @@ -6587,6 +6589,7 @@ if enabled vaapi; then check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth check_struct "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer" output_hdr_metadata 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 527c6a08b2..d391218529 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -21049,6 +21049,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 +need input video has 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 are yuv420p format. +@example +-i INPUT -i LOGO -filter_complex "[0:v]hwupload[a], [1:v]format=yuv420p, hwupload[b], [a][b]overlay_vaapi, hwdownload" 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" OUTPUT +@end example + +@end itemize + @section tonemap_vappi Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with tone-mapping. diff --git a/libavfilter/Makefile b/libavfilter/Makefile in
[FFmpeg-devel] [PATCH] configure: Change the configure check for tonemap_vaapi
"VAProcFilterParameterBufferHDRToneMapping" was defined in libva 2.4.1, which will lead to build failure for the filter tonemap_vaapi for libva 2.3.0 with current check. This patch is to fix this build error. Signed-off-by: Xinpeng Sun --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index eec43c3b06..157dc30132 100755 --- a/configure +++ b/configure @@ -3580,7 +3580,7 @@ tinterlace_filter_deps="gpl" tinterlace_merge_test_deps="tinterlace_filter" tinterlace_pad_test_deps="tinterlace_filter" tonemap_filter_deps="const_nan" -tonemap_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer_output_hdr_metadata" +tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping_type" tonemap_opencl_filter_deps="opencl const_nan" transpose_opencl_filter_deps="opencl" transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags" @@ -6585,7 +6585,7 @@ if enabled vaapi; then check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC" check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth -check_struct "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer" output_hdr_metadata +check_struct "va/va.h va/va_vpp.h" "VAProcFilterParameterBufferHDRToneMapping" type check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC" check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG" -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 2/2] configure: Reorder the filters part by alphabet
Signed-off-by: Xinpeng Sun --- configure | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 01b4acd77e..e7036b04ec 100755 --- a/configure +++ b/configure @@ -3510,6 +3510,7 @@ interlace_filter_deps="gpl" kerndeint_filter_deps="gpl" ladspa_filter_deps="ladspa libdl" lensfun_filter_deps="liblensfun version3" +libvmaf_filter_deps="libvmaf pthreads" lv2_filter_deps="lv2" mcdeint_filter_deps="avcodec gpl" movie_filter_deps="avcodec avformat" @@ -3530,6 +3531,7 @@ owdenoise_filter_deps="gpl" pan_filter_deps="swresample" perspective_filter_deps="gpl" phase_filter_deps="gpl" +pixfmts_super2xsai_test_deps="super2xsai_filter" pp7_filter_deps="gpl" pp_filter_deps="gpl postproc" prewitt_opencl_filter_deps="opencl" @@ -3545,6 +3547,7 @@ sab_filter_deps="gpl swscale" scale2ref_filter_deps="swscale" scale_filter_deps="swscale" scale_qsv_filter_deps="libmfx" +scale_vaapi_filter_deps="vaapi" select_filter_select="scene_sad" sharpness_vaapi_filter_deps="vaapi" showcqt_filter_deps="avcodec avformat swscale" @@ -3572,15 +3575,14 @@ sr_filter_select="dnn" stereo3d_filter_deps="gpl" subtitles_filter_deps="avformat avcodec libass" super2xsai_filter_deps="gpl" -pixfmts_super2xsai_test_deps="super2xsai_filter" superequalizer_filter_select="rdft" surround_filter_select="rdft" tinterlace_filter_deps="gpl" tinterlace_merge_test_deps="tinterlace_filter" tinterlace_pad_test_deps="tinterlace_filter" tonemap_filter_deps="const_nan" -tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping" tonemap_opencl_filter_deps="opencl const_nan" +tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping" transpose_opencl_filter_deps="opencl" transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags" unsharp_opencl_filter_deps="opencl" @@ -3588,15 +3590,13 @@ uspp_filter_deps="gpl avcodec" vaguedenoiser_filter_deps="gpl" vidstabdetect_filter_deps="libvidstab" vidstabtransform_filter_deps="libvidstab" -libvmaf_filter_deps="libvmaf pthreads" -zmq_filter_deps="libzmq" -zoompan_filter_deps="swscale" -zscale_filter_deps="libzimg const_nan" -scale_vaapi_filter_deps="vaapi" vpp_qsv_filter_deps="libmfx" vpp_qsv_filter_select="qsvvpp" yadif_cuda_filter_deps="ffnvcodec" yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm" +zmq_filter_deps="libzmq" +zoompan_filter_deps="swscale" +zscale_filter_deps="libzimg const_nan" # examples avio_dir_cmd_deps="avformat avutil" -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 1/2] configure: Change the configure check for tonemap_vaapi
"VAProcFilterParameterBufferHDRToneMapping" was defined in libva 2.4.1, which will lead to build failure for the filter tonemap_vaapi for libva 2.3.0 with current check. This patch is to fix this build error. Signed-off-by: Xinpeng Sun --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 43dc409fe6..01b4acd77e 100755 --- a/configure +++ b/configure @@ -3579,7 +3579,7 @@ tinterlace_filter_deps="gpl" tinterlace_merge_test_deps="tinterlace_filter" tinterlace_pad_test_deps="tinterlace_filter" tonemap_filter_deps="const_nan" -tonemap_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer_output_hdr_metadata" +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" @@ -6584,7 +6584,7 @@ if enabled vaapi; then check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC" check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth -check_struct "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer" output_hdr_metadata +check_type "va/va.h va/va_vpp.h" "VAProcFilterParameterBufferHDRToneMapping" check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC" check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG" -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] avfilter: add overlay vaapi filter
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 965b4c71b8..374a4316c9 100755 --- a/configure +++ b/configure @@ -3526,6 +3526,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" owdenoise_filter_deps="gpl" pan_filter_deps="swresample" perspective_filter_deps="gpl" @@ -3583,6 +3584,7 @@ tonemap_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer_output_hdr_metada 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" @@ -6586,6 +6588,7 @@ if enabled vaapi; then check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth check_struct "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer" output_hdr_metadata 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 ba00989987..2d69fa0363 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -21124,6 +21124,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 x 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 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_vappi Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with tone-mapping. diff --git a/libavfilter/Makefile b/libavfilter/Makefile in
[FFmpeg-devel] [PATCH] avfilter/tonemap_vaapi: pass filter parameters to VA parameter buffer
Signed-off-by: Xinpeng Sun --- libavfilter/vf_tonemap_vaapi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavfilter/vf_tonemap_vaapi.c b/libavfilter/vf_tonemap_vaapi.c index 2f41b90424..540d656dca 100644 --- a/libavfilter/vf_tonemap_vaapi.c +++ b/libavfilter/vf_tonemap_vaapi.c @@ -296,6 +296,9 @@ static int tonemap_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame if (err < 0) goto fail; +params.filters = &vpp_ctx->filter_buffers[0]; +params.num_filters = vpp_ctx->nb_filter_buffers; + err = ff_vaapi_vpp_render_picture(avctx, ¶ms, output_frame); if (err < 0) goto fail; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".