From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTPS id 23B2B4BC0C
	for <ffmpegdev@gitmailbox.com>; Sat, 29 Mar 2025 20:59:52 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4739E687B8C;
	Sat, 29 Mar 2025 22:59:48 +0200 (EET)
Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com
 [209.85.160.44])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 53454687B8C
 for <ffmpeg-devel@ffmpeg.org>; Sat, 29 Mar 2025 22:59:41 +0200 (EET)
Received: by mail-oa1-f44.google.com with SMTP id
 586e51a60fabf-2b2b6019a74so1691667fac.0
 for <ffmpeg-devel@ffmpeg.org>; Sat, 29 Mar 2025 13:59:41 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1743281979; x=1743886779; darn=ffmpeg.org;
 h=content-transfer-encoding:mime-version:message-id:date:subject:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=aZc8Bi+Bm9K1i0OUVQuM5b/KsEaaTyixgtnS9Ppreto=;
 b=Qq8v1Ig6E1OjRSdtJKHIAbRhDy07aW7YZCHdpU/Q64ZWC7uzcRxOQME+hZLe/7PGEx
 KpVtVYJLuL/Me1U8/5SrgtSjlt9SAjjyIGhov4bcgT+EzcWQBvoKPvJDBsrQA8LBrpmD
 nWD/R8Ujdq5ihvBhEf+VPzciLPtdiL4OngxZFYn6XnYFZrLOCjBzZNvT8OV0o34b70A9
 TGLVarw/EZ7yDAu0YGnQwzekaDGrAdVFy2nGSK4DGF6F+pOEMgOHKqbapImxi3mC/5BG
 8N88zcVpKx2QhjkreuDwRwf16DP46E4qCU4T4iRrpmIVPUczzxWhVyDjupI3Lu6wvWnU
 bTjA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1743281979; x=1743886779;
 h=content-transfer-encoding:mime-version:message-id:date:subject:to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=aZc8Bi+Bm9K1i0OUVQuM5b/KsEaaTyixgtnS9Ppreto=;
 b=T9zRvS4HxOUJDYZHZsRPv6fEWy6KzKdzQmDtmOSHlZySotngGMIhaPMhRjIVS8p/Tp
 zZwVHbggHoydhsHLBhBbJfnvScP6FdcFB7qnQCOFh1SYKaEE4ZUp+/x+zRBMCN/xaPxy
 k2ugnxph+3GCKjiJtZB8CXZEB1gWnK9nnD8sbaVxEURQrQrS86mXNn9iVn7MlqJbURDE
 79+5Gxq3mOWS2Xdx+PlIhpSbs5ONaDdJIr6mKBGYKJsCc1He/GAhy2NVNyjRdYFgNwq5
 XiB5jpMjawaKfg2CC8j9q/9jsDFmq+LUNBqBNQFyQT/I3e+pF259eQUCA9EfjXGTdjHF
 G63A==
X-Forwarded-Encrypted: i=1;
 AJvYcCVJiFGZfh9s/DU5nKWPb8zdIPLyaAKnpE7nkPWpiwoPd7vWzKngMSq2WU6ZEKfXlYnR+zK2zJvVBAsufxU=@ffmpeg.org
X-Gm-Message-State: AOJu0YzRjuAkuedUBVBeVD1YAy22HX+5yZuktkXjVre7RZyQqFW4E7zb
 ZsG30AQ3QBiHwxW8bDsi4D/hxzxCsW7xkhukZht8ZptGQTDEuDddjO+L1w==
X-Gm-Gg: ASbGnctnIVoiENUqI4Dabd93n1/u/lVJOV6RrTy1UEGQmyGBRkV9gxsOTLITJTU5p/0
 Ih3cI2qxDqcZ0YJE+OK4EfQzONmJNyj2o11dFHWW6Qza3QVMAFX0OCjA/Mhv3FlZMmjOdxjzgQ6
 zybvMdFXYs22XPFOV6tX9s8JuITMdtLIFEc5qZWCvxj3DVLcGC7V7mufV4AIW4+ALzPM3x7RZ36
 R91GykJVVDSAho524mRTVSX+9UwnNtv1+nsXHbXOkyzteTNau3k2sNQGfq3uvfBQ01SnRwSPPtc
 AKoY9M5F6ex9soPJKEJb8vrtb91iAZHhjDMWeR/RBYrzEQ56f4oCwebpFH6Alw==
