[vlc-commits] dxva: we don't need a special release or Extract callback

Steve Lhomme git at videolan.org
Thu Jun 22 17:27:11 CEST 2017


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Mon Jun 19 17:20:37 2017 +0200| [e57c97af86237b55d22757e50ff5f3f9667b9a91] | committer: Jean-Baptiste Kempf

dxva: we don't need a special release or Extract callback

the picture context reference handling does it all

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 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 4f23e3f2f1..059727175b 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -175,11 +175,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;
 }
 
@@ -344,15 +340,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)
 {
@@ -435,11 +422,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 768953ae83..d0f39bf064 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 1f2eab0f69..3c425c2780 100644
--- a/modules/codec/avcodec/va_surface.c
+++ b/modules/codec/avcodec/va_surface.c
@@ -126,6 +126,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;
         }



More information about the vlc-commits mailing list