[vlc-devel] [PATCH 07/39] dxva: don't store the surface in the picture context

Steve Lhomme robux4 at videolabs.io
Fri Jun 2 16:46:10 CEST 2017


it's an old hack we don't need with picture_sys_t.
---
 modules/codec/avcodec/d3d11va.c  | 23 ++++++++++++++---------
 modules/codec/avcodec/dxva2.c    |  6 +++---
 modules/video_chroma/d3d11_fmt.h |  1 +
 modules/video_chroma/d3d9_fmt.h  |  1 +
 4 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 89500f1868..0b72e43741 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -179,7 +179,7 @@ static int Extract(vlc_va_t *va, picture_t *output, uint8_t *data)
 {
     vlc_va_sys_t *sys = va->sys;
     ID3D11VideoDecoderOutputView *src = (ID3D11VideoDecoderOutputView*)(uintptr_t)data;
-    vlc_va_surface_t *surface = output->context; /* when coming from our local pool */
+    vlc_va_surface_t *surface = output->p_sys->va_surface;
     int ret = VLC_SUCCESS;
 
     picture_sys_t *p_sys_out = surface ? surface->p_pic->p_sys : output->p_sys;
@@ -300,8 +300,11 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
     {
         assert(!va->sys->b_extern_pool);
         vlc_va_surface_t *va_surface = directx_va_Get(va, &va->sys->dx_sys, data);
-        pic->context = va_surface;
-        return va_surface ? VLC_SUCCESS : VLC_EGENERIC;
+        if (!va_surface)
+            return VLC_EGENERIC;
+        pic->p_sys = va_surface->p_pic->p_sys;
+        pic->p_sys->va_surface = va_surface;
+        return VLC_SUCCESS;
     }
 
     if (p_sys->decoder == NULL)
@@ -332,11 +335,13 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
         return VLC_EGENERIC;
     *data = p_sys->decoder;
     return VLC_SUCCESS;
-#else
-    vlc_va_surface_t *va_surface = directx_va_Get(va, &va->sys->dx_sys, data);
-    pic->context = va_surface;
-    return va_surface ? VLC_SUCCESS : VLC_EGENERIC;
 #endif
+    vlc_va_surface_t *va_surface = directx_va_Get(va, &va->sys->dx_sys, data);
+    if (!va_surface)
+        return VLC_EGENERIC;
+    pic->p_sys = va_surface->p_pic->p_sys;
+    pic->p_sys->va_surface = va_surface;
+    return VLC_SUCCESS;
 }
 
 static void Close(vlc_va_t *va, AVCodecContext *ctx)
@@ -371,8 +376,8 @@ static void ReleasePic(void *opaque, uint8_t *data)
 {
     (void)data;
     picture_t *pic = opaque;
-    directx_va_Release(pic->context);
-    pic->context = NULL;
+    directx_va_Release(pic->p_sys->va_surface);
+    pic->p_sys->va_surface = NULL;
     picture_Release(pic);
 }
 
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index f510704971..ff87d3a693 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -221,7 +221,7 @@ static int CheckDevice(vlc_va_t *va)
 static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
 {
     vlc_va_surface_t *va_surface = directx_va_Get(va, &va->sys->dx_sys, data);
-    pic->context = va_surface;
+    pic->p_sys->va_surface = va_surface;
     return va_surface ? VLC_SUCCESS : VLC_EGENERIC;
 }
 
@@ -258,8 +258,8 @@ static void ReleasePic(void *opaque, uint8_t *data)
 {
     (void)data;
     picture_t *pic = opaque;
-    directx_va_Release(pic->context);
-    pic->context = NULL;
+    directx_va_Release(pic->p_sys->va_surface);
+    pic->p_sys->va_surface = NULL;
     picture_Release(pic);
 }
 
diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index aa43c46d08..3006593a03 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -42,6 +42,7 @@ struct picture_sys_t
     ID3D11VideoProcessorInputView *processorInput; /* when used as processor input */
     ID3D11ShaderResourceView      *resourceView[D3D11_MAX_SHADER_VIEW];
     DXGI_FORMAT                   formatTexture;
+    void                          *va_surface;
 };
 
 /* index to use for texture/resource that use a known DXGI format
diff --git a/modules/video_chroma/d3d9_fmt.h b/modules/video_chroma/d3d9_fmt.h
index 4694acbf31..63b5f605a2 100644
--- a/modules/video_chroma/d3d9_fmt.h
+++ b/modules/video_chroma/d3d9_fmt.h
@@ -27,6 +27,7 @@
 struct picture_sys_t
 {
     LPDIRECT3DSURFACE9 surface;
+    void               *va_surface;
 };
 
 static inline void ReleasePictureSys(picture_sys_t *p_sys)
-- 
2.12.1



More information about the vlc-devel mailing list