[vlc-devel] [PATCH 5/6] gl: vdpau: use the "decoder context" module
Thomas Guillem
thomas at gllm.fr
Sun Feb 24 12:27:07 CET 2019
---
modules/video_output/opengl/converter_vdpau.c | 53 +++++++++++++------
1 file changed, 37 insertions(+), 16 deletions(-)
diff --git a/modules/video_output/opengl/converter_vdpau.c b/modules/video_output/opengl/converter_vdpau.c
index 5036606e12..4882422c0e 100644
--- a/modules/video_output/opengl/converter_vdpau.c
+++ b/modules/video_output/opengl/converter_vdpau.c
@@ -32,6 +32,7 @@
#include <vlc_common.h>
#include <vlc_vout_window.h>
#include <vlc_xlib.h>
+#include <vlc_codec.h>
#include "../../hw/vdpau/vlc_vdpau.h"
#include "internal.h"
@@ -110,33 +111,26 @@ Close(vlc_object_t *obj)
{
opengl_tex_converter_t *tc = (void *)obj;
_glVDPAUFiniNV(); assert(tc->vt->GetError() == GL_NO_ERROR);
- vdp_release_x11(tc->priv);
}
static int
Open(vlc_object_t *obj)
{
opengl_tex_converter_t *tc = (void *) obj;
- if ((tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_420 &&
- tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_422 &&
- tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_444) ||
- !vlc_gl_StrHasToken(tc->glexts, "GL_NV_vdpau_interop") ||
- tc->gl->surface->type != VOUT_WINDOW_TYPE_XID)
+ if (tc->dec_context == NULL
+ || tc->dec_context->type != VLC_DECODER_CONTEXT_VDPAU
+ || (tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_420
+ && tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_422
+ && tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_444)
+ || !vlc_gl_StrHasToken(tc->glexts, "GL_NV_vdpau_interop")
+ || tc->gl->surface->type != VOUT_WINDOW_TYPE_XID)
return VLC_EGENERIC;
tc->fmt.i_chroma = VLC_CODEC_VDPAU_OUTPUT;
- if (!vlc_xlib_init(VLC_OBJECT(tc->gl)))
- return VLC_EGENERIC;
-
- vdp_t *vdp;
VdpDevice device;
-
- if (vdp_get_x11(tc->gl->surface->display.x11, -1,
- &vdp, &device) != VDP_STATUS_OK)
- return VLC_EGENERIC;
-
- tc->priv = vdp;
+ vdp_t *vdp = tc->dec_context->opaque;
+ vdp_hold_x11(vdp, &device);
void *vdp_gpa;
if (vdp_get_proc_address(vdp, device,
@@ -182,6 +176,30 @@ Open(vlc_object_t *obj)
return VLC_SUCCESS;
}
+static void
+DecoderContextClose(vlc_decoder_context *context)
+{
+ vdp_release_x11(context->sys);
+}
+
+static int
+DecoderContextOpen(vlc_decoder_context *context, vout_window_t *window)
+{
+ if (!vlc_xlib_init(VLC_OBJECT(window)))
+ return VLC_EGENERIC;
+
+ vdp_t *vdp;
+ VdpDevice device;
+
+ if (vdp_get_x11(window->display.x11, -1, &vdp, &device) != VDP_STATUS_OK)
+ return VLC_EGENERIC;
+
+ context->type = VLC_DECODER_CONTEXT_VDPAU;
+ context->sys = vdp;
+ context->opaque = vdp;
+ return VLC_SUCCESS;
+}
+
vlc_module_begin ()
set_description("VDPAU OpenGL surface converter")
set_capability("glconv", 2)
@@ -189,4 +207,7 @@ vlc_module_begin ()
set_category(CAT_VIDEO)
set_subcategory(SUBCAT_VIDEO_VOUT)
add_shortcut("vdpau")
+ add_submodule()
+ set_capability("decoder context", 3)
+ set_callbacks(DecoderContextOpen, DecoderContextClose)
vlc_module_end ()
--
2.20.1
More information about the vlc-devel
mailing list