From patchwork Tue Mar 3 21:49:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Cao X-Patchwork-Id: 18021 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 C04F4449423 for ; Tue, 3 Mar 2020 23:49:34 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9A8E768B603; Tue, 3 Mar 2020 23:49:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A9C9568B4E3 for ; Tue, 3 Mar 2020 23:49:27 +0200 (EET) Received: by mail-pl1-f195.google.com with SMTP id y1so10406plp.7 for ; Tue, 03 Mar 2020 13:49:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TrGYcmIBRE7mehoQdigIC1jLd5G+RLkk8PXPBBu+7Kc=; b=kFvkZE1qnl6Z+pJVjQr43qhJcBdiNlX5yobOXo418cNdujl1VZ2OwEsp8A1bNmukmu vauGG8Kzt8iR3y30mC24Iu2QFPG8zo6W/Vepzh+P/Ex4cLGRt/RVnDsxwU3pbZz3xt8f cvuIHovLfXsninElG9rpcUGK3hWVSsgRFmLnOYM7dlMK7Z/T0tqjmDsZ/MM9rRKlkhyZ MgIEMtGu0+klSI2eOb3UEEjU0tCnFB+AMyG+TqDhXPXIkIxqLC0nG//9viyIL+mlxprC /Zs6iuG+0r/nvMk4LCbKkBqtE8an+4Nu9wKZB47DE1BvSu/MWHK6xwnJpZoW4dTWGyfh ADLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TrGYcmIBRE7mehoQdigIC1jLd5G+RLkk8PXPBBu+7Kc=; b=HNxUXA5FzHsiaslCo9dbIaQwr71RFDQ4mVWuFNbZxXBVhPweO/41ROXtGKjLGd/nF/ AgEQGz3oytJMypqufkIAgfoy+xCpvcEXwcEg1WKaMD62/Y1WqQxTdM6DF0NXfqoPVL8w oCLfbsdv9r4DNe0LVAYATMz/QRQAbRz/EoRQ3caBsTK7EUTHsode2Su3+ObduHIAghiH dFZwflGfqLp/+WLwoAwmrEXjkqwOXtYeJhPphzIyUOR96G3pZDPcbzIK4h4+jl+1GQcO 75wIsDmBMRkSy5g3PsszHSgcctxIWobcwsmqA6/SnDAmyzAZ4xR/hIPBGEhamSq2Q/X5 CbOg== X-Gm-Message-State: ANhLgQ2J1DIgEzTBnKgcibDe+qq0m8UG8zl3iJTSLLTWuvw8W7RtQoZU HztiAQks/75xgYpGpDWzeW9C6TX2JvNBLw== X-Google-Smtp-Source: ADFU+vvWbArwhNdCvPguxSYkB7CXeIxDofiatvc27VXoC70moAtjANOLiK3dd3ozfzOkYI6aP0gvDA== X-Received: by 2002:a17:90b:3006:: with SMTP id hg6mr145957pjb.54.1583272165674; Tue, 03 Mar 2020 13:49:25 -0800 (PST) Received: from wangcao.bej.corp.google.com ([2401:fa00:45:201:7885:4f90:fa40:35]) by smtp.gmail.com with ESMTPSA id z17sm13729072pfk.110.2020.03.03.13.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 13:49:24 -0800 (PST) From: Wang Cao X-Google-Original-From: Wang Cao To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Mar 2020 05:49:13 +0800 Message-Id: <20200303214914.40085-1-wangcao@google.com> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] libavcodec/libaomenc.c: Add a libaom command-line opton 'tune' 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: Wang Cao Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Wang Cao --- doc/encoders.texi | 11 +++++++++++ libavcodec/libaomenc.c | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index e23b6b32fe..4215f237bd 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1508,6 +1508,17 @@ Complexity-based. Cyclic refresh. @end table +@item tune (@emph{tune}) +Set the distortion metric tuned with for encoder. Default is PSNR. + +@table @samp +@item psnr (@emph{0}) +PSNR as distortion metric + +@item ssim (@emph{1}) +SSIM as distortion metric +@end table + @item lag-in-frames Set the maximum number of frames which the encoder may keep in flight at any one time for lookahead purposes. Defaults to the internal diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 096aadbe1c..7fd624c470 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -94,6 +94,7 @@ typedef struct AOMEncoderContext { int enable_intrabc; int enable_restoration; int usage; + int tune; } AOMContext; static const char *const ctlidstr[] = { @@ -132,6 +133,7 @@ static const char *const ctlidstr[] = { [AV1E_SET_ENABLE_INTRABC] = "AV1E_SET_ENABLE_INTRABC", #endif [AV1E_SET_ENABLE_CDEF] = "AV1E_SET_ENABLE_CDEF", + [AOME_SET_TUNING] = "AOME_SET_TUNING", }; static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc) @@ -699,6 +701,8 @@ static av_cold int aom_init(AVCodecContext *avctx, codecctl_int(avctx, AOME_SET_STATIC_THRESHOLD, ctx->static_thresh); if (ctx->crf >= 0) codecctl_int(avctx, AOME_SET_CQ_LEVEL, ctx->crf); + if (ctx->tune >= 0) + codecctl_int(avctx, AOME_SET_TUNING, ctx->tune); codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, avctx->color_primaries); codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, avctx->colorspace); @@ -1096,6 +1100,9 @@ static const AVOption options[] = { { "usage", "Quality and compression efficiency vs speed tradeof", OFFSET(usage), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, "usage"}, { "good", "Good quality", 0, AV_OPT_TYPE_CONST, {.i64 = 0 /* AOM_USAGE_GOOD_QUALITY */}, 0, 0, VE, "usage"}, { "realtime", "Realtime encoding", 0, AV_OPT_TYPE_CONST, {.i64 = 1 /* AOM_USAGE_REALTIME */}, 0, 0, VE, "usage"}, + { "tune", "The metric that encoder tunes for", OFFSET(tune), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE, "tune"}, + { "psnr", "PSNR as distortion metric", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, "tune"}, + { "ssim", "SSIM as distortion metric", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "tune"}, { NULL }, };