From patchwork Thu Jun 7 15:08:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Koshevoy X-Patchwork-Id: 9279 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp327665jad; Thu, 7 Jun 2018 08:08:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJtqIqSIpVjQMS41EQFsb3dQ2vr80dckM3tPrbbSes6NFKd93iXFvR//tZdDK8MikHgxaSo X-Received: by 2002:adf:f6c9:: with SMTP id y9-v6mr2219136wrp.4.1528384110241; Thu, 07 Jun 2018 08:08:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528384110; cv=none; d=google.com; s=arc-20160816; b=Pcz1dVj/8T2YT94ZGIAmkkleK4gFQOsj1pXm5QwphwVvDJ0LP4MUOR90RVm/wX4ZMd oOepIhGtbWKmVm62dfmYT16wBq8zh9qapoXj93kPru8CCaDhbv7LkRaU4uOMXhi4Adh9 4A06h8RNHJJQBy0ieGlKVWoSaQXScERWlDOsjL4yzG0kOtC/T462tP9xWe0PNXtz62Bk AEtrVKfEBd9t/AotJ80zcpqzjfDnYnRcwS2Hsx1GPDWo9W2bUFkY6fFTTleTPndM4zCk fFwewuMUKXpFwXhWmfWc6T8DpP19jOa3wvyOg8eqqBKhnXLEpv1S7blhozhqzyb3JXiS EdWA== 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:dkim-signature:delivered-to:arc-authentication-results; bh=HTdXjfgSEGk7M2U8we/jUjqqDEIYH2W+xtXVr7ofy+U=; b=f4Uvle7c7XlGy+98Ovs/dewl64d0aCdmGbzCrIijfEoFPVQFbf7pKaUVhqzXNf4tAI 1/Z3Zeg2cnDE3+Q8jsg/NVinPJZO8BrD3vz/XWF72FicxxhxcAHeNBkubDLv3mzRbYjW cutpKm6SoOYuMtZT3F8W5gPV4YKaLm11ZPK478m3i5t5/O00IhHzEjpxLcEUtkClArxX cex0to5IJV+/CyYV4Nynv9S5dVClR6IcLCcNb2JXDmPku7w7Jv21dB1pW9v+6kZR7O8J JuOKRZ+KBL/uTLVf2MKLnzsY5KwV72z84rR+30+f0O/NPeRI0Ak7nns/y3AwOYqoNQMz LvzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=R0dAt3db; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z14-v6si26470345wrc.263.2018.06.07.08.08.28; Thu, 07 Jun 2018 08:08:30 -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=@gmail.com header.s=20161025 header.b=R0dAt3db; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 445A168A76C; Thu, 7 Jun 2018 18:07:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CDF6268A716 for ; Thu, 7 Jun 2018 18:07:32 +0300 (EEST) Received: by mail-pf0-f179.google.com with SMTP id y5-v6so4153300pfn.4 for ; Thu, 07 Jun 2018 08:08:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=baLykbeYwAgc/lLUGBYbcfRvEsgx8LH6a5Xix/gBWVc=; b=R0dAt3dbWUTKjUt+6Px2FQv9O89Y0KUPJ7ei6w2HjRPFP4W1bIp39W91wUcJamXj2x YFLlGrl+Je54yoVLjDt0XMHzb0xlvXtkUAF2MMEPZuTHgUHa9O/TrfBJ7aiWdo+BiPEr SiFRNE1kPgTNx3/ENpCbdjbp0HCRoMu3a9TySB9G61RF6/ktql3LddHs3XAZA4rIOSlR lvR1FK8QU4d0uNaxxdkrDj2YJfppbH3NneUWQ/9hWIFG2aGCUn/gNG1uWTi1xxL/PtVK VEPUo1IjZto5Wwxr85CnN8hGw62XxfClbAgJU4F3CGZSs+91lgrFkX0DjK3bopBt/DMF FYOA== 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=baLykbeYwAgc/lLUGBYbcfRvEsgx8LH6a5Xix/gBWVc=; b=MBGh+aZXvKRTFXllKuEroQfEyfvprk2n0S20qqtKn6UgfKvnNvRqKPAOxnLhNmNCP/ OEjD9cn8l4hpSmmt/NxOW5malI/1F0C65m4EFkmBTghFoQAV69k5KzrFET+dbG4xnLaO ntDfDtKM/9fk0yVNOOhvsMGwxQvRyOp82wdcp+ogjTfjva4WLId/ZSSxfL/pcA0mFIzF Fvu4qavRLVNhu5xV1XI/vioM6OdDPVFREuEQF5KPm6ahgY7M6SyH7Y5qtIdvJl2Z0c/K FscE9v/47BYSUq9WZS9/dNVoWJ0OEINOjya00IpOUodC2ekNZWLg/CzoCqPZESs8j1My a6WQ== X-Gm-Message-State: APt69E2u/wvtSIZvnMQyTB7/xlnk8NS5QHziTilH2jCckSrPmIX3EGXw jemlFpxruhpFKcj9TNOCIgz4tA== X-Received: by 2002:a63:a05d:: with SMTP id u29-v6mr1929762pgn.80.1528384098148; Thu, 07 Jun 2018 08:08:18 -0700 (PDT) Received: from homestead.aragog.com ([2605:a601:31e0:603:12c3:7bff:fe6c:2700]) by smtp.gmail.com with ESMTPSA id i7-v6sm76064860pfa.34.2018.06.07.08.08.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 08:08:16 -0700 (PDT) From: Pavel Koshevoy To: ffmpeg-devel@ffmpeg.org Date: Thu, 7 Jun 2018 09:08:15 -0600 Message-Id: <20180607150815.11337-1-pkoshevoy@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: References: Subject: [FFmpeg-devel] [PATCH] lavc/nvenc: enable nvenc encoder instance reuse (v2) 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: Pavel Koshevoy MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/nvenc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index b4186c0bec..cfa7268a5e 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -2051,8 +2051,16 @@ int ff_nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) if ((!ctx->cu_context && !ctx->d3d11_device) || !ctx->nvencoder) return AVERROR(EINVAL); - if (ctx->encoder_flushing) - return AVERROR_EOF; + if (ctx->encoder_flushing) { + if (avctx->internal->draining) + return AVERROR_EOF; + + ctx->encoder_flushing = 0; + ctx->first_packet_output = 0; + ctx->initial_pts[0] = AV_NOPTS_VALUE; + ctx->initial_pts[1] = AV_NOPTS_VALUE; + av_fifo_reset(ctx->timestamp_list); + } if (frame) { in_surf = get_free_frame(ctx);