[vlc-devel] [PATCH 1/6] converter_vaapi: check the buffers can be used in tc_va_check_derive_image

Thomas Guillem thomas at gllm.fr
Mon Dec 23 14:28:06 CET 2019


This check need to be done in the open() function in order to have a working module fallback .

The tc->texs[i] size could be passed to the tc_va_check_derive_image() function when called from Open().


On Mon, Dec 23, 2019, at 14:04, Steve Lhomme wrote:
> This is the same check that is done when creating the converter pool.
> 
> We must do the tc_va_check_derive_image() after the 
> opengl_fragment_shader_init()
> since we check the texture planes.
> ---
>  modules/video_output/opengl/converter_vaapi.c | 40 +++++++++++++++++--
>  1 file changed, 37 insertions(+), 3 deletions(-)
> 
> diff --git a/modules/video_output/opengl/converter_vaapi.c 
> b/modules/video_output/opengl/converter_vaapi.c
> index 6fb1085ec8e..6c0dce82e82 100644
> --- a/modules/video_output/opengl/converter_vaapi.c
> +++ b/modules/video_output/opengl/converter_vaapi.c
> @@ -348,6 +348,40 @@ tc_va_check_derive_image(opengl_tex_converter_t 
> *tc)
>      VAImage va_image = { .image_id = VA_INVALID_ID };
>      int ret = vlc_vaapi_DeriveImage(o, priv->vadpy, va_surface_ids[0],
>                                      &va_image);
> +    if (ret != VLC_SUCCESS)
> +        goto error;
> +
> +    assert(va_image.format.fourcc == priv->fourcc);
> +
> +    VABufferInfo va_buffer_info = (VABufferInfo) {
> +        .mem_type = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME
> +    };
> +    if (vlc_vaapi_AcquireBufferHandle(o ,priv->vadpy, va_image.buf,
> +                                      &va_buffer_info))
> +        goto error;
> +
> +    for (unsigned i = 0; i < va_image.num_planes; ++i)
> +    {
> +        EGLint w = (va_image.width * tc->texs[i].w.num) / 
> tc->texs[i].w.den;
> +        EGLint h = (va_image.height * tc->texs[i].h.num) / 
> tc->texs[i].h.den;
> +        EGLImageKHR egl_image =
> +            vaegl_image_create(tc, w, h, priv->drm_fourccs[i], 
> va_buffer_info.handle,
> +                               va_image.offsets[i], 
> va_image.pitches[i]);
> +        if (egl_image == NULL)
> +        {
> +            msg_Warn(o, "Can't create Image KHR: kernel too old ?");
> +            goto error;
> +        }
> +        vaegl_image_destroy(tc, egl_image);
> +    }
> +
> +error:
> +    if (va_image.image_id != VA_INVALID_ID)
> +    {
> +        if (va_image.buf != VA_INVALID_ID)
> +            vlc_vaapi_ReleaseBufferHandle(o, priv->vadpy, 
> va_image.buf);
> +        vlc_vaapi_DestroyImage(o, priv->vadpy, va_image.image_id);
> +    }
>  
>      picture_pool_Release(pool);
>  
> @@ -420,14 +454,14 @@ Open(vlc_object_t *obj)
>      if (tc_va_check_interop_blacklist(tc, priv->vadpy))
>          goto error;
>  
> -    if (tc_va_check_derive_image(tc))
> -        goto error;
> -
>      tc->fshader = opengl_fragment_shader_init(tc, GL_TEXTURE_2D, vlc_sw_chroma,
>                                                tc->fmt.space);
>      if (tc->fshader == 0)
>          goto error;
>  
> +    if (tc_va_check_derive_image(tc))
> +        goto error;
> +
>      tc->pf_update  = tc_vaegl_update;
>      tc->pf_get_pool = tc_vaegl_get_pool;
>  
> -- 
> 2.17.1
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list