From patchwork Mon Aug 21 03:04:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhong Li X-Patchwork-Id: 4782 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.37.132 with SMTP id g126csp2463504jag; Sun, 20 Aug 2017 20:08:23 -0700 (PDT) X-Received: by 10.28.224.138 with SMTP id x132mr5122309wmg.90.1503284903190; Sun, 20 Aug 2017 20:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503284903; cv=none; d=google.com; s=arc-20160816; b=VQ2UD60znhJJW5Q6LVZ6Ejiz9AX1h+GlOvmc3p/X6+3JlguTvK+1nzAGICgnbsZXuy bhNpJNY0GzAvEHELuakrgyQMr2hauHP29H9+2HI2eaWcJYyIuXnqSgKy5/+RG5ksfNin lQW/jKlbYxqL/e5BcuJHIb8s92/7qTMa8J6q72LwYlFnRJau9NFbM7m9RRD8T2bf0V0h uIQR8aF6OI7zgQGll3LhEof+hdP0CM2fawFOw4l1gmPCqntwI517RVF179y3HMp765QZ /b2CcIkaNN1w6i37j/1vSt8Dg4b0kl335ZsrX7d1f8WQLyBbgNEk4OqPL707PjJVHo6K PwEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=SzZ3+Au/yXHzPKFhwzgkyWDTKQqaIkyvEO26hts1nBU=; b=PRoTeUZdf2OY9AaEgoUT7SlAj5a/UezScVk7woCROCDZESyHojXApItTc2/JMhm+km NbqXPav5Xht3olPuOcE/1YXBoxnEfaE7MgnoORn5pC2r64XVDyPtw69libYIFQySmXhU D96AfA+1J+BplTypWUXlPzgbrmEiRJQ//Cr2VSTxkJLpqFlqcbJgYs/nD+J0Q7YRGWZC xSsnUR7UKDHRehFaqifTqj3BH6K+pot55gh8xpt5rwRaj3eQOHQiYgWXwLgiw0HsqRBR O2SWKf1HYWZ4B6kHubeljOZFoNuDu1d44H8HMtnviQobkLpFCfg6N9KX4Oqu6Mfc1OzG 0MUw== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k134si5090510wmg.256.2017.08.20.20.08.20; Sun, 20 Aug 2017 20:08:23 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 98A26689AEA; Mon, 21 Aug 2017 06:07:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EE60E68982F for ; Mon, 21 Aug 2017 06:07:49 +0300 (EEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Aug 2017 20:07:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.41,407,1498546800"; d="scan'208"; a="1208191614" Received: from bluekbl.sh.intel.com (HELO localhost.localdomain) ([10.239.159.160]) by fmsmga002.fm.intel.com with ESMTP; 20 Aug 2017 20:07:50 -0700 From: Zhong Li To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Aug 2017 11:04:03 +0800 Message-Id: <20170821030403.14381-1-zhong.li@intel.com> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH 1/2] vaapi_hevc: Add an option to set quality level 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: Zhong Li , sw@jkqxz.net, jun.zhao@intel.com, nfxjfg@googlemail.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Just like vaapi_h264 encoder, quality_level is set for tradeoff quality and performance. Signed-off-by: Zhong Li --- libavcodec/vaapi_encode_h265.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index cf6b9388d1..86bda4a27b 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -191,10 +191,19 @@ typedef struct VAAPIEncodeH265Context { VAEncMiscParameterBuffer misc; VAEncMiscParameterHRD hrd; } hrd_params; + +#if VA_CHECK_VERSION(0, 36, 0) + // Speed-quality tradeoff setting. + struct { + VAEncMiscParameterBuffer misc; + VAEncMiscParameterBufferQualityLevel quality; + } quality_params; +#endif } VAAPIEncodeH265Context; typedef struct VAAPIEncodeH265Options { int qp; + int quality; } VAAPIEncodeH265Options; @@ -1198,6 +1207,22 @@ static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx) av_assert0(0 && "Invalid RC mode."); } + if (opt->quality > 0) { +#if VA_CHECK_VERSION(0, 36, 0) + priv->quality_params.misc.type = + VAEncMiscParameterTypeQualityLevel; + priv->quality_params.quality.quality_level = opt->quality; + + ctx->global_params[ctx->nb_global_params] = + &priv->quality_params.misc; + ctx->global_params_size[ctx->nb_global_params++] = + sizeof(priv->quality_params); +#else + av_log(avctx, AV_LOG_WARNING, "The encode quality option is not " + "supported with this VAAPI version.\n"); +#endif + } + return 0; } @@ -1272,6 +1297,8 @@ static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx) static const AVOption vaapi_encode_h265_options[] = { { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)", OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 25 }, 0, 52, FLAGS }, + { "quality", "Set encode quality (trades off against speed, higher is faster)", + OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 7, FLAGS }, { NULL }, };