[vlc-devel] [PATCH 14/18] opengl: pass importer to "glconv" modules

Thomas Guillem thomas at gllm.fr
Mon Dec 23 11:56:38 CET 2019


I think you forgot converter_cvpx.c

On Fri, Dec 20, 2019, at 15:48, Romain Vimont wrote:
> Pass an importer instead of a tex converter to "glconv" modules.
> ---
>  modules/video_output/opengl/converter.h       |  2 --
>  .../video_output/opengl/converter_android.c   | 18 ++++++-------
>  modules/video_output/opengl/converter_vaapi.c | 25 +++++++++----------
>  modules/video_output/opengl/converter_vdpau.c | 23 ++++++++---------
>  modules/video_output/opengl/importer.h        |  2 ++
>  modules/video_output/opengl/vout_helper.c     | 10 ++++----
>  6 files changed, 38 insertions(+), 42 deletions(-)
> 
> diff --git a/modules/video_output/opengl/converter.h 
> b/modules/video_output/opengl/converter.h
> index 08616a4e3d..39414971be 100644
> --- a/modules/video_output/opengl/converter.h
> +++ b/modules/video_output/opengl/converter.h
> @@ -43,8 +43,6 @@ struct opengl_tex_converter_t
>  {
>      struct vlc_object_t obj;
>  
> -    module_t *p_module;
> -
>      /* Pointer to object gl, set by the caller */
>      vlc_gl_t *gl;
>  
> diff --git a/modules/video_output/opengl/converter_android.c 
> b/modules/video_output/opengl/converter_android.c
> index 1d3e2348f2..359a6e3611 100644
> --- a/modules/video_output/opengl/converter_android.c
> +++ b/modules/video_output/opengl/converter_android.c
> @@ -93,8 +93,8 @@ tc_get_transform_matrix(const struct vlc_gl_importer 
> *imp)
>  static void
>  Close(vlc_object_t *obj)
>  {
> -    opengl_tex_converter_t *tc = (void *)obj;
> -    struct priv *priv = tc->priv;
> +    struct vlc_gl_importer *imp = (void *)obj;
> +    struct priv *priv = imp->priv;
>  
>      if (priv->stex_attached)
>          SurfaceTexture_detachFromGLContext(priv->awh);
> @@ -105,8 +105,7 @@ Close(vlc_object_t *obj)
>  static int
>  Open(vlc_object_t *obj)
>  {
> -    opengl_tex_converter_t *tc = (void *) obj;
> -    struct vlc_gl_importer *imp = &tc->importer;
> +    struct vlc_gl_importer *imp = (void *) obj;
>  
>      if (imp->fmt.i_chroma != VLC_CODEC_ANDROID_OPAQUE
>       || !imp->gl->surface->handle.anativewindow
> @@ -167,12 +166,13 @@ Open(vlc_object_t *obj)
>              break;
>      }
>  
> -    tc->fshader = opengl_fragment_shader_init(tc, GL_TEXTURE_EXTERNAL_OES,
> -                                              VLC_CODEC_RGB32,
> -                                              COLOR_SPACE_UNDEF);
> -    if (!tc->fshader)
> +    int ret = opengl_importer_init(imp, GL_TEXTURE_EXTERNAL_OES,
> +                                        VLC_CODEC_RGB32,
> +                                        COLOR_SPACE_UNDEF);
> +
> +    if (ret != VLC_SUCCESS)
>      {
> -        free(tc->priv);
> +        free(imp->priv);
>          return VLC_EGENERIC;
>      }
>  
> diff --git a/modules/video_output/opengl/converter_vaapi.c 
> b/modules/video_output/opengl/converter_vaapi.c
> index 27313d986c..dcf9907fee 100644
> --- a/modules/video_output/opengl/converter_vaapi.c
> +++ b/modules/video_output/opengl/converter_vaapi.c
> @@ -288,11 +288,11 @@ error:
>  static void
>  Close(vlc_object_t *obj)
>  {
> -    opengl_tex_converter_t *tc = (void *)obj;
> -    struct priv *priv = tc->importer->priv;
> +    struct vlc_gl_importer *imp = (void *)obj;
> +    struct priv *priv = imp->priv;
>  
>      if (priv->last.pic != NULL)
> -        vaegl_release_last_pic(tc->importer, priv);
> +        vaegl_release_last_pic(imp, priv);
>  
>      free(priv);
>  }
> @@ -355,17 +355,16 @@ tc_va_check_derive_image(const struct 
> vlc_gl_importer *imp)
>  static int
>  Open(vlc_object_t *obj)
>  {
> -    opengl_tex_converter_t *tc = (void *) obj;
> -    struct vlc_gl_importer *imp = tc->importer;
> +    struct vlc_gl_importer *imp = (void *) obj;
>  
>      if (imp->vctx == NULL)
>          return VLC_EGENERIC;
>      vlc_decoder_device *dec_device = vlc_video_context_HoldDevice(imp->vctx);
>      if (dec_device->type != VLC_DECODER_DEVICE_VAAPI
>       || !vlc_vaapi_IsChromaOpaque(imp->fmt.i_chroma)
> -     || tc->gl->ext != VLC_GL_EXT_EGL
> -     || tc->gl->egl.createImageKHR == NULL
> -     || tc->gl->egl.destroyImageKHR == NULL)
> +     || imp->gl->ext != VLC_GL_EXT_EGL
> +     || imp->gl->egl.createImageKHR == NULL
> +     || imp->gl->egl.destroyImageKHR == NULL)
>      {
>          vlc_decoder_device_Release(dec_device);
>          return VLC_EGENERIC;
> @@ -377,7 +376,7 @@ Open(vlc_object_t *obj)
>          return VLC_EGENERIC;
>      }
>  
> -    const char *eglexts = tc->gl->egl.queryString(tc->gl, 
> EGL_EXTENSIONS);
> +    const char *eglexts = imp->gl->egl.queryString(imp->gl, 
> EGL_EXTENSIONS);
>      if (eglexts == NULL || !vlc_gl_StrHasToken(eglexts, 
> "EGL_EXT_image_dma_buf_import"))
>      {
>          vlc_decoder_device_Release(dec_device);
> @@ -409,7 +408,7 @@ Open(vlc_object_t *obj)
>          goto error;
>  
>      priv->glEGLImageTargetTexture2DOES =
> -        vlc_gl_GetProcAddress(tc->gl, "glEGLImageTargetTexture2DOES");
> +        vlc_gl_GetProcAddress(imp->gl, "glEGLImageTargetTexture2DOES");
>      if (priv->glEGLImageTargetTexture2DOES == NULL)
>          goto error;
>  
> @@ -422,9 +421,9 @@ Open(vlc_object_t *obj)
>      if (tc_va_check_derive_image(imp))
>          goto error;
>  
> -    tc->fshader = opengl_fragment_shader_init(tc, GL_TEXTURE_2D, vlc_sw_chroma,
> -                                              imp->fmt.space);
> -    if (tc->fshader == 0)
> +    int ret = opengl_importer_init(imp, GL_TEXTURE_2D, vlc_sw_chroma,
> +                                   imp->fmt.space);
> +    if (ret != VLC_SUCCESS)
>          goto error;
>  
>      static const struct vlc_gl_importer_ops ops = {
> diff --git a/modules/video_output/opengl/converter_vdpau.c 
> b/modules/video_output/opengl/converter_vdpau.c
> index 6f7dbae143..ec4661daae 100644
> --- a/modules/video_output/opengl/converter_vdpau.c
> +++ b/modules/video_output/opengl/converter_vdpau.c
> @@ -116,9 +116,9 @@ tc_vdpau_gl_update(const struct vlc_gl_importer 
> *imp, GLuint textures[],
>  static void
>  Close(vlc_object_t *obj)
>  {
> -    opengl_tex_converter_t *tc = (void *)obj;
> -    _glVDPAUFiniNV(); assert(tc->vt->GetError() == GL_NO_ERROR);
> -    converter_sys_t *sys = tc->importer->priv;
> +    struct vlc_gl_importer *imp = (void *)obj;
> +    _glVDPAUFiniNV(); assert(imp->vt->GetError() == GL_NO_ERROR);
> +    converter_sys_t *sys = imp->priv;
>      vlc_decoder_device *dec_device = sys->dec_device;
>      vlc_decoder_device_Release(dec_device);
>  }
> @@ -126,9 +126,7 @@ Close(vlc_object_t *obj)
>  static int
>  Open(vlc_object_t *obj)
>  {
> -    opengl_tex_converter_t *tc = (void *) obj;
> -    struct vlc_gl_importer *imp = tc->importer;
> -
> +    struct vlc_gl_importer *imp = (void *) obj;
>      if (imp->vctx == NULL)
>          return VLC_EGENERIC;
>      vlc_decoder_device *dec_device = 
> vlc_video_context_HoldDevice(imp->vctx);
> @@ -137,13 +135,13 @@ Open(vlc_object_t *obj)
>        && imp->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_422
>        && imp->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_444)
>       || !vlc_gl_StrHasToken(imp->glexts, "GL_NV_vdpau_interop")
> -     || tc->gl->surface->type != VOUT_WINDOW_TYPE_XID)
> +     || imp->gl->surface->type != VOUT_WINDOW_TYPE_XID)
>      {
>          vlc_decoder_device_Release(dec_device);
>          return VLC_EGENERIC;
>      }
>  
> -    converter_sys_t *sys = vlc_obj_malloc(VLC_OBJECT(tc), sizeof(*sys));
> +    converter_sys_t *sys = vlc_obj_malloc(VLC_OBJECT(imp), sizeof(*sys));
>      if (unlikely(sys == NULL))
>      {
>          vlc_decoder_device_Release(dec_device);
> @@ -168,7 +166,7 @@ Open(vlc_object_t *obj)
>      }
>  
>  #define SAFE_GPA(fct) \
> -    _##fct = vlc_gl_GetProcAddress(tc->gl, #fct); \
> +    _##fct = vlc_gl_GetProcAddress(imp->gl, #fct); \
>      if (!_##fct) \
>      { \
>          vlc_decoder_device_Release(dec_device); \
> @@ -187,10 +185,9 @@ Open(vlc_object_t *obj)
>  
>      INTEROP_CALL(glVDPAUInitNV, (void *)(uintptr_t)device, vdp_gpa);
>  
> -    tc->fshader = opengl_fragment_shader_init(tc, GL_TEXTURE_2D,
> -                                              VLC_CODEC_RGB32,
> -                                              COLOR_SPACE_UNDEF);
> -    if (!tc->fshader)
> +    int ret = opengl_importer_init(imp, GL_TEXTURE_2D, VLC_CODEC_RGB32,
> +                                   COLOR_SPACE_UNDEF);
> +    if (ret != VLC_SUCCESS)
>      {
>          Close(obj);
>          return VLC_EGENERIC;
> diff --git a/modules/video_output/opengl/importer.h 
> b/modules/video_output/opengl/importer.h
> index 75ee3f514d..ef30f25129 100644
> --- a/modules/video_output/opengl/importer.h
> +++ b/modules/video_output/opengl/importer.h
> @@ -110,6 +110,8 @@ struct vlc_gl_importer_ops {
>  
>  struct vlc_gl_importer {
>      vlc_object_t obj;
> +    module_t *module;
> +
>      vlc_gl_t *gl;
>      const opengl_vtable_t *vt;
>      GLenum tex_target;
> diff --git a/modules/video_output/opengl/vout_helper.c 
> b/modules/video_output/opengl/vout_helper.c
> index cd2ca02eb1..caae213793 100644
> --- a/modules/video_output/opengl/vout_helper.c
> +++ b/modules/video_output/opengl/vout_helper.c
> @@ -507,11 +507,11 @@ opengl_deinit_program(vout_display_opengl_t *vgl, 
> struct prgm *prgm)
>  {
>      opengl_tex_converter_t *tc = prgm->tc;
>      struct vlc_gl_importer *imp = tc->importer;
> -    if (tc->p_module != NULL)
> -        module_unneed(tc, tc->p_module);
> +    if (imp->module != NULL)
> +        module_unneed(imp, imp->module);
>      else if (imp->priv != NULL)
>          opengl_importer_generic_deinit(imp);
> -    vlc_object_delete(tc->importer);
> +    vlc_object_delete(imp);
>      if (prgm->id != 0)
>          vgl->vt.DeleteProgram(prgm->id);
>  
> @@ -612,10 +612,10 @@ opengl_init_program(vout_display_opengl_t *vgl, 
> vlc_video_context *context,
>          {
>              /* Opaque chroma: load a module to handle it */
>              imp->vctx = context;
> -            tc->p_module = module_need_var(tc, "glconv", "glconv");
> +            imp->module = module_need_var(imp, "glconv", "glconv");
>          }
>  
> -        if (tc->p_module != NULL)
> +        if (imp->module != NULL)
>              ret = VLC_SUCCESS;
>          else
>          {
> -- 
> 2.24.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