[vlc-devel] [RFC 2/2] avcodec: va: don't pass the hwaccel_context on module delete
Tristan Matthews
tmatth at videolan.org
Thu Dec 20 16:01:04 CET 2018
Hi,
On Thu, Dec 20, 2018 at 4:30 AM Steve Lhomme <robux4 at ycbcr.xyz> wrote:
>
> ---
> modules/codec/avcodec/d3d11va.c | 8 +++-----
> modules/codec/avcodec/dxva2.c | 8 +++-----
> modules/codec/avcodec/va.c | 9 ++++-----
> modules/codec/avcodec/va.h | 2 +-
> modules/codec/avcodec/vaapi.c | 7 ++-----
> modules/codec/avcodec/video.c | 6 ++----
> modules/hw/vdpau/avcodec.c | 4 +---
> 7 files changed, 16 insertions(+), 28 deletions(-)
>
> diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
> index 1f982ad7e3..59896cbaa3 100644
> --- a/modules/codec/avcodec/d3d11va.c
> +++ b/modules/codec/avcodec/d3d11va.c
> @@ -57,7 +57,7 @@
>
> static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
> const es_format_t *, picture_sys_t *p_sys);
> -static void Close(vlc_va_t *, void **);
> +static void Close(vlc_va_t *);
>
> vlc_module_begin()
> set_description(N_("Direct3D11 Video Acceleration"))
> @@ -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 );
> @@ -404,7 +402,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 9569990841..f20a97e278 100644
> --- a/modules/codec/avcodec/dxva2.c
> +++ b/modules/codec/avcodec/dxva2.c
> @@ -45,7 +45,7 @@
>
> static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
> const es_format_t *, picture_sys_t *p_sys);
> -static void Close(vlc_va_t *, void **);
> +static void Close(vlc_va_t *);
>
> vlc_module_begin()
> set_description(N_("DirectX Video Acceleration (DXVA) 2.0"))
> @@ -237,14 +237,12 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
> return res;
> }
>
> -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)
> @@ -337,7 +335,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 ecf4e8aa14..0a7a12c4b7 100644
> --- a/modules/codec/avcodec/va.c
> +++ b/modules/codec/avcodec/va.c
> @@ -104,10 +104,9 @@ static int vlc_va_Start(void *func, va_list ap)
> static void vlc_va_Stop(void *func, va_list ap)
> {
> vlc_va_t *va = va_arg(ap, vlc_va_t *);
> - void *hwctx = va_arg(ap, void *);
> - void (*close)(vlc_va_t *, void *) = func;
> + void (*close)(vlc_va_t *) = func;
>
> - close(va, hwctx);
> + close(va);
> }
>
> vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
> @@ -131,8 +130,8 @@ 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)
> {
> - vlc_module_unload(va, va->module, vlc_va_Stop, va, hwctx);
> + vlc_module_unload(va, va->module, vlc_va_Stop, va);
> vlc_object_release(va);
> }
> diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
> index 178047ad16..955e216cd8 100644
> --- a/modules/codec/avcodec/va.h
> +++ b/modules/codec/avcodec/va.h
> @@ -79,6 +79,6 @@ static inline int vlc_va_Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
> * 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 d8fafed094..e7a9e4fd6b 100644
> --- a/modules/codec/avcodec/vaapi.c
> +++ b/modules/codec/avcodec/vaapi.c
> @@ -138,13 +138,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_vaapi_ReleaseInstance(sys->va_inst);
> @@ -247,12 +245,11 @@ static int GetDRM(vlc_va_t *va, picture_t *pic, uint8_t **data)
> return VLC_SUCCESS;
> }
>
> -static void DeleteDRM(vlc_va_t *va, void **hwctx)
> +static void DeleteDRM(vlc_va_t *va)
> {
> vlc_va_sys_t *sys = va->sys;
> vlc_object_t *o = VLC_OBJECT(va);
>
> - (void) hwctx;
> picture_pool_Release(sys->pool);
> 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);
> diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
> index 9e83695e73..0866591d85 100644
> --- a/modules/codec/avcodec/video.c
> +++ b/modules/codec/avcodec/video.c
> @@ -1360,7 +1360,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 );
>
> @@ -1372,11 +1371,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 );
> @@ -1667,7 +1665,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;
> }
This sounds like it refs https://trac.videolan.org/vlc/ticket/21497
Best,
-t
>
> diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
> index 40b1d8ab23..f99d979c43 100644
> --- a/modules/hw/vdpau/avcodec.c
> +++ b/modules/hw/vdpau/avcodec.c
> @@ -205,12 +205,10 @@ error:
> return VLC_EGENERIC;
> }
>
> -static void Close(vlc_va_t *va, void **hwctx)
> +static void Close(vlc_va_t *va)
> {
> vlc_va_sys_t *sys = va->sys;
>
> - assert(hwctx == NULL);
> -
> for (unsigned i = 0; sys->pool[i] != NULL; i++)
> vlc_vdp_video_destroy(sys->pool[i]);
> vdp_release_x11(sys->vdp);
> --
> 2.17.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list