[vlc-devel] [PATCH 25/42] avcodec: vdpau: use the decoder device to get the vdp_t*

Steve Lhomme robux4 at ycbcr.xyz
Wed Oct 16 16:59:00 CEST 2019


---
 modules/hw/vdpau/avcodec.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index 3c8317ca12d..23c8b14bbd2 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -35,6 +35,7 @@
 #include <vlc_plugin.h>
 #include <vlc_fourcc.h>
 #include <vlc_picture.h>
+#include <vlc_codec.h>
 #include <vlc_xlib.h>
 #include "vlc_vdpau.h"
 #include "../../codec/avcodec/va.h"
@@ -136,7 +137,8 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, const AVPixFmtDescriptor *d
                 enum PixelFormat pix_fmt,
                 const es_format_t *fmt, void *p_sys, vlc_decoder_device *dec_device)
 {
-    if (pix_fmt != AV_PIX_FMT_VDPAU)
+    if (pix_fmt != AV_PIX_FMT_VDPAU|| dec_device == NULL ||
+        dec_device->type != VLC_DECODER_DEVICE_VDPAU)
         return VLC_EGENERIC;
 
     (void) fmt;
@@ -177,13 +179,8 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, const AVPixFmtDescriptor *d
     sys->width = width;
     sys->height = height;
     sys->hwaccel_context = NULL;
-
-    err = vdp_get_x11(NULL, -1, &sys->vdp, &sys->device);
-    if (err != VDP_STATUS_OK)
-    {
-        free(sys);
-        return VLC_EGENERIC;
-    }
+    sys->vdp = dec_device->opaque;
+    vdp_hold_x11(sys->vdp, &sys->device);
 
     unsigned flags = AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH;
 
-- 
2.17.1



More information about the vlc-devel mailing list