From patchwork Sat Mar 18 08:56:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wm4 X-Patchwork-Id: 2998 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp609764vsy; Sat, 18 Mar 2017 01:56:58 -0700 (PDT) X-Received: by 10.28.145.130 with SMTP id t124mr1830257wmd.39.1489827418237; Sat, 18 Mar 2017 01:56:58 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n22si14438148wra.196.2017.03.18.01.56.57; Sat, 18 Mar 2017 01:56:58 -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; dkim=neutral (body hash did not verify) header.i=@googlemail.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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6187E688388; Sat, 18 Mar 2017 10:56:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8E286688302 for ; Sat, 18 Mar 2017 10:56:04 +0200 (EET) Received: by mail-wr0-f194.google.com with SMTP id u48so12003370wrc.1 for ; Sat, 18 Mar 2017 01:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PNntPhfEq6+OCW5RoBEcryZa6/ZAgxVrYOmvKCEszM4=; b=OGXv54mCHwCx1vjeMScU2G5f5532OVlQURD6dRJGZbOl6/xCmPB6L/J+1D87skQ40d rq5FXrmo+OC92V5hmIGlb8l/XRFLe6rgV6nl+3GPoitnMBsVZAGFcqoz7s9qXEs4tgiL 2yUsyUc65LHWdUI/m9k9zDSfxKdYMzL8iRun7QTet14p39IeHpW5DFF2htcoX2h1OBP2 VUt/sIwYtvmT26+WVyLM2mBQnvFMt9SebBxONUYRb30wY6o79+zshiMSOroS9EwCsKYd zHyKkI+jfnZgV14x5C+nzp61R0CboMwCAtbqSGhyhwJTzVx6VPpC3xhDcv/LeoGr3Ffs fFwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PNntPhfEq6+OCW5RoBEcryZa6/ZAgxVrYOmvKCEszM4=; b=fUVQ1RAz3Gv2qQZh+oet9kPtcXD8tkDd5WyLQqU53gIjMEShxH5hvsuee5dnBPKZqp abxR0T0u3Xa8WHY5u0QajThrR6nVNUNmSR7fp3Zi3PUp7bYlGf4jYSKPStP2K7MVm787 fE5PuF1jLZfW744DYU3nCmOkft32wPsrHNs5DlH5OMR6yLXDjRhJHkX0DpoUNA3R7BbQ LqZSx0aKZm9Gkn4QVbDa7dD4YGzBG/quPrGjfFspva4QnsDtw51egueYO/76BWISKMWF ReIoNphPpZh8dLNDqZAwajULkWx25edXJLrfm7WDumbN6SPgo6cWT5Qbz6bXDKnDwTca NKxA== X-Gm-Message-State: AFeK/H0oKBzQE+MOMaxcnuaPewu+bsIlzURk0R7+7uiPZfHGRiIIG+gbD0mv08RndxtszQ== X-Received: by 10.223.134.44 with SMTP id 41mr16536337wrv.26.1489827381481; Sat, 18 Mar 2017 01:56:21 -0700 (PDT) Received: from localhost.localdomain (p4FF02CC6.dip0.t-ipconnect.de. [79.240.44.198]) by smtp.googlemail.com with ESMTPSA id p12sm12879637wrb.46.2017.03.18.01.56.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Mar 2017 01:56:20 -0700 (PDT) From: wm4 To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 Mar 2017 09:56:01 +0100 Message-Id: <20170318085606.26011-5-nfxjfg@googlemail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170318085606.26011-1-nfxjfg@googlemail.com> References: <20170318085606.26011-1-nfxjfg@googlemail.com> Subject: [FFmpeg-devel] [PATCH 4/9] pthread_frame: Unreference hw_frames_ctx on per-thread codec contexts 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: wm4 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Mark Thompson When decoding with threads enabled, the get_format callback will be called with one of the per-thread codec contexts rather than with the outer context. If a hwaccel is in use too, this will add a reference to the hardware frames context on that codec context, which will then propagate to all of the other per-thread contexts for decoding. Once the decoder finishes, however, the per-thread contexts are not freed normally, so these references leak. Merges Libav commit fd0fae60. Signed-off-by: wm4 --- libavcodec/pthread_frame.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 18f89ee73d..b16c1b9928 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -620,8 +620,11 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) av_freep(&p->avctx->slice_offset); } - if (p->avctx) + if (p->avctx) { av_freep(&p->avctx->internal); + av_buffer_unref(&p->avctx->hw_frames_ctx); + } + av_freep(&p->avctx); }