lavfi: add a flag for filters able to work with hw_device_ctx

This way the caller can set it just on the filters that can make use of
it.
This commit is contained in:
Anton Khirnov 2023-03-15 18:57:36 +01:00
parent 30cea1d39b
commit 632c349931
32 changed files with 55 additions and 13 deletions

View File

@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
API changes, most recent first:
2023-03-xx - xxxxxxxxxx - lavfi 9.5.100 - avfilter.h
Add AVFILTER_FLAG_HWDEVICE.
2023-03-21 - xxxxxxxxxx - lavu 58.5.100 - hdr_dynamic_metadata.h
Add av_dynamic_hdr_plus_from_t35() and av_dynamic_hdr_plus_to_t35()
functions to convert between raw T.35 payloads containing dynamic

View File

@ -131,6 +131,11 @@ enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
* received by the filter on one of its inputs.
*/
#define AVFILTER_FLAG_METADATA_ONLY (1 << 3)
/**
* The filter can create hardware frames using AVFilterContext.hw_device_ctx.
*/
#define AVFILTER_FLAG_HWDEVICE (1 << 4)
/**
* Some filters support a generic "enable" expression option that can be used
* to enable or disable a filter in the timeline. Filters supporting this
@ -444,6 +449,10 @@ struct AVFilterContext {
* in particular, a filter which consumes or processes hardware frames will
* instead use the hw_frames_ctx field in AVFilterLink to carry the
* hardware context information.
*
* May be set by the caller on filters flagged with AVFILTER_FLAG_HWDEVICE
* before initializing the filter with avfilter_init_str() or
* avfilter_init_dict().
*/
AVBufferRef *hw_device_ctx;

View File

