[vlc-devel] [PATCH 1/2] vdpau: free the hwaccel_context allocated locally ourself

Rémi Denis-Courmont remi at remlab.net
Tue Jul 23 08:06:56 CEST 2019


IIRC that does not work because FFmpeg could reallocate it.

Le 23 juillet 2019 08:57:44 GMT+03:00, Steve Lhomme <robux4 at ycbcr.xyz> a écrit :
>---
> modules/hw/vdpau/avcodec.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
>diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
>index 913e391562..49536e6d60 100644
>--- a/modules/hw/vdpau/avcodec.c
>+++ b/modules/hw/vdpau/avcodec.c
>@@ -44,6 +44,7 @@ struct vlc_va_sys_t
>     vdp_t *vdp;
>     VdpDevice device;
>     VdpChromaType type;
>+    void *hwaccel_context;
>     uint32_t width;
>     uint32_t height;
>     vlc_vdp_video_field_t *pool[];
>@@ -124,7 +125,8 @@ static void Close(vlc_va_t *va, void **hwctx)
>     for (unsigned i = 0; sys->pool[i] != NULL; i++)
>         vlc_vdp_video_destroy(sys->pool[i]);
>     vdp_release_x11(sys->vdp);
>-    av_freep(hwctx);
>+    if (sys->hwaccel_context)
>+        av_free(sys->hwaccel_context);
>     free(sys);
> }
> 
>@@ -172,6 +174,7 @@ static int Open(vlc_va_t *va, AVCodecContext
>*avctx, enum PixelFormat pix_fmt,
>     sys->type = type;
>     sys->width = width;
>     sys->height = height;
>+    sys->hwaccel_context = NULL;
> 
>     err = vdp_get_x11(NULL, -1, &sys->vdp, &sys->device);
>     if (err != VDP_STATUS_OK)
>@@ -189,6 +192,7 @@ static int Open(vlc_va_t *va, AVCodecContext
>*avctx, enum PixelFormat pix_fmt,
> 
>     if (av_vdpau_bind_context(avctx, sys->device, func, flags))
>         goto error;
>+    sys->hwaccel_context = avctx->hwaccel_context;
>     va->sys = sys;
> 
>     unsigned i = 0;
>@@ -221,6 +225,8 @@ static int Open(vlc_va_t *va, AVCodecContext
>*avctx, enum PixelFormat pix_fmt,
>     return VLC_SUCCESS;
> 
> error:
>+    if (sys->hwaccel_context)
>+        av_free(sys->hwaccel_context);
>     vdp_release_x11(sys->vdp);
>     free(sys);
>     return VLC_EGENERIC;
>-- 
>2.17.1
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190723/ccbeb3ed/attachment.html>


More information about the vlc-devel mailing list