From patchwork Fri May 12 06:27:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 3655 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp190100vsd; Thu, 11 May 2017 23:28:01 -0700 (PDT) X-Received: by 10.28.207.201 with SMTP id f192mr1380228wmg.79.1494570481019; Thu, 11 May 2017 23:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494570480; cv=none; d=google.com; s=arc-20160816; b=rNig2oSXVrikjHSVJuaAPJRyTW9i0fmBHPLgCKtdwaRik2bCPAz1slaskPp6xKU79t tMKsDJovgOPW7YY7Vn4UWBt8pb6qjHDu5FI9Zxi0HG+XiKhYmddIJ4tN6yqYfvrZKYcJ DS03qNakVR0nHSVdOR8+XS4BsET74diVbppgqNLv5RmrLNp9uQCpyO92Z3fCw/LT86kT a0jlUPWnro/AIdlogfoDLPH2ahsvMY1LKWdNvMNidXsStZV4GIi+FzcY8oZb2ZkyTQW8 bmCcqs7D4aSZHHNSPaQdWsFoZS8KkBvJNVyWRrH3WggfzWuEy2E03Olbefctndvs3r9r EDmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:mime-version:user-agent:date:message-id:from:to :dkim-signature:delivered-to:arc-authentication-results; bh=29vzJHyoV0BcA7hpQA+cIUng8Fc7a4wwW2ofgdpdbPc=; b=A69kzUxEVUqWSNYdrRSFpuwHAKm2Kx/nzd0Bcmm/HlmYdxC9jbxfCERxcRlzH2/8xe lFCo/aAx2JoKcGaSDlnP8XhDzcCPz+CPCG9eE88kkFmaGbvSnoPDLP1AaoyQkaddQFTr /2yuYqQQU05UKjyV0WUofNu6PVWiMPcxwPC+NGviBLqEsxQy/XHLTZxgiKAqjhVjecqm I3osSkKFkGs0vCCmw/HSEREs4K4XyQn8KcCjfssRsHbzcVimghVz4FZHrvyw1Q4DRX3G m08sfobpb1OaPqfVl0OpRihTfA38HkwJXGuSR2GX4iyKvBNNAtIpyNvBiDTNOrlihmzm d2DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; 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=NONE 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 c45si2584664wra.181.2017.05.11.23.28.00; Thu, 11 May 2017 23:28:00 -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; 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=NONE 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 1C253689221; Fri, 12 May 2017 09:27:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg0-f44.google.com (mail-pg0-f44.google.com [74.125.83.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 32C28680AA7 for ; Fri, 12 May 2017 09:27:43 +0300 (EEST) Received: by mail-pg0-f44.google.com with SMTP id x64so6235869pgd.3 for ; Thu, 11 May 2017 23:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=ek1Kr5ufH4WnDgPiFAFMi1TMZ5/W0TUX9EpwASBfXQg=; b=NW+CuW9QAaZxGSVXBS3tLPbuv/lwjioIygUUt3IG27YKtXSK5JjeAkHsX307gOA7lY HevCDM+5fncCO/4Pf3fj/yMvanDHcvdtQ7HNMQGPp+gKn8NvSxK3dwe6ENC7sLLHOXI7 Z4nFBGIwDPoZPiShdGEfcox8xPSZfJSBD7pSxRvrC6SlHY3C2gyLNJTC2OX7wpLxUGv5 95Smb/0n+wZST1cqxz8CJ0/76sZXA3Q1EkfUPSYKvD+hLVtY5ZPifykT+md6QGe7PrjV 76wfecMmSMj6dtD/biQIDc3ZCP7sTZY8dRElCgKWHa8hqsCs08VgloH7rdzL8GRUZgbr rDbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=ek1Kr5ufH4WnDgPiFAFMi1TMZ5/W0TUX9EpwASBfXQg=; b=tcryE8vvpmlc2i3mYWXal/tDL8k9sLL8egNpZ8QZSvne7rwOCVi71oyYJyF0XJII/e tm5f4zt7U+Enq8FDlRvcO+J70Y4z8zhNVEwVypvT4S++pqHOx/OY+lba40f+tM6DWVQ9 pDjGMqJFJsLNFjwTSs/ch3oFRc7X+JyEZOCwzV7H/ZylUZ+o1gdZ7XoXh2BzA26TDA1G vj6E8FxCaKAXlZcHnUmVqLiB54LIBTwaEUDP7TJfECuwwOPL8r7FoS4tXegTigVDPy5D J7+3DotXifevMNygHlhbjnulg5WNp7hXpHtO/jaVMLFWvLpMhLJU2CixankmpoVigQCa KE4A== X-Gm-Message-State: AODbwcC7RpD11x31DsRWQyllLC6kzyRTaPFLW3QVI4/AOhRUNnw+NL4q PMWUpwJK644Pww== X-Received: by 10.84.232.204 with SMTP id x12mr3511004plm.77.1494570468980; Thu, 11 May 2017 23:27:48 -0700 (PDT) Received: from [10.239.205.153] ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id 66sm3627350pgd.47.2017.05.11.23.27.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 May 2017 23:27:47 -0700 (PDT) To: FFmpeg development discussions and patches , Mark Thompson From: Jun Zhao Message-ID: <264d9cfe-cb0d-838a-d990-f4025a85b797@gmail.com> Date: Fri, 12 May 2017 14:27:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 Content-Language: en-US Subject: [FFmpeg-devel] [PATCH V2] lavc/vaapi_encode_h264: Enable MB rate control 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" V2: - Refine the name/value type to mb_rate_control/bool. - Only supported GEN9+ (SKL/APL/KBL/...) - i965 driver default use frame-level rate control algorithm (generate the QP for each frame), when enable mb_rate_control, it's will enable the MB-level RC algorithm (generate the QP for each MB). - enables MB-level bitrate control that generally improves subjective visual quality, but have negative impact on performance and objective visual quality metric. From 9223a87e48c846f1ab7c65ba857d902de70349a8 Mon Sep 17 00:00:00 2001 From: Jun Zhao Date: Tue, 9 May 2017 08:19:16 +0800 Subject: [PATCH V2] lavc/vaapi_encode_h264: Enable MB rate control. Enables macroblock-level bitrate control that generally improves subjective visual quality. It may have a negative impact on performance and objective visual quality metrics. Default is off and can't compatible with Constant QP. Signed-off-by: Jun Zhao --- libavcodec/vaapi_encode_h264.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index 92e29554ed..6b97a7fd85 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -168,6 +168,7 @@ typedef struct VAAPIEncodeH264Options { int qp; int quality; int low_power; + int mb_rate_control; } VAAPIEncodeH264Options; @@ -1133,8 +1134,11 @@ static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx) priv->fixed_qp_p = 26; priv->fixed_qp_b = 26; - av_log(avctx, AV_LOG_DEBUG, "Using %s-bitrate = %"PRId64" bps.\n", + ctx->rc_params.rc.rc_flags.bits.mb_rate_control = opt->mb_rate_control; + + av_log(avctx, AV_LOG_DEBUG, "Using %s-bitrate %s MB rate control = %"PRId64" bps.\n", ctx->va_rc_mode == VA_RC_CBR ? "constant" : "variable", + opt->mb_rate_control ? "with" : "without", avctx->bit_rate); } else { @@ -1283,6 +1287,8 @@ static const AVOption vaapi_encode_h264_options[] = { { "low_power", "Use low-power encoding mode (experimental: only supported " "on some platforms, does not support all features)", OFFSET(low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS }, + { "mb_rate_control", "MB level bitrate control (only supported on GEN9+)", + OFFSET(mb_rate_control), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS, "mb_rate_control" }, { NULL }, };