From patchwork Tue Mar 9 12:31:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 26279 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id C26D44487C8 for ; Tue, 9 Mar 2021 14:32:01 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9D73468A7DE; Tue, 9 Mar 2021 14:32:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 045DD688176 for ; Tue, 9 Mar 2021 14:31:56 +0200 (EET) Received: by mail-wm1-f51.google.com with SMTP id e23so1580953wmh.3 for ; Tue, 09 Mar 2021 04:31:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=LeVf+Wadoh3RZZuRYX7hGfWsnyh0/QO3J2hk+Yxexo4=; b=TmTnL0l0NGQH0nyltN4FnRn+RKL+WKiOpyFRAwzlTTs++36woE5oAnKmCJWv9sFWMp wGQ9iow8XSaHE41EpH3WZZKhspgcoNRQjvh8Kg12/F03PBujPne2ZEYWZZEcY/I7MdiO gtXJBfunhwkaA7KN18xvUxKU8pVDHLIzmEeTXZ8mwvlNlpEB2UydjruAKd7Ybr9k5QII 7rKrcH+ERo7f5TIw6KlYHU7jTz9e4mTeZsOG76TqCiHLwVSICBYCQWNGpaivUxgobVK+ EYbFiIlv+95htGKm2wBRTYcXR4H0h5QOGqhAXQkODjeN3TVIXaLeVd0YffXoIorR0G3e FS2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=LeVf+Wadoh3RZZuRYX7hGfWsnyh0/QO3J2hk+Yxexo4=; b=HI7mJT5SiH626F29hvUaUZMS4QGVVykCzW9q7LU+U8e+xTl64UussTPVh7/x8uDplo RpvmJyiNcX0CWR+ZiRluoqEPh4E3ulO0xoAUnl2GdBJLOYNMKqEyroAMNhvWosy7dC+r gt1Jh/4luPI9txWUZ17GC7GAty9L1hQhx0BxvKKaaTsM+8rPNZnXAre8HVRr3uSt2+s4 R0OosKyiRts+m/7u9/7RozSBxEA43ynocvXFI2LmtHDxWYuj3lz1d+GRTpKZmx3OnbH3 PYbG9klF7svtke/nFcv5e0ZkijeCDTTsAouiAFpCoghFFglVw37tQhhJk/HVDG/28anm k//A== X-Gm-Message-State: AOAM533nKLmsb8Pl7BB47lmV704PotARB5gFstybu876uKySwpoUh223 BzU223DWS+cYwPSYSShjcsB/ubznFc/MQqJg X-Google-Smtp-Source: ABdhPJw90AvzuWBghthmnRoq9c1LHSY/EGsXESkXx9NovDI0RHCUvoSPaASPKLjWQO5gbPgpRWQSSg== X-Received: by 2002:a1c:22c2:: with SMTP id i185mr3749434wmi.99.1615293115460; Tue, 09 Mar 2021 04:31:55 -0800 (PST) Received: from localhost (host-96-177.parnet.fi. [77.234.96.177]) by smtp.gmail.com with ESMTPSA id m14sm4355488wmi.27.2021.03.09.04.31.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 09 Mar 2021 04:31:54 -0800 (PST) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Tue, 9 Mar 2021 14:31:54 +0200 Message-Id: <20210309123154.59060-1-martin@martin.st> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] nvenc: Fix output dts if encoding with implicitly enabled b-frames 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Since a0949d0bcb0eee2f3fffcf9a4810c0295d14c0dc, the b-frames setting defaults to -1, which uses the preset's default setting. If b-frames are enabled, but max_b_frames is kept at <= 0, the output dts are inconsistent. --- libavcodec/nvenc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index a061dee880..6baeec6d36 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -1380,8 +1380,11 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) if (res < 0) return res; - if (ctx->encode_config.frameIntervalP > 1) + if (ctx->encode_config.frameIntervalP > 1) { avctx->has_b_frames = 2; + if (avctx->max_b_frames <= 0) + avctx->max_b_frames = 1; + } if (ctx->encode_config.rcParams.averageBitRate > 0) avctx->bit_rate = ctx->encode_config.rcParams.averageBitRate;