From patchwork Sun Feb 10 19:46:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 12029 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 5F4F444665E for ; Sun, 10 Feb 2019 21:47:22 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5039868A65F; Sun, 10 Feb 2019 21:47:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3A38C68A6A0 for ; Sun, 10 Feb 2019 21:47:15 +0200 (EET) Received: by mail-wm1-f49.google.com with SMTP id t200so12961268wmt.0 for ; Sun, 10 Feb 2019 11:47:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7S7NiNdJa8TYq5FT90RvPr6mg5kKWOH8hTtpUKTD0Ew=; b=t0IXHKznVufflTaiT4omYnIIHkB5ZCrOuQQqKTAdnQNwusL2PT1fIDGDLpnBi8AQov DPUodJ3M7qYoTTwvBXnL+5a+Ud+dxkgPZiL/lLzOb8Aa8MIjR/VOhTEsE1v6kgmWnmmP V/4TNTuMIfE9PybhpTyO0e6cYPwNJqz1bIDC86Opo04owQ0o21YmGZg5aAbX5e0r1tBu Pwrv/VGjJDAeXjij4j5AASpd+tjdbAns5bj6q3amyuqLhql8KTD8FvVwM58bwg14HGug YLrn8frcpnP9cPk5IkvCNz+45p63jHQalvo0CM7XHK9hNGlCukynoJvzjC+HehgrLUqo FYwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7S7NiNdJa8TYq5FT90RvPr6mg5kKWOH8hTtpUKTD0Ew=; b=kJmB3tBgxrLBJ45bgoSyn+1TY05OzT+1Q7RLpmD2LcVKsU+pwdmztVXbayM+MV69jY n7QD9TJqQVw/HzX6zncSCiN5Br4jHVxr857ZFwXixjqIAMuwWM4tBk3DEJn3VcesoDcF LuZowGhvjaqrbvBJgrXcrzpuSodtjKr6XVUHnSx+bidMrGaOM0Pycbp2ZLZ32JYa8J/Z cFo/5CNaMl/IwaxNlmeA5YrjKP4BDMwG3U06KQ4JAWu5HaBB+2Ub/4QBmhbrhighGyI/ NRm8uvC0TRv6a+OLi0WOLUMw/87+iNWt5muvn5+TiYXR1N+4Be2d4b8yPQOmlxMWrNEi EjxA== X-Gm-Message-State: AHQUAuZ/or+CxHzfHOpf/BlFozpt1XKvNEqfip37h9do5R0+j5rMfrwc zRr88U4OyypihAMW9ZiM0S+rXuPPDGQFsQ== X-Google-Smtp-Source: AHgI3IbBSeblfc18bdesfLm6sNJxWF9TrgH53/mxdBNi3omizbMlPzA7pR3tUQapbV6Wdep3ET2rvA== X-Received: by 2002:a5d:4711:: with SMTP id y17mr5435446wrq.141.1549828034410; Sun, 10 Feb 2019 11:47:14 -0800 (PST) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id u15sm24059889wrm.63.2019.02.10.11.47.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 11:47:13 -0800 (PST) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Feb 2019 19:46:57 +0000 Message-Id: <20190210194705.3598-4-sw@jkqxz.net> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190210194705.3598-1-sw@jkqxz.net> References: <20190210194705.3598-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 04/12] vaapi_encode_mpeg2: Enable support for more RC modes 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" --- libavcodec/vaapi_encode_mpeg2.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index 9d42c3e644..174611ff24 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -521,19 +521,17 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx) return err; if (ctx->va_rc_mode == VA_RC_CQP) { - priv->quant_p = av_clip(avctx->global_quality, 1, 31); + priv->quant_p = av_clip(ctx->rc_quality, 1, 31); if (avctx->i_quant_factor > 0.0) - priv->quant_i = av_clip((avctx->global_quality * - avctx->i_quant_factor + - avctx->i_quant_offset) + 0.5, - 1, 31); + priv->quant_i = + av_clip((avctx->i_quant_factor * priv->quant_p + + avctx->i_quant_offset) + 0.5, 1, 31); else priv->quant_i = priv->quant_p; if (avctx->b_quant_factor > 0.0) - priv->quant_b = av_clip((avctx->global_quality * - avctx->b_quant_factor + - avctx->b_quant_offset) + 0.5, - 1, 31); + priv->quant_b = + av_clip((avctx->b_quant_factor * priv->quant_p + + avctx->b_quant_offset) + 0.5, 1, 31); else priv->quant_b = priv->quant_p; @@ -542,7 +540,9 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx) priv->quant_i, priv->quant_p, priv->quant_b); } else { - av_assert0(0 && "Invalid RC mode."); + priv->quant_i = 16; + priv->quant_p = 16; + priv->quant_b = 16; } ctx->slice_block_rows = FFALIGN(avctx->height, 16) / 16; @@ -567,6 +567,8 @@ static const VAAPIEncodeType vaapi_encode_type_mpeg2 = { .configure = &vaapi_encode_mpeg2_configure, + .default_quality = 10, + .sequence_params_size = sizeof(VAEncSequenceParameterBufferMPEG2), .init_sequence_params = &vaapi_encode_mpeg2_init_sequence_params, @@ -637,6 +639,7 @@ static av_cold int vaapi_encode_mpeg2_close(AVCodecContext *avctx) #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) static const AVOption vaapi_encode_mpeg2_options[] = { VAAPI_ENCODE_COMMON_OPTIONS, + VAAPI_ENCODE_RC_OPTIONS, { "profile", "Set profile (in profile_and_level_indication)", OFFSET(profile), AV_OPT_TYPE_INT, @@ -671,7 +674,6 @@ static const AVCodecDefault vaapi_encode_mpeg2_defaults[] = { { "i_qoffset", "0" }, { "b_qfactor", "6/5" }, { "b_qoffset", "0" }, - { "global_quality", "10" }, { "qmin", "-1" }, { "qmax", "-1" }, { NULL },