[FFmpeg-devel] lavc/vaapi: release buffer before destroy context.

Submitted by Ruiling Song on Feb. 8, 2018, 1:35 a.m.

Details

Message ID 1518053714-3345-1-git-send-email-ruiling.song@intel.com
State New
Headers show

Commit Message

Ruiling Song Feb. 8, 2018, 1:35 a.m.
The common way to use libVA was first destroy the buffer, then the
context. I am not sure whether libVA has clear statement on this.
This patch just make things simple. This would fix an segmentation
fault issue against iHD open source driver.

Signed-off-by: Ruiling Song <ruiling.song@intel.com>
---
 libavcodec/vaapi_encode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jun Zhao Feb. 8, 2018, 3:08 a.m.
On 2018/2/8 9:35, Ruiling Song wrote:
> The common way to use libVA was first destroy the buffer, then the
> context. I am not sure whether libVA has clear statement on this.
> This patch just make things simple. This would fix an segmentation
> fault issue against iHD open source driver.
>
> Signed-off-by: Ruiling Song <ruiling.song@intel.com>
> ---
>  libavcodec/vaapi_encode.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index 550ea47..607e3ab 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -1562,6 +1562,8 @@ av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
>          vaapi_encode_free(avctx, pic);
>      }
>  
> +    av_buffer_pool_uninit(&ctx->output_buffer_pool);
> +
>      if (ctx->va_context != VA_INVALID_ID) {
>          vaDestroyContext(ctx->hwctx->display, ctx->va_context);
>          ctx->va_context = VA_INVALID_ID;
> @@ -1572,7 +1574,6 @@ av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
>          ctx->va_config = VA_INVALID_ID;
>      }
>  
> -    av_buffer_pool_uninit(&ctx->output_buffer_pool);
>  
>      av_freep(&ctx->codec_sequence_params);
>      av_freep(&ctx->codec_picture_params);
I think Mark have submit this patch in Libav: 
https://patches.libav.org/patch/64112/
Ruiling Song Feb. 8, 2018, 3:17 a.m.
> -----Original Message-----

> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of

> Jun Zhao

> Sent: Thursday, February 8, 2018 11:08 AM

> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>;

> Song, Ruiling <ruiling.song@intel.com>

> Subject: Re: [FFmpeg-devel] [PATCH] lavc/vaapi: release buffer before destroy

> context.

> 

> 

> 

> On 2018/2/8 9:35, Ruiling Song wrote:

> > The common way to use libVA was first destroy the buffer, then the

> > context. I am not sure whether libVA has clear statement on this.

> > This patch just make things simple. This would fix an segmentation

> > fault issue against iHD open source driver.

> >

> > Signed-off-by: Ruiling Song <ruiling.song@intel.com>

> > ---

> >  libavcodec/vaapi_encode.c | 3 ++-

> >  1 file changed, 2 insertions(+), 1 deletion(-)

> >

> > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c

> > index 550ea47..607e3ab 100644

> > --- a/libavcodec/vaapi_encode.c

> > +++ b/libavcodec/vaapi_encode.c

> > @@ -1562,6 +1562,8 @@ av_cold int

> ff_vaapi_encode_close(AVCodecContext *avctx)

> >          vaapi_encode_free(avctx, pic);

> >      }

> >

> > +    av_buffer_pool_uninit(&ctx->output_buffer_pool);

> > +

> >      if (ctx->va_context != VA_INVALID_ID) {

> >          vaDestroyContext(ctx->hwctx->display, ctx->va_context);

> >          ctx->va_context = VA_INVALID_ID;

> > @@ -1572,7 +1574,6 @@ av_cold int

> ff_vaapi_encode_close(AVCodecContext *avctx)

> >          ctx->va_config = VA_INVALID_ID;

> >      }

> >

> > -    av_buffer_pool_uninit(&ctx->output_buffer_pool);

> >

> >      av_freep(&ctx->codec_sequence_params);

> >      av_freep(&ctx->codec_picture_params);

> I think Mark have submit this patch in Libav:

> https://patches.libav.org/patch/64112/


I am sorry I did not notice that. Please ignore the patch.
I think we can merge Mark's patch now so we can have some try on iHD open source driver.

Ruiling
> _______________________________________________

> ffmpeg-devel mailing list

> ffmpeg-devel@ffmpeg.org

> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Patch hide | download patch | download mbox

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 550ea47..607e3ab 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1562,6 +1562,8 @@  av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
         vaapi_encode_free(avctx, pic);
     }
 
+    av_buffer_pool_uninit(&ctx->output_buffer_pool);
+
     if (ctx->va_context != VA_INVALID_ID) {
         vaDestroyContext(ctx->hwctx->display, ctx->va_context);
         ctx->va_context = VA_INVALID_ID;
@@ -1572,7 +1574,6 @@  av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
         ctx->va_config = VA_INVALID_ID;
     }
 
-    av_buffer_pool_uninit(&ctx->output_buffer_pool);
 
     av_freep(&ctx->codec_sequence_params);
     av_freep(&ctx->codec_picture_params);