[FFmpeg-devel] [PATCH v2 1/2] avfilter: add a hflip_vulkan filter

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Thu Nov 18 07:26:37 EET 2021


Wu, Jianhua:
> Andreas Rheinhardt wrote:
>> Wu Jianhua:
>>> The following command is on how to apply hflip_vulkan filter:
>>>
>>> ffmpeg -init_hw_device vulkan -i input.264 -vf
>>>
>> hwupload=extra_hw_frames=16,hflip_vulkan,hwdownload,format=yuv420p
>>> output.264
>>>
>>> Signed-off-by: Wu Jianhua <jianhua.wu at intel.com>
>>> ---
>>>  configure                     |   1 +
>>>  libavfilter/Makefile          |   1 +
>>>  libavfilter/allfilters.c      |   1 +
>>>  libavfilter/vf_hflip_vulkan.c | 276
>>> ++++++++++++++++++++++++++++++++++
>>>  4 files changed, 279 insertions(+)
>>>  create mode 100644 libavfilter/vf_hflip_vulkan.c
>>>
>>
>>> +
>>> +static const AVOption hflip_vulkan_options[] = {
>>> +    { NULL },
>>> +};
>>> +
>>> +AVFILTER_DEFINE_CLASS(hflip_vulkan);
>>> +
>>
>> What is the point of this class with its empty options?
> 
> The AVFILTER_DEFINE_CLASS needs the hflip_vulkan_options and the reason why it's NULL
> is that the most other filters do it like that.
> 

And why do you add an AVClass at all?
(The reason that there are some filters with AVClass and empty options
is a bug in avfilter_init_str() which errors out when given options for
a filter without AVClass, although it is perfectly fine to set options
on a filter without AVClass, namely generic AVFilter options (this is
important for e.g. framesync filters, but not for this filter here).)

>>
>>> +static const AVFilterPad hflip_vulkan_inputs[] = {
>>> +    {
>>> +        .name         = "default",
>>> +        .type         = AVMEDIA_TYPE_VIDEO,
>>> +        .filter_frame = &hflip_vulkan_filter_frame,
>>> +        .config_props = &ff_vk_filter_config_input,
>>> +    }
>>> +};
>>> +
>>> +static const AVFilterPad hflip_vulkan_outputs[] = {
>>> +    {
>>> +        .name         = "default",
>>> +        .type         = AVMEDIA_TYPE_VIDEO,
>>> +        .config_props = &ff_vk_filter_config_output,
>>> +    }
>>> +};
>>> +
>>> +const AVFilter ff_vf_hflip_vulkan = {
>>> +    .name           = "hflip_vulkan",
>>> +    .description    = NULL_IF_CONFIG_SMALL("Horizontally flip the input
>> video in Vulkan"),
>>> +    .priv_size      = sizeof(HFlipVulkanContext),
>>> +    .init           = &ff_vk_filter_init,
>>> +    .uninit         = &hflip_vulkan_uninit,
>>> +    FILTER_INPUTS(hflip_vulkan_inputs),
>>> +    FILTER_OUTPUTS(hflip_vulkan_outputs),
>>> +    FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN),
>>> +    .priv_class     = &hflip_vulkan_class,
>>> +    .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, };
>>>


More information about the ffmpeg-devel mailing list