From patchwork Thu Sep 16 10:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 30273 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1131647iov; Thu, 16 Sep 2021 03:55:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMjlT+MgrW7WCRipRnB9OGa9NQwL8jGc4mWSganLR1nPMQrDC49D/8m47jMnutd2+JMnDk X-Received: by 2002:a17:907:d0c:: with SMTP id gn12mr5336923ejc.359.1631789718019; Thu, 16 Sep 2021 03:55:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631789718; cv=none; d=google.com; s=arc-20160816; b=SsdCdqywSHvAb2PbVp9mx+zuq8cTErqs97jfesUjazThh/ZEor1gSDuC2Zr75cJMBA HkIzpiorc4yHFwBgtMVXTaUzZ3TnJPRzDRIhlRHZpgacjWwyloQpRE8AHlcxIa6NzvZg +L2Z8d6KaR/UMWE75zgSugIRd5utyx0Uj+DI9C5nU21i18oEAvE/2pDcehw1WKouHoSW MNSWMrGQC9wIV6yQlHuO+CElcr1XZGCbMNv5YUY/X2JNXFnx15AXgZ1sjiHn5yxC2JNI socgNe6Er0Lnut5Vn0NQVWIDkRPih0a9xe0NfWbNaKlHU+3QWRk+wSdEShlNJmtkdor3 ULxw== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=bp8+y+a0ha/cy2KEeJNnLR6pRJgpsy59pxAJlpB8FoU=; b=kHYOetzx8kCVvEih8zU/Q3QJOr5QeoVu38yHqyBNbfUMrMtwt8G7rAxNbV2wrksw+m cGaX7vvGf8NgNYtHMg4SKnE3qZrU6CfXxzRBy5cx6cFqsoYjCLJEFGWPB0ArBNrpczs3 mmKfDY0idw67Y2zX7xxvwkvdHZmhr6SUvLVJAHoVpEjKkpf5gfbk983mXXysDl7EPtEY d4kWPqy3ESXB2JzUtURJgulmosg1sQ/Qr5lSnNxxbH0UYPcvDKOaHRN2fo1fWklL4q4r GzBNr9cXtNSk9PNScMjj4sKMevGACSbmX/Y4lpazcyzgmSFNpQNqRUKcot9KejUAqzAv yINA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=o5E3njT7; 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=QUARANTINE 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 mq9si2957656ejc.683.2021.09.16.03.55.17; Thu, 16 Sep 2021 03:55:18 -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 header.s=20210112 header.b=o5E3njT7; 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=QUARANTINE 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 8A5EB68AEAF; Thu, 16 Sep 2021 13:54:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1419D68ADC9 for ; Thu, 16 Sep 2021 13:54:29 +0300 (EEST) Received: by mail-pf1-f173.google.com with SMTP id m26so5560116pff.3 for ; Thu, 16 Sep 2021 03:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=H1oz592qfcSKT8i5MJz0ag4EHJgD8cjLgvDsfvLvW2w=; b=o5E3njT7qKNsauvvyHoQ1JTPaQpLsHQ1vjEper0oKremycq1zllEyjuYYgynXORbfZ JbssUI6ozmYMSssRg4mcBRbD75K6gDMYrAaIVZ4zSRcufs9Y6CglRuZE3ocGBMjK3lg3 zmI8GcE1ngm7VnlzFek75mzzGy1DE5OmiBtt2Bxc4/v8OS2/IfKirmZ8aBIsXIzujFfU 4wZY8iA7DBZNaVuWjNgOCLWl2zCMTJcskoKeDHvQHmon3P4WeCfFS4nLXNy4/y8sEbEx XCjNMbN575bw9YpoCJeW9B5VziYg26YN+FgRIxZtb9Vo8D9OSLXOUIOJOrlh7qLDGgQb tITA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=H1oz592qfcSKT8i5MJz0ag4EHJgD8cjLgvDsfvLvW2w=; b=5KzjbUJBDUuGbbrVICGaWyCOYuaLY6gG7y3N/BfKmVhsCw5qEPDETof9ReLDB98N06 EW3bWgAF8eIv54lWR8iriSaIxd+bNar3eKG+i3eg+rICj+6kUEET5xPBBQSylvvmrWBO I565Feb1a7KtjO32E73h3g1LXliPkBjIWPmH5fF+89pB8kSh7z1ObVP7RVtKJA0dI9lp /ORhz2xhSkC34xnx0cRKMkjixomBN84j6Z4O0fRJUujGCBBQMbEgCm5fXdKlMmZZ0Uqe Ebapts45GBD4+IJqBlAEXhQlKCAnpyGSmZ+P0ZyQozQyr+ZedPRvGRb3sP++8yHmVOxv yOWQ== X-Gm-Message-State: AOAM531uasbPKQGaqP536oX/mgRC9sx5H05UP3JTa6mFbbqg77UhDvqq Uv8wPOZaPg9uQyJ3lmhvyfvIAPN7exI= X-Received: by 2002:a63:79c7:: with SMTP id u190mr4437382pgc.378.1631789667273; Thu, 16 Sep 2021 03:54:27 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id h4sm2959020pgn.6.2021.09.16.03.54.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Sep 2021 03:54:27 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Sep 2021 18:54:17 +0800 Message-Id: <1631789657-16936-5-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1631789657-16936-1-git-send-email-lance.lmwang@gmail.com> References: <1631789657-16936-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 5/5] avcodec/libsvtav1: support constant quality mode X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: cVALdFsIHaPJ From: Limin Wang Signed-off-by: Limin Wang --- doc/encoders.texi | 7 ++++++- libavcodec/libsvtav1.c | 10 +++++++++- libavcodec/version.h | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 64d604e..2300bb9 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1807,9 +1807,11 @@ Set the rate control mode to use. Possible modes: @table @option @item cqp -Constant quantizer: use fixed values of qindex (dependent on the frame type) +Constant quantizer(not set crf): use fixed values of qindex (dependent on the frame type) throughout the stream. This mode is the default. +Constant quality(set crf): maintain a constant QP throughout the stream. + @item vbr Variable bitrate: use a target bitrate for the whole stream. @@ -1826,6 +1828,9 @@ Set the minimum quantizer to use when using a bitrate mode. @item qp Set the quantizer used in cqp rate control mode (0-63). +@item crf +Select the quality for constant quality mode (0-63). + @item sc_detection Enable scene change detection. diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 1f1f86b..29be4bd 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -66,6 +66,7 @@ typedef struct SvtContext { int rc_mode; int scd; int qp; + int crf; int tier; @@ -210,6 +211,10 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, param->min_qp_allowed = avctx->qmin; } else { param->enable_tpl_la = 0; /* CQP need turn off enable_tp_la */ + if ( svt_enc->crf > 0) { + param->qp = svt_enc->crf; + param->enable_tpl_la = 1; + } } /* 2 = IDR, closed GOP, 1 = CRA, open GOP */ @@ -523,13 +528,16 @@ static const AVOption options[] = { { "rc", "Bit rate control mode", OFFSET(rc_mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, VE , "rc"}, - { "cqp", "Constant quantizer", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "rc" }, + { "cqp", "Constant quantizer(not set crf), Constant quality(set crf)", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "rc" }, { "vbr", "Variable Bit Rate, use a target bitrate for the entire stream", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "rc" }, { "cvbr", "Constrained Variable Bit Rate, use a target bitrate for each GOP", 0, AV_OPT_TYPE_CONST,{ .i64 = 2 }, INT_MIN, INT_MAX, VE, "rc" }, { "qp", "Quantizer to use with cqp rate control mode", OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 50 }, 0, 63, VE }, + { "crf", "Select the quality for constant quality mode", OFFSET(crf), + AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 63, VE }, + { "sc_detection", "Scene change detection", OFFSET(scd), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, diff --git a/libavcodec/version.h b/libavcodec/version.h index 4b4fe54..b0a741b 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 59 #define LIBAVCODEC_VERSION_MINOR 7 -#define LIBAVCODEC_VERSION_MICRO 103 +#define LIBAVCODEC_VERSION_MICRO 104 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \