[FFmpeg-devel] [PATCH] hwcontext_videotoolbox: add vt_device_derive

Mark Thompson sw at jkqxz.net
Thu Feb 22 21:28:00 EET 2024


On 22/02/2024 18:46, gnattu via ffmpeg-devel wrote:
> There is no device context to be setup, nor devices to be
> selected with VideoToolbox. Just a simple return would allow
> us to use derived device in filters like
> `hwupload=derive_device=videotoolbox`
> 
> Signed-off-by: Gnattu OC <gnattuoc at me.com>
> ---
>   libavutil/hwcontext_videotoolbox.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/libavutil/hwcontext_videotoolbox.c b/libavutil/hwcontext_videotoolbox.c
> index fe469dc161..d13199eca7 100644
> --- a/libavutil/hwcontext_videotoolbox.c
> +++ b/libavutil/hwcontext_videotoolbox.c
> @@ -759,6 +759,14 @@ static int vt_device_create(AVHWDeviceContext *ctx, const char *device,
>       return 0;
>   }
>   
> +static int vt_device_derive(AVHWDeviceContext *device_ctx,
> +                            AVHWDeviceContext *src_ctx, AVDictionary *opts,
> +                            int flags)
> +{
> +    // There is no context to be setup with VT, just return.
> +    return 0;
> +}
> +
>   const HWContextType ff_hwcontext_type_videotoolbox = {
>       .type                 = AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
>       .name                 = "videotoolbox",
> @@ -766,6 +774,7 @@ const HWContextType ff_hwcontext_type_videotoolbox = {
>       .frames_priv_size     = sizeof(VTFramesContext),
>   
>       .device_create        = vt_device_create,
> +    .device_derive        = vt_device_derive,
>       .frames_hwctx_size    = sizeof(AVVTFramesContext),
>       .frames_init          = vt_frames_init,
>       .frames_get_buffer    = vt_get_buffer,

This derivation behaviour doesn't make any sense inside libavutil.  Features which are only for the ffmpeg utility should be implemented inside the ffmpeg utility.

(Also, try -init_hw_device.)

Thanks,

- Mark


More information about the ffmpeg-devel mailing list