[vlc-commits] directx_va: get the picture_context_t from the va_pool

Steve Lhomme git at videolan.org
Tue Jun 25 13:50:22 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jun 19 07:44:45 2019 +0200| [4cd31c8384a98aae3f3f7c84e0e01e169ad1b082] | committer: Steve Lhomme

directx_va: get the picture_context_t from the va_pool

We can fill the picture outside of this call.

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

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

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index a1beacc6f7..d52fa80da5 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -287,9 +287,10 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
     else
 #endif
     {
-        int res = va_pool_Get(&va->sys->dx_sys.va_pool, pic);
-        if (unlikely(res != VLC_SUCCESS))
-            return res;
+        picture_context_t *pic_ctx = va_pool_Get(&va->sys->dx_sys.va_pool);
+        if (unlikely(pic_ctx == NULL))
+            return VLC_ENOITEM;
+        pic->context = pic_ctx;
     }
     *data = (uint8_t*)((struct va_pic_context *)pic->context)->picsys.decoder;
     return VLC_SUCCESS;
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index da029b5a18..4899a6be3a 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -229,10 +229,13 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
         return VLC_EGENERIC;
     }
 
-    int res = va_pool_Get(&sys->dx_sys.va_pool, pic);
-    if (likely(res==VLC_SUCCESS))
-        *data = (uint8_t*)((struct va_pic_context*)pic->context)->picsys.surface;
-    return res;
+    picture_context_t *pic_ctx = va_pool_Get(&sys->dx_sys.va_pool);
+    if (likely(pic_ctx==NULL))
+        return VLC_ENOITEM;
+
+    pic->context = pic_ctx;
+    *data = (uint8_t*)((struct va_pic_context*)pic->context)->picsys.surface;
+    return VLC_SUCCESS;
 }
 
 static void Close(vlc_va_t *va, void **ctx)
diff --git a/modules/codec/avcodec/va_surface.c b/modules/codec/avcodec/va_surface.c
index 6e266b6663..7f96d65ef2 100644
--- a/modules/codec/avcodec/va_surface.c
+++ b/modules/codec/avcodec/va_surface.c
@@ -157,24 +157,23 @@ static picture_context_t *GetSurface(va_pool_t *va_pool)
     return NULL;
 }
 
-int va_pool_Get(va_pool_t *va_pool, picture_t *pic)
+picture_context_t *va_pool_Get(va_pool_t *va_pool)
 {
     unsigned tries = (VLC_TICK_FROM_SEC(1) + VOUT_OUTMEM_SLEEP) / VOUT_OUTMEM_SLEEP;
     picture_context_t *field;
 
     if (va_pool->surface_count == 0)
-        return VLC_ENOITEM;
+        return NULL;
 
     while ((field = GetSurface(va_pool)) == NULL)
     {
         if (--tries == 0)
-            return VLC_ENOITEM;
+            return NULL;
         /* Pool empty. Wait for some time as in src/input/decoder.c.
          * XXX: Both this and the core should use a semaphore or a CV. */
         vlc_tick_sleep(VOUT_OUTMEM_SLEEP);
     }
-    pic->context = field;
-    return VLC_SUCCESS;
+    return field;
 }
 
 void va_surface_AddRef(vlc_va_surface_t *surface)
diff --git a/modules/codec/avcodec/va_surface_internal.h b/modules/codec/avcodec/va_surface_internal.h
index c11e6ea9fd..41360ee0e2 100644
--- a/modules/codec/avcodec/va_surface_internal.h
+++ b/modules/codec/avcodec/va_surface_internal.h
@@ -78,7 +78,7 @@ int va_pool_Open(vlc_va_t *, const video_format_t *, va_pool_t *);
 void va_pool_Close(vlc_va_t *va, va_pool_t *);
 int va_pool_SetupDecoder(vlc_va_t *, va_pool_t *, const AVCodecContext *, unsigned count, int alignment);
 int va_pool_SetupSurfaces(vlc_va_t *, va_pool_t *, unsigned count);
-int va_pool_Get(va_pool_t *, picture_t *);
+picture_context_t *va_pool_Get(va_pool_t *);
 void va_surface_AddRef(vlc_va_surface_t *surface);
 void va_surface_Release(vlc_va_surface_t *surface);
 



More information about the vlc-commits mailing list