X-Google-Smtp-Source: AGHT+IFqDyDDQHTmWk+0/irtDLUZl5EAUCvrYQZSuipW25is1mPYgpcCLwJbsgS7SwE9muKKJPanBg==
X-Received: by 2002:a05:6870:2e0e:b0:296:bbc8:4a82 with SMTP id
 586e51a60fabf-2cbcf755648mr2492409fac.27.1743281979216; 
 Sat, 29 Mar 2025 13:59:39 -0700 (PDT)
Received: from cassini.localdomain ([2600:1702:50c6:cf10:38b3:1353:266b:b701])
 by smtp.gmail.com with ESMTPSA id
 46e09a7af769-72c58267cb9sm859177a34.50.2025.03.29.13.59.37
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 29 Mar 2025 13:59:38 -0700 (PDT)
From: Cameron Gutman <aicommander@gmail.com>
To: timo@rothenpieler.org,
	ffmpeg-devel@ffmpeg.org
Date: Sat, 29 Mar 2025 15:58:57 -0500
Message-ID: <20250329205922.293412-1-aicommander@gmail.com>
X-Mailer: git-send-email 2.49.0
MIME-Version: 1.0
Subject: [FFmpeg-devel] [PATCH v2] avcodec/nvenc: add option to skip padding
 OBUs
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250329205922.293412-1-aicommander@gmail.com/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

Some scenarios (such as game streaming or videoconferencing) may use CBR
to strictly cap the maximum encoded bitrate, but they don't mind the
bitrate falling below the target if the encoder doesn't need the
additional headroom.

Allow users to opt-out of filler data in CBR mode for those usecases
where it is unwanted.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
---
v2: Rebased to resolve conflicts against master
---
 libavcodec/nvenc.c     | 2 +-
 libavcodec/nvenc.h     | 1 +
 libavcodec/nvenc_av1.c | 2 ++
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 0f5e772b3e..0f2336b0ec 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1624,7 +1624,7 @@ static av_cold int nvenc_setup_av1_config(AVCodecContext *avctx)
 
     av1->idrPeriod = cc->gopLength;
 
-    if (IS_CBR(cc->rcParams.rateControlMode)) {
+    if (ctx->filler_data && IS_CBR(cc->rcParams.rateControlMode)) {
         av1->enableBitstreamPadding = 1;
     }
 
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index e035e123c6..3431457422 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -309,6 +309,7 @@ typedef struct NvencContext
     int unidir_b;
     int split_encode_mode;
     int mdm, cll;
+    int filler_data;
 } NvencContext;
 
 int ff_nvenc_encode_init(AVCodecContext *avctx);
diff --git a/libavcodec/nvenc_av1.c b/libavcodec/nvenc_av1.c
index 01626113ab..c00817af7b 100644
--- a/libavcodec/nvenc_av1.c
+++ b/libavcodec/nvenc_av1.c
@@ -156,6 +156,8 @@ static const AVOption options[] = {
                                                             OFFSET(extra_sei),    AV_OPT_TYPE_BOOL,  { .i64 = 1 }, 0, 1, VE },
     { "a53cc",        "Use A53 Closed Captions (if available)", OFFSET(a53_cc),   AV_OPT_TYPE_BOOL,  { .i64 = 1 }, 0, 1, VE },
     { "s12m_tc",      "Use timecode (if available)",        OFFSET(s12m_tc),      AV_OPT_TYPE_BOOL,  { .i64 = 1 }, 0, 1, VE },
+    { "filler_data",  "Use filler data to ensure CBR bitrate is strictly adhered to",
+                                                            OFFSET(filler_data),  AV_OPT_TYPE_BOOL,  { .i64 = 1 }, 0, 1, VE },
 #ifdef NVENC_HAVE_H264_AND_AV1_TEMPORAL_FILTER
     { "tf_level",     "Specifies the strength of the temporal filtering",
                                                             OFFSET(tf_level),     AV_OPT_TYPE_INT,   { .i64 = -1 }, -1, INT_MAX, VE, .unit = "tf_level" },
-- 
2.49.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".