[vlc-devel] [PATCH 21/38] avcodec: provide the vlc_decoder_device from the vout thread to the VA constructor

Steve Lhomme robux4 at ycbcr.xyz
Tue Oct 1 13:12:44 CEST 2019


This is used to initialize the VA instead of the picture_sys_t from the
external decoder pool.
---
 modules/codec/avcodec/d3d11va.c | 4 ++--
 modules/codec/avcodec/dxva2.c   | 4 ++--
 modules/codec/avcodec/va.c      | 7 ++++---
 modules/codec/avcodec/va.h      | 5 +++--
 modules/codec/avcodec/vaapi.c   | 2 +-
 modules/codec/avcodec/video.c   | 2 +-
 modules/hw/vdpau/avcodec.c      | 2 +-
 7 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index d6477cfaca2..dc4eba1bd7a 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -56,7 +56,7 @@ typedef picture_sys_d3d11_t VA_PICSYS;
 #include "directx_va.h"
 
 static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
-                const es_format_t *, void *);
+                const es_format_t *, void *, vlc_decoder_device *);
 
 vlc_module_begin()
     set_description(N_("Direct3D11 Video Acceleration"))
@@ -303,7 +303,7 @@ static void Close(vlc_va_t *va)
 static const struct vlc_va_operations ops = { Get, Close, };
 
 static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
-                const es_format_t *fmt, void *picsys)
+                const es_format_t *fmt, void *picsys, vlc_decoder_device *dec_device)
 {
     int err = VLC_EGENERIC;
 
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 24eb59415c3..4822d8d2e08 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -43,7 +43,7 @@ typedef picture_sys_d3d9_t VA_PICSYS;
 #include "directx_va.h"
 
 static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
-                const es_format_t *, void *);
+                const es_format_t *, void *, vlc_decoder_device *);
 
 vlc_module_begin()
     set_description(N_("DirectX Video Acceleration (DXVA) 2.0"))
@@ -244,7 +244,7 @@ static void Close(vlc_va_t *va)
 static const struct vlc_va_operations ops = { Get, Close, };
 
 static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
-                const es_format_t *fmt, void *picsys)
+                const es_format_t *fmt, void *picsys, vlc_decoder_device *dec_device)
 {
     int err = VLC_EGENERIC;
 
diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
index 7558b2b6874..2e9938755bf 100644
--- a/modules/codec/avcodec/va.c
+++ b/modules/codec/avcodec/va.c
@@ -94,16 +94,17 @@ static int vlc_va_Start(void *func, bool forced, va_list ap)
     AVCodecContext *ctx = va_arg(ap, AVCodecContext *);
     enum PixelFormat pix_fmt = va_arg(ap, enum PixelFormat);
     const es_format_t *fmt = va_arg(ap, const es_format_t *);
+    vlc_decoder_device *device = va_arg(ap, vlc_decoder_device *);
     void *p_sys = va_arg(ap, void *);
     vlc_va_open open = func;
 
     (void) forced;
-    return open(va, ctx, pix_fmt, fmt, p_sys);
+    return open(va, ctx, pix_fmt, fmt, p_sys, device);
 }
 
 vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
                      enum PixelFormat pix_fmt, const es_format_t *fmt,
-                     void *sys)
+                     vlc_decoder_device *device, void *sys)
 {
     struct vlc_va_t *va = vlc_object_create(obj, sizeof (*va));
     if (unlikely(va == NULL))
@@ -112,7 +113,7 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
     char *modlist = var_InheritString(obj, "avcodec-hw");
 
     if (vlc_module_load(va, "hw decoder", modlist, true,
-                        vlc_va_Start, va, avctx, pix_fmt, fmt, sys) == NULL)
+                        vlc_va_Start, va, avctx, pix_fmt, fmt, device, sys) == NULL)
     {
         vlc_object_delete(va);
         va = NULL;
diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
index 3e6b827c8f2..ee5af4d89d6 100644
--- a/modules/codec/avcodec/va.h
+++ b/modules/codec/avcodec/va.h
@@ -27,6 +27,7 @@
 
 typedef struct vlc_va_t vlc_va_t;
 typedef struct vlc_va_sys_t vlc_va_sys_t;
+typedef struct vlc_decoder_device vlc_decoder_device;
 
 struct vlc_va_operations {
     int (*get)(vlc_va_t *, picture_t *pic, uint8_t **surface);
@@ -41,7 +42,7 @@ struct vlc_va_t {
 };
 
 typedef int (*vlc_va_open)(vlc_va_t *, AVCodecContext *, enum PixelFormat,
-                           const es_format_t *, void *);
+                           const es_format_t *, void *, vlc_decoder_device *);
 
 #define set_va_callback(activate, priority) \
     { \
@@ -68,7 +69,7 @@ vlc_fourcc_t vlc_va_GetChroma(enum PixelFormat hwfmt, enum PixelFormat swfmt);
  */
 vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *,
                      enum PixelFormat, const es_format_t *fmt,
-                     void *p_sys);
+                     vlc_decoder_device *device, void *p_sys);
 
 /**
  * Get a hardware video surface for a libavcodec frame.
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index d2bc5644725..5dee6687d40 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -146,7 +146,7 @@ static void Delete(vlc_va_t *va)
 static const struct vlc_va_operations ops = { Get, Delete, };
 
 static int Create(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
-                  const es_format_t *fmt, void *p_sys)
+                  const es_format_t *fmt, void *p_sys, vlc_decoder_device *device)
 {
     if (pix_fmt != AV_PIX_FMT_VAAPI_VLD || p_sys == NULL)
         return VLC_EGENERIC;
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 7f124e6258c..e3aa179bdd7 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1749,7 +1749,7 @@ no_reuse:
         // TEMP: decoder_NewPicture cannot be used until decoder_UpdateVideoOutput is called
         vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context, hwfmt,
                                   &p_dec->fmt_in,
-                                  NULL);
+                                  init_device, NULL);
         if (init_device)
             vlc_decoder_device_Release(init_device);
         if (va == NULL)
diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index 599e86cc06e..5c66b1bbc4e 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -133,7 +133,7 @@ static void Close(vlc_va_t *va)
 static const struct vlc_va_operations ops = { Lock, Close, };
 
 static int Open(vlc_va_t *va, AVCodecContext *avctx, enum PixelFormat pix_fmt,
-                const es_format_t *fmt, void *p_sys)
+                const es_format_t *fmt, void *p_sys, vlc_decoder_device *device)
 {
     if (pix_fmt != AV_PIX_FMT_VDPAU)
         return VLC_EGENERIC;
-- 
2.17.1



More information about the vlc-devel mailing list