From patchwork Thu Dec 20 20:40:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 11498 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 30F6544CCED for ; Thu, 20 Dec 2018 22:45:46 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5A23068AE14; Thu, 20 Dec 2018 22:45:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8C3B968AD4D for ; Thu, 20 Dec 2018 22:45:39 +0200 (EET) Received: by mail-wm1-f52.google.com with SMTP id m1so3394014wml.2 for ; Thu, 20 Dec 2018 12:45:42 -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=gnsHdame97cffFc1s15pxKXwnDuK3f4aEq+mh8JNcLUuI9zZ5eFM1y8hnsQxJeKDht zTHwEU0Ku3MxFsYDMH+qe/4FXRiPlSiNld+mmMh/bRkpW9TfIxcToNDn/g3GSjSphFKD QqWxnwdj8S5dUbzPw18vZzExvPwvCjVYSC3goDX2neKC9JV5C8CTR/zZcrOGTimAVup5 4Y16RE4r6g6vyaXskcKegERTd2srX9N6Cu5v5O8E+TtxruEpK2W9FsD8aGUQJk4hE4Cy aibU4ECoJcmBVrRJjGFcWQrZXiRFq7OcafWtIYOnsZC/mGXX+2DFzb23GSV6EIbdygni eq4g== 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=D07JbgESPoF7NjRy38Hz5LmYLhfPwuoFNAckQuh/WJh+qm5UOhRI3PDejH51zQPaUr BHj9TmG6w9cIO4bL4qfnksBQ8xezRxkgVvqAuy4T/T+zR6qpTlErkDrFGSOfuKtRHrbe futydB+1uwkzrZCLiWEI14vyEuhgocR1ypRnWLKzcsiONwlNKETXVWjzJ7ylB8ud2Z7Q 5VP6y8hYvwfwl8JTrW0EaO07PJ7DfMPHFaTcJXX+hRscG4Jwrr7lD1eGFAwo6js6cZ64 R7Nw5wIlLjQJ0qijYrNawriDt3r3jnjk1Z33md8rd5cBpJ5MfWxqIixaAKNo+RWZzjDV zWcA== X-Gm-Message-State: AJcUukfBYnAJbrqOAXq0CcurQf9ib1jGdAakTHMBjoUIndIrYpp9kAoX wYJKu5Ve3WgfcAeaIfxG246ZKON1+rk= X-Google-Smtp-Source: ALg8bN6uXSMV+dejIFk+YnY8l9rSZRk85bt+TTiu3Vpo8IVqluNWZ7LlpmR6ffQMzQQ+YwUaztBXhA== X-Received: by 2002:a1c:9e4a:: with SMTP id h71mr164402wme.82.1545338423624; Thu, 20 Dec 2018 12:40:23 -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 x10sm11956884wrn.29.2018.12.20.12.40.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 12:40:22 -0800 (PST) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Thu, 20 Dec 2018 20:40:04 +0000 Message-Id: <20181220204008.32766-10-sw@jkqxz.net> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181220204008.32766-1-sw@jkqxz.net> References: <20181220204008.32766-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/14] 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 },