From patchwork Thu Feb 8 01:35:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruiling Song X-Patchwork-Id: 7527 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.150.1 with SMTP id c1csp1279905jai; Wed, 7 Feb 2018 17:35:21 -0800 (PST) X-Google-Smtp-Source: AH8x227wpOTYzYQCGYpGhWPFiCaL1fGvV0Vv0bRf3SsxRw087tXq5EhQAqYIL22+S/Cj9nBpKYOF X-Received: by 10.223.195.141 with SMTP id p13mr7130947wrf.19.1518053721328; Wed, 07 Feb 2018 17:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518053721; cv=none; d=google.com; s=arc-20160816; b=njACq03/BemmVpqSEFyG9TdxIZLDYKqT3FecbA6lG8asByqvWJ8pPmW8UtbcIj7PEx a5Im9iObMpAnT5BTex/tNaxna0Zel+9mnH8s1o6n0+fj8kBg6FqUI82TvYN6NIbFQLiI HQb/ik2YCr7KEonMmoRhbXHFGodOxHg/67PYnLCl9CP8hSGp2xDhbZDsM88yQFY8LmMS jCANHuPb3nELNxXjeEdAdAwBQOBKaeH8Kp5RXDUVU3bhB1es3EGCHDUAA6M1BDmTfcp4 a31Nhj3MGGyImzn6Zizx7eOUr3Si7/UL33pymSZWeIuvWU3JT8oD1nczgBZHkUsYIr/9 oUCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=bZgPPF4AuHHIECZLWxwXRWVbEethYpCCtX1Yu4sqTQo=; b=tP5Y/8Mt2+1AgNARWJLxFPnG3qPFh0g/sse7zwpp8WKIB5zm8uMg1Z07dacpqBOoqC odkM02AykNb/MN1CJ8CzebfUInXZgcJN4mwaLKxUFz2ctUUCq/BhNZX9WugC5HhncLAP j0aAFwMT3hWtrdGTnD8Xe8n3aLDWdA9RepmNj0lrIwWv77exC2Xk69tIgvU6x6MDr/87 wwIJZzG8S+bOXBVEwGSw6q6Bp8UWZQIsygOWC3ezzol7dSBvI47FnuYTGbtFTgotExMh OLIYCw+2755AdbgnBiY2vr7i70czk8Ogkl9XwFf+LupZOT/1ckQDh/vkolJzHDpuc4FE QGiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b8si2079718wrh.502.2018.02.07.17.35.20; Wed, 07 Feb 2018 17:35:21 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F06D2680376; Thu, 8 Feb 2018 03:35:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 66755680252 for ; Thu, 8 Feb 2018 03:35:04 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Feb 2018 17:35:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,476,1511856000"; d="scan'208";a="29037231" Received: from ruiling-skl2.sh.intel.com ([10.239.160.43]) by fmsmga001.fm.intel.com with ESMTP; 07 Feb 2018 17:35:09 -0800 From: Ruiling Song To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Feb 2018 09:35:14 +0800 Message-Id: <1518053714-3345-1-git-send-email-ruiling.song@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH] lavc/vaapi: release buffer before destroy context. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Ruiling Song MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 --- 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);