[vlc-devel] [PATCH 24/32] avcodec: do not use a picture from the display before creating the VA

Steve Lhomme robux4 at ycbcr.xyz
Thu Sep 26 16:00:15 CEST 2019


---
 modules/codec/avcodec/d3d11va.c | 20 ++------------------
 modules/codec/avcodec/dxva2.c   | 12 ++----------
 modules/codec/avcodec/va.c      |  7 +++----
 modules/codec/avcodec/va.h      |  4 ++--
 modules/codec/avcodec/vaapi.c   |  2 +-
 modules/codec/avcodec/video.c   |  4 +---
 modules/hw/vdpau/avcodec.c      |  3 +--
 7 files changed, 12 insertions(+), 40 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index a16af7c8a3f..a89f66f5c39 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 *, vlc_decoder_device *);
+                const es_format_t *, 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, vlc_decoder_device *dec_device)
+                const es_format_t *fmt, vlc_decoder_device *dec_device)
 {
     int err = VLC_EGENERIC;
 
@@ -354,22 +354,6 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
                D3D11_ReleaseDevice(&sys->d3d_dev);
             } else {
                 sys->hw.video_context = d3dvidctx;
-
-                if (picsys != NULL)
-                {
-                    picture_sys_d3d11_t *p_sys = picsys;
-                    /* TODO this will go away in push, we decide the decoding format */
-                    assert(p_sys->texture[KNOWN_DXGI_INDEX] != NULL);
-                    D3D11_TEXTURE2D_DESC dstDesc;
-                    ID3D11Texture2D_GetDesc( p_sys->texture[KNOWN_DXGI_INDEX], &dstDesc);
-                    sys->render = dstDesc.Format;
-                    if (dstDesc.BindFlags & D3D11_BIND_DECODER)
-                    {
-                        sys->textureWidth = dstDesc.Width;
-                        sys->textureHeight = dstDesc.Height;
-                        sys->totalTextureSlices = dstDesc.ArraySize;
-                    }
-                }
             }
         }
     }
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 22ee6bf657a..4c8cf03e15f 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 *, vlc_decoder_device *);
+                const es_format_t *, 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, vlc_decoder_device *dec_device)
+                const es_format_t *fmt, vlc_decoder_device *dec_device)
 {
     int err = VLC_EGENERIC;
 
@@ -268,14 +268,6 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
             free( sys );
             return VLC_EGENERIC;
         }
-        if (picsys != NULL)
-        {
-            picture_sys_d3d9_t *p_sys = picsys;
-            /* TODO this will go away in push, we decide the decoding format */
-            D3DSURFACE_DESC src;
-            if (SUCCEEDED(IDirect3DSurface9_GetDesc(p_sys->surface, &src)))
-                sys->render = src.Format;
-        }
     }
     else if (D3D9_Create(va, &sys->hd3d) != VLC_SUCCESS) {
         msg_Warn(va, "cannot load d3d9.dll");
diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
index 2e9938755bf..ee7d5084e40 100644
--- a/modules/codec/avcodec/va.c
+++ b/modules/codec/avcodec/va.c
@@ -95,16 +95,15 @@ static int vlc_va_Start(void *func, bool forced, va_list ap)
     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, device);
+    return open(va, ctx, pix_fmt, fmt, device);
 }
 
 vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
                      enum PixelFormat pix_fmt, const es_format_t *fmt,
-                     vlc_decoder_device *device, void *sys)
+                     vlc_decoder_device *device)
 {
     struct vlc_va_t *va = vlc_object_create(obj, sizeof (*va));
     if (unlikely(va == NULL))
@@ -113,7 +112,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, device, sys) == NULL)
+                        vlc_va_Start, va, avctx, pix_fmt, fmt, device) == NULL)
     {
         vlc_object_delete(va);
         va = NULL;
diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
index ee5af4d89d6..7c82facb23e 100644
--- a/modules/codec/avcodec/va.h
+++ b/modules/codec/avcodec/va.h
@@ -42,7 +42,7 @@ struct vlc_va_t {
 };
 
 typedef int (*vlc_va_open)(vlc_va_t *, AVCodecContext *, enum PixelFormat,
-                           const es_format_t *, void *, vlc_decoder_device *);
+                           const es_format_t *, vlc_decoder_device *);
 
 #define set_va_callback(activate, priority) \
     { \
@@ -69,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,
-                     vlc_decoder_device *device, void *p_sys);
+                     vlc_decoder_device *device);
 
 /**
  * Get a hardware video surface for a libavcodec frame.
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index dff3d6a771e..aa80cb85211 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -149,7 +149,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, vlc_decoder_device *dec_device)
+                  const es_format_t *fmt, vlc_decoder_device *dec_device)
 {
     if (pix_fmt != AV_PIX_FMT_VAAPI_VLD || dec_device == NULL)
         return VLC_EGENERIC;
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index e7376d19039..11e431a1ca9 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1738,11 +1738,9 @@ no_reuse:
             continue; /* Unsupported brand of hardware acceleration */
         post_mt(p_sys);
 
-        // TEMP: decoder_NewPicture cannot be used until decoder_UpdateVideoOutput is called
-        picture_t *test_pic = NULL;
         vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context, hwfmt,
                                   &p_dec->fmt_in,
-                                  init_device, NULL);
+                                  init_device);
         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 5c66b1bbc4e..31a5bd6e21e 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -133,13 +133,12 @@ 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, vlc_decoder_device *device)
+                const es_format_t *fmt, vlc_decoder_device *device)
 {
     if (pix_fmt != AV_PIX_FMT_VDPAU)
         return VLC_EGENERIC;
 
     (void) fmt;
-    (void) p_sys;
     void *func;
     VdpStatus err;
     VdpChromaType type;
-- 
2.17.1



More information about the vlc-devel mailing list