[vlc-commits] avcodec: provide the vlc_decoder_device from the vout thread to the VA constructor

Steve Lhomme git at videolan.org
Fri Oct 18 09:47:07 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Jun 13 14:18:53 2019 +0200| [d5acac3b10b64c41b5255b6c1ce354b2b73c05c7] | committer: Steve Lhomme

avcodec: provide the vlc_decoder_device from the vout thread to the VA constructor

This is used to initialize the VA instead of the picture_sys_t from the
external decoder pool.

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

 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 e0f4b66e01..fb138e35c3 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -62,7 +62,7 @@ struct d3d11va_pic_context
 #include "directx_va.h"
 
 static int Open(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *, enum PixelFormat,
-                const es_format_t *, void *);
+                const es_format_t *, void *, vlc_decoder_device *);
 
 vlc_module_begin()
     set_description(N_("Direct3D11 Video Acceleration"))
@@ -317,7 +317,7 @@ static const struct vlc_va_operations ops = { Get, Close, };
 
 static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
                 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 23e73382d1..38c1f5b894 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -49,7 +49,7 @@ struct dxva2_pic_context
 #include "directx_va.h"
 
 static int Open(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *, 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"))
@@ -255,7 +255,7 @@ static const struct vlc_va_operations ops = { Get, Close, };
 
 static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
                 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 4e60ad3e97..77fdbf6f6b 100644
--- a/modules/codec/avcodec/va.c
+++ b/modules/codec/avcodec/va.c
@@ -102,17 +102,18 @@ static int vlc_va_Start(void *func, bool forced, va_list ap)
     const AVPixFmtDescriptor *src_desc = va_arg(ap, const AVPixFmtDescriptor *);
     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, src_desc, pix_fmt, fmt, p_sys);
+    return open(va, ctx, src_desc, pix_fmt, fmt, p_sys, device);
 }
 
 vlc_va_t *vlc_va_New(vlc_object_t *obj,
                      AVCodecContext *avctx, const AVPixFmtDescriptor *src_desc,
                      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))
@@ -121,7 +122,7 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj,
     char *modlist = var_InheritString(obj, "avcodec-hw");
 
     if (vlc_module_load(va, "hw decoder", modlist, true,
-                        vlc_va_Start, va, avctx, src_desc, pix_fmt, fmt, sys) == NULL)
+                        vlc_va_Start, va, avctx, src_desc, 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 7011124baa..8bf2cfa551 100644
--- a/modules/codec/avcodec/va.h
+++ b/modules/codec/avcodec/va.h
@@ -28,6 +28,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);
@@ -43,7 +44,7 @@ struct vlc_va_t {
 
 typedef int (*vlc_va_open)(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *,
                            enum PixelFormat,
-                           const es_format_t *, void *);
+                           const es_format_t *, void *, vlc_decoder_device *);
 
 #define set_va_callback(activate, priority) \
     { \
@@ -70,7 +71,7 @@ vlc_fourcc_t vlc_va_GetChroma(enum PixelFormat hwfmt, enum PixelFormat swfmt);
  */
 vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *, const AVPixFmtDescriptor *,
                      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 a374cedd50..87c67b79aa 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -147,7 +147,7 @@ static const struct vlc_va_operations ops = { Get, Delete, };
 
 static int Create(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
                   enum PixelFormat pix_fmt,
-                  const es_format_t *fmt, void *p_sys)
+                  const es_format_t *fmt, void *p_sys, vlc_decoder_device *device)
 {
     VLC_UNUSED(desc);
     if (pix_fmt != AV_PIX_FMT_VAAPI_VLD || p_sys == NULL)
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 9c2090e602..af90a01fe3 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1752,7 +1752,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, src_desc, hwfmt,
                                   &p_dec->fmt_in,
-                                  NULL);
+                                  init_device, NULL);
         if (init_device)
             vlc_decoder_device_Release(init_device);
         vlc_mutex_lock(&p_sys->lock);
diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index e0b94ec55e..3c8317ca12 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -134,7 +134,7 @@ static const struct vlc_va_operations ops = { Lock, Close, };
 
 static int Open(vlc_va_t *va, AVCodecContext *avctx, const AVPixFmtDescriptor *desc,
                 enum PixelFormat pix_fmt,
-                const es_format_t *fmt, void *p_sys)
+                const es_format_t *fmt, void *p_sys, vlc_decoder_device *dec_device)
 {
     if (pix_fmt != AV_PIX_FMT_VDPAU)
         return VLC_EGENERIC;



More information about the vlc-commits mailing list