[vlc-devel] [PATCH 13/17] dxva: we don't need a special release or Extract callback

Steve Lhomme robux4 at videolabs.io
Tue Jun 20 17:45:45 CEST 2017


the picture context reference handling does it all
---
 modules/codec/avcodec/d3d11va.c    | 21 ++-------------------
 modules/codec/avcodec/dxva2.c      | 17 +++--------------
 modules/codec/avcodec/va_surface.c |  1 +
 3 files changed, 6 insertions(+), 33 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index c27ee90df0..14c20bf8b8 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -174,11 +174,7 @@ void SetupAVCodecContext(vlc_va_t *va)
 
 static int Extract(vlc_va_t *va, picture_t *output, uint8_t *data)
 {
-    VLC_UNUSED(va); VLC_UNUSED(data);
-    struct va_pic_context *pic_ctx = (struct va_pic_context*)output->context;
-    if (pic_ctx->va_surface)
-        va_surface_AddRef(pic_ctx->va_surface);
-    assert(data == (void*)pic_ctx->picsys.decoder);
+    VLC_UNUSED(va); VLC_UNUSED(output); VLC_UNUSED(data);
     return VLC_SUCCESS;
 }
 
@@ -343,15 +339,6 @@ static vlc_fourcc_t d3d11va_fourcc(enum PixelFormat swfmt)
     }
 }
 
-static void ReleasePic(void *opaque, uint8_t *data)
-{
-    (void)data;
-    picture_t *pic = opaque;
-    struct va_pic_context *pic_ctx = (struct va_pic_context*)pic->context;
-    va_surface_Release(pic_ctx->va_surface);
-    picture_Release(pic);
-}
-
 static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
                 const es_format_t *fmt, picture_sys_t *p_sys)
 {
@@ -434,11 +421,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
     va->description = DxDescribe(dx_sys);
     va->setup   = Setup;
     va->get     = Get;
-#if D3D11_DIRECT_DECODE
-    va->release = sys->b_extern_pool ? NULL : ReleasePic;
-#else
-    va->release = ReleasePic;
-#endif
+    va->release = NULL;
     va->extract = Extract;
 
     return VLC_SUCCESS;
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 52c92d2bbe..6fdad96d24 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -174,11 +174,9 @@ void SetupAVCodecContext(vlc_va_t *va)
         sys->hw.workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
 }
 
-static int Extract(vlc_va_t *va, picture_t *picture, uint8_t *data)
+static int Extract(vlc_va_t *va, picture_t *output, uint8_t *data)
 {
-    VLC_UNUSED(va); VLC_UNUSED(data);
-    struct va_pic_context *pic_ctx = (struct va_pic_context*)picture->context;
-    va_surface_AddRef(pic_ctx->va_surface);
+    VLC_UNUSED(va); VLC_UNUSED(output); VLC_UNUSED(data);
     return VLC_SUCCESS;
 }
 
@@ -273,15 +271,6 @@ static vlc_fourcc_t d3d9va_fourcc(enum PixelFormat swfmt)
     }
 }
 
-static void ReleasePic(void *opaque, uint8_t *data)
-{
-    (void)data;
-    picture_t *pic = opaque;
-    struct va_pic_context *pic_ctx = (struct va_pic_context*)pic->context;
-    va_surface_Release(pic_ctx->va_surface);
-    picture_Release(pic);
-}
-
 static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
                 const es_format_t *fmt, picture_sys_t *p_sys)
 {
@@ -347,7 +336,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
     va->description = DxDescribe(sys);
     va->setup   = Setup;
     va->get     = Get;
-    va->release = ReleasePic;
+    va->release = NULL;
     va->extract = Extract;
     return VLC_SUCCESS;
 
diff --git a/modules/codec/avcodec/va_surface.c b/modules/codec/avcodec/va_surface.c
index 291d134251..f4beec4e89 100644
--- a/modules/codec/avcodec/va_surface.c
+++ b/modules/codec/avcodec/va_surface.c
@@ -128,6 +128,7 @@ static picture_context_t *GetSurface(va_pool_t *va_pool)
         if (atomic_compare_exchange_strong(&surface->va_surface->refcount, &expected, 2))
         {
             picture_context_t *field = surface->s.copy(&surface->s);
+            /* the copy should have added an extra reference */
             atomic_fetch_sub(&surface->va_surface->refcount, 1);
             return field;
         }
-- 
2.12.1



More information about the vlc-devel mailing list