From patchwork Tue Apr 28 09:16:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 19307 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 A839E44B25E for ; Tue, 28 Apr 2020 12:18:05 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9938768BC0B; Tue, 28 Apr 2020 12:18:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E84B668BA8F for ; Tue, 28 Apr 2020 12:17:58 +0300 (EEST) IronPort-SDR: Rf89SrFLL4aKM2j6Kv9XJrl9PYLgrjLrO5S/Kz5Uo4hYUKPOkQ2kuE3oQ427lzbxtQlVoRk8lr yWVzfJzGwW1A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2020 02:17:58 -0700 IronPort-SDR: hWv6YiZBOvYS1PLtrLEvekcg4aaSdg+1/WmJ4HEFldbsj2v5AC3Q3JnnRpXMJ/GEz0JLCo24Ld iW55+DgscKfw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,327,1583222400"; d="scan'208";a="261037295" Received: from icl-dev.sh.intel.com ([10.239.158.73]) by orsmga006.jf.intel.com with ESMTP; 28 Apr 2020 02:17:57 -0700 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Tue, 28 Apr 2020 17:16:01 +0800 Message-Id: <1588065363-7104-4-git-send-email-linjie.fu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1588065363-7104-1-git-send-email-linjie.fu@intel.com> References: <1588065363-7104-1-git-send-email-linjie.fu@intel.com> Subject: [FFmpeg-devel] [PATCH v5 3/5] lavc/libopenh264enc: add bit rate control select support 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: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" RC_BITRATE_MODE: set BITS_EXCEEDED to iCurrentBitsLevel and allows QP adjust in RcCalculatePictureQp(). RC_BUFFERBASED_MODE: use buffer status to adjust the video quality, introduced in release 1.2. RC_TIMESTAMP_MODE: bit rate control based on timestamp, introduced in release 1.4. Default to use RC_QUALITY_MODE. Signed-off-by: Linjie Fu --- libavcodec/libopenh264enc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index 0951412..93d3de2 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -49,6 +49,9 @@ typedef struct SVCContext { int skip_frames; int skipped; int cabac; + + // rate control mode + int rc_mode; } SVCContext; #define OFFSET(x) offsetof(SVCContext, x) @@ -73,6 +76,18 @@ static const AVOption options[] = { { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, { "allow_skip_frames", "allow skipping frames to hit the target bitrate", OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, + + { "rc_mode", "Select rate control mode", OFFSET(rc_mode), AV_OPT_TYPE_INT, { .i64 = RC_QUALITY_MODE }, RC_OFF_MODE, RC_TIMESTAMP_MODE, VE, "rc_mode" }, + { "off", "bit rate control off", 0, AV_OPT_TYPE_CONST, { .i64 = RC_OFF_MODE }, 0, 0, VE, "rc_mode" }, + { "quality", "quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RC_QUALITY_MODE }, 0, 0, VE, "rc_mode" }, + { "bitrate", "bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = RC_BITRATE_MODE }, 0, 0, VE, "rc_mode" }, +#if OPENH264_VER_AT_LEAST(1, 2) + { "buffer", "using buffer status to adjust the video quality (no bitrate control)", 0, AV_OPT_TYPE_CONST, { .i64 = RC_BUFFERBASED_MODE }, 0, 0, VE, "rc_mode" }, +#endif +#if OPENH264_VER_AT_LEAST(1, 4) + { "timestamp", "bit rate control based on timestamp", 0, AV_OPT_TYPE_CONST, { .i64 = RC_TIMESTAMP_MODE }, 0, 0, VE, "rc_mode" }, +#endif + { NULL } };