@ -333,7 +333,7 @@ static const AVFilterPad stack_outputs[] = {
{ NULL } \
}
#define DEFINE_STACK_FILTER(category, api, capi) \
#define DEFINE_STACK_FILTER(category, api, capi, filter_flags) \
static const AVClass category##_##api##_class = { \
.class_name = #category "_" #api, \
.item_name = av_default_item_name, \
@ -351,5 +351,5 @@ static const AVFilterPad stack_outputs[] = {
FILTER_QUERY_FUNC(api##_stack_query_formats), \
FILTER_OUTPUTS(stack_outputs), \
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, \
.flags = AVFILTER_FLAG_DYNAMIC_INPUTS, \
.flags = AVFILTER_FLAG_DYNAMIC_INPUTS | filter_flags, \
}

View File

@ -31,7 +31,7 @@
#include "version_major.h"
#define LIBAVFILTER_VERSION_MINOR 4
#define LIBAVFILTER_VERSION_MINOR 5
#define LIBAVFILTER_VERSION_MICRO 100

View File

@ -390,6 +390,7 @@ const AVFilter ff_vf_boxblur_opencl = {
FILTER_OUTPUTS(avgblur_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};
#endif /* CONFIG_BOXBLUR_OPENCL_FILTER */

View File

@ -418,4 +418,5 @@ const AVFilter ff_vf_avgblur_vulkan = {
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN),
.priv_class = &avgblur_vulkan_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -500,5 +500,6 @@ const AVFilter ff_vf_blend_vulkan = {
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN),
.priv_class = &blend_vulkan_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
.process_command = &process_command,
};

View File

@ -349,4 +349,5 @@ const AVFilter ff_vf_chromaber_vulkan = {
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN),
.priv_class = &chromaber_vulkan_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -238,5 +238,6 @@ const AVFilter ff_vf_colorkey_opencl = {
FILTER_INPUTS(colorkey_opencl_inputs),
FILTER_OUTPUTS(colorkey_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -373,6 +373,7 @@ const AVFilter ff_vf_convolution_opencl = {
FILTER_OUTPUTS(convolution_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};
#endif /* CONFIG_CONVOLUTION_OPENCL_FILTER */
@ -399,6 +400,7 @@ const AVFilter ff_vf_sobel_opencl = {
FILTER_OUTPUTS(convolution_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};
#endif /* CONFIG_SOBEL_OPENCL_FILTER */
@ -425,6 +427,7 @@ const AVFilter ff_vf_prewitt_opencl = {
FILTER_OUTPUTS(convolution_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};
#endif /* CONFIG_PREWITT_OPENCL_FILTER */
@ -451,6 +454,7 @@ const AVFilter ff_vf_roberts_opencl = {
FILTER_OUTPUTS(convolution_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};
#endif /* CONFIG_ROBERTS_OPENCL_FILTER */

View File

@ -2169,5 +2169,6 @@ const AVFilter ff_vf_deshake_opencl = {
FILTER_INPUTS(deshake_opencl_inputs),
FILTER_OUTPUTS(deshake_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -366,4 +366,5 @@ const AVFilter ff_vf_flip_vulkan = {
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN),
.priv_class = &flip_vulkan_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -503,4 +503,5 @@ const AVFilter ff_vf_gblur_vulkan = {
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN),
.priv_class = &gblur_vulkan_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -893,4 +893,5 @@ const AVFilter ff_vf_libplacebo = {
FILTER_QUERY_FUNC(libplacebo_query_format),
.priv_class = &libplacebo_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -312,6 +312,7 @@ const AVFilter ff_vf_dilation_opencl = {
FILTER_OUTPUTS(neighbor_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};
#endif /* CONFIG_DILATION_OPENCL_FILTER */

View File

@ -438,4 +438,5 @@ const AVFilter ff_vf_nlmeans_opencl = {
FILTER_OUTPUTS(nlmeans_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -322,4 +322,5 @@ const AVFilter ff_vf_overlay_opencl = {
FILTER_OUTPUTS(overlay_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -429,4 +429,5 @@ const AVFilter ff_vf_overlay_qsv = {
FILTER_QUERY_FUNC(overlay_qsv_query_formats),
.priv_class = &overlay_qsv_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -494,4 +494,5 @@ const AVFilter ff_vf_overlay_vulkan = {
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN),
.priv_class = &overlay_vulkan_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -391,5 +391,6 @@ const AVFilter ff_vf_pad_opencl = {
FILTER_INPUTS(pad_opencl_inputs),
FILTER_OUTPUTS(pad_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -362,7 +362,8 @@ const AVFilter ff_vf_program_opencl = {
.description = NULL_IF_CONFIG_SMALL("Filter video using an OpenCL program"),
.priv_size = sizeof(ProgramOpenCLContext),
.priv_class = &program_opencl_class,
.flags = AVFILTER_FLAG_DYNAMIC_INPUTS,
.flags = AVFILTER_FLAG_DYNAMIC_INPUTS |
AVFILTER_FLAG_HWDEVICE,
.preinit = &program_opencl_framesync_preinit,
.init = &program_opencl_init,
.uninit = &program_opencl_uninit,
@ -421,6 +422,7 @@ const AVFilter ff_vsrc_openclsrc = {
FILTER_OUTPUTS(openclsrc_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};
#endif

View File

@ -351,4 +351,5 @@ const AVFilter ff_vf_remap_opencl = {
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.priv_class = &remap_opencl_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -531,4 +531,5 @@ const AVFilter ff_vf_scale_vulkan = {
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN),
.priv_class = &scale_vulkan_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -235,20 +235,20 @@ static int qsv_stack_query_formats(AVFilterContext *ctx)
#if CONFIG_HSTACK_QSV_FILTER
DEFINE_HSTACK_OPTIONS(qsv);
DEFINE_STACK_FILTER(hstack, qsv, "Quick Sync Video");
DEFINE_STACK_FILTER(hstack, qsv, "Quick Sync Video", AVFILTER_FLAG_HWDEVICE);
#endif
#if CONFIG_VSTACK_QSV_FILTER
DEFINE_VSTACK_OPTIONS(qsv);
DEFINE_STACK_FILTER(vstack, qsv, "Quick Sync Video");
DEFINE_STACK_FILTER(vstack, qsv, "Quick Sync Video", AVFILTER_FLAG_HWDEVICE);
#endif
#if CONFIG_XSTACK_QSV_FILTER
DEFINE_XSTACK_OPTIONS(qsv);
DEFINE_STACK_FILTER(xstack, qsv, "Quick Sync Video");
DEFINE_STACK_FILTER(xstack, qsv, "Quick Sync Video", AVFILTER_FLAG_HWDEVICE);
#endif

View File

@ -234,20 +234,20 @@ static int vaapi_stack_query_formats(AVFilterContext *avctx)
#if CONFIG_HSTACK_VAAPI_FILTER
DEFINE_HSTACK_OPTIONS(vaapi);
DEFINE_STACK_FILTER(hstack, vaapi, "VA-API");
DEFINE_STACK_FILTER(hstack, vaapi, "VA-API", 0);
#endif
#if CONFIG_VSTACK_VAAPI_FILTER
DEFINE_VSTACK_OPTIONS(vaapi);
DEFINE_STACK_FILTER(vstack, vaapi, "VA-API");
DEFINE_STACK_FILTER(vstack, vaapi, "VA-API", 0);
#endif
#if CONFIG_XSTACK_VAAPI_FILTER
DEFINE_XSTACK_OPTIONS(vaapi);
DEFINE_STACK_FILTER(xstack, vaapi, "VA-API");
DEFINE_STACK_FILTER(xstack, vaapi, "VA-API", 0);
#endif

View File

@ -547,4 +547,5 @@ const AVFilter ff_vf_tonemap_opencl = {
FILTER_OUTPUTS(tonemap_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -281,4 +281,5 @@ const AVFilter ff_vf_transpose_opencl = {
FILTER_OUTPUTS(transpose_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -343,4 +343,5 @@ const AVFilter ff_vf_transpose_vulkan = {
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN),
.priv_class = &transpose_vulkan_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -407,4 +407,5 @@ const AVFilter ff_vf_unsharp_opencl = {
FILTER_OUTPUTS(unsharp_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -649,6 +649,7 @@ const AVFilter ff_vf_##sn##_qsv = { \
fmts, \
.activate = activate, \
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, \
.flags = AVFILTER_FLAG_HWDEVICE, \
};
#if CONFIG_VPP_QSV_FILTER

View File

@ -433,4 +433,5 @@ const AVFilter ff_vf_xfade_opencl = {
FILTER_OUTPUTS(xfade_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};

View File

@ -1056,4 +1056,5 @@ const AVFilter ff_vsrc_ddagrab = {
FILTER_OUTPUTS(ddagrab_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_D3D11),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
.flags = AVFILTER_FLAG_HWDEVICE,
};