[vlc-commits] dxva: change surface context allocation to allow local types for each variant

Steve Lhomme git at videolan.org
Tue Oct 8 15:06:49 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Sep 13 14:42:14 2019 +0200| [9f25d132ac6235c957e9c19db04390cb1a94c8fb] | committer: Steve Lhomme

dxva: change surface context allocation to allow local types for each variant

We don't use a custom/fake VA_PICSYS in the va_surface API. Each type is
responsible for storing the picture_sys_t where they want (if any).

The va_surface API only deals with picture_context_t now.

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

 modules/codec/avcodec/d3d11va.c             | 4 ++--
 modules/codec/avcodec/dxva2.c               | 4 ++--
 modules/codec/avcodec/va_surface.c          | 7 +++----
 modules/codec/avcodec/va_surface_internal.h | 2 +-
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 2182bab2e4..79d32e6f2e 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -206,7 +206,7 @@ done:
     return pic_ctx;
 }
 
-static struct va_pic_context* NewSurfacePicContext(vlc_va_t *va, int surface_index, vlc_va_surface_t *va_surface)
+static picture_context_t* NewSurfacePicContext(vlc_va_t *va, int surface_index, vlc_va_surface_t *va_surface)
 {
     vlc_va_sys_t *sys = va->sys;
     ID3D11VideoDecoderOutputView *surface = sys->hw_surface[surface_index];
@@ -234,7 +234,7 @@ static struct va_pic_context* NewSurfacePicContext(vlc_va_t *va, int surface_ind
      * when the pool is emptied */
     ReleaseD3D11PictureSys(&pic_ctx->picsys);
     pic_ctx->va_surface = va_surface;
-    return pic_ctx;
+    return &pic_ctx->s;
 }
 
 static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index f90b963984..862f55329a 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -190,7 +190,7 @@ static struct va_pic_context *CreatePicContext(IDirect3DSurface9 *surface, IDire
     return pic_ctx;
 }
 
-static struct va_pic_context* NewSurfacePicContext(vlc_va_t *va, int surface_index, vlc_va_surface_t *va_surface)
+static picture_context_t* NewSurfacePicContext(vlc_va_t *va, int surface_index, vlc_va_surface_t *va_surface)
 {
     vlc_va_sys_t *sys = va->sys;
     struct va_pic_context *pic_ctx = CreatePicContext(sys->hw_surface[surface_index], sys->hw.decoder);
@@ -201,7 +201,7 @@ static struct va_pic_context* NewSurfacePicContext(vlc_va_t *va, int surface_ind
      * when the pool is emptied */
     ReleaseD3D9PictureSys(&pic_ctx->picsys);
     pic_ctx->va_surface = va_surface;
-    return pic_ctx;
+    return &pic_ctx->s;
 }
 
 static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
diff --git a/modules/codec/avcodec/va_surface.c b/modules/codec/avcodec/va_surface.c
index 643dbd39e4..05617b0ddc 100644
--- a/modules/codec/avcodec/va_surface.c
+++ b/modules/codec/avcodec/va_surface.c
@@ -35,14 +35,12 @@
 #include <vlc_picture.h>
 
 #include "va_surface_internal.h"
-typedef int VA_PICSYS;
-#include "va_surface.h"
 
 #include "avcodec.h"
 
 struct vlc_va_surface_t {
     atomic_uintptr_t     refcount;
-    struct va_pic_context *pic_va_ctx;
+    picture_context_t    *pic_va_ctx;
 };
 
 static void DestroyVideoDecoder(vlc_va_sys_t *sys, va_pool_t *va_pool)
@@ -128,7 +126,8 @@ static picture_context_t *GetSurface(va_pool_t *va_pool)
 
         if (atomic_compare_exchange_strong(&surface->refcount, &expected, 2))
         {
-            picture_context_t *field = surface->pic_va_ctx->s.copy(&surface->pic_va_ctx->s);
+            picture_context_t *pic_ctx = surface->pic_va_ctx;
+            picture_context_t *field = pic_ctx->copy(pic_ctx);
             /* the copy should have added an extra reference */
             atomic_fetch_sub(&surface->refcount, 1);
             return field;
diff --git a/modules/codec/avcodec/va_surface_internal.h b/modules/codec/avcodec/va_surface_internal.h
index 8f95d06967..6d451e233a 100644
--- a/modules/codec/avcodec/va_surface_internal.h
+++ b/modules/codec/avcodec/va_surface_internal.h
@@ -71,7 +71,7 @@ struct va_pool_cfg {
     /**
      * Create a new context for the surface being acquired
      */
-    struct va_pic_context* (*pf_new_surface_context)(vlc_va_t *, int surface_index, vlc_va_surface_t *);
+    picture_context_t* (*pf_new_surface_context)(vlc_va_t *, int surface_index, vlc_va_surface_t *);
 };
 
 int va_pool_Open(vlc_va_t *, const struct va_pool_cfg *, va_pool_t *);



More information about the vlc-commits mailing list