From patchwork Tue Apr 3 01:50:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruiling Song X-Patchwork-Id: 8297 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp3150044jad; Mon, 2 Apr 2018 18:51:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Meg/frvF5g7THVNOwu1FuUZwC0HKN1PLT2tRlDcA6LAG68OTNtCphNGL8UHefGGhKSeYn X-Received: by 10.223.142.23 with SMTP id n23mr8682614wrb.28.1522720267490; Mon, 02 Apr 2018 18:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522720267; cv=none; d=google.com; s=arc-20160816; b=fhKvEMYjD16fpjkLcetDuscZULvCs28JMqs1RvvLg+KSn13xp8mmAQMU6fRh7rOuqN Z0KVaG+MQi1j41wIoUADCDEqUnSmCPBZ1uESxqh//ZrazAFMYUlOlZ3YH4YLM33fDqp8 /LQxfAozKtmrzM7BCyDGGH+lfx+jTg+6wwJRcv33ZtyPcjJuOzl2QF5IGHtZla8jgzPh iu1gS18bxMDWGYZF1plZ8xj8cW+EX6YTAPev8PRw3uAHrAL7X3vVWuZJtg2Br94DV1vE XW8v2g5UT1WKgySAu8ePpUd7p0w4tr+cRx9M68eqKOhM4AYRVuNIIyKBLQbTm9EBHtSY eLSQ== 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:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=OVa+INqSRodej7bstFUP/1J1B+Hdfq9NssoQsKoHRGE=; b=pK/1WV0Awlngu9GYgRrHJWV45sV/WN2gXxCCiKXrHT9E4/4pUCvXC5XeD3QzLzKr9E 684Vr+INRALhV4BYZ8B4470hq418PnFzekLkv3KQeeeRuf9PLlaITLD0Da+EpmIunr3V KU6SvA1aTdn9qseMNIdqIJsYIeFo/zJAVPekC8FAE0KVTCw9Rzyr6iTsGzIuDKXFz9fa vqj+o+Y1VzCs2B5L+lAzK1VSGlbv+VALta9ejNlY8BdNydZSHtJTWr+W+MM4NheVhMY2 VZWYjATwM7U8pC8AqPo+CcJP2Rnt/YcTXUoq7jcynvpUWBG44iZV590TVQ0DiCRvNB2L JT+A== 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 y190si1262887wme.20.2018.04.02.18.51.07; Mon, 02 Apr 2018 18:51:07 -0700 (PDT) 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 3B3AF689CC4; Tue, 3 Apr 2018 04:50:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7D41B689CBE for ; Tue, 3 Apr 2018 04:50:33 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Apr 2018 18:50:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,398,1517904000"; d="scan'208";a="38897707" Received: from ruiling-skl2.sh.intel.com ([10.239.160.154]) by FMSMGA003.fm.intel.com with ESMTP; 02 Apr 2018 18:50:44 -0700 From: Ruiling Song To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 Apr 2018 09:50:20 +0800 Message-Id: <1522720220-12326-2-git-send-email-ruiling.song@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522720220-12326-1-git-send-email-ruiling.song@intel.com> References: <1522720220-12326-1-git-send-email-ruiling.song@intel.com> Subject: [FFmpeg-devel] [PATCH v2 2/2] lavf/qsv: clone the frame which may be managed by framework 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" For filters based on framesync, the input frame was managed by framesync, so we should not directly keep and destroy it, instead we make a clone of it here, or else double-free will occur. But for other filters not based on framesync, we still need to free the input frame inside filter_frame. That's why I made this v2 to fix the side-effect on normal filters. v2: and one av_frame_free() in vf_vpp_qsv.c Signed-off-by: Ruiling Song --- libavfilter/qsvvpp.c | 4 ++-- libavfilter/vf_vpp_qsv.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index f32b46d..86787c5 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -296,7 +296,7 @@ static QSVFrame *submit_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *p av_log(ctx, AV_LOG_ERROR, "QSVVPP gets a wrong frame.\n"); return NULL; } - qsv_frame->frame = picref; + qsv_frame->frame = av_frame_clone(picref); qsv_frame->surface = (mfxFrameSurface1 *)qsv_frame->frame->data[3]; } else { /* make a copy if the input is not padded as libmfx requires */ @@ -318,7 +318,7 @@ static QSVFrame *submit_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *p av_frame_copy_props(qsv_frame->frame, picref); av_frame_free(&picref); } else - qsv_frame->frame = picref; + qsv_frame->frame = av_frame_clone(picref); if (map_frame_to_surface(qsv_frame->frame, &qsv_frame->surface_internal) < 0) { diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index bd5fc32..4ef5bfb 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -326,8 +326,11 @@ static int config_output(AVFilterLink *outlink) static int filter_frame(AVFilterLink *inlink, AVFrame *picref) { VPPContext *vpp = inlink->dst->priv; + int ret = 0; - return ff_qsvvpp_filter_frame(vpp->qsv, inlink, picref); + ret = ff_qsvvpp_filter_frame(vpp->qsv, inlink, picref); + av_frame_free(&picref); + return ret; } static int query_formats(AVFilterContext *ctx)