From patchwork Thu Oct 31 17:04:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaullier Nicolas X-Patchwork-Id: 16044 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 0DFF8449753 for ; Thu, 31 Oct 2019 19:05:11 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E655168B138; Thu, 31 Oct 2019 19:05:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtp-2.arkena.net (smtp-2.arkena.net [95.81.173.75]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2B03468AEA8 for ; Thu, 31 Oct 2019 19:05:03 +0200 (EET) Received: from secu2 (unknown [10.180.103.10]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-2.arkena.net (Postfix) with ESMTPSA id 473sBk5lVlzHh96; Thu, 31 Oct 2019 17:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arkena.com; s=20150421; t=1572541502; bh=ODp9eIOfMU2czViY7MjVbW7drOgOjrGo2kexcLIvqVU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=uTpsg2Jcmxn/CTKIIMmAjaX+KzOT0T018IYvlP1x20Ib08tVilyql1MSJeKVRwRvW C3h2VarzgeteAZbb+IGuXYV00xIwFdLiPeFCDxJe2O6UeyJ4Cl7GoDhfY7WND8DVV8 TX9WEsfi5CyrGjXGIWX40oNnvL8u9bF4ODI7I8gI= Received: from arkena.com (unknown [172.16.3.159]) by secu2 (Postfix) with ESMTP id 7FA0E3FA6D; Thu, 31 Oct 2019 18:05:00 +0100 (CET) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Thu, 31 Oct 2019 18:04:58 +0100 Message-Id: <20191031170458.22515-2-nicolas.gaullier@arkena.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20191031170458.22515-1-nicolas.gaullier@arkena.com> References: <20191031170458.22515-1-nicolas.gaullier@arkena.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/1] avformat/mpegenc.c: vbvsize option 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: Nicolas Gaullier Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Allow the user to set or override the vbv size --- libavformat/mpegenc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index f6980231a2..1613c8afa1 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -67,6 +67,7 @@ typedef struct MpegMuxContext { int system_header_freq; int system_header_size; int user_mux_rate; /* bitrate in units of bits/s */ + int user_vbv_size; /* vbv buffer size in units of bits/s */ int mux_rate; /* bitrate in units of 50 bytes/s */ /* stream info */ int audio_bound; @@ -433,7 +434,9 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) stream->id = mpv_id++; props = (AVCPBProperties*)av_stream_get_side_data(st, AV_PKT_DATA_CPB_PROPERTIES, NULL); - if (props && props->buffer_size) + if (s->user_vbv_size) + stream->max_buffer_size = 6 * 1024 + s->user_vbv_size / 8; + else if (props && props->buffer_size) stream->max_buffer_size = 6 * 1024 + props->buffer_size / 8; else { av_log(ctx, AV_LOG_WARNING, @@ -1268,6 +1271,7 @@ static void mpeg_mux_deinit(AVFormatContext *ctx) #define E AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { { "muxrate", NULL, OFFSET(user_mux_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, ((1<<22) - 1) * (8 * 50), E }, + { "vbvsize", "set vbv buffer size (in bits)", OFFSET(user_vbv_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, (1LL<<32) - 1, E}, { "preload", "Initial demux-decode delay in microseconds.", OFFSET(preload), AV_OPT_TYPE_INT, { .i64 = 500000 }, 0, INT_MAX, E }, { NULL }, };