[vlc-commits] opengl/vdpau: avoid ugly cast

Rémi Denis-Courmont git at videolan.org
Mon Dec 24 18:23:17 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Dec 24 19:19:14 2018 +0200| [a11e724864b5b17db0ae1a29c03bafa13339f2fd] | committer: Rémi Denis-Courmont

opengl/vdpau: avoid ugly cast

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a11e724864b5b17db0ae1a29c03bafa13339f2fd
---

 modules/hw/vdpau/vlc_vdpau.h                  | 3 ++-
 modules/video_output/opengl/converter_vdpau.c | 8 +++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/modules/hw/vdpau/vlc_vdpau.h b/modules/hw/vdpau/vlc_vdpau.h
index e29013620a..83c53d92b9 100644
--- a/modules/hw/vdpau/vlc_vdpau.h
+++ b/modules/hw/vdpau/vlc_vdpau.h
@@ -206,6 +206,7 @@ void vdp_release_x11(vdp_t *);
 /* VLC specifics */
 # include <stdatomic.h>
 # include <stdbool.h>
+# include <stdint.h>
 # include <vlc_common.h>
 # include <vlc_fourcc.h>
 # include <vlc_picture.h>
@@ -303,7 +304,7 @@ typedef struct vlc_vdp_output_surface
     VdpOutputSurface surface;
     VdpDevice device;
     vdp_t *vdp;
-    void *gl_nv_surface;
+    ptrdiff_t gl_nv_surface;
 } vlc_vdp_output_surface_t;
 
 picture_t *vlc_vdp_output_surface_create(vdp_t *vdp, VdpRGBAFormat rgb_fmt,
diff --git a/modules/video_output/opengl/converter_vdpau.c b/modules/video_output/opengl/converter_vdpau.c
index 769f351dfa..b5af7dc479 100644
--- a/modules/video_output/opengl/converter_vdpau.c
+++ b/modules/video_output/opengl/converter_vdpau.c
@@ -80,7 +80,7 @@ tc_vdpau_gl_get_pool(opengl_tex_converter_t const *tc,
 
         vlc_vdp_output_surface_t *picsys = pics[i]->p_sys;
 
-        *(GLvdpauSurfaceNV *)&picsys->gl_nv_surface = 0;
+        picsys->gl_nv_surface = 0;
     }
 
     picture_pool_t *pool = picture_pool_New(requested_count, pics);
@@ -106,8 +106,10 @@ tc_vdpau_gl_update(opengl_tex_converter_t const *tc, GLuint textures[],
 
     vlc_vdp_output_surface_t *p_sys = pic->p_sys;
 
-    GLvdpauSurfaceNV *p_gl_nv_surface =
-        (GLvdpauSurfaceNV *)&p_sys->gl_nv_surface;
+    static_assert (_Generic (p_sys->gl_nv_surface, GLvdpauSurfaceNV: 1,
+                                                   default: 0), "Mismatch");
+
+    GLvdpauSurfaceNV *p_gl_nv_surface = &p_sys->gl_nv_surface;
 
     if (*p_gl_nv_surface)
     {



More information about the vlc-commits mailing list