[vlc-devel] [PATCH 2/2] avcodec: va: do not pass the hwaccel_context to the close function

Steve Lhomme robux4 at ycbcr.xyz
Tue Jul 23 07:57:45 CEST 2019


---
 modules/codec/avcodec/d3d11va.c | 6 ++----
 modules/codec/avcodec/dxva2.c   | 6 ++----
 modules/codec/avcodec/va.c      | 4 ++--
 modules/codec/avcodec/va.h      | 4 ++--
 modules/codec/avcodec/vaapi.c   | 4 +---
 modules/codec/avcodec/video.c   | 6 ++----
 modules/hw/vdpau/avcodec.c      | 2 +-
 7 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 29d21ab8d5..4999639db5 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -294,12 +294,10 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
     return VLC_SUCCESS;
 }
 
-static void Close(vlc_va_t *va, void **ctx)
+static void Close(vlc_va_t *va)
 {
     vlc_va_sys_t *sys = va->sys;
 
-    (void) ctx;
-
     directx_va_Close(va, &sys->dx_sys);
 
     D3D11_Destroy( &sys->hd3d );
@@ -414,7 +412,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
     return VLC_SUCCESS;
 
 error:
-    Close(va, NULL);
+    Close(va);
     return err;
 }
 
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index e5c8a1f043..8f777b05a7 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -235,14 +235,12 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
     return VLC_SUCCESS;
 }
 
-static void Close(vlc_va_t *va, void **ctx)
+static void Close(vlc_va_t *va)
 {
     vlc_va_sys_t *sys = va->sys;
     if ( sys == NULL )
         return;
 
-    (void) ctx;
-
     directx_va_Close(va, &sys->dx_sys);
 
     if (sys->dxva2_dll)
@@ -342,7 +340,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
     return VLC_SUCCESS;
 
 error:
-    Close(va, NULL);
+    Close(va);
     return VLC_EGENERIC;
 }
 /* */
diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
index edfe3b6f43..7558b2b687 100644
--- a/modules/codec/avcodec/va.c
+++ b/modules/codec/avcodec/va.c
@@ -122,9 +122,9 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
     return va;
 }
 
-void vlc_va_Delete(vlc_va_t *va, void **hwctx)
+void vlc_va_Delete(vlc_va_t *va)
 {
     if (va->ops->close != NULL)
-        va->ops->close(va, hwctx);
+        va->ops->close(va);
     vlc_object_delete(va);
 }
diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
index a03374c038..3e6b827c8f 100644
--- a/modules/codec/avcodec/va.h
+++ b/modules/codec/avcodec/va.h
@@ -30,7 +30,7 @@ typedef struct vlc_va_sys_t vlc_va_sys_t;
 
 struct vlc_va_operations {
     int (*get)(vlc_va_t *, picture_t *pic, uint8_t **surface);
-    void (*close)(vlc_va_t *, void **hwctx);
+    void (*close)(vlc_va_t *);
 };
 
 struct vlc_va_t {
@@ -97,6 +97,6 @@ static inline int vlc_va_Get(vlc_va_t *va, picture_t *pic, uint8_t **surface)
  * Destroys a libavcodec hardware acceleration back-end.
  * All allocated surfaces shall have been released beforehand.
  */
-void vlc_va_Delete(vlc_va_t *, void **);
+void vlc_va_Delete(vlc_va_t *);
 
 #endif
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index d997c5867e..68442d5ee2 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -132,13 +132,11 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
     return VLC_SUCCESS;
 }
 
-static void Delete(vlc_va_t *va, void **hwctx)
+static void Delete(vlc_va_t *va)
 {
     vlc_va_sys_t *sys = va->sys;
     vlc_object_t *o = VLC_OBJECT(va);
 
-    (void) hwctx;
-
     vlc_vaapi_DestroyContext(o, sys->hw_ctx.display, sys->hw_ctx.context_id);
     vlc_vaapi_DestroyConfig(o, sys->hw_ctx.display, sys->hw_ctx.config_id);
     vlc_decoder_device_Release(sys->dec_device);
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 0829bfc6ee..28b0fdb35a 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1368,7 +1368,6 @@ void EndVideoDec( vlc_object_t *obj )
     decoder_t *p_dec = (decoder_t *)obj;
     decoder_sys_t *p_sys = p_dec->p_sys;
     AVCodecContext *ctx = p_sys->p_context;
-    void *hwaccel_context;
 
     post_mt( p_sys );
 
@@ -1380,11 +1379,10 @@ void EndVideoDec( vlc_object_t *obj )
 
     cc_Flush( &p_sys->cc );
 
-    hwaccel_context = ctx->hwaccel_context;
     avcodec_free_context( &ctx );
 
     if( p_sys->p_va )
-        vlc_va_Delete( p_sys->p_va, &hwaccel_context );
+        vlc_va_Delete( p_sys->p_va );
 
     vlc_sem_destroy( &p_sys->sem_mt );
     free( p_sys );
@@ -1677,7 +1675,7 @@ no_reuse:
     if (p_sys->p_va != NULL)
     {
         msg_Err(p_dec, "existing hardware acceleration cannot be reused");
-        vlc_va_Delete(p_sys->p_va, &p_context->hwaccel_context);
+        vlc_va_Delete(p_sys->p_va);
         p_sys->p_va = NULL;
     }
 
diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index 49536e6d60..599e86cc06 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -118,7 +118,7 @@ static int Lock(vlc_va_t *va, picture_t *pic, uint8_t **data)
     return VLC_SUCCESS;
 }
 
-static void Close(vlc_va_t *va, void **hwctx)
+static void Close(vlc_va_t *va)
 {
     vlc_va_sys_t *sys = va->sys;
 
-- 
2.17.1



More information about the vlc-devel mailing list